Re: obtain values of a single contour

From: David Brown <dbrown_at_nyahnyahspammersnyahnyah>
Date: Tue Apr 16 2013 - 23:43:08 MDT

Hi Mark,

The immediate cause of the error message is that when you set gsnYAxisIrregular2Linear = True, the gsn code does an overlay behind
the scenes onto an "irregular" plot. This means that plot0 is no longer itself a contour plot. The contour plot id is available as an attribute of plot0.
So the get_isolines call needs be:

isolines = get_isolines(plot0@contour,(/2.0/))

However, it turns out that there are still some issues with this scenario and get_isolines needs some more work. When not over a map, get_isolines is
returning values in a low-level coordinate system rather than as data coordinates. However, there is a workaround that should give you what you want:
Set trGridType = "TriangularMesh". In this mode it does return data coordinates and also it linearizes the YAxis without using the special gsnYAxisIrregularToLinear resource.
I am attaching a revised version of your plot that works. I also modified the polyline drawing code to draw a line on top of the
original contour line using the returned coordinate values to demonstrate that they do match. Note that if you only ask for one level get_isolines returns an array not a list.
Hope this helps.
 -dave

On Apr 16, 2013, at 6:09 PM, <Mark.Collier@csiro.au> wrote:

> Hi Dave,
> I put the script plot_davetest.ncl and input data file davetest.nc in the incoming area. I tried it under both 6.1.1 and 6.1.2 with same error.
>
> uname -a
> Linux dcc 2.6.18-348.3.1.el5 #1 SMP Mon Mar 11 19:39:25 EDT 2013 x86_64 x86_64 x86_64 GNU/Linux
>
> Regards,
> Mark.
> On 17/04/2013, at 5:57 AM, David Brown <dbrown@ucar.edu> wrote:
>
>> Hi Mark,
>> I'm sorry to hear you are having problems with this routine. I just ran a test using the plot value returned from
>> gsn_csm_contour as the input to get_isolines pretty much as you have it here. It ran without problems. I tried it both
>> with my development version of NCL on my mac and on our cluster using the release version of 6.1.2.
>>
>> I would be happy to take a look at your code (and sufficient data to get it to run) to see if there is some other factor
>> coming into play here. I think you know the upload routine but just in case for reference it is detailed at http://www.ncl.ucar.edu/report_bug.shtml.
>> -dave
>>
>>
>> On Apr 15, 2013, at 10:44 PM, <Mark.Collier@csiro.au> wrote:
>>
>>> Hi Dave,
>>> the interface looked simple enough but my best attempt gave:
>>>
>>> fatal:NhlGetIsoLines: invalid contourplot id
>>> fatal:NhlGetIsolines: error retrieving isolines
>>> fatal:["Execute.c":8128]:Execute: Error occurred at or near line 251 in file plot_tropoh_climdiff.ncl
>>>
>>> what I tried was:
>>>
>>> plot0=gsn_csm_contour(wks,clim1_hist_ea,conres2)
>>>
>>> isolines = get_isolines(plot0,(/2.0/))
>>>
>>> where plot0 renders normally, and it contains the 2.0 contour level.
>>>
>>> I'm using version 6.1.2
>>>
>>> Thanks,
>>> Mark.
>>> ________________________________________
>>> From: David Brown [dbrown@ucar.edu]
>>> Sent: Tuesday, 16 April 2013 4:01 AM
>>> To: Collier, Mark (CMAR, Aspendale)
>>> Cc: ncl-talk@ucar.edu
>>> Subject: Re: obtain values of a single contour
>>>
>>> Hi Mark,
>>> I recently created a function that will do what you want. It is available in NCL 6.1.1 and later. Check out:
>>>
>>> http://www.ncl.ucar.edu/Document/Functions/Built-in/get_isolines.shtml
>>>
>>> -dave
>>>
>>>
>>> On Apr 15, 2013, at 12:41 AM, <Mark.Collier@csiro.au> wrote:
>>>
>>>> Hi,
>>>> I plot a single unique contour of a 2d array using @cnLevels = val using the gsn_csm_contour function.
>>>>
>>>> is there a way of obtaining the x-y values of that line from the plot?
>>>>
>>>> Regards,
>>>> Mark.
>>>> _______________________________________________
>>>> ncl-talk mailing list
>>>> List instructions, subscriber options, unsubscribe:
>>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>> _______________________________________________
>>> ncl-talk mailing list
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk

Received on Tue Apr 16 23:43:22 2013

This archive was generated by hypermail 2.1.8 : Tue Apr 23 2013 - 12:54:13 MDT