[Thread Prev][Thread Next][Index]

Re: [ferret_users] special functions in ferret



Hi Martin,

There are two options with PyFerret that I can think of: one within PyFerret, the other outside PyFerret.

The option for doing it within PyFerret is to write an Ferret external function written in Python.  This function can then be called at the Ferret prompt.  The ferret_init method of your Python script describes the result grid; the ferret_compute method will be given NumPy arrays of your input and a NumPy array for you to assign with your result.  This is probably the easiest and cleanest way to do standard calculations.  All the PyFerret statistical functions are done this way, making use of SciPy statistical functions.
See: http://ferret.pmel.noaa.gov/Ferret/documentation/pyferret/pyefs
also at a Python prompt (after importing pyferret): help(pyferret.ferret_pyfunc)

The other option is to get the input data (as NumPy arrays) from PyFerret using pyferret.getdata, do your calculations (at the Python prompt), then push the data back into PyFerret using pyferret.putdata.  This is more complex but gives you more freedom.  It would be nicer if PyFerret used xarray - high on the to-do list but still not there yet.

Kind regards,
Karl


On Sat, May 5, 2018 at 1:10 AM, Martin Schmidt <martin.schmidt@xxxxxxxxxxxxxxxxx> wrote:
Hi all,

I would like to apply special functions (Bessel function) in ferret or more specifically in pyferret. One option is to use a library like gsl and to import it as an external function. Saving an intermediate result to file and using ncap2 works too.

However, I wounder if it is possible to import python module like  numpy, scipy or teos-10 into ferret. Searching the manual showed me only the opposite way, i.e., how to import pyferret into python.

Any suggestion, especially short examples as a starting point would be of great help.

Greetings,

Martin







--
Karl M. Smith, Ph.D.
JISAO Univ. Wash. and PMEL NOAA
"The contents of this message are mine personally and do
not necessarily reflect any position of the Government
or the National Oceanic and Atmospheric Administration."

[Thread Prev][Thread Next][Index]
Contact Us
Dept of Commerce / NOAA / OAR / PMEL / Ferret

Privacy Policy | Disclaimer | Accessibility Statement