We can use F-TDS to run Ferret commands and define new variable from the variables in the dataset, and present these new variables in the F-TDS dataset.
To define a variable on a depth axis from a sigma-coordinate axis, we write a Ferret script that opens the dataset, defines the new Z axis and a new variable on that axis.
! sigma_script_example.jnl
! Script to define variables for the conversion to depth in meters.
! Open the dataset
USE "/home/data/ansley/las_data/uvst.nc"
! Regridding from sigma-z levels to depths.
! These are the depths from the LEvitus Climatology. Any appropriate set of values may be used.
DEFINE AXIS/Z/UNITS=meters/DEPTH zaxmeters = \
{0,10,20,30,50,75,100,150,200,300,400,600,800,1000,1200,1500,2000,3000,4000,5000}
LET zaxvar = z[gz=zaxmeters]
LET Zdepth = depth * Z[g=u]
! regrid in Z. Defining the variables with /D=1 assigns them to the dataset we opened above.
LET/D=1/UNITS="`u,RETURN=units`"/TITLE="`u,RETURN=title`" u_z = ZAXREPLACE(u, Zdepth, zaxvar)
LET/D=1/UNITS="`v,RETURN=units`"/TITLE="`v,RETURN=title`" v_z = ZAXREPLACE(v, Zdepth, zaxvar)
LET/D=1/UNITS="`temp,RETURN=units`"/TITLE="`temp,RETURN=title`" temp_z = ZAXREPLACE(temp, Zdepth, zaxvar)
LET/D=1/UNITS="`salt,RETURN=units`"/TITLE="`salt,RETURN=title`" salt_z = ZAXREPLACE(salt, Zdepth, zaxvar)
Test your script. From the Ferret command line, run the script and then issue a "show data" command. The new variables are listed after the original file variables.
% ferret
yes? go sigma_script_example.jnl
... commands are echoed
yes? show data
currently SET data sets:
1> /home/data/ansley/las_data/uvst.nc (default)
name title I J K L
U Eastward Water Velocity 1:217 1:160 1:37 1:27
V Northward Water Velocity 1:217 1:160 1:37 1:27
SALT Salinity 1:217 1:160 1:37 1:27
TEMP Temperature 1:217 1:160 1:37 1:27
DEPTH Bathymetry 1:217 1:160 ... ...
------------------------------
SALT_Z[D=uvst] = ZAXREPLACE(SALT, ZDEPTH, ZAXVAR)
TEMP_Z[D=uvst] = ZAXREPLACE(TEMP, ZDEPTH, ZAXVAR)
V_Z[D=uvst] = ZAXREPLACE(V, ZDEPTH, ZAXVAR)
U_Z[D=uvst] = ZAXREPLACE(U, ZDEPTH, ZAXVAR)
Now, make a directory called "scripts" under your $TOMCAT_HOME/content/las/conf/server/data directory, and place this script in it. Redeploy, and now this directory will be in your thredds catalog, under las/scripts.
and within it, the new dataset is called sigma_script_example.jnl
Now, we can use this URL, and run addXML on the dataset
$LAS_HOME/bin/addXML.sh -n http://dunkel.pmel.noaa.gov:8380/thredds/dodsC/las/scripts/sigma_script_...
Note that the resulting xml contains the original variables on the LON-LAT-SIGMA-TIME grid and also the variables defined in our script on the LON-LAT-zaxmeters-TIME grid.
<datasets>
<id-bb9504ba75 name="http://dunkel.pmel.noaa.gov:8380/thredds/dodsC/las/scripts/sigma_script_example.jnl" url="http://dunkel.pmel.noaa.gov:8380/thredds/dodsC/las/scripts/sigma_script_example.jnl">
<variables>
<DEPTH-id-bb9504ba75 name="bathymetry" units="meters" url="#DEPTH">
<link match="/lasdata/grids/grid-LON-LAT-id-bb9504ba75" />
</DEPTH-id-bb9504ba75>
<SALT-id-bb9504ba75 name="Salinity" units="ppt" url="#SALT">
<link match="/lasdata/grids/grid-LON-LAT-SIGMA-TIME-id-bb9504ba75" />
</SALT-id-bb9504ba75>
...
<salt_z-id-bb9504ba75 name="Salinity" units="ppt" url="#salt_z">
<link match="/lasdata/grids/grid-LON-LAT-zaxmeters-TIME-id-bb9504ba75" />
One might decide to delete the variables on LON-LAT-SIGMA-TIME from the XML (watching for and deleting any composite variables defined using these variables), or redefine their definitions in the script to include the fact that they are on a sigma-depth axis:
! At the end of the script sigma_script_example.jnl
! add sigma_z to the title of the original variables
SET VAR/TITLE="`u,RETURN=title` on sigma-z" u
SET VAR/TITLE="`v,RETURN=title` on sigma-z" v
SET VAR/TITLE="`salt,RETURN=title` on sigma-z" salt
SET VAR/TITLE="`temp,RETURN=title` on sigma-z" temp