Re: Values inside a polygon

From: Manisha Ganeshan <manisha.ganeshan86_at_nyahnyahspammersnyahnyah>
Date: Tue Jul 17 2012 - 13:02:13 MDT

I believe that error message in the grib file must be because only 93% of
the file was copied over through ftp. I had to then rename the file to
'gribfile.grb' to upload successfully via ftp. Anyway, the error was
unrelated to the gribfile. After modifying my polygon variable's
dimensions, I got 95 'True' points as well. The script works now.

Thanks,
Manisha

On Tue, Jul 17, 2012 at 2:55 PM, Adam Phillips <asphilli@ucar.edu> wrote:

> Hi Manisha,
> When I ran your script an hour ago using NCl 6.1.0-beta, I was getting 95
> points that were being returned as True from gc_inout:
> inout = gc_inout(lat_new, lon_new, latcity, loncity)
> print(num(ind(inout)))
> exit
>
> However, I noticed that upon reading in your grib file I was getting an
> error message:
> fatal:Premature end-of-file, file appears to be truncated
>
> I didn't think anything of the error message as your script seemed to be
> working. I have never seen that error message before, and it makes me
> wonder if something is amiss with your .grb file. I tried rerunning your
> script using ncl v6.0.0. I did get the same error message, but this time I
> see that gc_inout is not returning any True values, as you were
> experiencing.
>
> I see from your latest email you have gotten around the issue. If you need
> us to investigate any further let ncl-talk know. Adam
>
>
> On 07/17/2012 12:15 PM, Manisha Ganeshan wrote:
>
> Hello,
>
> Thanks again for the reply. The problem is not related to the plotting
> of the variable. I put the plot there only to show that the polygon lies
> within the lat/lon range of the grib file. My problem is that gc_inout does
> not produce any 'True' value, meaning that the output suggests all points
> lie outside of the polygon. Is there a particular direction
> (clockwise/anti-clockwise) that the polygon indices need to be specified?
>
> Note: In my script, the indices variable is used to count the 'True'
> values produced by gc_inout. This variable consists of a missing value
> indicating that only False values are produced by the function.
>
> Manisha
>
> On Tue, Jul 17, 2012 at 1:57 PM, Adam Phillips <asphilli@ucar.edu> wrote:
>
>> Hi Manisha,
>> (So you know: The reason I asked about the input/output
>> latitudes/longitudes ranges matching is because ~90% of the time when
>> people have issues with procedures/functions that have input/output
>> lats/lons, it is due to a mismatch in range or direction of the
>> coordinates.)
>>
>> Looking at your script, I think the issue is occurring because you are
>> plotting T, and not T_new. If you change this:
>> plot = gsn_contour_map(wks,T,res) ; Draw a contour plot.
>> to this:
>> plot = gsn_contour_map(wks,T_new,res) ; Draw a contour plot.
>>
>> your script works, and the resulting plot looks correct to me.
>>
>> In the future, we try to keep most ncl-talk communication online so that
>> others can help in diagnosing issues. That way other ncl-talk subscribers
>> can help out, and the original person who replied can get assistance from
>> the community at-large in answering follow up issues. It's not a problem at
>> all that you replied directly to me this time, but next time please respond
>> to ncl-talk. Thanks! Adam
>>
>>
>> On 07/16/2012 10:36 PM, Manisha Ganeshan wrote:
>>
>> Hi Adam,
>>
>> I am not sure what you mean by matching of the lat/lon range. I am
>> certain that my polygon values lie within the specified lat/lon range in
>> the grib file. Anyway, I have uploaded the grib file through ftp in the
>> 'incoming' directory. I have renamed it as "gribfile.grb". I would be very
>> grateful if you could kindly take a look, and figure out where I am going
>> wrong.
>>
>> Thanks,
>> Manisha
>>
>> On Mon, Jul 16, 2012 at 10:51 PM, Adam Phillips <asphilli@ucar.edu>wrote:
>>
>>> Hi Nisha,
>>> I cannot see what is wrong with your script without the .grb file.
>>> Generally, the first thing I would check is to make sure the polygon
>>> latitudes/longitudes match the range of the latitudes/longitudes in the
>>> .grb file. Thus, if the .grb file has longitudes that run from -180:180E,
>>> your polygon coordinates should as well.
>>>
>>> If both the .grb file and your polygon ranges match, please follow the
>>> directions here on how to send in your .grb file via ftp:
>>> http://www.ncl.ucar.edu/report_bug.shtml
>>> Adam
>>>
>>>
>>> On 7/16/12 11:37 AM, Manisha Ganeshan wrote:
>>>
>>> Hi Adam,
>>>
>>> Thank you for your response. I tried using the gc_inout function in a
>>> script to determine points lying inside a polygon. However, it appears to
>>> produce false results. I am reading the polygon lat/lon values from a text
>>> file, and am able to plot it successfully on a pre-defined map. However, I
>>> cant seem to get the lat/lon values inside the polygon using gc_inout. The
>>> function gives me "False" values for all points in my domain.
>>>
>>> I am attaching my script here, along with the auxiliary text files. Hope
>>> that you can take a look and help me figure out what's going wrong.
>>>
>>> Thanks,
>>> Nisha
>>> On Fri, Jul 13, 2012 at 6:12 PM, Adam Phillips <asphilli@ucar.edu>wrote:
>>>
>>>> Hi Nisha,
>>>> You can use the output from gc_inout:
>>>> http://www.ncl.ucar.edu/Document/Functions/Built-in/gc_inout.shtml
>>>> (See example #3)
>>>> gc_inout will return data of type logical, and you can use that data in
>>>> a where statement to mask out your data array.
>>>> http://www.ncl.ucar.edu/Document/Functions/Built-in/where.shtml
>>>> Then you can average over the remaining (non-missing) data.
>>>>
>>>> Hope that helps.. If not, please respond to ncl-talk..
>>>> Adam
>>>>
>>>>
>>>>
>>>> On 07/13/2012 02:35 PM, Manisha Ganeshan wrote:
>>>>
>>>> Hello,
>>>>
>>>> Is there a NCL function that can compute the indices of all points
>>>> lying inside a pre-defined polygon? For example, I have used
>>>> gsn_add_polygon function to draw a polygon on a contour map, but I now wish
>>>> to find an average value of a quantity over points lying inside this
>>>> polygon.
>>>>
>>>> Thanks,
>>>> Nisha
>>>>
>>>>
>>>> _______________________________________________
>>>> ncl-talk mailing list
>>>> List instructions, subscriber options, unsubscribe:http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>>
>>>>
>>>> --
>>>> ______________________________________________________________
>>>> Adam Phillips asphilli@ucar.edu
>>>> NCAR/Climate and Global Dynamics Division (303) 497-1726
>>>> P.O. Box 3000
>>>> Boulder, CO 80307-3000 http://www.cgd.ucar.edu/cas/asphilli
>>>>
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> ncl-talk mailing list
>>>> List instructions, subscriber options, unsubscribe:
>>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>>
>>>>
>>>
>>>
>>
>> --
>> ______________________________________________________________
>> Adam Phillips asphilli@ucar.edu
>> NCAR/Climate and Global Dynamics Division (303) 497-1726
>> P.O. Box 3000
>> Boulder, CO 80307-3000 http://www.cgd.ucar.edu/cas/asphilli
>>
>>
>>
>>
>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
> --
> ______________________________________________________________
> Adam Phillips asphilli@ucar.edu
> NCAR/Climate and Global Dynamics Division (303) 497-1726
> P.O. Box 3000
> Boulder, CO 80307-3000 http://www.cgd.ucar.edu/cas/asphilli
>
>
>
>
> _______________________________________________
> 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 Jul 17 13:02:27 2012

This archive was generated by hypermail 2.1.8 : Wed Jul 18 2012 - 14:33:00 MDT