[ncl-talk] lonFlip function

Sunmin Park mireiyue at gmail.com
Fri Feb 20 08:04:21 MST 2015


Dear NCL users

I am trying to change longitude 0,360 to -180,180. I used the function lonFlip to change longitude but it has wrong values. When I use printVarSummary the coordinate looks fine but when I print it out (print) it doesn’t change LON (the file that I am using is GPCP monthly mean precipitation from NCAR) How can I get correct LON (-180,180)?

Thank you in advance,
Sun- 

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

begin

;==============================================================
; Open the file:
;================================================================

  diri    = "/Users/spark/vertical/00_DATA/"
  fili    = "precipmonmean.nc"
  f       = addfile (diri+fili+".nc", "r")
  varname = "precip"
  data = f->$varname$

  LON1     = f->lon ;({-180:180})  ;
  LAT     = f->lat ;({-90:90})  ;
  LON     = lonFlip(LON1)

  printVarSummary(data)
  printVarSummary(LON)
  print(LON)
return


Variable: LON
Type: float
Total Size: 576 bytes
            144 values
Number of Dimensions: 1
Dimensions and sizes:	[lon | 144]
Coordinates:
            lon: [-178.75..178.75]
Number Of Attributes: 6
  units :	degrees_east
  long_name :	Longitude
  actual_range :	( 1.25, 358.75 )
  standard_name :	longitude
  axis :	X
  lonFlip :	longitude coordinate variable has been reordered via lonFlip

(0)	181.25
(1)	183.75
(2)	186.25
(3)	188.75
(4)	191.25
(5)	193.75
(6)	196.25
(7)	198.75
(8)	201.25
(9)	203.75
(10)	206.25
.
.
.
(135)	158.75
(136)	161.25
(137)	163.75
(138)	166.25
(139)	168.75
(140)	171.25
(141)	173.75
(142)	176.25
(143)	178.75


More information about the ncl-talk mailing list