It’s been some very busy months lately. Since I started my Master’s degree, I’ve been working hard on my research and on publications based on it. I am happy to announce that the first draft of my first first author paper is done, and now I wait for the comments of other authors. Also, in December I became a rotation author on Astrobites, which is pretty cool. I’m also working on an extra project (which I can’t talk much about right now) and doing other science stuff on the side when there’s free time.
So, as you can imagine, there hasn’t been much room for writing non-scientific articles. Even gaming (my cup of tea when it comes to cheap entertainment) is set to background lately. The posts here in this blog are actually a repost from my previous website, so that is why there is some weird stuff like missing images and so on. Additionally, they reflect opinions that I had at the time of writing, and they probably changed a lot since. I don’t wanna erase these posts though. In fact, I want to go back to writing again.
Since I stopped blogging, I feel like there’s this hairball of ideas inside my stomach that can’t find its way out. Things like the current state of science in Brazil, where things are going, the situation of diversity in all kinds of fields, personal life strife that’s been going on, and even some experiences that I think worth of writing about.
I’ve been actively tweeting these issues, but it just doesn’t feel the same. For instance, how is it possible to regurgitate all my opinions on, say, the directions that the skeptical and atheist movements are taking at the moment (which, by the way, are thoughtfully explored on the blog Skepchick) in just 140 characters? The answer is: it is not. Also, I feel that tweeting doesn’t click the same skill buttons as does full-fledged blogging: it seems like I’m rusty on the non-scientific writing, which is really bad.
In conclusion: yes, I do intend on getting back to writing again. I might as well start making this blog a bit more public if that happens, since I’ve kept it behind the curtains for too long of a time now. Posts will generally be shorter too, because that is in vogue at the moment. I think 500 words limit is a good choice. Don’t wanna ramble too much. Also, no more obligatory featured image: it just gets in the way of writing. No more eye-candy for the readers, I guess.
In 2011, I made a choice that would completely change my life: I decided to become a scientist. It was a very weird period, I was doubtful and delusional. The thing that I didn’t realize, however, is that the feeling of doubt and delusion would never go away, the better I tried.
The change itself was actually reinvigorating. Since when I first had a talk with the like-minded, I felt an urge, an euphoria, that I still feel when I go up a mountain to work at an observatory. I absolutely love to observe the sky, and the sensation seems to become ever stronger the more I do. The twilight is the beginning of a new night, of new opportunities and a travel that might end at new discoveries and excitement. For the first time in my entire life, I really feel like I belong somewhere.
And this is why… I am afraid. Almost every day, while sailing through the internet or visiting Twitter, I end up reading a post about how academia is broken; that there are too many students or postdocs trying to get an academic job and there are not many being offered; that working in academia is frustrating and it pays badly. I am afraid I might end up leaving science, and coming back to the same frustrations I had when I was looking for a job in corporations.
Since I made the decision to become a scientist, I knew that it wouldn’t be easy. To be completely honest, I was in the “follow your passion” mindset. I had confidence that everything would be fine if I did my best. Some say that we are afraid of what we don’t know, so it could be that I’m afraid now because I don’t know the exact level of difficulty of being a scientist or just because my future is uncertain.
Money is not a bigdeal for me: I was born in a simple family, and I can live comfortably with just a couple of bucks to buy me food and pay for the internet. But I know that many people want to construct their families, and have a nice house to raise their kids, pay for good education for them. So it’s understandable why a career in academia is problematic on that point. A scientist will only be able to have these good things when they are on a professorship track, and it can take a couple of decades to achieve that.
One can argue that I can be an astronomer or a scientist, even without being in academia: I could, for example, be working on data science, since it is big thing right now with corporations; or I could be a writer, working in science outreach. So there is that: looking for something outside academia. Of course, the chances and opportunities would depend mostly on luck, but also on what you have “worked” on during your graduate courses (the quotation marks are there because some companies don’t consider research as “working”). And this is where all my frustrations with corporations come from: not seeing the value in science.
When I read these inspirational and informative posts about looking for jobs outside academia, it’s a bit unsettling to read about isolated cases. I mean, maybe John was lucky enough to find a position as data scientist in an awesome company, and maybe Mary hit the ballpark when she founded her own business; but what about all the other people who left academia and are stuck at uninteresting jobs, just as almost all of my friends who went straight from undergrad to corporations? What do they have to say? Do they exist? We don’t have numbers on it, or at least I never saw them. As an astronomer obsessed with statistics, I find it hard to believe that getting a satisfying job outside academia is an easier task. We should be honest about the issue.
Outside of academia, I know very few people who actually enjoy their jobs as much as I do with astronomy, and all of them have a larger income than I do. They have cars, live in nice places, post selfies on Facebook when they’re traveling, but they hate to wake up in the morning and having to go to work. For them, the weekend is a blessing, and the weekdays are a curse. This is exactly what I want to avoid. Finding a satisfying job is hard, anywhere; there is no magic pill that will solve this quest.
I was talking to a friend this week, who is a professor, and he said things were even worse, in Brazil, a few years ago (around the 90’s and 2000’s). When he was in my position, a graduate student, in the same institution, he had absolutely no prospects of finding a job. Research in our country was sparse and fellowships were rare. It is just now that we are getting on our feet with science. Additionally, most of Brazilian research is done exclusively in academia, far away from companies. So, as you can see, at the current generation of scientists, there are two prospects: 1) In public universities, there are many positions being created as the result of investments and outright retirement of the old professors; for instance, at IAG/USP, most professors are either very old or very young, because of the recession gap from the 90’s to the 2000’s. 2) As the local culture of scientific jobs changes, there will [hopefully] be a broader integration between research and companies, which will open up opportunities outside academia.
Sometimes I think that being a scientist is like being an artist: it’s a very elusive position, one that few can get into; one that not everyone recognizes its importance; one that is full of ups and downs; and most importantly: one that takes a lot from you, and it will probably not financially pay-off your efforts. But, damn, it’s awfully satisfying.
Maybe I should stop focusing too much on the objectives, it’s not like a “if you die in science, you die for real” kind of situation. Perhaps I should just enjoy the ride, whatever the destination. To be honest, it’s been like that since the beginning: for instance, I never chose my exact field of study (apart from focusing more on stellar astrophysics, which I find very enticing), and that’s the reason why I’ve wondered through stellar evolution, formation of stars, interstellar medium and now solar twins and spectroscopy. Also, if you asked me 5 years ago, I would never have said that I wanted to be an exchange student in Netherlands. Things just happen, and our inclinations change. Maybe the randomness of life is what makes it worth living.
Last Tuesday (Apr 14), there was an interesting discussion at IAG/USP about the outcomes of a poll, or rather, a survey that some of the astronomers did about the attendance to the department’s talks (seminars and colloquia). I don’t have the actual numbers, but there were some results like this:
50% of the faculty staff and 50% of the postdoc answered the survey, and so did some 60% of the graduate students, plus a handful of undergraduate students
Most people said they only attended talks related to, specifically, their field of research
Most people answered that the main reason for not attending other talks was because they were bad, and the second (but close) reason was “lack of time”
While these results are somewhat alarming, they are not at all surprising. I have to confess that I too shared this closed-mindedness of only attending to talks that only belonged to my area. But luckily I was remembered that astronomy is not only the study of stars, or galaxies, or any other particular field: astronomy is a body of knowledge that encompasses countless aspects of the universe. I think it is common to separate things because we like to work with compartmentalized blocks, it’s easier that way. Or at least it seems, most of the time.
First point: why go?
The discussions reminded me of this cartoon: don’t forget the bigger picture, it says. And now that I think about it, I’ll probably print it and glue it to my office’s door, just because more people should see it. It’s not like a simple cartoon will magically change someone’s mind, but it can help. There are countless reasons why we should listen to other fields of research, such as networking opportunities, intuition pumps, the sharing of new ideas, and maybe even a potential new collaboration.
One of the reasons why people decide to become scientists is the autonomy. Scientists have, to a certain level, more freedom than other professional careers. In principle, we are not generally forced to attend meetings that are not of our immediate interest, nor do we have to have a fixed, written in stone, schedule. While we have our own interests and motivations, it is important to remind that we need to address to certain expectations. Scientists are expected to produce knowledge, to answer questions, to give back to the people who paid their salaries. There is no such a thing as a free lunch. The better we can weave our little dents in humanity’s body of knowledge, the better scientists we are.
Okay, but what if talks are outright bad or too hard to understand? What if the talkers don’t introduce the subject? What if they do not consider that they are addressing a broader audience, even if the organizers said them so? There are a few mitigating actions that can help in this point, such as red-flagging bad talkers and making sure they are prepared to talk to a particular target audience. In the discussion, someone gave the idea of a postdoc giving an introductory talk [a few days] before the main one, so as to “normalize” everyone to the same level. So, there are things we can do, and others that we can’t. If the talker is just bad, what can effectively be done about it? Nothing more than a red flag. So there is no point in discussing this. There will always be some bad talks, we just have to deal with them.
Second point: quantity vs. quality
An important issue that was pointed out is that it is not always about the quantity of people that attend talks, but rather how much knowledge is exchanged, which is the actual point of having a talk. As someone wisely said, it is possible to have a wonderful session with just ten people.
Some people criticize their snappy-styled, sitcom-sized talks, but there is much we can learn from TED. Their talks engage people in ways that, sadly, few scientists can do. Last week, during a Data Science Workshop at IAG/USP, we had a wonderful and engaging presentation by Professor Claudia Medeiros (Instituto de Computação/USP), where she introduced us into the many doors that were open for data scientists in the corporate world. She didn’t delve into the technicalities of data science, she focused on a broader topic that would suit the varied audience we had. And she delivered the message, that was received with many curious questions.
But as I said previously, expecting to always have a good talk is not a good thing. Let’s be more pratical: what can we do to make people engage more? A suggestion made on that discussion is to give an opportunity to people who were too embarrassed to ask questions, such as using an anonymous questioning system or even Twitter hashtags (which is a great idea). Also, we should avoid pointless questions such as “did you consider the magnetic fields?”: they do not help in engaging people; in fact, they can make it harder. Please, leave technical questions for an after-talk session or just read the paper; unless, of course, the talk is targeted to a technical audience who will actually be interested to know about your goddamned magnetic fields.
Another idea I read somewhere was that some people find the informal sessions, such as the coffee-break and the dinner, actually more productive, science-wise. Maybe we could have meetings that consisted only on feasting. I don’t think I would suit to these, though, because I would always have my mouth busy and wouldn’t be able to talk.
Second point: blaming an abstract entity
Something was brought up in the discussion that made me a bit uneasy at the time, and in hindsight, I completely disagree with: they said the lack of care for talks or other areas of astronomy (or the fact that students are afraid to ask questions) are part of “our culture” (whatever they meant by that). In fact, I think it is a dangerous line of thought. This thing about always blaming our culture for its miseries has a name in Brazil: it is known as Complexo de Vira-lata (which literally translates to “the Mutt Complex”). If you’re reading this post and work in another astronomy department somewhere else, you’ll most probably relate to the issues of talk attendance. When I was an exchange at Kapteyn Astronomical Institute, at the University of Groningen, the attendance to talks too wasn’t that prolific (I don’t have numbers to cite, though). And the faculty staff didn’t stimulate students to attend them; in fact, it was only my graduate colleagues that did.
I don’t think this is an issue of the culture of our country or of our astronomy departments. First of all, how to objectively define a culture? And how can we change it? Or rather, is it possible to change a culture? How can we change something that we can’t even define? As with the bad talkers, there is no point in discussing this. We should not blame what we can’t define.
Wrapping up: my suggestion
And after presenting you with the discussion we had, here is my take on the issue: can we try smaller groups of discussion? I remember that the best science discussion sessions I had during my course in academia, so far, have been with small groups: up to 10 people, tops. The problem with big sessions is that they will eventually turn into the so dreaded traditional talks, which are less engaging and are more prone to frustrations, almost like classes. Sometimes they are unavoidable, such as in congresses and scientific meetings, and maybe this is their place. But in weekly sessions, it is probably too much.
When we use our eyes and common light detectors on telescopes, we see mostly what is called visible light, or rather, a very limited interval of wavelengths (in the order of hundreds of nanometers). In this regime, we can observe and study many objects in the sky, but not the ones that are shrouded by clouds of gas and dust, because visible light cannot pierce through these barriers: it is in fact absorbed or scattered. For that end, we invented infrared astronomy: by using different detectors, we can observe light in the infrared wavelengths (in the order of micrometers). And since we started using that, we’ve been able to peer through the curtain of gas and dust that obscured our vision for many regions of the sky.
Some of the most interesting objects that we can observe with infrared telescopes are protostars. These are objects that have already started collapsing and forming cores of dense material that emit radiation, and because they’re still very young, they are completely wrapped around clouds that did not collapse. The interaction between the radiation and the material around protostars produce an intriguing environment, where large and complex molecules can grow. The protostars will eventually turn into full-fledged stars, possibly with planets, comets and asteroids around them, and these objects will be populated by the complex molecules formed when the stars were only babies in their dusty cradles.
One way to understand how planets and stars are formed is through the chemistry of their beginnings, a field of study that is today known as astrochemistry. Although Hubble’s near-infrared detector and the Spitzer telescope produce some pretty cool images, in order to understand better the chemistry of the regions around protostars, we need to “see” the molecules themselves. And for that we have high-resolution spectrum detectors coupled to telescopes like the Herschel Space Observatory. By using spectra, we can observe the light emitted by molecules when they are excited by the radiation from the protostar, just like atoms do (electronic transitions). Unlike atoms, molecules emission comes from vibrations and oscillations in their structure, and they can happen in various ways, which produce various emission lines in the spectrum. Herschel is a single-dish telescope, which is basically an antenna that captures information on a single-pixel (just like the Arecibo Observatory). Herschel is amazing in observing spectra, but it has a downside: poor angular resolution. I mean, it’s observing a rather large region of the sky (with a beam size of ~20 to ~40”) in only a single-pixel!
One of the ways of doing astrochemistry is performing various experiments here on Earth, trying to simulate the conditions of space and then constructing models from these experiments and from the theory (such as radiative transfer). With these, we can try to figure out what is the chemical composition of an object in the sky just by looking at its spectra. And people have been doing that. In particular, this pre-print on arXiv caught my attention the other day (it was accepted for publication on The Astrophysical Journal). Apparently, there is a current trend of underestimation of abundances of complex organic molecules (COMs) on low-mass protostars when we try to model them through astrochemistry.
The general idea was that this could be caused by the rather large beam size of submilimeter telescopes (particularly Herschel), because the objects being observed were much smaller than the region being probed by the antenna. For instance, the hot corinos, which are the most dense regions of a low-mass protostar, have an angular size of less than 1”, generally. So the light coming from them gets averaged through beamsizes of 10 to 20”. The authors of this study decided then to observe two low-mass protostars with IRAM Plateau de Bure Interferometer (PdBi), which can achieve a spatial resolution of 1 to 2”. There’s a price to pay though: it has way less spectral resolution than Herschel’s instruments, so extreme care had to be taken when analyzing the spectra in order to study superimposing lines.
They detected a number of molecular lines from COMs (see table 2 on the pre-print), but some of them had to be discarded because of blending (caused by the low spectral resolution) and dubious identifications. They even had the first detection of glycolaldehyde in low-mass protostars other than IRAS 16293.
After the spectral analysis, the next step was constructing rotational diagrams. With these plots, we can derive how the molecules are being excited (through a parameter called excitation temperature) and their density on the line of sight (or column density). The first one is important to compare to other such objects and to estimate the actual [kinetic] temperature of the environment. The column densities are important to analyze the optical depth of the molecules, which in turn is used to model the emission of the object. Once we can model the emission, we can estimate abundances (a measure of how abundant is a molecule in relation to a another given molecule). In this case study, because methanol is the most abundant organic molecule in such objects, they used as the “given molecule” to compute the abundances of other COMs.
What they saw from the results was different from the previous observations done on single-dish. For one, the latter carried many uncertainties due to spectral contamination by weak lines and different calibration methods. In the end, the abundances from single-dish were generally overestimated compared to the ones from interferometry. When compared to other similar sources, the two protostars from this study showed lower abundances of methanol, but the authors argue that these discrepancies may arise from the different methods used to study such objects, instead of actually different chemical conditions between the protostars. This study also conclude that the abundance ratios of COMs stay relatively constant with the luminosity of protostars, which means that the low-mass ones may have a very similar chemistry as do their massive counterparts. This is a very important result.
But all these were results derived from observation. Actually, I cannot stress enough how absolutely amazing is that we can extract so much information from just tiny specks of light from the sky. But can we reproduce the same chemical conditions from our astrochemical models? The authors used a fairly recent model (Garrod 2013) and another not-that-recent-but-still-good (Rodgers & Charnley 2001). In the end, both of them predicted a lot less methyl formate than what was observed, and results for other molecules hints us about how some of these COMs can be formed in such environments (either in gas phase or as ices on dust grains).
Studying very young stellar objects (YSOs) is one of the most active fields in astronomy today, and it is exciting because there are so many things still unknown. And it gets even more interesting when we try to fuse other fields, such as chemistry. In the end, everything will (hopefully, if humanity doesn’t destroy itself) come together to an intricate understanding that will explain our very origins. This is the stars and their beauty in deconstruction.
In 2009, Brazil showed an interest to become the first non-European member of ESO, the European Southern Observatory, one the the most successful international efforts in astronomy. In the end of his mandate as minister of science and technology, Sérgio Rezende was one on the front of the membership agreement proposed to ESO. Since then, the consortium has been allowing Brazilian astronomers to use its facilities in Chile before the agreement is completed. Great scientific feats of astronomy were made with the participation of Brazilian astronomers, such as the discovery of the oldest solar twin and even the detection of a ring system around asteroid Chariklo. Both studies were featured in international scientific publications.
Even though ESO has already given carte blanche for the membership of Brazil, the process is still stuck in political bureaucracy. Currently, it’s been more than 4 years since the initiative, and it is still being held under procedure by the plenary, in state of urgency. ESO has been waiting patiently for the political decision because it is going to cost Brazil 130 million euros (according to this FAQ), or 800 million reals (according to the plenary, or US$ 283 million), and this money is going to be used for the construction of E-ELT, the biggest telescope ever built (its primary mirror will have a diameter of 39 m).
However, all this effort for the development of astronomy and science is under severe threat: on February 5th, the member of the parliament Fábio Garcia (which ironically is affiliated to PSB, the same political party the Sérgio Rezende is part of) blocked the appreciation of the project in the plenary, saying the following:
At this moment of crisis that our country faces, we can’t pay 800 million reals in commitment with astronomical studies. Meanwhile, the Brazilian people suffer with lack of quality in health, education and public safety […] I asked for the removal of the project from the agenda in order to buy time and enlighten you [the plenary] about this agreement. I intend to convince you that we have other, more urgent, issues to be solved.
Now, let’s analyze these affirmations by Fábio Garcia, point by point.
1. “At this moment of crisis that our country faces, we can’t pay 800 million reals in commitment with astronomical studies”
Really? Let’s see: Brazil has 513 members of the parliament, and the annual cost of each one is, according to Transparência Brasil, R$ 6.6 million (US$ 2.3 million). Supposing that the ESO’s fee of 800 million reals would be paid in equal parts (which it won’t) over 10 years (which it will), each part would cost Brazil the equivalent to 12 members of the parliament per year. On the other hand, in 2014, the federal government spent more than 820 million reals in investments on equipment and materials for the CNH Industrial Latin America. Just in one year! Actually, still in 2014, the federal government invested 95 billion reals on individuals and companies. One 10th part of ESO’s payment would cost 0.08% of the total investments done in 2014.
2. “Meanwhile, the Brazilian people suffer with lack of quality in health, education and public safety”
This is pure demagogy. Yes, in fact a lot of Brazilians suffer with poor health, education and public safety, but this argument is used only as a distraction. In 2014, the federal government injected 93.9 billion reals to public health, 91.7 billion reals to education (in contrast, only 9 billion to science and technology), and 8.5 billion reals to public safety. If each 10th part of ESO’s fee was equally divided to each of the three sectors, it would result in a raise of 0.028%, 0.029% and 0.314%, respectively to the budgets of health, education and public safety.
The problem is not the invested quantities, it is the way they are spent. And it is exactly at this point that we scientists keep on hammering: the money spent on science is not an expenditure, it is an investment. The return of this investment is sufficiently important to make other BRICS countries elbow each other on the queue for ESO membership, if Brazil defaults. Sadly, one of the things that Fábio Garcia fails to see that science does not only need scientists, and that astronomy is not only made for and by astronomers. As an example, the National Astrophysics Laboratory (LNA) is composed of 27 technicians and technologists in engineering and science, 5 in precision machining, 13 in observatory coordination, 6 in maintenance services, 58 employees on management and logistic support, and only 22 astronomers. As we can see, astronomy (as any other science) employs a diversified and very specialized workforce (positions that Brazil lacks profoundly).
I also do not understand why Fábio Garcia separated astronomy from education. To me, both are so intimately bonded that it is impossible to keep them apart. This is something that I keep repeating on my texts: education is not only to sit in a stupid chair for hours inside four walls. Education is much more than that: it is engaging with learning. And astronomy is one the most successful sciences in doing that. If, on one side, physics and mathematics can be discouraging (more for a cultural reason, in my opinion), astronomy manages to inspire and rouse people’s curiosity.
Astronomy unites people. Maybe one the most remarkable natures of this science is the international cooperation (the whole point about ESO, by the way), and I have wonderful experiences with that. During my exchange period through the Science without Borders program, I had the pleasure of studying and living with people from all over the world, all of them aiming towards the same path: exploring the universe. If that is not education, I don’t know what it is.
3. “I asked for the removal of the project from the agenda in order to buy time and enlighten you about this agreement”
I shudder to think that Fábio Garcia wants to “enlighten” the other parliament members about this, given that he doesn’t seem to have even read about the Brazil/ESO agreement. Much of the international scientific and astronomical communities wait for the ratification of the agreement. We can’t spent any more days, we are losing time!
Brazil has already benefited from the ESO facilities, who is letting us do so even before the agreement is finished. Additionally, our country has already agreed to pay part of the E-ELT construction, and the consortium (along with the entire astronomical community) waits anxiously to start this enterprise. If Brazil give up now, that would mean to default one of the most prestigious scientific agencies of the world, and another stigma for Brazil’s young science (along with defaulting ISS and CERN).
4. “I intend to convince you that we have other, more urgent, issues to be solved”
Contrary to Fábio Garcia, I think that the development of science, technology and education should be indeed priorities of Brazil (as I said, I can’t keep education apart from all this). Public safety and health may have urgent issues to be solved, but the investment in astronomy is not an antagonist. In fact, these aspects go hand in hand in developed and developing nations. For instance, some of the techniques used today in medicine (such as the imaging of internal parts of the body) are a reality because of astronomy. Technology that is common place today, such as digital cameras attached to cellphones and safety cameras, are also products of investments in astronomy.
I understand Fábio Garcia’s want to make Brazil a better country, and I think he acts with good intentions. However, his lack of information about the subjects (international relations, science, technology and their implications) and his short-sight can be harmful to the efforts made by Brazilian science. Developed and other developed countries give extreme priority to education, science and technology, and if Brazil wants to reach that place someday, we need to take these issued more seriously that we do today. Otherwise, we will always be the “country of the future”.
On February 13, Fábio Garcia stated on his Facebook page that he had a talk with the astronomers Marcos Diaz (University of São Paulo) and Gustavo Rojas (Universidade Federal de São Carlos), in which they could show him the aspects of the Brazil/ESO agreement. Garcia said that the federal government needs to fulfill the agreement and also the obligations with states and municipalities. He proposed to have reunions with the Ministries of Finance and Science & Technology to deal with these issues.
This is good news, and as I said, Garcia seems to be well-intentioned. And it is good to know that he is open to discussion. However, the decision must be taken as soon as possible, given that the ratification has been delayed countless times, dragged around for more than 2 years. All this gives the Brazilian scientists an optimism injection, but it is important to not let our guards down. Astronomy is still seen, sometimes, as a superfluous and frivolous science, but it’s been one of the most important tools of humanity since the birth of agriculture. We have to fight to warrant Brazilian science a place on the global scene.
Featured image: artistic depiction of the ring system around asteroid Chariklo, a discovery that had participation of Brazilian astronomers. Credit: ESO, L. Calçada, Nick Risinger
Since I started studying Python programming, I’ve been creating some sample codes, here and there, that solve physics problems. Most of them are exercises from books, the internet and occasionally from school assignments. I have a lot of fun creating them, even though they can be quite difficult to compute sometimes. Because of that, I started a very laid back project called Pysics, which is basically publicizing a compilation of these exercises, so that they can be used by other students.
Initially I was creating a program on GitHub, but since I got to know this amazing tool called IPython Notebook, I realized that this should be the best manifestation of Pysics, without question.
So, here it is, the Pysics notebook one. You can also download the ipynb file here. It basically contains four exercises: plotting the electric field produced by point-size electric charges, calculating the time-evolution of a coupled triple pendulum, computing Bessel functions and simulating the diffraction pattern of a telescope.
I plan on working on one or two more notebooks, which I will release someday (not sure when, for my graduate school starts in just a few weeks and I will be busy with the preparations). But, for now, I hope this notebook can be useful and inspiring to you.
Featured image: the diffraction pattern produced by a point-like source of light as seen on a telescope.
If you’re a gamer (or at least have met one), you will know that, in order for a computer to run a fairly recent game, it needs a little more then just a [central] processing unit (aka CPU): it also needs a graphics processing unit (aka GPU). This is because these games require an incredible amount of computing, and the elements to be computed are very special: arrays. Arrays are kinda like matrices (or other multi-dimensional structures), but they are optimized in a way that it is easier to make calculations on them.
One example of array computing is image processing. Digital images are composed of pixels, and each pixel stores a specific value. An image editing software (such as Adobe Photoshop or GIMP) is capable of manipulating these values for each pixel.
One of the biggest advances in modern computing is something called parallelism. With that, it is possible to make a processing unit work on various elements of an array at the same time, in parallel, hence the name. Each element is processed as a thread (that’s why parallelization is sometimes called threading). You might remember that a few years ago, dual core processors started being used on personal computers, and it was a rage. These CPUs could parallelize jobs to the two cores and were crazy fast for their time. Today, high-end machines can have a CPU with something like 12 or 16 cores.
On the other hand, GPUs (also called video cards or graphic cards) can work on many, many more threads than CPUs, because they are optimized for that type of job (dealing with arrays). In fact, the NVIDIA graphic card I have on my notebook has 2 multiprocessors with 192 cores each, and it can work with 2048 threads per multiprocessor. It can actually run games just a little better than a PlayStation 3.
But besides games and image/video processing, there are many other applications that use array-type structures, including scientific ones. For instance, astronomers constantly work with arrays of data coming from observations, signal processing, multiple-dimensional simulations and so on. Is it possible to make GPUs work for science?
The answer is yes. In fact, NVIDIA has developed a programming environment especially for end-users to be able to harness the power of their graphic cards. It is called CUDA. So it’s kinda like a new programming language, but not quite. CUDA revolves around using very specific lines of code, and they work as substitutes to normal C code blocks, almost like transplanting a (sometimes) better and more efficient block than the original one. Since it’s a “strange body” inside the C code, the user has to be careful in making the original code able to talk with CUDA. This might not seem like a big deal for programmers who’ve always been working with C, but it’s very weird to, e.g., Python users. And here comes some good and bad (?) news.
The first good news is that it is possible to make use of CUDA programming in Python codes, and that is a huge thing for scientists, because there are many of us who use this language. There is an open-source tool for that: PyCUDA. It works as a library that enables Python codes to be able to talk with the CUDA software and hardware in your machine. I’ve been able to install and run the sample codes that come with PyCUDA in my notebook. However, and this is the bad news, attaching a CUDA block is not as easy and bureaucracy-free as the Python codes we are used to. Because it is very much like C, CUDA codes inherit all the caveats from that language, which include dealing variable declaration, memory allocation and the dreaded pointers. PyCUDA includes a bunch of neat “shortcut” functions that can make everything easier on Python programmers, such as multiplying arrays, but in order to do more complicated calculations, it is probably necessary to know your C and CUDA languages.
I am a bit hung up on that part. I’ve been re-studying a bit of C in my free time and when the hot weathers gives in a little bit so I can work on my PC without quickly wearing out (no air-conditioning here). I’ve also been reading a bit about CUDA coding, so I guess it will take me some time to be able to use PyCUDA as I really intended to.
And here comes the second good news: maybe there is no need for all that. Some really clever people have worked on a tool that can help Python users to harness the power of their GPUs without the need to deal with C and most of CUDA coding. It’s Continuum Analytics’ Anaconda. The way it works is by attaching decorators to Python codes and the software behind Anaconda does most of the work of translating that to CUDA and sending the code to be processed on the GPU. There are some tutorials on YouTube about this tool, and I think it’s really handy. But, as you might have guessed, there is also a bit of bad news: Anaconda is not free. However, students and people affiliated to education institutes are allowed to have a free license of Anaconda, with all the features that it has. And that is really, really cool on their part. I have downloaded and installed Anaconda on my notebook, with no big hassles, but I haven’t tried using it in my codes yet.
Speaking about hassles, I have to say, installing CUDA on a Linux machine is probably not one of the easiest things. The installer from NVIDIA’s website will, by default, install the latest driver for your video card, and we all know that dealing with official NVIDIA drivers on Linux can be a huge pain in the ass, depending in what is your GPU and your distro, and may actually become downright frustrating. Ugh. But I think it pays off. Actually, for me, the pay off for using the latest driver is great. The previous driver I was using, version 331.113, which is currently listed on Linux Mint’s driver manager, didn’t work optimally in accelerating the graphics on my notebook. But when I installed the driver version 340.29 that came with CUDA, everything worked like a charm. Now I have a pretty satisfying acceleration and games play beautifully on Steam. And even so, power consumption is still pretty much the same (but, of course, when I want to use a lot of graphics acceleration, I just plug it in).
So, there you go, you have my take on CUDA computing for now. I still want to talk about how some Python codes improve by running them on the GPU, and comparing them with the CPU counterparts, but I will leave that for another post. I plan on putting up some GPU accelerated pieces of code into the public so anyone can also try and see how it plays on their video cards. I could try it either with PyCUDA and Anaconda, but the second option will only work for people who have a license, and that is kind of a bummer. It is difficult to produce open-source codes if part of them depend on licensed software. Actually, could it even be called open-source in that case?