[ncl-talk] question about get locations

Dennis Shea shea at ucar.edu
Thu Oct 13 09:11:00 MDT 2016


re:
===
Is there an **NCL supported**  "method to get the locations of a threshold
value?"

IE: threshold value => contour level? To my knowledge, the short answer is
"no".

I know of no way to retrieve the lat/lon locations of a specific or an
arbitrary contour level.
===

I stand corrected. Dave Brown pointed me toward 'get_isolines'

   http://www.ncl.ucar.edu/Document/Functions/Built-in/get_isolines.shtml

This will return the x,y (lon,lat) values of specified contour lines.

**Usage will require careful reading of the documentation.**

====


Using the example previously referred to:

  f = addfile("$NCARG_ROOT/lib/ncarg/data/cdf/uv300.nc","r")
   u = f->U
   printVarSummary(u)
   printMinMax(u,1)

   nt = 0

   wks = gsn_open_wks("png","TEST")                  ; send graphics to PNG
file
   plot = gsn_csm_contour_map(wks,u(nt,:,:),False)   ; create a default plot

   print(plot)
   print("===============================================")

;;--------------
;; Variable: plot
;; Type: obj
;; Total Size: 4 bytes
;;             1 values
;; Number of Dimensions: 1
;; Dimensions and sizes:        [1]
;; Coordinates:
;; Number Of Attributes: 3
;;   tickmarks :        tickmarks       tickMarkClass   52
;;   data :     TEST_data       scalarFieldClass        9
;;   contour :  TEST_contour    contourPlotClass        11     <=== graphic
object
;; (0)  map     mapPlotClass    37
;;--------------

   thresh   = 10.0
   isolines = get_isolines(plot at contour, thresh)       ; <=== input to
get_isolines
   print(isolines)             ; [yx | 2] x [points | 72]

;; Variable: isolines                     ; simple variable*
;; Type: float
;; Total Size: 576 bytes
;;             144 values
;; Number of Dimensions: 2
;; Dimensions and sizes:        [yx | 2] x [points | 72]   <=====
;; Coordinates:
;; Number Of Attributes: 5
;;   _FillValue :       9.96921e+36
;;   level :    10
;;   segment_count :    2
;;   start_point :      ( 0, 50 )      <==== important
;;   n_points : ( 50, 22 )            <====     "
   print("===============================================")
   print("isolines(0,:)="+isolines(0,:)+  "   "+ isolines(1,:))
   print("===============================================")

=================================
For multiple contour lines, the function returns a variable of type 'list'.
Each element of the list contains the x,y (lon,lat) of each contour line

Good Luck

On Wed, Oct 12, 2016 at 3:34 PM, Dennis Shea <shea at ucar.edu> wrote:

> Is there an **NCL supported**  "method to get the locations of a threshold
> value?"
>
> IE: threshold value => contour level? To my knowledge, the short answer is
> "no".
>
> I know of no way to retrieve the lat/lon locations of a specific or an
> arbitrary contour level.
>
> ====
>
> This is a task that is conceptually easy to address. One simple method is
> to use linear interpolation. (see attached)  However, in practice, there
> are issues.
>
> Look at the main plot for zonal wind:
>       http://www.ncl.ucar.edu/Applications/cylineq.shtml
>
> Say, your threshold value is 12.3 m/s.
>
> At each longitude, there are one or more '12.3' values looking
> pole_to_pole.
>
> Choose -8.0 .... at some longitudes there is no such value while at
> others, there are multiple values (closed contours). What to do? How to
> return reasonable values?
>
> I am attaching a simple scrip and function that uses the uv300.nc file
> distributed with NCL.
> You can play with this. Currently, it returns the locations of the 1st
> encountered threshold value.
>
> If you are looking at (say) the northern hemisphere and there is one
> 5880gpm contour, it may work for you.
>
> Good luck
>
>
> On Sun, Oct 9, 2016 at 10:57 PM, 陈婕 <chenj2014 at lzu.edu.cn> wrote:
>
>> Dear Mr/Mrs,
>>
>>  I want to get locations of a threshold value. For example, I want to
>> know the locations of 5880gpm contour line at 500hpa. Actually,I only can
>> find the approximate values and their locations from the original grid
>> data. Is there a function for interpolation or a method to get the
>> locations of a threshold value?
>>
>>
>> Best regards,
>> Jie Chen
>> _______________________________________________
>> 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/20161013/b81a2e20/attachment.html 


More information about the ncl-talk mailing list