[ncl-talk] getind_latlon2d with rectilinear grid

Dennis Shea shea at ucar.edu
Thu Sep 18 14:22:58 MDT 2014


I'll respond here but I am quite busy and just can not answer multiple
questions.

Perhaps someone else can chime in?

[1] The original file you provided had no explicit time dimension.
     The 'time' was includes as an attribute of the variable.
     Note that there are no attributes (eg: hours since ) associated with
the time attribute.
     Actually, I believe that netCDF does not allow an attribute (here
'time') to have
     have an attribute.

[2] In this case it is *user* responsibility to manually create a time
dimension.
     It is user responsibility to manually provide this information. It is
not on the file.

See attached

**Please respond to ncl-talk only. Do not include a salutation to any
individual. Thank You**


On Wed, Sep 17, 2014 at 5:50 PM, Jiaxin Zhang <jiaxinzhang3 at gmail.com>
wrote:

> Thank you so much, Dennis!
> This works perfectly!
>
> I just have a couple of questions. I am trying to do this for different
> times using the attached script and data file (for 12 months). For
> simplicity, in the attached script I am testing for only one site (instead
> of 3 sites). Although the script apparently extracts the variable values
> for that grid in all 12 times, I guess there are some errors in the script
> because the new netcdf created with the extracted variable values does not
> have the time variable. What is necessary to modify in the attached script
> so that the original time information is copied in the new created netcdf?
>
> Another issue I noticed is that when extracting variable values from 3
> sites (3 grids) at the same time and after that creating a new netcdf,
> apparently the new netcdf has only the lat and lon for the last site but
> not for the rest of the extracted sites. Would it be possible to keep the
> lat and lon information for all the sites from the original file in the new
> created netcdf?
>
> Thank you!
>
> Jiaxin
>
>
> 2014-09-17 5:57 GMT-07:00 Dennis Shea <shea at ucar.edu>:
>
>> Using getind_latlon2d should have failed. The 1st two arguments are
>> prototyped as 2-dimensional. You are inputting one-dimensional arrays.
>>
>>
>> 	function getind_latlon2d (
>> 		lat2d [*][*] : numeric,     <=== you are inputting lat[*]
>> 		lon2d [*][*] : numeric,     <===                   lon[*]
>> 		lat      [*] : numeric,
>> 		lon      [*] : numeric
>> 	)
>>
>> ==========
>> Let NCL do it
>>
>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
>>
>>     diri = "/Users/shea/Downloads/"
>>     fili = "cVeg_CanESM2_1time.nc"
>>     pthi = diri+fili
>>     fi   = addfile(pthi,  "r")
>>    ;print(fi)
>>
>>     latpt = (/ 42.5, 25.4, 35.0 /)
>>     lonpt = (/-72.2,-81.1,-84.3 /)
>>     lonpt = where(lonpt.lt.0, lonpt+360, lonpt)
>>     npt   = dimsizes(latpt)
>>
>>     cVegpt= new ( npt, getfilevartypes(fi, "cVeg"), 1e20)
>>
>>     do np=0,npt-1
>>        cVegpt(np) = fi->cVeg({latpt(np)},{lonpt(np)})
>>     end do
>>     print(cVegpt)
>>
>>
>> On Tue, Sep 16, 2014 at 1:29 PM, Jiaxin Zhang <jiaxinzhang3 at gmail.com>
>> wrote:
>>
>>> Dear NCL users,
>>>
>>> I am trying to follow the example provided for getind_latlon2d in:
>>>
>>>
>>> http://www.ncl.ucar.edu/Document/Functions/Contributed/getind_latlon2d.shtml
>>>
>>> My data is in a rectilinear grid that can be completely described by one
>>> dimensional lat and lon arrays, whereas getind_latlon2d requires 2d arrays
>>> for lat and lon. How can I solve this problem? Is it better to use a
>>> different function from getind_latlon2d for 1d lat and lon arrays?
>>>
>>> I am attaching my NCL script and my file. I have 3 different sites (with
>>> given coordinates in attached script), that I would need to locate in the
>>> data grid. After that I would need to extract the value in that particular
>>> location (extract only the value of the 3 grids that contain the 3 sites).
>>> I was using getind_latlon2d to locate the 3 points in the data grid, but
>>> maybe there is better option to do that for rectilinear grids.
>>>
>>> Your help is very appreciated.
>>> Thank you!
>>>
>>> Jiaxin
>>>
>>>
>>> _______________________________________________
>>> ncl-talk mailing list
>>> 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/20140918/00ede466/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: JiaxinZhang.ncl
Type: application/octet-stream
Size: 2262 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20140918/00ede466/attachment.obj 


More information about the ncl-talk mailing list