Tuesday, July 20, 2010

Mollweide projection with gnuplot

Most of the people knows I am a fun of the plotting tool gnuplot.


Well, I needed to do some plots using the elliptical projection or Mollweide projection of some data. Unfortunately, gnuplot is not able (not out the box :) ) to do that. So, I create the proper function to perform that. This is the code to add:


mwhigh(x) = 1.0 + -0.919061*(abs(1.0-x))**0.674635
mwmed(x) = mwhigh(x) -0.0807765 + 0.161136*x -0.0796311*x**2
mwlow(x) = mwmed(x) -3.53551e-05 + 0.000645749*x

mwst(x) = x < 0.2 ? mwlow(x) : (x < 0.9 ? mwmed(x) : mwhigh(x) )

mwt(b) = b>0 ? asin(mwst(sin(abs(b)))) : -asin(mwst(sin(abs(b))))

mwx(b,l) = 2.0*sqrt(2.0) * l * cos(mwt(b))
mwy(b,l) = sqrt(2.0) * sin(mwt(b))



so, for a table b (-pi/2, pi/2) and l (-pi,pi) the functions mwx and mwy generate the map. :)



very nice, no?

3 comments:

MarioAAO said...

Nice, indeed!

Juan C. Tello said...
This comment has been removed by the author.
JunCTionS said...

Thanks! it's very very nice!

I used this for something I'm working on and also wrote about in another blog so hopefully more people can get to it (I tried to write it in a manner understandable to someone who like me has little idea about gnuplot).