Re: County average using shape files

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Wed Jul 02 2014 - 17:21:23 MDT

Carl,

I think you can just subtract 360 from the longitude array, and you want to
do it for both:

data&lon = data&lon -360
lon = lon - 360

Let me know if this doesn't work.


--Mary


On Wed, Jul 2, 2014 at 5:04 PM, Cary Lynch <lynchc6@uw.edu> wrote:

> I can shift longitude in my data file by using cdo commands, which then
> allows the data to work in the example 13 script. But is there a way to do
> this in NCL?
> The cdo commands are as follows:
> cdo griddes toe_tmax.nc [ofile]
> edit [ofile] and set xfirst to [235.312 - 360]
> cdo setgrid,[ofile] toe_tmax.nc toe_tmax2.nc
>
> Thanks again!
>
>
> On Wed, Jul 2, 2014 at 1:05 PM, Cary Lynch <lynchc6@uw.edu> wrote:
>
>> Thank you very much for your rapid response. Using the data created by
>> the function "dummy_data" works in creating the overlay plots (at the
>> resolution of my data), but using my data I get the same error as before:
>> fatal: Subscript out of range, error in subscript #0
>> fatal: An error occurred reading skip_check
>>
>> After commenting out the lines that create and later call the
>> function"dummy_data", I added the following lines:
>>
>> hf1 = addfile("toe_tmax.nc","r")
>> data = hf1->minmod
>> lat = hf1->lat
>> lon = hf1->lon
>> ; lon: [235.312..292.938]
>>
>> I am at a loss to reorder the longitude values as "data" is not global.
>> Is there a way to do a 'lonFlip" or "lonPivot" for non-global data? My
>> data is rectilinear gridded.
>>
>>
>>
>> On Tue, Jul 1, 2014 at 10:05 PM, Mary Haley <haley@ucar.edu> wrote:
>>
>>> Hi Carl,
>>>
>>> One guess at the problem is that the min/max longitude you've specified
>>> is in the range 0 to 360, and the longitudes in the shapefile are probably
>>> -180 to 180.
>>>
>>> Try subtracting 360 from your minlon/maxlon values and see if this helps.
>>>
>>> I'm not sure how many points you need to mask, but checking against
>>> every county outline in the United States could get quite expensive, since
>>> some counties have several segments that you need to check against. This
>>> is especially true for coastal areas.
>>>
>>> I've created a modified version of shapefiles_13.ncl that should check
>>> against every county in the U.S. This example was taking a really long
>>> time, so I decided to limit the area to just New Mexico and Colorado. You
>>> will need to remove the two locations where I specify these two states.
>>> Search for the word "kludge" and you will see the code you'll need to
>>> modify.
>>>
>>> See attached script and image.
>>>
>>> --Mary
>>>
>>>
>>> On Tue, Jul 1, 2014 at 11:21 AM, Cary Lynch <lynchc6@uw.edu> wrote:
>>>
>>>> Hello,
>>>> I am having trouble calculating the US county area averages using
>>>> gridded CONUS data and US county shape file data. The county polyline
>>>> overlay works, but I cannot get the county area average function to work
>>>> with my data.
>>>> Following the example script
>>>> www.ncl.ucar.edu/Applications/Scripts/shapefiles_13.ncl
>>>> I am getting the following error:
>>>>
>>>> fatal: Subscript out of range, error in subscript #0
>>>> fatal: An error occurred reading skip_check
>>>>
>>>> ;The CONUS data is land only for the coterminous US:
>>>>
>>>> hf1 = addfile("conus.nc","r")
>>>> data = hf1->tmaxhist(:,:) ; ((/nlat,nlon/),float)
>>>> lat = hf1->lat
>>>> lon = hf1->lon
>>>>
>>>> ; The attributes of data and lat/lon are as follows:
>>>> ; nlat = 222
>>>> ; nlon = 462
>>>> ; minlat/maxlat = 25.1875/52.8125
>>>> ; minlon/maxlon = 235.312/292.938
>>>> ; lat@units = "degrees_north"
>>>> ; lon@units = "degrees_east"
>>>>
>>>>
>>>> Any help would be much appreciated. Thank you.
>>>> --
>>>> Cary Lynch
>>>>
>>>>
>>>> _______________________________________________
>>>> ncl-talk mailing list
>>>> List instructions, subscriber options, unsubscribe:
>>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>>
>>>>
>>>
>>
>>
>> --
>> Cary Lynch, PhD
>> Climate Impacts Group
>> College of the Environment
>> University of Washington
>>
>
>
>
> --
> Cary Lynch, PhD
> Climate Impacts Group
> College of the Environment
> University of Washington
>

Received on Wed Jul 02 11:21:23 2014

This archive was generated by hypermail 2.1.8 : Wed Jul 23 2014 - 15:33:46 MDT