Package: ferretmagic
ipython_ferretmagicIPython notebook extension for ferret (a great software for Data Visualisation and Analysis from NOAA/PMEL).Browse the demo notebooks fromhttp://nbviewer.ipython.org/github/PBrockmann/ipython_ferretmagic/tree/master/notebooksCombine ferret and ipython widgets and create interactive notebooks !Test it with binder.Browse a basic ferret tutorial using ferretmagic from:https://github.com/PBrockmann/C-CASCADES_notebooks/blob/master/ferretBasics.ipynbLatest news2022/08/25Fix to run with ipykernel 6.15.12020/06/03Update pip package to offer /outline control (now last version is 20200603https://pypi.org/project/ferretmagic/)2019/11/13Tested with python 3.7, pyferret 7.5.0Notebooks run with mybinder.org with 2 files (environment.yml and postBuild)2018/12/10Tested with pyferret==7.442018/10/01Compatibility with python 3 with print command and base64 encodingTested with pyferret==7.43, notebook==5.7.0, jupyter==1.0.0, ipython==5.8.0, ipywidgets==7.4.2Update pip package (now last version is 20181001https://pypi.org/project/ferretmagic/)2018/01/18a Docker image is available fromhttps://hub.docker.com/r/pbrockmann/pyferret-7.3/pyferret 7.3 and ferretmagic extension can now be fully tested from binder (http://mybinder.readthedocs.io/en/latest) !Tested with pyferret==7.3, jupyter==4.4.0, ipython==5.5.0, ipywidgets==7.0.52017/03/17Tested with pyferret==7.1, jupyter==4.2.0, ipywidgets==6.0.02016/10/28Tested with pyferret==7.0, jupyter==4.2.0 and ipython==5.1.0Installation from pipInstallationInstall PyFerret following instructions fromhttp://ferret.pmel.noaa.gov/Ferret/documentation/pyferretIt will set all directories needed to run pyferret (font, ppl, jnls, datasets, ...).You can also install PyFerret as a conda package fromhttps://anaconda.org/conda-forge/pyferret(no datasets distributed).Then install the ferret magic extension (ferretmagic.py) by typingpip install ferretmagicUsageIn a Jupyter notebook with kernel python (previously named ipython), load the magics:In [2]: %load_ext ferretmagicLine magicsThe%ferret_runmagic 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 magicsMulti-line input can be entered with the%%ferretcell magic:In [4]: %%ferret
  ....: use levitus_climatology
  ....: shade temp[k=1]			! commentsControl 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 ferretVariables 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 myvarExplore notebook for examples.Known issues and limitationsNote that the pdf file produced by -p,--pdf option is not embedded in the notebookLimitations are the ones exposed from pyferret, the qualifier /pattern is not usable for example. Readhttp://ferret.pmel.noaa.gov/Ferret/documentation/pyferret/known-issues