Last modified: Mon, 04/09/2018 - 15:15
What's new in Ferret / PyFerret v7
PyFerret V7 includes all of the features of Ferret V7, as well as new capabilities for the Python programmer. Ferret and PyFerret now use the same version number.
New Features in PyFerret
- Ferret string variable arrays can now be brought into Python using the pyferret.getstrdata method.
>>> errval, errmsg = pyferret.run('use coads_climatology') >>> varnamesdict = pyferret.getstrdata('..varnames') >>> varnamesdict['data'].flatten() array(['SST', 'AIRT', 'SPEH', 'WSPD', 'UWND', 'VWND', 'SLP'], dtype='|S5')
- New Python objects and methods simplify working with the Ferret "engine" at the core of PyFerret. These Python objects strive to allow Python users to work in PyFerret without knowledge of the Ferret "language". This is a work in progress, so at this time only the most common Ferret operations are supported.
The Python objects include:
- Represents a variable in Ferret. Can be used in mathematical operations with other FerVar objects and numbers to create new FerVar objects.
- A type of FerVar whose data was provided to Ferret as a Python NumPy array.
- Represents a dataset in Ferret. Contains a FerVar object for each variable in the dataset. Also used to assign new variables in Ferret.
- A type of FerDSet that is , an on-the-fly aggregation of datasets in Ferret. Contains a FerVar object for each variable all the datasets have in common.
- Represents a grid for a variable in Ferret.
- Represents an axis in Ferret.
- Represents a region in Ferret. Specifies the longitude, latitude, level, time, ensemble, and/or forecast elements of interest.
New pyferret methods include:
- Show information about all datasets currently open in the Ferret.
- Specify the plotting window, including size of the window, to use for subsequent plots.
- Specify the style, including font, of the text in any subsequent plots.
- Create a contour plot of a Ferret variable.
- Create a color-filled contour plot of a Ferret variable. Drawing of the contour lines themselves is optional.
- Create a line plot of the given Ferret variable, possibly versus another Ferret variable, possibly colored by yet another Ferret variable.
- Create a point (scatter) plot of the given Ferret variable, possibly versus another Ferret variable, possibly colored by yet another Ferret variable.
- Create a grid plot colored by values of a Ferret variable
- Shade land masses for the current longitude-latitude plot or a specified X-Y region.
- Shade water masses for the current longitude-latitude plot or a specified X-Y region.
- Save the current plot in a specified format; size of the saved plot can be specified
New Features/Enhancements in both PyFerret and Ferret:
- The PyFerret and Ferret source code is available from the NOAA-PMEL PyFerret and Ferret GitHub repositories. The master branches of the source code in these repositories are regularly updated with enhancements and fixes. Please see the Downloads pages for PyFerret and Ferret for details.
- On-the-fly aggregations in Ensemble, Time and Forecast-time directions. Aggregations are virtual datasets defined at the Ferret command line to combine sets of datasets (local files or URL's) to be treated within the Ferret session as a single dataset. Aggregations may be nested: For instance, time-step files are aggregated to form a time series; forecast runs aggregated to create a Forecast Model Run Collection (FMRC); and a number of FMRC's may be combined into an ensemble set of forecast model runs. These capabilities are illustrated in several
- In Ferret commands, it is no longer necessary to put path names in double-quotes. Journal files with pathnames, data file names with pathnames, and url's may be specified without quotes.
- A new graphics option: PLOT/ALONG= draws a set of line plots from a 2-D or higher dimension data variable. These commands draw a set of lines in the X direction, for each Y between -25 and 25 degrees, in increments of 4 degrees. This is useful in comparing Ensembles, time series at different locations, etc.
yes? use http://server.models/directory/model_data.nc yes? plot/along=t/x=30/y=34/L=1:400/z=100:1000/skipsym=10 thetao
- A new qualifier PLOT/SKIPSYM= Adding /SKIP= for a line plot that is drawn with SYMBOLS plots a symbol only at each Nth point. The line plot itself is drawn with full resolution. For instance in the above plot, /skip=10 thins out the symbols to every tenth one
- New qualifiers on plot commands for customizing Longitude and Latitude axis labels.
- A new qualifier on plot commands, /DEGMINSEC= sets the Longitude and Latitude axes to be labeled with degrees-minutes-seconds instead of degrees and fractions of degrees. It takes a value of 1 for degrees-minutes, which is the default, or =2 for degrees-minutes-seconds. Previously this feature was available only as a PPLUS setting.
- A new qualifier on plot commands, /HALFSPACE adds a half space between the degree sign and the E/W or N/S on Longitude and Latitude axes. This was at the request of a user to make graphics which comply with a new regulation of the European Geosciences Union.
- The output of SHOW GRID now includes a new column, "subset", with information about the range of data along the different axes for the grid of the variable. When a dimension is removed by a transformation, as in an AVERAGE along that dimension, it is listed as compressed.
yes? use coads_climatology yes? show grid sst[x=240:320,y=0,t=@ave] GRID GSQ1 name axis # pts start end subset COADSX LONGITUDE 180mr 21E 19E(379) 39 pts COADSY LATITUDE 90 r 89S 89N 1 pt normal Z TIME TIME 12mr 16-JAN 06:00 16-DEC 01:20 compressed normal E normal F
- It is now allowed to have multiple slashes between qualifiers in Ferret commands. Previously this resulted in an error. Now the extra slashes are ignored.
- The output of SHOW COMMANDS is easier to control. Previously SHOW COMMAND command_name listed all of that command's sub-commands. Now any abbreviation of the sub-command name lists only the command/sub-command and relevant qualifiers.
yes? show command SHOW mem ! lists only SHOW MEMORY and its qualifiers, not all of the SHOW options.
- Overlaying and making custom labels on plots involving time: Time series lines plotted over 2-D Hovmuller plots previously did not work unless the time axes had units of hours. Similarly adding labels to time plots was tricky These restriction is lifted. See Overlaying a time series on a 2D plot and Locating Labels on a Time-Axis plot
- The number of items in a constant-array list was previously limited to 250 items. This is increased to 1000 items (though the command-line buffer will often limit us to less than that.)
- MODE UPCASE and CANCEL MODE UPCASE previously applied to saving variables and coordinate axes to netCDF datasts. Now they apply to SHOW commands of all sorts, as well as `var,return=*axis`, so that what is returned by this command corresponds to what is in the dataset or variable definitions.
yes? cancel mode upcase yes? use mydata.nc 1> ./mydata.nc olr outgoing longwave radiation 1:5 1:5 ... 1:3 ... ... yes? say ` olr,return=xaxis` !-> MESSAGE/CONTINUE ax_x_R ax_x_R
- When defining variables with LET/D= to associate user-defined variables with specific datasets, variables with the same name but different definitions may be defined for different datasets.
- MODE CALENDAR is used to turn time labeling on when the time axis is defined in terms of dates. It's on by default, and is set to label time in minutes, for instance in the time label in the upper left of plots. In a new option (which is a provisional, beta capability), SET MODE CALENDAR:auto will automatically choose an appropriate resolution depending on the time resolution of the axis.
- Keywords are available for access to dataset information, see the list in Chapter 3. New keywords are added to refer to the coordinate variables in the dataset.
yes? use dataset.nc yes? list ..coordnames yes? list ..ncoordvars.
Bug Fixes in both Pyferret and Ferret:
- An incorrect value was shown for the amount of memory needed when a request to load data exceeds the available allocated memory. This is fixed. Setting the memory to the amount shown in the message will be adequate.
- Bugs with the behavior of the SUBSPAN MODULO feature are fixed. Previously, transformations and other expressions were not handled correctly along these axes.
- A bug is fixed when showing a SHADE plot of values-greater-than, or values-less-than some single value. These plots now correctly color all values less than 20, or all values greater than 20.
yes? shade/lev=(-inf)(20) sst yes? shade/lev=(20)(inf) sst
- When writing data to netCDF files, if MODE UPCASE is canceled, then a user-defined axis was written to the file incorrectly. This is fixed.
- Plotting a single vector arrow over a vector field previously did not work if /NOLABEL was given. This is fixed.
- An incorrect data type was returned for some functions which take either numeric or string arguments, e.g. XCAT, when called with a string argument. This is fixed.
- The results of specifying the precision on a grave-accent expression is improved. `var,prec=6`. Previously the returned value often had more digits than requested. Additionally sometimes a long integer value was returned when a shorter exponential form is preferred.
- For Hovmuller plots (e.g. X-T or Y-T slices), a band of missing-values appeared where data was not missing in some instances. This is fixed.
- A bug is fixed related to grave-accent evaluations inside REPEAT loops.
- A coordinate axis defined with /EDGES, where the grid cells are in fact of equal length, had incorrect coordinate values. This is fixed.
- When a dataset has grids that are defined with dimensions but not coordinate variables, writing a netCDF file with a subset along that dimension yielded an error. This is fixed.
- A plot in which the color key is drawn in an OVERLAY step resulted in an incorrect color used to outline the color key. This is fixed.
- The lower-left label drawn on an overlay plot was incorrect in some instances where a variable is all missing. this is fixed.
- A plot with /KEY=centerlab in some instances put the graphics in a state where the next plot also had a centered-label key. This is fixed.
- The graphics issue when resizing plots in Ferret on RHEL6 systems with recent versions of X-Windows has been resolved.
- Contour plots in PyFerret with the line color specified using the (R,G,B) or (R,G,B,A) tuple notation while also using a system font for text (for the contour line labels) would cause PyFerret to crash. This is fixed.