INTERPLATLON Interpolation for working with latitude and longitude. INTERPLATLON performs 2D or 3D interpolation appropriate for latitude and longitude. It deals with issues arising from the periodicity of longitude in addition to performing several other convenient functions. __________________________________________________________________ 2D Interpolation Z=INTERPLATLON(LATO,LONO,[],ZO,LAT,LON) performs a 2D interpolation from the array ZO, which has latitude varying in LENGTH(LATO) rows and longitude varying in LENGTH(LONO) columns, onto locations (LAT,LON). Here LAT and LON are 2D arrays of the same size. LATO and LONO should 1D arrays such that ZO is plaid; otherwise see SPHEREINTERP. A difficulty in interpolating latitude and longitude is that longitude is periodic, for example, if LONO=0.5:1:359.5. Then the interpolation can fail if 0INTERPLATLON checks for LONO being periodic, and if so it handles the interpolation appropriately by appending the last column of ZO to its front and the last to is back. INTERPLATLON accounts for the fact that LONO may have an arbitrary starting value, not necessarily -180 or 0, as its initial point, e.g. LONO may begin at -20 and end at 340. Note that both LONO and LON are interpreted as angles on the complex plane, so the modifications LONO+n*360 or LON+n*360 for integer n would not change the result. ZO may have multiple elements along its 3rd, 4th, or 5th dimension. Z will then have its first two dimensions matching LAT and LON, and higher dimensions matching ZO. Z=INTERPLATLON(LATO,LONO,[],ZO,LAT,LON,[],BOOL), where BOOL is a boolean array with size SIZE(LAT), sets the corresponding entries of Z to NaNs. BOOL could for example be true over land. If Z has more than 2 dimensions, this is done for each SIZE(LAT) element of Z. __________________________________________________________________ Interpolation algorithm By default, INTERPLATLON uses Matlab's INTERP2 with linear interpolation. Alternatively, INTERPLATLON(...,METHOD) uses the method specified by the string METHOD, as described in INTERP2. Data points for which the chosen interpolation method does not return a valid value are then filled using nearest-neighbor interpolation. INTERPLATON(...,'fill'), if LAT and LON are matrices of the from output by MESHGRID, will instead fill missing data points from the linear interpolation with the results of a bin-averaging. This typically affects only a small number of points, but is useful in controlling exactly what constitutes missing data. For example, when interpolating an ocean field from a finer grid to a coaser grid, linear interpolation will result in somewhat degraded continental boundaries. The 'fill' algorithm puts back in a few data points that would otherwise be missed by linear interpolation. __________________________________________________________________ 3D Interpolation Z=INTERPLATLON(LATO,LONO,TO,ZO,LAT,LON,T) similarly performs a 3D interpolation, where TO is now time, with SIZE(ZO,3) being the same as LENGTH(TO). LAT, LON, and T are all the same size. Again, INTERPLATLON(...,METHOD) specifies the interpolation method, which defaults to 'linear'. Note that the 'fill' option does not work with 3D interpolation. __________________________________________________________________ Usage: z=interplatlon(lato,lono,[],zo,lat,lon); z=interplatlon(lato,lono,[],zo,lat,lon,[],bool); z=interplatlon(lato,lono,to,zo,lat,lon,t); z=interplatlon(lato,lono,to,zo,lat,lon,t,bool); __________________________________________________________________ This is part of JLAB --- type 'help jlab' for more information (C) 2018--2022 J.M. Lilly --- type 'help jlab_license' for details