NOTE: Sections 8.1 through 8.6 refer to dataset organization and techniques previous to the Discrete Sampling Geometries Standard in CF. Skip to Section 8.10 for discussion of Discrete Sampling Geometries data. Support for Discrete Sampling Geometries datasets begins with PyFerret/Ferret v7.6.
A single profile, possibly consisting of multiple variables, can be regarded as a simple 1-dimensional data set. Ferret's plotting and analysis tools apply in a straightforward manner.
Collections of profiles resemble point data sets in their X,Y, and T structure, however at each point there is a 1-dimensional Z-axis structure. In general, the Z axes at each point may differ.
8.3.1 How collections of profiles are structured in Ferret
If the collection of profiles is sufficiently small (say 4 or fewer) then it is straightforward to handle them simply as 4 separate data sets. The D= qualifier may be used to designate which profile is being referred to. The IF ... THEN ... ELSE syntax may be used to combine the profiles into expressions.
As the number of profiles in the collection grows larger, however, it becomes necessary to merge them into a single structure. Typically, the sequence number of the profile, 1, 2, ...,N, becomes the X axis of the collection. The longitude, latitude, and time of each profile become dependent variables indexed by the sequence number. The Z structures of the profiles are blended into a single Z axis by a choice of techniques. The steps to creating a blended data set then become:
1. Determine the nature of the Z axis to be used and the collection of variables to be defined on the grid
2. Create an empty grid with the desired structure in a file
3. Populate the file with the profiles, each profile in turn.
The determination of the Z axis structure may be by any of these techniques:
1. Supply an arbitrary Z axis to which all of the individual profiles will be regridded by linear interpolation. This technique produces a data set which is very easy to work with and small in size, however, some of the data have been altered by linear interpolation. The default Ferret regridding (GZ=@LIN) is used for this technique.
2. Create a Z axis which is a superset of the Z axis points from all of the grids. In the final data set this axis will be sparsely populated, containing only those Z points that were actually present in each profile.
This technique produces a data set which is 100% faithful to the original data and reasonably easy to work with, but may become very large if the number of profiles is large and the Z axes vary greatly. Ferret "exact match" regridding (GZ=@XACT) is used for this technique.
3. Do not create a Z axis at all ‚Äî instead store the Z coordinates as a dependent variable. The Z axis becomes simply an index counter of length equal to the longest profile. This technique produces a data set which is 100% faithful to the original data and of modest size, however it is the most laborious to work with.
The choice of technique depends on the nature of the profile collection and the types of analysis or visualization to be done. Often it is desirable to combine technique 1, which is fast and simple with 2 or 3, which can be used for spot checking if there is a question of data fidelity. If method 3 is chosen (Z coordinates in a dependent variable) the techniques for handling the variables are very similar to sigma coordinate data, described in a separate section of this chapter.
As of 4/99 the approaches to merging collections of profiles into a single structure are still "manual." (Data which are stored as global attributes in the input files, as is done in EPIC files, are lost in this process.) This text describes an example of the manual process used, where the target Z axis is created arbitrarily and data are interpolated to it. In this example the profiles are read from ASCII files, so the Z axis of each profile has to be created. This example does not save the longitude, latitude, and time positions of the casts.
! for this example we begin by manufacturing some data ! ... pretend this is one of your casts - unequal vertical spacing LIST/FILE=test_cast.dat/NOHEAD/FORM=(2F)/I=1:10 10*i+randu(i), sin(i/6) ! create a grid suitable for ALL casts together ! make the points regular in X and Z ... they need not be, however DEFINE AXIS/DEPTH/Z=0:1000:20/UNIT=meters zall ! Arbitrarty z axis DEFINE AXIS/X=0:9:1/UNIT="sequence" xall DEFINE GRID/X=xall/Z=zall gall ! create an empty output file ! if we were reading netCDF files we would create variables to hold ! longitude, latitude, and time (year, month, day). ! A latitude output variable, for example, is created below LET outvar = 1/0 * x[g=gall] * z[g=gall] SET VARIABLE/TITLE="My merged var"/UNITS="my units" outvar SAVE/FILE=all_casts.cdf/ILIMITS=1:10/ZLIMITS=0:1000 outvar LET LAT = 1/0*X[gx=gall] SET VARIABLE/TITLE="Latitude"/UNITS="degrees" lat SAVE/APPEND/FILE=all_casts.cdf/ILIMITS=1:10 lat ! read in a single cast (the fake data we created) ! if we were reading a netCDF file this block would be unnecessary FILE/VAR=depth,invar test_cast.dat ! make Z axis for 1 profile DEFINE AXIS/Z/DEPTH/UNIT=meters z1cast=depth DEFINE AXIS/X=0:0:1/UNIT="sequence" x1cast ! sequence no. of 1st cast DEFINE GRID/X=x1cast/Z=z1cast g1cast CANC DATA 1 ! save first cast interpolated to many-point Z axis FILE/VAR="-,invar"/GRID=g1cast test_cast.dat LET outvar = invar[g=gall] SAVE/APPEND/FILE=all_casts.cdf outvar[I=1] CANCEL DATA 1 ! if available, output latitude thusly ! LET lat = 0*X[g=gall] + RESHAPE(Y[G=invar],X[gx=gall]) ! SAVE/append/file=all_casts.cdf lat[I=1] ! save next cast DEFINE AXIS/X=1:1:1/UNIT="sequence" x1cast ! X position of 2nd cast FILE/VAR="-,invar"/grid=g1cast test_cast2.dat SAVE/APPEND/FILE=all_casts.cdf outvar[I=2] CANC DATA 1 ! etc for next 8 casts ... ! This may be automated with: REPEAT/I=1:10 GO output_one_profile ! where the script output_one_profile.jnl reads profile file names ! from a list. ! The output data set which we create will be structured as follows: yes? CANCEL VAR/ALL yes? USE all_casts yes? SHOW DATA currently SET data sets: 1> ./all_casts.cdf (default) name title I J K L OUTVAR My merged var 1:10 ... 1:51 ... LAT Latitude 1:10 ... ... ...
In the data set created above the profiles may or may not be ordered as needed to create a valid section. There are many possible ways to order the data. Often more than one technique is applicable to a single data set. The data may be ordered along a ship track, ordered by increasing latitude, ordered by path distance along a regression line, etc.
Continuing with the example above, we can order the profiles into increasing latitude with:
yes? let order = SORTI(lat) yes? let section = SAMPLEI(outvar, order)
Other definitions of the variable order may be created by straightforward means to apply other ordering principles.
As defined above, "section" has an X axis which is the values 1, 2, 3,...N from the Ferret ABSTRACT axis. To cast this on a proper latitude axis, use these two steps:
yes? DEFINE AXIS/Y/UNITS=degrees yax_sect=SAMPLEI(lat, order) yes? LET ysection = RESHAPE(section,Y[gy=yax_sect]+Z[gz=all])
The variables "section" and "ysection" defined above may be plotted and analyzed with the normal gridded plot commands. For examples,
yes? CONTOUR section ! contour plot ordered on X=1,2,3,... yes? FILL ysection ! color contour plot on formatted latitude axis yes? PLOT/Y=20S/Z=100:500 ysection ! profile at 20 south yes? PLOT ysection[Z=@loc:20] ! depth of 20 degree isotherm
The technique described for sampling grids at scattered point values will work unmodified for collections of vertical profiles. The Z coordinate of the gridded variable will be retained unmodified throughout the sampling operations. Regrid the final result variable to other Z axes as desired.