<div dir="ltr">Thank you so much, Dennis!<div><br></div><div>Sorry, I did modify the script, but I did not send the modified version of the script to the list because I was thinking that it would be easier for NCL users using that script instead of using my modified script. </div><div>My error was in the time do loop. </div><div><br></div><div>Thanks!</div><div><br></div><div>Jiaxin</div></div><div class="gmail_extra"><br><div class="gmail_quote">2014-09-18 16:05 GMT-07:00 Dennis Shea <span dir="ltr">&lt;<a href="mailto:shea@ucar.edu" target="_blank">shea@ucar.edu</a>&gt;</span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div>Ummm ... You did not try anything. You just reformatted  and forwarded the question.<br></div>The whole point was for *you* do to something. That is how you learn.<br><br></div>I am responding because I don&#39;t want others to have to spend time and effort.<br></div><div><br></div><br><div><div><br><br></div></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Sep 18, 2014 at 4:37 PM, Jiaxin Zhang <span dir="ltr">&lt;<a href="mailto:jiaxinzhang3@gmail.com" target="_blank">jiaxinzhang3@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Dear NCL users,<div><br></div><div>I am trying to extract variable values in some grids in specific locations for different times.</div><div><br></div><div>I am attaching the NCL script that Dennis kindly provided to extract the values for 3 grids and 1 time only. The attached NCL script works well with the attached file &quot;cVeg_CanESM2_1time.nc&quot; that only contains 1 time. But I am having problems when I try to run the same script for the attached file &quot;cVeg_CanESM2_12months.nc&quot; that contains variable values for 12 times. After modifying the script to include time as dimension when reading the input file, I am getting error messages. I guess I am missing something but I can not figure out what is wrong.</div><div><br></div><div>Could you please modify the attached script so that it works with the file &quot;cVeg_CanESM2_12months.nc&quot;?</div><div><br></div><div>Your help is very appreciated!</div><div>Many thanks in advance!</div><div><br></div><div>Jiaxin</div></div><div class="gmail_extra"><br><div class="gmail_quote">2014-09-18 13:22 GMT-07:00 Dennis Shea <span dir="ltr">&lt;<a href="mailto:shea@ucar.edu" target="_blank">shea@ucar.edu</a>&gt;</span>:<div><div><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div><div><div><div>I&#39;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 &#39;time&#39; 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 &#39;time&#39;) 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><div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Sep 17, 2014 at 5:50 PM, Jiaxin Zhang <span dir="ltr">&lt;<a href="mailto:jiaxinzhang3@gmail.com" target="_blank">jiaxinzhang3@gmail.com</a>&gt;</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><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><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>2014-09-17 5:57 GMT-07:00 Dennis Shea <span dir="ltr">&lt;<a href="mailto:shea@ucar.edu" target="_blank">shea@ucar.edu</a>&gt;</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><br><br><pre>        function getind_latlon2d (
                lat2d [*][*] : numeric,     &lt;=== you are inputting lat[*]
                lon2d [*][*] : numeric,     &lt;===                   lon[*]
                lat      [*] : numeric,  
                lon      [*] : numeric   
        )
</pre>==========<br></div></div></div><div><div>Let NCL do it<br><br>load &quot;$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl&quot;<br><br>    diri = &quot;/Users/shea/Downloads/&quot;<br>    fili = &quot;cVeg_CanESM2_1time.nc&quot;<br>    pthi = diri+fili<br>    fi   = addfile(pthi,  &quot;r&quot;)<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, &quot;cVeg&quot;), 1e20)<br><br>    do np=0,npt-1<br>       cVegpt(np) = fi-&gt;cVeg({latpt(np)},{lonpt(np)})<br>    end do<br>    print(cVegpt)<br><br></div></div></div><div><div><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">&lt;<a href="mailto:jiaxinzhang3@gmail.com" target="_blank">jiaxinzhang3@gmail.com</a>&gt;</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>
</div></div></blockquote></div></div></div><br></div>
<br>_______________________________________________<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>