Monday, June 20, 2011

Contour Plotting

I'm doing a lot of graphing this summer, so I'm still doing many kinds of Python exercises. Today I made a contour map plotter function of a 2-D Gaussian Distribution. I'm pretty sure this code will be very useful in the future, when I start plotting the brightness of each pixel in CCD images.

The graph plots a Gaussian function defined by these equations:

G(x,y)=A0+Aexp(-U/2)
Where:
U=(x'/a)2 + (y'/b)2
and
x'=(x-h)cos T - (y-k)sin T
y'=(x-h)sin T + (y-k)cos T


A0 = constant offset
A1 = amplitude
a = s width of Gaussian in the X direction
b = s width of Gaussian in the Y direction
h = X centroid
k = Y centroid
T = Theta, the rotation of the ellipse from the X axis in radians.


You can pick between two different types of contour maps: Solid or not solid. 
Solid looks like this:
While not solid looks like this:
As you can see, you can also set a bunch of different arguments, including the x and y range, resolution, the angle of rotation, x-axis sigma, y-axis sigma, amplitude, offset, etc.... There is also a handy little column on the right indicating the corresponding values of the colors. 

One very important thing to note is that the solid contour map takes ages to plot. You would be better off not using it. By default, the argument solid is set to false, so that a line contour map is plotted. 
------
Aside from that, today I created my blog and caught up on some posting I should have done last week. I also managed to finish reading one of the research papers I was supposed to. 

Learned:
Contour mapping on Python. Also that it's best not to use fancy solid rainbow colors and stick to lines. 

*I should probably mention that the exercises I do come from this page: 
I just use Python instead of IDL to code. 

No comments:

Post a Comment