[ncl-talk] lonFlip function

Adam Phillips asphilli at ucar.edu
Fri Feb 20 08:17:02 MST 2015


Hi Sunmin,
lonFlip flips the attached longitude *coordinate variable,* and not the
array itself. Try:
printVarSummary(data)
data = lonFlip(data)
printVarSummary(data)
If you have any further questions please respond to ncl-talk.
Adam

On Fri, Feb 20, 2015 at 8:04 AM, Sunmin Park <mireiyue at gmail.com> wrote:

> 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
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>



-- 
Adam Phillips
Associate Scientist,  Climate and Global Dynamics Division, NCAR
www.cgd.ucar.edu/staff/asphilli/   303-497-1726

<http://www.cgd.ucar.edu/staff/asphilli>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150220/07db22a1/attachment.html 


More information about the ncl-talk mailing list