[ncl-talk] Errors using get_isolines and area_poly_sphere together

Dennis Shea shea at ucar.edu
Mon Apr 29 14:08:56 MDT 2019


*Also: get_unique_values
<http://www.ncl.ucar.edu/Document/Functions/Built-in/get_unique_values.shtml>*
may not return values in the order one might expect. See the end of this
email.

-----
See attached library: *eliminate_dups.ncl*

It  eliminates (removes) assorted duplicate sequences.
For some reason these functions were never included in an NCL release.

Some  test functions are included.

Maybe:  *eliminate_dup_pairs_all *or *eliminate_dup_pairs_consecutive*

is what Phillipe would want to use

Let me know if these do/don't do the job.

===
The following illustrates the *eliminate_dup_all*


* %> ncl test_x.eliminate_dups.ncl*

* %> ncl test_xy.eliminate_dups.ncl*
===

  s     = (/"qqqq","1234","qqqq","9999","ert","vve","qqqq","9999"/)
  sout  = *eliminate_dup_all*(s)
*; outpu*t
  sout   = (/ "qqqq","1234", "9999","ert","vve" /)

  SOUT  = *eliminate_dup_all_unique(*s)     ; <== calls *get_unique_values*
<http://www.ncl.ucar.edu/Document/Functions/Built-in/get_unique_values.shtml>
*output:*
  SOUT = (/ "1234","9999", "ert","qqqq", "vve" /)


D




On Mon, Apr 29, 2019 at 10:44 AM Rick Brownrigg <brownrig at ucar.edu> wrote:

> Thanks to Rashed for replying here. However, I'm not sure
> get_unique_values() will do the job, as it expects a 1D array, and what
> Philippe needs is something to weed out duplicates in both lon *and* lat.
> In looking around, I don't see an NCL function that will do this -- it
> might likely involve writing a loop to do this yourself. I don't know if
> one can simply replace any found duplicates with _FillValue and get correct
> behavior, or if one must actually remove the duplicates from the array.
>
>
>
> On Mon, Apr 29, 2019 at 6:58 AM Rashed Mahmood <rashidcomsis at gmail.com>
> wrote:
>
>> Hi Philippe,
>> I think, it makes sense to expect two same lat or lon for a circle since
>> at two different longitudes there could be possibility of getting two
>> latitudes and vice versa. To get unique values, you can use the following
>> function:
>> For example:
>>
>>  y:= get_unique_values(y)
>>
>>
>> https://www.ncl.ucar.edu/Document/Functions/Built-in/get_unique_values.shtml
>>
>> Cheers,
>> Rashed
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> On Fri, Apr 26, 2019 at 2:51 PM Philippe Papin <pppapin at gmail.com> wrote:
>>
>>> Hi All,
>>>
>>> I've been running into an issue from the combined usage of the
>>> "get_isolines" and "area_poly_sphere" functions. First, I'm using
>>> get_isolines to isolate a contour that completes loop around some location
>>> on the globe. Then I want to find the area within that contour.
>>>
>>> What I've noticed is that occasionally (not always) the get_isolines
>>> function will find a contour with multiple identical lat,lon pairs for the
>>> given contour. This is problematic for the area_poly_sphere code which
>>> requires unique vertex points as far as I can tell.
>>>
>>> Is there anyway to avoid get_isolines from providing identical lat,lon
>>> points for a unique contour? If not, is there a function I could use to
>>> remove non-unique lat,lon pairs?
>>>
>>> Here is a print out snippet of the relevant get_isolines output of what
>>> I'm trying to avoid (see index values 212,213).
>>>
>>> Variable: x
>>>
>>> Type: float
>>>
>>> Total Size: 2452 bytes
>>>
>>>             613 values
>>>
>>> Number of Dimensions: 1
>>>
>>> Dimensions and sizes: [points | 613]
>>>
>>> Coordinates:
>>>
>>> Number Of Attributes: 5
>>>
>>>   n_points : ( 4, 613, 29, 7, 21, 41, 38, 45, 29 )
>>>
>>>   start_point : ( 0, 4, 617, 646, 653, 674, 715, 753, 798 )
>>>
>>>   segment_count : 9
>>>
>>>   level : 2
>>>
>>>   _FillValue : 9.96921e+36
>>>
>>>
>>> (211) 17.06323
>>>
>>> (212) 16
>>>
>>> (213) 16
>>>
>>> (214) 14.94309
>>>
>>> (215) 13.88631
>>>
>>> Variable: y
>>>
>>> Type: float
>>>
>>> Total Size: 2452 bytes
>>>
>>>             613 values
>>>
>>> Number of Dimensions: 1
>>>
>>> Dimensions and sizes: [points | 613]
>>>
>>> Coordinates:
>>>
>>> Number Of Attributes: 5
>>>
>>>   n_points : ( 4, 613, 29, 7, 21, 41, 38, 45, 29 )
>>>
>>>   start_point : ( 0, 4, 617, 646, 653, 674, 715, 753, 798 )
>>>
>>>   segment_count : 9
>>>
>>>   level : 2
>>>
>>>   _FillValue : 9.96921e+36
>>>
>>>
>>> (211) 69.65783
>>>
>>> (212) 69.83716
>>>
>>> (213) 69.83716
>>>
>>> (214) 70.0269
>>>
>>> (215) 70.21735
>>>
>>> It seems like the code is outputting an unnecessary extra lat,lon pair
>>> at 69.83716 N, 16E. Why does this happen, and how can I avoid this for
>>> accurate spherical area calculations?
>>>
>>> Thanks,
>>> Philippe
>>> --
>>>
>>> -------------------------------------
>>> Philippe P. Papin, Ph.D.
>>> NRC Research Associate
>>> Global Modeling Division
>>> Naval Research Laboratory - Monterey, CA
>>> http://www.atmos.albany.edu/student/ppapin/
>>> _______________________________________________
>>> 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/20190429/5c663b0a/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: eliminate_dups.ncl
Type: application/octet-stream
Size: 3954 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20190429/5c663b0a/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test_x.eliminate_dups.ncl
Type: application/octet-stream
Size: 2308 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20190429/5c663b0a/attachment-0001.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test_xy.eliminate_dups.ncl
Type: application/octet-stream
Size: 834 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20190429/5c663b0a/attachment-0002.obj>


More information about the ncl-talk mailing list