Some Ferret tips and pointers

From Planets
Revision as of 14:06, 17 October 2023 by Mwolff (talk | contribs) (Commands used on a Macbook Pro with the M2 ARM chipset (summer 2023))

Jump to: navigation, search

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 the Mac OSX version as of 2023-June with respect to plotting. The bug is not subtle as the plotting does not work. 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_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 ...

Various tips and pointers

...

How to make a 1D plot

...

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

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]