TRAJCHUNK Chunks Lagrangian trajectories based on the Coriolis period. TRAJCHUNK is used to split float or drifter data into chunks such that the length of each chunk is a fixed multiple of one over the mean Coriolis frequency. This can be useful in spectral analysis. [NUMO,LATO]=TRAJCHUNK(NUM,LAT,P), where NUM and LAT are date number and latitude for Lagangian float or drifter data, re-organizes these into chunks such that the average Coriolis frequency f_C in each chunk is at least P times the Rayleigh frequency f_R for that chunk. The Rayleigh frequency is f_R=2*pi/(DT*N), in units of radians per unit time, where DT is the sample interval and N is the number of samples. The Rayleigh frequency decreases as the chunk length increases. The input fields NUM and LAT may either be numerical arrays, or cell arrays of numerical arrays, e.g. NUM{1}=NUM1, NUM{2}=NUM2, etc. The output variables NUM and LAT are cell arrays of numerical arrays, with each cell being just long enough such that f_C > P * f_R. Trajectories that are not long enough to satisfy this criterion are discarded, as are short residual segments at the end of trajectories. Each input trajectory is thus split into zero, one, or more than one cells in the output variables. TRAJCHUNK(...,P,LMIN) additionally specifies a mininum number of points LMIN for each chunk. __________________________________________________________________ Multiple input / output arguments [NUMO,LATO,Y1,Y2,...,YM]=TRAJCHUNK(NUM,LAT,X1,X2,...XM,P) chunks the M input arrays X1, X2,... XM in the same manner, and returns these as Y1, Y2,... YM. The input variables may either all be numerical arrays of all the same size, or cell arrays of numerical arrays. In the case of cell array input, some of the XM may be numerical arrays of the same length as the cells NUM and LAT. The corresponding output variable will then also be a numerical array. An example of such a field is the identification number used in FLOATS.MAT and DRIFTERS.MAT. TRAJCHUNK with no output arguments overwrites the original named output variables. __________________________________________________________________ Optional behaviors By default, any data in short trajectories for which f_C < P * f_R are discarded, as are data segments at the end of the trajectories. TRAJCHUNK(...,'keep') keeps these instead. Short trajectories are returned in their own chunks, and leftover segments are appended to the end of the preceding chunk. TRAJCHUNK(...,'full') instead ensures that the output cells span the full duration of the input fields. This is done by appending a final cell having f_C > P * f_R, like the others, but that ends at the final data point, regardless of the degree of overlap with the previous cell. Data from cells shorter than the specified length are discarded. __________________________________________________________________ Overlap TRAJCHUNK(...,'overlap',PCT) outputs chunks with a percentage PCT overlap. For example, TRAJCHUNK(...,'overlap',50) outputs chunks that overlap by 50%. The default behavior gives chunks with no overlap. __________________________________________________________________ See also CELLCHUNK. 'trajchunk --t' runs a test. Usage: [num,lat]=trajchunk(num,lat,P); [num,lat,lon,cv]=trajchunk(num,lat,lon,cv,P); [num,lat,lon,cv]=trajchunk(num,lat,lon,cv,P,lmin); [num,lat,lon,cv]=trajchunk(num,lat,lon,cv,P,'overlap',50); trajchunk(num,lat,lon,cv,P); __________________________________________________________________ This is part of JLAB --- type 'help jlab' for more information (C) 2014--2019 J.M. Lilly --- type 'help jlab_license' for details