NCL Website header
NCL Home > Documentation > Functions > Lat/Lon functions

lonFlip

Reorders a global rectilinear array about the central longitude coordinate variable.

Prototype

load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"

	function lonFlip (
		x  : numeric   
	)

	return_val [dimsizes(x)] :  typeof(x)

Arguments

x

A rectilinear array of any dimensionality. The rightmost dimension must be the longitude dimension, which must be global and without a cyclic point. The size of the longitude dimension must be an even number. The "central value" is assummed to be the Grenwich Meridion (GM; 0 longitude) or the International Data Line; IDL/DL; 180 longitude).

Return value

The results are returned in an array of the same type and dimensionality as x.

Description

This function reorders (flips) the global input array about the longitude coordinate variable associated with the input variable. The size of the longitude dimension must be an even number.

This function implicitly assumes that the grid nominally spans:

  • (a): 0 to 360 with the nominal mid-point being the International Data Line (IDL/DL; 180 longitude). Example: lon: [ 0..357.5] or [ 1.25..358.75] with nlon=144
  • (b): -180 to 180 with the nominal mid-point being the Grenwich Meridion (GM; 0 longitude). Example: lon: [-180..177.1875] or [-178.59375..178.59375] with nlon=128

The lonPivot is more flexible.

This function only works for a global rectilinear grid. A rectilinear grid is one where both spatial coordinate variables (latitude and longitude) are one dimensional: Eg: lat[*] and lon[*].

See Also

lonPivot

Examples

Example 1: Let variable 't' be:

   printVarSummary(t)
produces:
     Variable: t
     Type: float
     Total Size: 589824 bytes
	         147456 values
	    Number of Dimensions: 4
	    Dimensions and sizes:   [time | 1] x [lev | 18] x [lat | 64] x [lon | 128]
	    Coordinates: 
	      time: [  31..  31]
              lev: [4.8093..992.528]
	      lat: [-87.8638..87.8638]
	      lon: [ 0..357.1875]         >>   mid-point 180 (DL)
	    Number Of Attributes: 3
	      long_name :   temperature
	      units :       K
	      time_op :     average
Then the following code will reorder the variable about the center longitude (here: 180):
   t = lonFlip(t) ; reorder
   printVarSummary(t)
will produce:
     Variable: t
     Type: float
     Total Size: 589824 bytes
                 147456 values
              Number of Dimensions: 4
	      Dimensions and sizes:   [time | 1] x [lev | 18] x [lat | 64] x [lon | 128]
	      Coordinates: 
                time: [  31..  31]
                lev: [4.8093..992.528]
		lat: [-87.8638..87.8638]
		lon: [-180..177.1875]         >>   mid-point 0 (GM)     
	      Number Of Attributes: 4
	        long_name :   temperature
		units :       K
		time_op :     average
If it is preferred to retain the original variable and create a new variable:
          ; create a new variable
   t_flip = lonFlip(t)
   printVarSummary(t_flip)
will produce:
     Variable: t_flip
     Type: float
     Total Size: 589824 bytes
                 147456 values
              Number of Dimensions: 4
	      Dimensions and sizes:   [time | 1] x [lev | 18] x [lat | 64] x [lon | 128]
	      Coordinates: 
                time: [  31..  31]
                lev: [4.8093..992.528]
		lat: [-87.8638..87.8638]
		lon: [-180..177.1875]
 
	      Number Of Attributes: 4
	        long_name :   temperature
		units :       K
		time_op :     average