lesommer / oocgcm

oocgcm is a python library for the analysis of large gridded geophysical dataset.
http://oocgcm.rtfd.io
Apache License 2.0
39 stars 11 forks source link

Porting equation of state related quantities from PyDom. #20

Open lesommer opened 8 years ago

lesommer commented 8 years ago

see PyDom.eos

lesommer commented 8 years ago

or rely on

rabernat commented 8 years ago

I have a fortran module which I extracted from POP to compute the JMD95 EOS. https://bitbucket.org/ryanaberanthey/pop_water_mass/src/master/watermasstools/jmd95.F90?at=master&fileviewer=file-view-default

I compiled it with f2py and it works great, super fast.

This could be a good approach.

lesommer commented 8 years ago

thanks for the input Ryan. Providing access to JMD95 would be a very good addition to the library.

I am a bit worried though with the idea of using externally compiled code in oocgcm. I would like the library to be as easy to deploy as possible and therefore I would like to use pure Python when feasible and avoid relying to much on FORTRAN and/or C.

An option could be to rewrite this module in pure python with numba or numpy based functions. Do you think that would be a lot of work ? do you think that the performances will be critically reduced ?

rabernat commented 8 years ago

The pure Python TEOS10 is extremely slow in my experience. I think numba is a very promising idea for the EOS.

Sent from my iPhone

On May 28, 2016, at 6:18 AM, Julien Le Sommer notifications@github.com wrote:

thanks for the input Ryan. Providing access to JMD95 would be a very good addition to the library.

I am a bit worried though with the idea of using externally compiled code in oocgcm. I would like the library to be as easy to deploy as possible and therefore I would like to use pure Python when feasible and avoid relying to much on FORTRAN and/or C.

An option could be to rewrite this module in pure python with numba or numpy based functions. Do you think that would be a lot of work ? do you think that the performances will be critically reduced ?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

lesommer commented 8 years ago

there is also a pure python version of jmd95 here.

jinbow commented 8 years ago

Python JMD95 from lesommer's link is originally from the MITgcm link. I agree with Ryan that the pure python version is a bit slower than fortran code, but it could be modified to work better with multi-dimensional array. The speed limitation will then be associated with numpy.

lesommer commented 8 years ago

thanks for your input, Jinbo.

As mentionned above, I would a priori prefer to avoid compiled code in oocgcm, except if really necessary.

since we are here only talking about a polynomial, I would not expect a python/numpy code to be more than say 50% slower than FORTRAN. plus we can probably get a speed-up with numba.

so I guess this probably needs someone to do a clean benchmark of the several options.

I will probably start by rewriting a jmd95 eos from scratch for these tests and let you know about the results.

lesommer commented 8 years ago

just coded a numba implementation of spice in eos.misc for profiling the execution time.

simon3122 commented 8 years ago

Hi Julien, Did you get the chance to do the profiling on the spice computation? Why not get a working version of the eos and try thinking about performance then? cheers

apatlpo commented 8 years ago

Simon implemented a non-optimized version of JMD95 (code from pydom), see https://github.com/lesommer/oocgcm/commit/e27d04d74f39020916dc11d6ba2c9e2cbed38e19 He is currently testing it. There seems to be unresolved issues with large grids. more details to come