# [ncl-talk] Problem of using "get_isolines"

David Brown dbrown at ucar.edu
Thu Jun 1 17:16:50 MDT 2017

The reason get_isolines returns longitudes that vary in the longitude cycle
(-180 - 180) or (0,360) or (0- -360) is so that it can avoid
discontinuities in the sequence of numbers, which is important for some
applications.
Instead of returning a sequence like (178, 179, 180, -179), it simply
continues the sequence (178, 179, 180, 181).  The NCL map plotting code
accepts as valid longitudes any number between -540 and +540, so returning
the values this way is not at all a problem for NCL plotting, although
admittedly there are situations where it is best to have the numbers
confined to a single longitude cycle.
If you do need to get to a single cycle you can do it using the where
function. Assuming you want to confine the values to the range -180 - 180,
then these two statements should do it for you, assuming that lon is
assigned the x value returned from get_isolines:

lon = where(lon .gt. 180, lon - 360, lon)
lon = where(lon .lt. -180, lon + 360, lon)

Hope this helps.
-dave

On Thu, Jun 1, 2017 at 3:16 PM, Mary Haley <haley at ucar.edu> wrote:

> Hi,
>
> We were looking into this problem using a different example, and seeing
> some odd results.
>
> Is it possible for you to provide us with the pt.nc file?
>
> You can use our ftp, if the file is not too large:
>
> http://www.ncl.ucar.edu/report_bug.shtml#HowToFTP
>
> Thanks,
>
> --Mary
>
>
> On Tue, May 30, 2017 at 8:17 PM, 王淼 <miaowang2015 at pku.edu.cn> wrote:
>
>> Hi Ncl Talk,
>>    I used get_isolines to get the points that define a contour line
>> .When I printed the longitude of these points ,  the distribution of the
>> longitude wasn't the same(gonna show in the following example) ,may be
>> [0~-360] or [20~-340],etc. I have expected the function may return the
>> longitude as [0~360] or [-180~180]. I googled it ,but didn't help.I still
>> don't know what caused the effect, so I ask you for help. Thanks!
>>
>> Here is the code and resluts:
>>
>>
>> begin
>>
>> pt=short2flt(f1->pt)
>> pt=lonFlip(pt)                  ;lon=0~360degrees
>>
>> n=dimsizes(pt&time)
>>
>>
>>   wks = gsn_open_wks("pdf","sypt_all")
>>
>>   res                      = True
>>   res at gsnDraw              = False
>>   res at gsnFrame             = False
>>
>>   res at cnFillOn             = False
>>   res at cnLinesOn            = True
>>
>>   res at cnLevelSelectionMode   = "ExplicitLevels"
>>   res at cnLevels              = (/350,360/)
>>
>>
>>   res at mpMinLatF            = 0
>>   res at mpCenterLonF         =180
>> res at trGridType = "TriangularMesh"
>>
>>
>> do i = 0, n-1                                           ;time
>>     plot=gsn_csm_contour_map_ce(wks, pt(i,:,:), res)
>>
>>      isolines = get_isolines(plot at contour,"plot")
>>
>>     do j= 0, ListCount(isolines) - 1
>>       iso := isolines[j]
>>
>>       idx=maxind(iso at n_points)
>>       b = iso at start_point(idx)
>>       e = b + iso at n_points(idx) - 1
>>       y := iso(0,b:e)
>>       x := iso(1,b:e)                   ;y=lat,x=lon
>>       print(x)
>>     end do
>> end do
>> end
>>
>> result1 result2
>> 0 0
>> -1.8 -1.3
>> -2.5 -2.5
>>      …      …
>> -358.9 -339.8
>> -359.7 -340
>> -360      …
>> 20
>> 18.6
>>>> 2.5
>> 0.5
>> 0
>>
>>
>>
>> ncl-talk mailing list
>> ncl-talk at ucar.edu
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at ucar.edu
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170601/f8881346/attachment.html