Skip to main content

ipython extension for pyferret

Project description


IPython notebook extension for ferret (a great software for Data Visualisation and Analysis from NOAA/PMEL).

Browse the demo notebooks from

Combine ferret and ipython widgets and create interactive notebooks !

Test it with binder. Binder

Browse a basic ferret tutorial using ferretmagic from:


Latest news


  • Tested with python 3.7, pyferret 7.5.0
  • Notebooks run with with 2 files (environment.yml and postBuild)


  • Tested with pyferret==7.44


  • Compatibility with python 3 with print command and base64 encoding
  • Tested with pyferret==7.43, notebook==5.7.0, jupyter==1.0.0, ipython==5.8.0, ipywidgets==7.4.2
  • Update pip package (now last version is 20181001



  • Tested with pyferret==7.1, jupyter==4.2.0, ipywidgets==6.0.0


  • Tested with pyferret==7.0, jupyter==4.2.0 and ipython==5.1.0
  • Installation from pip


Install PyFerret following instructions from It will set all directories needed to run pyferret (font, ppl, jnls, datasets, ...).

You can also install PyFerret as a conda package from (no datasets distributed).

Then install the ferret magic extension ( by typing pip install ferretmagic


In a Jupyter notebook with kernel python (previously named ipython), load the magics:

In [2]: %load_ext ferretmagic

Line magics

The %ferret_run magic enables one-line execution of ferret command in the IPython interpreter or notebook:

    In [3]: for i in [100,500,1000]:
      ....: 	%ferret_run -s 400,400 'plot sin(i[i=1:%(i)s]*0.1)' % locals()

Cell magics

Multi-line input can be entered with the %%ferret cell magic:

In [4]: %%ferret
  ....: use levitus_climatology
  ....: shade temp[k=1]			! comments
  • Control size of plot with --size, -s option.
  • Create a local pdf at the same time with --pdf, -p option.
In [5]: %%ferret -s 400,300 -pdf myfig.pdf
  ....: shade temp[k=1]			

Passing variables between Python and ferret

  • Variables can be pushed from IPython into ferret with %ferret_putdata:
In [18]: %%ferret
   ....: use levitus_climatology
In [19]: %ferret_getdata tempdict = temp
   ....: Message: tempdict is now available in python as a dictionary containing the variable's metadata and data array.
In [20]: print tempdict.keys()
   ....: ['axis_coords', 'axis_types', 'data_unit', 'axis_units', 'title', 'axis_names', 'missing_value', 'data']
  • Variables can be pulled from ferret into IPython with %ferret_getdata:
In [31]: import numpy as np
   ....: b = {}
   ....: b['name']='myvar'
   ....: b['name']='myvar'
   ....: x=np.linspace(-np.pi*4, np.pi*4, 500)
   ....: b['data']=np.sin(x)/x
   ....: b.keys()
Out[31]: ['data', 'name']
In [32]: %ferret_putdata --axis_pos (1,0,2,3,4,5) b
   ....: Message: b is now available in ferret as myvar

Explore notebook for examples.

Known issues and limitations

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ferretmagic-20200603.tar.gz (7.7 kB view hashes)

Uploaded source

Built Distribution

ferretmagic-20200603-py3-none-any.whl (9.1 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page