Return to Ferret FAQ


Use of W Longitude axis


Question:

On Apr 6,  3:04pm, Emilio Mayorga wrote:
> Subject: definition and use of W Longitude axis
> I've had some problems with the definition and use of West Longitudes
> since I started using Ferret. I assign negative values to the W
> longitude axis variable in my netcdf files. These sometimes create
> errors in Ferret.
>
> For instance, in the GUI I have to switch the Longitude option to use
> x-index instead, otherwise I only get error messages like this one:
>
>  **ERROR: illegal limits: PRECIP is not in the range X=65W
>           Axis extremes are X=80W(-80):45W(-45)
>
> In the command-line Ferret, I also encounter this problem sometimes,
> such as the following, where the first line works fine and the second
> results in the error message:
>
> yes? shade/t=0:83/y=20S:6N precip[x=-65]
> yes? shade/t=0:83/y=20S:6N precip[x=65W]
>  **ERROR: illegal limits: PRECIP is not in the range X=65W
>           Axis extremes are X=80W(-80):45W(-45)
>
> Lastly (as another illustration), I just noticed that for these
> variables that I've defined with negative values for W lon, using a
> region specifier such as x=290E will result in an error message when
> plotting variables (all my variables are defined in the window 80W to
> 55W, 2S to 6N).

Example:

set data etopo60
shade rose[x=-140:40]
 *** NOTE: Modulo axis index is too negative: ROSE[X=140W(-140):40E,D=2]
 *** NOTE: This can crash FERRET!!! --> Use higher coordinate values.

Explanation:

The longitude encodings used in data sets, as we know, are not standardized. The most common encodings are 0 to 360 and -180 to 180. Ferret does not mandate any particular encoding. Ferret uses the "modulo" property of a longitude axis to translate between encodings.

Internally, Ferret always interprets formatted longitudes as positive values. For example SET REGION/X=165W is identical to SET REGION/X=195.

Now consider the command

	PLOT/X=165W my_var[D=my_data_set.nc]
Ferret sees this as a reference to "X=195". If data set my_data_set.nc uses a 0 to 360 longitude encoding then the operations are straightforward. If, on the other hand, the data set uses a -180 to 180 encoding then Ferret has to apply modulo-360 transformation to the reference. The modulo operation actually occurs in "index space" -- indices of less than one or greater than N are allowed inside Ferret -- which is why Ferret can easily make 2-world wide plots (e.g. X=0:720) and multi-year monthly climatologies (e.g. L=1:36). In most cases, Ferret does modulo translations transparently. Your questions point to special cases where it does not:

  1. If a longitude axes is not "modulo" the modulo-360 translation will not be performed. A longitude axis is modulo only if
    1. it is 360 degrees wide
    2. it is designated as modulo (e.g. SET AXIS/MODULO or DEFINE AXIS/MODULO) In Emilio's question his data set extends only from "X=80W(-80):45W(-45)".

    Solution: Specify X in the encoding used by the data set, such as "X=-65" instead of "X=65W".

    (Note: modulo longitude axes of less than 360 degrees are allowed, but are of interest only for special problems such as nymerical models with "cyclic" boundary conditions.)

  2. If the modulo operation generates negative indices less than I=-100 Ferret will issue the warning message that Stefan referred to. This occurs when the referenced X values are LESS than the longitude values encoded in the X axis of the data set. For example, if an axis runs from X=0 to 360 and we refer to X=-180 we will generate negative index references.

    Solution: Add a multiple of 360 to the X references. For example, X=180:540 is equivalent to X=-180:180 and will usually avoid negative subscripts.

  3. When using /OVERLAY on a plotting command, the longitude encodings of the overlay must match the encodings of the base plot.

    Solution: Add or subtract a multiple of 360 to your longitudes as needed to ensure this. The same consideration may apply when SAVE/APPEND is used to add additional data to a NetCDF file.


Last modified: Apr 9, 1997