Expand a 1-D variable in X, to an X-T variable
EXPNDI_BY_T(dat,mask,n_profiles,max_profile_len)
Use to split a variable into a set of time series (see also the EXPNDI_BY_Z function for Z profiles)
Arguments: |
DAT |
Variable to expand, a 1D variable on X axis |
MASK |
Each valid point starts a new T column |
|
n_profiles |
Number of time-series profiles: |
|
max_profile_len |
Max length of each profile: |
|
Result Axes: |
X |
Abstract: length is argument 3 |
Y |
Inherited from DAT and MASK |
|
Z |
Inherited from DAT and MASK |
|
T |
ABSTRACT: length is argument 4 |
|
E |
Inherited from DAT and MASK |
|
F |
Inherited from DAT and MASK |
Example:
Data read from ascii files or data organized as simple 1-D lists may represent sets of time series, but of different lengths. See how DAY starts with 5 for each station, but there are a different number of measurements for each time series.
STATION DAY LON LAT TEMP SALINITY 1 5 12.45 45.5 24.25 36.42 1 6 12.45 45.5 24.46 36.42 1 7 12.45 45.5 24.23 36.43 2 5 15.08 51.3 24.74 36.06 2 6 15.08 51.3 24.65 36.05 2 7 15.08 51.3 24.74 36 2 8 15.08 51.3 24.75 35.98 2 9 15.08 51.3 24.75 35.95 2 10 15.08 51.3 24.75 35.95 2 11 15.08 51.3 24.75 35.96 3 5 17.11 41.3 24.79 36.34 3 6 17.11 41.3 24.8 36.34 3 7 17.11 41.3 24.79 36.35 3 8 17.11 41.3 24.78 36.34 3 9 17.11 41.3 24.78 36.31 3 10 17.11 41.3 24.78 36.34 3 11 17.11 41.3 24.77 36.31 3 12 17.11 41.3 24.78 36.32 3 13 17.11 41.3 25.1 36.27 3 14 17.11 41.3 24.56 36.24 3 15 17.11 41.3 24.81 36.3 3 16 17.11 41.3 24.8 36.31
Open this dataset. Read the data as single 1-D lists, then define a XT variable.
yes? define axis/x=1:22:1 xinyes? define grid/x=xin input_gridyes? file/skip=1/var="sta, day, lat, lon, temp, salt"/grid=input_grid tprofiles.datyes? list day, temp, salt DATA SET: ./tprofiles.dat X: 0.5 to 22.5 Column 1: DAY Column 2: TEMP Column 3: SALT DAY TEMP SALT1 / 1: 5.00 24.25 36.422 / 2: 6.00 24.46 36.423 / 3: 7.00 24.23 36.434 / 4: 5.00 24.74 36.065 / 5: 6.00 24.65 36.056 / 6: 7.00 24.74 36.007 / 7: 8.00 24.75 35.988 / 8: 9.00 24.75 35.959 / 9: 10.00 24.75 35.9510 / 10: 11.00 24.75 35.9611 / 11: 5.00 24.79 36.3412 / 12: 6.00 24.80 36.34...! Define the mask variable so that each new station is marked with a 1.! (We could also have said "let mask = if day eq 5 then 1")yes? let mask = if day[i=@ddb] LT 0 then 1yes? list day, mask DATA SET: ./tprofiles.dat X: 0.5 to 22.5 Column 1: DAY Column 2: MASK is IF DAY[I=@DDB] LT 0 THEN 1 DAY MASK1 / 1: 5.00 ....2 / 2: 6.00 ....3 / 3: 7.00 ....4 / 4: 5.00 1.0005 / 5: 6.00 ....6 / 6: 7.00 ....7 / 7: 8.00 ....8 / 8: 9.00 ....9 / 9: 10.00 ....10 / 10: 11.00 ....11 / 11: 5.00 1.00012 / 12: 6.00 ....13 / 13: 7.00 ....! Note that the first is profile is not marked in the mask.yes? let n_profiles = `1 + mask[i=@ngd]`! We may be able to define the size of the profile using the data, ! Depending on the information available we might just give some upper bound.yes? let max_profile_len = day[i=@max] - day[i=@min] + 1yes? let sal_xt = expndi_by_t(salt, mask, n_profiles, max_profile_len)yes? list sal_xt VARIABLE : EXPNDI_BY_T(SALT, MASK, N_PROFILES, MAX_PROFILE_LEN) FILENAME : tprofiles.dat SUBSET : 3 by 12 points (X-T) 1 2 3 1 2 3 1 / 1: 36.42 36.06 36.34 2 / 2: 36.42 36.05 36.34 3 / 3: 36.43 36.00 36.35 4 / 4: .... 35.98 36.34 5 / 5: .... 35.95 36.31 6 / 6: .... 35.95 36.30 7 / 7: .... 35.96 36.31 8 / 8: .... .... 36.32 9 / 9: .... .... 36.27 10 / 10: .... .... 36.24 11 / 11: .... .... 36.30 12 / 12: .... .... 36.31
Now we could define a time axis in units of days, from the data in variable DEPTH, and regrid variable sal_xt to that axis using the @ASN transformation. We could also go on to use the information in the file to locate the profiles in X and Y.