NCINTERP One-line interpolation from 3D lat/lon/time field in NetCDF file. X=NCINTERP(FILENAME,NUM,LAT,LON,VARNAME) interpolates the field VARNAME from the NetCDF file FILENAME onto positions given by date numbers NUM, latitudes LAT, and longitudes LON, and returns the results in X. The interpolation is linear interpolation performed with INTERP3. Longitude boundaries and near-polar latitudes are both accommodated. The field VARNAME must have three dimensions, latitude, longitude, and time. By default, the dimension order is expected to be (1) latitude, (2) longitude, and (3) time. NCINTERP(...,'transpose') specifies that the order is instead (1) longitude, (2) latitude, and (3) time. The NetCDF fil must also have variables named 'lat', 'lon', and 'num' which give the values along the dimensions. Both lat and lon are oriented in order of increasing values (i.e. lon cannot be discontinuous), while the time NUM is given in Matlab's DATENUM format. NCINTERP detects if longitude in FILENAME spans 360 degrees, and if so, interpolation across the longitudinal boundaries is correctly handled. Note that longitudes can be specified as [-180,180] or [0,360]. NUM, LAT, and LON are all arrays of the same size, or else cell arrays of numeric arrays. In the latter case, X will also be a cell array. [X1,X2,...,XN]=NCINTERP(FILENAME,NUM,LAT,LON,NAME1,NAME2,...,NAMEN), with multiple variable names input, also works, for example: [uwnd,vwnd]=ncinterp(filename,num,lat,lon,'uwnd','vwnd'); FILENAME should specify a file on the Matlab search path, or should include the full pathname, e.g. FILENAME='/Volumes/Data/ncep_winds.nc'. Failures in the interpolation, for example, if the data falls outside the region covered by the NetCDF file, are set to values of INF. __________________________________________________________________ Algorithms NCINTERP has two different approaches to reading the data. The default behavior is to load in time chunks such that each double-precision variable read in is smaller than a specified size, chosen as 16 GB. NCINTERP(...,M) instead uses M gigabytes as the cutoff for the chunk. This method tends to be relatively fast. NCINTERP(...,'loop') alternatively reads each time slice invididually This method is very slow and is recommended only for testing purposes. __________________________________________________________________ Handling domain edges If the NetCDF file spans 360 degrees of longitude, the first and last longitude are periodically wrapped to provide continuous interpolation. To prevent the interpolation from failing very near the poles, the first and last latitudes are also repeated, provided the last latitude is within one latitude spacing interval of the pole. __________________________________________________________________ Usage: x=ncinterp(filename,num,lat,lon,varname); [x1,x2]=ncinterp(filename,num,lat,lon,varname1,varname2); __________________________________________________________________ This is part of JLAB --- type 'help jlab' for more information (C) 2016--2021 J.M. Lilly --- type 'help jlab_license' for details