Some Ferret tips and pointers
Ferret
Ferret is a NetCDF vizualisation tool which can be used to postprocess and visualize PCM outputs.
This free software is from NOAA (National Oceanic and Atmospheric Administration) and the relevant webpage where you can learn how to install and use it is here: https://ferret.pmel.noaa.gov/Ferret/
[For Mac users] It is recommended to use/migrate-to PyFerret. However, there is a bug in later versions that can render plotting problematic even in the Linux environment. Fortunately, there is a work around, which we will address specifically for the Mac environment (a post to the Ferret listserv is referenced, and it deals specifically with Linux). See section below.
For first timers
Ferret is essentially a command line tool so the first thing you'll need to do is launch it from your terminal
ferret
(on some system, e.g. Ubuntu, the executable is called ferret_c (and the related package ferret_viz) because another unrelated software also called ferret exists).
Once under Ferret you should see the Ferret prompt:
yes?
To load a datafile, for example diagfi.nc issue command:
yes? use diagfi.nc
Once the file has been loaded, you can query for its contents with the command show data. This will let you know about available fields (and their shapes: usually i along longitudes, j along latitudes, k along pseudo-altitudes and l along time). e.g
yes? show data currently SET data sets: 1> ./diagfi.nc (default) name title I J K L AIRE 1:65 1:49 ... ... PHISINIT 1:65 1:49 ... ... TSURF 1:65 1:49 ... 1:1464 PS 1:65 1:49 ... 1:1464 TEMP 1:65 1:49 1:73 1:1464 U 1:65 1:49 1:73 1:1464 V 1:65 1:49 1:73 1:1464
In the example above the file contains AIRE and PHISINIT, which are 2D (indexed along i and j indexes, i.e. longitude and latitude == surface fields), TSURF, PS, which are 3D (indexed along i, j and l indexes, i.e. longitude, latitude and time == surface fields evolving in time) and TEMP, U and V, which are 4D).
Various tips and pointers
- Never kill the Ferret graphic plot window (by clicking on the cross at the top right corner); Ferret won't recover, you'll have to exit and start again...
- One can refer to a field coordinates either via indexes i, j, k, l or via associated real world coordinates x, y, z, t.
How to make a 1D plot
You simply need to specify along which coordinate the variable should be plotted, e.g.
yes? plot/i=13/j=15 PS
Or equivalently
yes? plot PS[i=13,j=15]
Or similarly using real world coordinates, e.g.
yes? plot PS[x=12,y=35]
How to make a 2D map
...
How to compute a zonal average
...
Installation tips
Mac OSX (PyFerret) and Graphics bug
Miniconda
conda is the preferred environment for the install. miniconda (a subset of conda) is a lighter-weight option which is a good choice. Installation instructions for both may be found here.
PyFerret
Once one has a conda installation of some type, the instructions are straight-forward. The official installation documentation is here.
Commands used on a Macbook Pro with the M2 ARM chipset (summer 2023)
- Install miniconda using script
bash Miniconda3-latest-MacOSX-arm64.sh #can "yes" to activate, but we will deactivate # do not automatically activate on startup conda config --set auto_activate_base false # initialize for tcsh (it will write code into one's .tcshrc file) /Users/mwolff/miniconda3/bin/conda init tcsh
- Install pyferret (latest version)
It is recommended that one use virtual environments, and alias the environment activation for simplicity. The following section is to install pyferret in virtual environment called FERRET.
Note: the pyferret command from the official site did NOT work for me. It complained about not finding the needed packages. For reference, this command was
# line below did not work. it is here for reference conda create -n FERRET -c conda-forge pyferret ferret_datasets --yes
Instead, use the following instead:
conda create -n FERRET -c conda-forge/osx-64 pyferret ferret_datasets --yes
This can be actived using an alias for brevity. In (t)csh world, this would be
alias FERRET "conda activate FERRET"
- Dealing with plotting bug. As can be seen in the post on the Ferret group here, there can be problems for plotting with the latest version(s), even on Linux. Below, we use a command that works for Mac OSX.
Install a slightly older version of pyferret (i.e., one where the plotting works) using the command in the referenced post in the last paragrph):
# we have had to change the channel from the example in the referenced ferret group post (to install for Mac OS conda create -n oldFERRET -c conda-forge/osx-64/label/cf202003 pyferret ferret_datasets --yes
Assuming an alias oldFERRET that activates this older version, a plotting test can be runs as
[avory:~] mwolff oldFERRET (oldFERRET) [avory:~] mwolff pyferret NOAA/PMEL TMAP PyFerret v7.5 (optimized) Darwin 17.7.0 - 12/16/19 6-Apr-23 10:50 yes? use coads_climatology yes? fill sst[l=1]