PyFerret

From ScientificComputing
Jump to: navigation, search

Category

Visualization, Data analysis

Description

PyFerret is a Python module wrapping Ferret. Ferret is an interactive computer visualization and analysis environment designed to meet the needs of oceanographers and meteorologists analyzing large and complex gridded data sets. Ferret was developed by the Thermal Modeling and Analysis Project (TMAP) at PMEL in Seattle to analyze the outputs of its numerical ocean models and compare them with gridded, observational data. The model data sets are generally multi-gigabyte in size with mixed multi-dimensional variables defined on staggered grids. Ferret offers a Mathematica-like approach to analysis; new variables may be defined interactively as mathematical expressions involving data set variables. Calculations may be applied over arbitrarily shaped regions. Fully documented graphics are produced with a single command.

Available versions (Euler, old software stack)

Legacy versions Supported versions New versions
1.0.2

Please note that this page refers to installations from the old software stack. There are two software stacks on Euler. Newer versions of software are found in the new software stack.

Environment modules (Euler, old software stack)

Version Module load command Additional modules loaded automatically
1.0.2 module load gcc/4.8.2 pyferret/1.0.2 openblas/0.2.13_seq python/2.7.6 java/1.8.0_31 szip/2.1 hdf5/1.8.12 netcdf/4.3.1

Please note that this page refers to installations from the old software stack. There are two software stacks on Euler. Newer versions of software are found in the new software stack.

Interactive session

In order to start an interactive PyFerret session on one of the login nodes, you can use the command pyferret to start the PyFerret interpreter.
[sfux@eu-login-04 ~]$ module load gcc/4.8.2 pyferret/1.0.2
Autoloading openblas/0.2.13_seq
[sfux@eu-login-04 ~]$ pyferret 
    WARNING: Unable to import shapefile;
             shapefile_* Ferret functions will not be added.
    WARNING: Unable to import ESMP;
             curv2rect* Ferret functions will not be added.
             Use curv_to_rect* functions instead
        NOAA/PMEL TMAP
        FERRET v6.9 (PyFerret 1.0.2)
        Linux 2.6.32-431.5.1.el6.euler.x86_64 - 07/16/14
        27-Jan-17 13:11     

yes?
Please note that computations cannot be run on the login nodes and need to be submitted as batch jobs.

How to submit a job

In order to submit a PyFerret job in batch mode, you need to create a .jnl script and execute it in batch mode. You can for instance submit a script example.jnl with the following command:
sbatch [Slurm options] --wrap="pyferret [pyferret options] -batch -script example.jnl"
Here you need to replace [pyferret options] with pyferret command line options (please run pyferret -h for getting a list of all command line options) and [Slurm options] with Slurm parameters for the resource requirements of the job. Please find a documentation about the parameters of sbatch on the wiki page about the batch system.

Example

As an example for using PyFerret, we run the bar_chart_demo.jnl script, that is part of the PyFerret installation.
[leonhard@euler08 ~]$ cat bar_chart_demo.jnl 
! bar_chart.jnl
! *sh* 6/99
! *acm* 7/01 update /xlimits to /hlimits

! Description: demonstrate usage of bar charts

set mode verify

! most basic example -- no overlay, no axes
let a = RANDN(I[i=1:8]) + 1
go bar_chart3 poly/line/fill/nolabel/noaxis a a
label/nouser 0.5,-.1,1,90,.16 @CRItem 1
label/nouser 1.5,-.1,1,90,.16 @CRItem 2
label/nouser 2.5,-.1,1,90,.16 @CRItem 3
\pause

! overlay two variables on auto-formatted axes
let a = 1+RANDU(I[i=1:10])
ppl axset 0,1,1,0  ! remove top and right axes
plot/hlimits=0.5:10.5/sym/ylim=0:2/title="My Bars" 0*a+0.5
go bar_chart3 poly/line/palette=red/overlay/title="My reds" a
let b = RANDU(I[i=1:10]+1)
go bar_chart3 poly/line/palette=blue/overlayy/title="My blues" b
ppl axset 1,1,1,1  ! restore normal axes
\pause

! time series colored by magnitude
let a = RANDN(T[T=2-jan-1990:1-jun-1990:24])
plot/ylim=-3:3/title="hist-style plot" 0*a
go bar_chart3 poly/over/palette=no_green_centered/levels=(-3,3,.5)/nolab a a

[leonhard@euler08 ~]$ module load gcc/4.8.2 pyferret/1.0.2
Autoloading openblas/0.2.13_seq
[leonhard@euler08 ~]$ bsub -n 1 -W 0:15 -R "rusage[mem=512]" "pyferret -batch -script bar_chart_demo.jnl"
Generic job.
Job <36553098> is submitted to queue <normal.4h>.
[leonhard@euler08 ~]$ bjobs
JOBID      USER       STAT  QUEUE      FROM_HOST   EXEC_HOST   JOB_NAME   SUBMIT_TIME
36553098   leonhard   PEND  normal.4h  euler08                 *_demo.jnl Jan 30 09:56
[leonhard@euler08 ~]$ bjobs
JOBID      USER       STAT  QUEUE      FROM_HOST   EXEC_HOST   JOB_NAME   SUBMIT_TIME
36553098   leonhard   RUN   normal.4h  euler08     e1339       *_demo.jnl Jan 30 09:56
[leonhard@euler08 ~]$ bjobs
No unfinished job found
[leonhard@euler08 ~]$ ls
bar_chart_demo.jnl  ferret.png  lsf.o36553098

The demo script creates a bar chart and saves the result as .png. If no name for the file is given the file will be saved as ferret.png.

Bar chart example

License information

Ferret license

Links

http://ferret.pmel.noaa.gov/Ferret/downloads/pyferret

https://github.com/NOAA-PMEL/PyFerret