<div dir="ltr"><div><div><div><div><div><div><div>I'll respond here but I am quite busy and just can not answer multiple questions.<br><br></div>Perhaps someone else can chime in?<br><br></div>[1] The original file you provided had no explicit time dimension.<br></div> The 'time' was includes as an attribute of the variable.<br></div><div> Note that there are no attributes (eg: hours since ) associated with the time attribute.<br></div><div> Actually, I believe that netCDF does not allow an attribute (here 'time') to have<br></div><div> have an attribute.<br></div><div><br></div>[2] In this case it is *user* responsibility to manually create a time dimension.<br></div> It is user responsibility to manually provide this information. It is not on the file.<br><br></div>See attached<br><br></div>**Please respond to ncl-talk only. Do not include a salutation to any individual. Thank You**<br><div><div><div> <br></div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Sep 17, 2014 at 5:50 PM, Jiaxin Zhang <span dir="ltr"><<a href="mailto:jiaxinzhang3@gmail.com" target="_blank">jiaxinzhang3@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><span class=""><span style="font-family:arial,sans-serif;font-size:13px">Thank you so much, Dennis!</span><div style="font-family:arial,sans-serif;font-size:13px">This works perfectly!</div><div style="font-family:arial,sans-serif;font-size:13px"><br></div></span><div style="font-family:arial,sans-serif;font-size:13px">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?</div><span class=""><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">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?</div><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">Thank you!</div><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">Jiaxin</div><div style="font-family:arial,sans-serif;font-size:13px"><br></div></span><div class="gmail_extra"><br><div class="gmail_quote"><span class="">2014-09-17 5:57 GMT-07:00 Dennis Shea <span dir="ltr"><<a href="mailto:shea@ucar.edu" target="_blank">shea@ucar.edu</a>></span>:<br></span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Using getind_latlon2d should have failed. The 1st two arguments are prototyped as 2-dimensional. You are inputting one-dimensional arrays.<div><div class="h5"><br><br><pre>        function getind_latlon2d (
                lat2d [*][*] : numeric, <=== you are inputting lat[*]
                lon2d [*][*] : numeric, <=== lon[*]
                lat [*] : numeric,
                lon [*] : numeric
        )
</pre>==========<br></div></div></div><div><div class="h5">Let NCL do it<br><br>load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"<br><br> diri = "/Users/shea/Downloads/"<br> fili = "cVeg_CanESM2_1time.nc"<br> pthi = diri+fili<br> fi = addfile(pthi, "r")<br> ;print(fi)<br><br> latpt = (/ 42.5, 25.4, 35.0 /)<br> lonpt = (/-72.2,-81.1,-84.3 /)<br> lonpt = where(lonpt.lt.0, lonpt+360, lonpt)<br> npt = dimsizes(latpt)<br><br> cVegpt= new ( npt, getfilevartypes(fi, "cVeg"), 1e20)<br><br> do np=0,npt-1<br> cVegpt(np) = fi->cVeg({latpt(np)},{lonpt(np)})<br> end do<br> print(cVegpt)<br><br></div></div></div><div><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote"><div><div>On Tue, Sep 16, 2014 at 1:29 PM, Jiaxin Zhang <span dir="ltr"><<a href="mailto:jiaxinzhang3@gmail.com" target="_blank">jiaxinzhang3@gmail.com</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div><div dir="ltr">Dear NCL users,<div><br></div><div>I am trying to follow the example provided for getind_latlon2d in:</div><div><br></div><div><a href="http://www.ncl.ucar.edu/Document/Functions/Contributed/getind_latlon2d.shtml" target="_blank">http://www.ncl.ucar.edu/Document/Functions/Contributed/getind_latlon2d.shtml</a><br></div><div><br></div><div>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? </div><div><br></div><div>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. </div><div><br></div><div>Your help is very appreciated.</div><div>Thank you!</div><span><font color="#888888"><div><br></div><div>Jiaxin</div><div> </div></font></span></div>
<br></div></div>_______________________________________________<br>
ncl-talk mailing list<br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div>
</div></div></blockquote></div><br></div></div>
</blockquote></div><br></div>