Creating visualisations in Ferret

by Saurabh Rathore

Ferret and pyferret are the same software but the advantage of pyfrret over ferret is that you get a beautiful plot and all the analysis.

Pyferret uses Python for plotting data sets. Here I illustrate the use of the software to plot and analyse model data sets very easily and effectively. In this illustration I tried to show the line plots, section plots, overlaid line plots, depth profiles.

Ferret/pyferret can be used to produce multiple png or gif plot files or make animations. To find out more about this click on this link. There is also a strong  ferret community to help you out for the problems very quickly and effectively.

Ferret has been developed by NOAA and is open source, so you can use it without any license agreement. It is particularly powerful when it comes ot handling NetCDF files. Using ferret/pyferret you can do interpolation, regridding, create a netcdf file and text file very easily. 

 

This is the ferret prompt you will get after typing 

ferret -nojnl
or 
pyferret -nojnl

yes?

 

Now you are in ferret prompt, which will run .jnl scripts by the command 

go file_name.jnl

file_name.jnl is the jnl script you created for ferret/pyferret 

 

The command to create the .jnl file is 

yes? sp vi file_name.jnl        !!!! in ferret command !!!

or 

vi file_name.jnl                      !!!! in linux terminal !!!

 

What ever the command you use in linux terminal is accesible in ferret/pyferret by  using “sp” before the command in the ferret/pyferret prompt

e.g.

in linux “ls” shows the contents of a directory
in ferret prompt it is “sp ls” 

and

pwd” in linux
sp pwd” in ferret 

 


Example Visualisation. Coding can be found below the image.

 

! exclamation mark (!) is used for commenting which makes the line not to run in the script !

 

!! defining the multi panel plot space !!

go multi_view 3,2,.43,0.058,0.055,.26,.060,0.058,a

 

!! go multi_view rows, columns, xsize, xstarts, xgap, ysize, ystarts, ygap, panel_variable !!

!!!!!!! loading the file in ferret or py-ferret !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

use "/home/srathore/ferret_arc/file.nc"

 

!! or you can also load the file without giving the full path if you opened the ferret in the same directory !!

!! use file.nc !!

 

!!!!! use command will load the file in the ferret !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!! displaying the variable !!

 

show data     

!! i=longitudes, j=latitudes, k=depths, l=time !!

!! or in short for just type 'sh da' !!

!! showing the variable info in detail !!

 

sh gr sst

 

!! in full form it is 'show grid variable_name' !!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

 

 

!!!! ploting the basin average line plot !!!!!!!

let sst_basin_ave=sst[x=@ave,y=@ave]      !!!! assign the variable and doing the global average as x=@ave, y=@ave  x=longitudes, y=latitudes and level 1 !!!!!

set view_port a11                                                       !! setting the view port !!

plot/nolab/nokey/col=blue/thick/set sst_basin_ave                       !! plot command makes the line plot !!

ppl axlsze .19, .17                                                     !! control the font size on axis !!

ppl txlsze .15                                                          !! same but for time axis !!

ppl tics .1,.1,.0,.1,1,1                                                !! control the tics on the plot !!

ppl plot                                                                !! mandatory for using ppl command !!

label/nouser `($ppl$xlen)/1.9`,`($ppl$ylen)*1.04`,0,0,0.18 "@CR a) globally average SST degree celcius"                 !! label over the plot !!

 

 

!!!!! plotting the variable in 2-dimensional lat-lon plot !!!!!!!

set view_port a12

fill/pal=blue_orange/lev=(-2,32,2)/nolab/nokey/set sst[l=1:12@ave]        !! plotting the variable for time average, with palette color blue_orange, lev is lev of color bar and with no label and color key !!

ppl axlsze .16, .16

ppl tics .0,.1,.0,.1,1,1

ppl fill                                                                  !! ppl fill is mandatory and the /set in fill is to apply the palatte color

ppl axlabp -1 -1                                                          !! lat long on the axis in our plot it is -1 for lower botton and left side !!

go fland

label/nouser `($ppl$xlen)/1.9`,`($ppl$ylen)*1.04`,0,0,0.18 "@CR b) SST long term mean degree celcius"

 

 

!!!! ploting the basin average line plot !!!!!!!

let sst_basin_ave=sst[x=@ave,y=@ave,k=1]                                   !!!! assign the variable and doing the global average as x=@ave, y=@ave  x=longitudes, y=latitudes !!!!!

let sst1=sst[x=85E,y=16N,k=1]                                              !!! extracting data at a point !!

let sst2=sst[x=170W,y=5S,k=1]

let sst3=sst[x=40W,y=0,k=1]

set view_port a21                                                   !! setting the view port !!

plot/nolab/nokey/col=blue/thick/axes/vlimits=25:31:1 sst1           !! plot command makes the line plot !!

ppl axlsze .19, .17                                                 !! control the font size on axis !!

ppl txlsze .15                                                      !! same but for time axis !!

ppl tics .1,.1,.0,.1,1,1                                            !! control the tics on the plot !!

ppl plot              

plot/noaxes/thick/col=red/nolab/nokey/dash/ov sst2                  !! /ov is overlay on the first line of sst1 /noaxes is dont draw axis as it is used in first line plot

plot/noaxes/thick/col=6/nolab/nokey/dash/ov sst3                    !! tick thin and dash control the line thickness

label/nouser `($ppl$xlen)/1.9`,`($ppl$ylen)*1.04`,0,0,0.18 "@CR c) SST at certain location degree celcius"

label/nouser 5.2,.2,.5,.5,.2 @p4 @TR IO

label/nouser 6.2,.2,.5,.5,.2 @p2 @TR PO                             !! label for lines draw

label/nouser 7.2,.2,.5,.5,.2 @p6 @TR AO

 

 

 

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

 

cancel data/all                                                          !! cancel the previously used data !!

use temp.nc                                                              !! loading new data !!

 

set view_port a22

fill/pal=blue_orange/lev=(-2,32,2)/nolab/nokey/set temp[z=150]           !! plotting the variable for 150m depth !!

ppl axlsze .16, .16

ppl tics .0,.1,.0,.1,1,1

ppl fill                                                                

ppl axlabp -1 -1                                                        

go fland

label/nouser `($ppl$xlen)/1.9`,`($ppl$ylen)*1.04`,0,0,0.18 "@CR d) temp at depth of 150 meters"

 

let temp_basin_ave=temp[x=20:120@ave,y=0:30@ave]                         !! assign the variable and doing the areal average !!

 

set view_port a31                                                       

plot/nolab/nokey/col=blue/thick/set temp_basin_ave                       !! plotting the temperature profile !!

ppl axlsze .19, .17                                                                     

ppl txlsze .15                                                                          

ppl tics .1,.1,.0,.1,1,1                                                                

ppl plot

label/nouser `($ppl$xlen)/1.9`,`($ppl$ylen)*1.04`,0,0,0.18 "@CR e) temp v/s depth in indian ocean area average"

 

 

set view_port a32

fill/pal=blue_orange/lev=(-2,32,2)/nolab/nokey/set temp[x=@ave]        !! plotting the variable for zonal average in latitudes and depth (section plot) !!

ppl shakey 1, 0, 0.12, , 6, 6, 2.4, 7.6, .3, .5                         !! ppl shakey helps to plot the color key !!

ppl axlsze .16, .16

ppl tics .0,.1,.0,.1,1,1

ppl fill                                                                 

ppl axlabp -1 -1

label/nouser `($ppl$xlen)/1.9`,`($ppl$ylen)*1.04`,0,0,0.18 "@CR f) ocean temperature section plot"

 

                      

frame/file=ferret_edu3.png                   !! saving the figure iin various format like png, jpeg, jpg, eps, ps, giff and pdf but this is available in pyferret only and in ferret it is gif only !!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

 

 

exit       !! is to exit and out !!

 

UNSW logo ANU logo Monash logo UMelb logo UTAS logo