[ncl-talk] lonPivot
Dennis Shea
shea at ucar.edu
Wed Sep 2 16:58:09 MDT 2015
FTR: AlanB and I had an email exchange offline. THX
===
There are some subtle issues.
The function 'lonPivot' uses a feature of NCL called "coordinate subscripting".
Coordinate subscripting *requires* a coordinate variable (CV). A CV
is defined by the netCDF Users Group (NUG) to be a one-dimensional
array whose values are monotonically increasing or decreasing.
The line in 'lonPivot' that uses coordinate subscripting is:
indP = ind(xlon.eq.xlon({pivotLon})) ; Note the
{...} bracket syntax.
If the 'lon' variable is not a strictly conforming CV then an error
message is issued.
---
The original lon array associated with the variable 'chi' has the
following values
float lon(lon) ;
lon:units = "degrees_east" ;
lon = 72.5, 73.5, 74.5, 75.5, 76.5, 77.5, 78.5, 79.5, 80.5, 81.5, 82.5,
83.5, 84.5, 85.5, 86.5, 87.5, 88.5, 89.5, 90.5, 91.5, 92.5, 93.5, 94.5,
[snip]
166.5, 167.5, 168.5, 169.5, 170.5, 171.5, 172.5, 173.5, 174.5, 175.5,
176.5, 177.5, 178.5, 179.5, -179.5, -178.5, -177.5, -176.5, -175.5,
-174.5, -173.5, -172.5, -171.5, -170.5, -169.5, -168.5, -167.5, -166.5,
-165.5, -164.5, -163.5, -162.5, -161.5, -160.5, -159.5, -158.5, -157.5,
[snip]
-12.5, -11.5, -10.5, -9.5, -8.5, -7.5, -6.5, -5.5, -4.5, -3.5, -2.5,
-1.5, -0.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5,
[snip]
48.5, 49.5, 50.5, 51.5, 52.5, 53.5, 54.5, 55.5, 56.5, 57.5, 58.5, 59.5,
60.5, 61.5, 62.5, 63.5, 64.5, 65.5, 66.5, 67.5, 68.5, 69.5, 70.5, 71.5 ;
This satisfies the requirement of one-dimensional but obviously it is
not monotonic.
This can be tested within NCL via the 'isMonotonic' function.
So, to get 'lonPivot' to work the 'lon' array associated with the 'chi' variable
must be made into a coordinate array. The 'lon' has 2 discontinuous points.
A function and test script + plot is attached.
Note that NCL correctly (I hope) plots the lon values even though the
reordered lon
exceed 360.
Variable: CHI
Type: float
Total Size: 191520 bytes
47880 values
Number of Dimensions: 2
Dimensions and sizes: [time | 133] x [lon | 360]
Coordinates:
lon: [20.5..379.5]
=====
CD: If this is not what you want ... please post back to ncl-talk.
Cheers
D
On Wed, Sep 2, 2015 at 11:56 AM, Alan Brammer <abrammer at albany.edu> wrote:
> See my edits to your script below.
>
> Note: In making the lon monotonic you may have to move you're pivot point
> outside of the typical 0-360 or -180-180 range. The return lons below
> range 72.5-431.5. NCL should handle these fine for plotting etc. but if you
> want to pivot around 30E, then choose 360+30.
>
>
> p.s. Unless mentioned otherwise try and keep ncl-talk cc'd so other people
> can assist and people can find the thread if they have a similar problem.
>
>
> On Wed, Sep 2, 2015 at 1:41 PM, clotilde dubois
> <clotilde.dubois at mercator-ocean.fr> wrote:
>>
>>
>> ; ===========================================
>> 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"
>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"
>> load "make_lon_monotonic.ncl"
>> ; ===========================================
>
>
> f = addfile ("sst_equa_ano.nc","r")
> ; scale = 1.e6 ; scale factor
> chi = f->tn(:,0,0:359) ; get chi
>
> lon = f->nav_lon(0,0:359)
> print("Is the input lon monotonic? 0 = No")
> print(isMonotonic(lon))
> print( lon(107:108) ) ;;; This should show you that the lon are not
> monotonic. They cross the dateline at
>
> ;;;;;;;;;;; Therefore use my function to make them monotonic.
>
> lon = make_lon_monotonic(lon)
> print("Lon Rearranged Should now be monotonic" )
> print("Is the input lon monotonic? 0=No ")
> print(isMonotonic( lon))
>
> lon at units = "degrees_east"
> lon!0="lon"
> lon&lon = lon
>
> chi!0="time"
> chi!1="lon"
>
>
> ;;;; chi at lon = lon ;;; This is incorrect and strong recommended against.
> chi&lon=lon
>
> ;; chi&lon at units = "degrees_east" Did this already, don't need to do again.
>
> print(isMonotonic(chi&lon))
>
>
>
>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: chi_lonPivot.ncl
Type: application/octet-stream
Size: 3504 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150902/674abdaa/attachment.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: chi.png
Type: image/png
Size: 46524 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150902/674abdaa/attachment.png
More information about the ncl-talk
mailing list