Friday, December 16, 2011

The Good, The Bad, and The IDL


Astrophysics (fortunately or unfortunately) involves one form of coding or another. In my case that code is IDL. Now if you talk to certain people about different codes they become… let’s just say, passionate. I however am in the group that codes because they have to and learns the code that the person they work for uses, as they will hopefully know more than you do.

I am sad to say that in the month since I finished my literature review I have spent my days coding away in IDL. It is not all bad though, what I have found is that in writing a code or even looking up routines on the internet you learn a great deal about the process that reveal your results. 

The ‘beauty’ of coding it that when things are going well you feel like nothing can stop you, you have a clear plan and an end goal in mind. When things go bad, however, it feels like it will never work and you want to break down and cry right there at your desk. In this situation I suggest you swiftly put on something to hide the tears, I usually go with Stargate but the end scene from V for vendetta works wonders too! 

And remember Google is your friend!
 
A FEW CODING NOTES THAT I WOULD HAVE FOUND USEFUL!
 
;Finding the centroid of a star;
                Xcenter = TOTAL(TOTAL(array,2) * (INDGEN(length of  array)) / TOTAL(array)
                Ycenter = TOTAL(TOTAL(array,1) * (INDGEN(length of  array)) / TOTAL(array)
 
;Multiple line plots;
                Plot1 = PLOT(x, y, TITLE=’plot’, XTITLE=’x’, YTITLE=’y’, NAME=’array1’)
                Plot2 = PLOT(x2,y2, ‘green’, NAME=’array2’,  /OVERPLOT)
                Legend1 = LEGEND(TARGET=[plot1,plot2], POSITION=[0.75,0.75])

;Errorbars;
                errplot = ERRORPLOT(array, errarray, TITLE=’error plot’, XTITLE=’x’, YTITLE=’y’, ERRORBAR_COLOR=’red’)