[ncl-talk] getind_latlon2d with rectilinear grid

Jiaxin Zhang jiaxinzhang3 at gmail.com
Wed Sep 17 17:50:18 MDT 2014


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/20140917/4064fc87/attachment-0001.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: extract_one_grid.ncl
Type: application/octet-stream
Size: 1075 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20140917/4064fc87/attachment-0001.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cVeg_CanESM2_12months.nc
Type: application/x-netcdf
Size: 396292 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20140917/4064fc87/attachment-0001.nc 


More information about the ncl-talk mailing list