<div dir="ltr"><div><div><div>The grids are rectiulinear: lat(lat), lon(lon)<br><br>============================<br><br>Please read about NCL's 'coordinate subscripting' in the 'Mini-Language Manual'<br>
<br> <a href="https://www.ncl.ucar.edu/Document/Manuals/">https://www.ncl.ucar.edu/Document/Manuals/</a><br><br></div><div>In fact, if you are new to NCL, read the above document.<br></div><div><br>============================<br>
</div>Also, search for 'coordinate subscripting' on the NCL page<br><br>=============================<br><br></div><div>The most important rule of data processing is **Look at the Data"<br></div><div>The longitudes on the netCDF files span 0 to 360. Your examples all use -180 to 180.<br>
</div><div>You *must* use the values consistent with those on the file.<br><br>=================================<br></div><div><br></div>The script below will bilinearly interpolate to 3 specified locations.<br><br></div>
PLease read the documentation for:<br><br><a href="https://www.ncl.ucar.edu/Document/Functions/Contributed/linint2_points_Wrap.shtml">https://www.ncl.ucar.edu/Document/Functions/Contributed/linint2_points_Wrap.shtml</a><br>
<br>================================<br><br><br>load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"<br><br> diri = "./"<br> fili = "cVeg_CanESM2_1time.nc"<br> pthi = diri+fili<br>
fi = addfile(pthi, "r")<br><br> latSite = (/ 42.5, 25.4, 35.0 /)<br> lonSite = (/-72.2,-81.1,-84.3 /)<br> lonSite = where(lonSite.lt.0, lonSite+360, lonSite)<br><br> buf = 5.0 ; buffer around region (arbitrary)<br>
latS = min(latSite)-buf<br> latN = max(latSite)+buf<br> lonL = min(lonSite)-buf<br> lonR = max(lonSite)+buf<br><br>; Read a region of globe that includes the specified points<br><br> cVegRegion = fi->cVeg({latS:latN},{lonL:lonR})<br>
printVarSummary(cVegRegion)<br><br> y = linint2_points_Wrap(cVegRegion&lon,cVegRegion&lat,cVegRegion, False, lonSite,latSite, 0)<br> y!0 = "Site"<br> printVarSummary(y)<br><br>; netCDF<br><br>
diro = "./"<br> filo = "cVeg_CanESM2_site.nc"<br> ptho = diro+filo<br><br> system("/bin/rm -f "+ptho)<br> fout = addfile(ptho, "c")<br> fout@title = "cVeg at selected sites"<br>
fout@method = "NCL: linint2_points_Wrap: bilinear interpolation"<br> fout@source = fili<br> fout@creation_date = systemfunc("date")<br> fout->cVeg = y<br><br>+++++++++++++++++++++++++++++++++++++<br>
<div><br>Variable: y<br>Type: float<br>Total Size: 12 bytes<br> 3 values<br>Number of Dimensions: 1<br>Dimensions and sizes: [Site | 3]<br>Coordinates: <br> Site: [0..2]<br>Number Of Attributes: 13<br>
_FillValue : 1e+20<br> time : 56924.5<br> standard_name : vegetation_carbon_content<br> long_name : Carbon Mass in Vegetation<br> units : kg m-2<br> original_name : CVEG<br> cell_methods : time: mean area: mean where land<br>
cell_measures : area: areacella<br> history : 2011-03-17T21:17:57Z altered by CMOR: replaced missing value flag (1e+38) with standard missing value (1e+20).<br>
associated_files : baseURL:
<a href="http://cmip-pcmdi.llnl.gov/CMIP5/dataLocation">http://cmip-pcmdi.llnl.gov/CMIP5/dataLocation</a> gridspecFile:
gridspec_land_fx_CanESM2_esmHistorical_r0i0p0.nc areacella:
areacella_fx_CanESM2_esmHistorical_r0i0p0.nc<br> missing_value : 1e+20<br> xcoord : ( 287.8, 278.9, 275.7 ) <===== lon locations<br> ycoord : ( 42.5, 25.4, 35 ) <===== lat locations<br><br>
<div><br></div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Aug 13, 2014 at 7:03 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"><p class="MsoNormal"><span lang="CA">Dear NCL users,</span></p>
<p class="MsoNormal"><span lang="CA"> </span></p>
<p class="MsoNormal"><span lang="CA">I want to extract
a few grids with given lon and lat from global netcdf of CMIP5.</span></p>
<p class="MsoNormal"><span lang="CA"> </span></p>
<p class="MsoNormal"><span lang="CA">I have extracted
one grid in a specific lat and lon using the attcahed script ("extract_grid.ncl") for site1, but I
did this part manually (I mean I had to look at all the values of lat and lon
in the global netcdf, found the ones that were the closest to the given lat and
lon and use the lat and lon indices that correspond to this grid to extract
it). I guess that there are most efficient ways to do this, right? What is the
best way to do it? What would be the recommended way to simoultaneously extract
moret han one grid (for instance site1, site2 and site3)?</span></p>
<p class="MsoNormal"><span lang="CA"> </span></p>
<p class="MsoNormal"><span lang="CA">In addition, some
of the files that correspond to different CMIP5 models have different spatial
resolution, and this means that the lat and lon for the same location would
have different indices for lat and lon in different models. </span></p>
<p class="MsoNormal"><span lang="CA">Could you please
give some adivice about the best way to extract some grids (in specific lat and
lon) from global netcdf with different spatial resolution?</span></p>
<p class="MsoNormal"><span lang="CA"> </span></p>
<p class="MsoNormal"><span lang="CA">Attached is the
code I used for site 1. Also attached are two different global netcdf (for just
1 time) from 2 models that use different spatial resolution. Is it possible to
modify the script so I can use it for netcdf with different spatial
resolutions? </span></p>
<p class="MsoNormal"><span lang="CA"> </span></p>
<p class="MsoNormal"><span lang="CA">Thank you!</span></p><span class="HOEnZb"><font color="#888888">
<p class="MsoNormal"><span lang="CA"> </span></p>
<p class="MsoNormal"><span lang="CA">Jiaxin</span></p></font></span></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>