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.
Simple example: Datasets that are written by ocean models often have a "mask" variable which is intended to be used to show where land is. The mask is 1 over the ocean and 0 over land so that if variables are multiplied by the mask they will be 0 over land and take their computed values over the ocean.
To present this data in LAS we would like to apply the mask so that land is "missing".
Write a Ferret script that opens the dataset and defines a new variable with the mask applied.
! mask_script_example.jnl
! Script to define variables for applying a mask.
! Open the dataset
! This dataset contains variables U, V, mask
use "/home/data/ansley/las_data/maskuv.nc"
! Define the mask. the file variable mask is 1 over ocean, 0 over land.
! We define mask_land which is 1 over ocean, and missing over land.
let mask_land = if mask eq 1 then mask
! Define the virtual masked variables. When multiplied by mask_land the
! virtual variables will have a missing-value flag over land.
! Keep the original units and title of each variable.
! Defining variables with /D=1 means that the variable is part of the dataset.
let/D=1/UNITS="`u,RETURN=units`"/TITLE="`u,RETURN=title`" UU = u*mask_land
let/D=1/UNITS="`v,RETURN=units`"/TITLE="`v,RETURN=title`" VV = v*mask_land
Try the script from the Ferret command line, then issue a "show data" command. You will see the new virtual variables listed. Note that the intermediate variable "mask_land" that we defined in the script is not listed in the output below, because it is not intended for the final dataset, and was not defined with the LET/D=1 qualifier in the script.
%ferret
yes? go mask_script_example
... ! commands are echoed
yes? show data
currently SET data sets:
1> /home/data/ansley/las_data/maskuv.nc (default)
name title I J K L
U Eastward Water Velocity 1:217 1:160 1:1 1:27
V Northward Water Velocity 1:217 1:160 1:1 1:27
MASK mask 1:217 1:160 ... ...
------------------------------
VV[D=maskuv] = V*MASK_LAND
UU[D=maskuv] = U*MASK_LAND
Create a directory called "scripts" under your $TOMCAT_HOME/content/las/conf/server/data directory, and place this script in it. Restart your tomcat server, and now this directory and the virtual dataset mask_script_example.jnl will be in your thredds catalog, under las/scripts.
The thredds server has a new url which is a dataset containing the original variables plus U_MASK and V_MASK.
http://dunkel.pmel.noaa.gov:8380/thredds/dodsC/las/scripts/mask_script_e...
We can point addXML to the dataset, to create some xml for LAS.
Note that the resulting xml contains the original variables and the new, virtual variables; including composite variables for U, V and UU, VV, but again it does not include the variable mask_land.
<datasets>
<id-9bf013169c name="http://dunkel.pmel.noaa.gov:8380/thredds/dodsC/las/scripts/mask_script_example.jnl"
url="http://dunkel.pmel.noaa.gov:8380/thredds/dodsC/las/scripts/mask_script_example.jnl">
<variables>
<MASK-id-9bf013169c name="Mask" units="no units" url="#MASK">
<link match="/lasdata/grids/grid-LONX-LATY-id-9bf013169c" />
</MASK-id-9bf013169c>
<U-id-9bf013169c name="Eastward Velocity" units="m/s" url="#U">
<link match="/lasdata/grids/grid-LONX-LATY-TIME-id-9bf013169c" />
</U-id-9bf013169c>
<UU-id-9bf013169c name="Eastward Velocity" units="m/s" url="#UU">
<link match="/lasdata/grids/grid-LONX-LATY-TIME-id-9bf013169c" />
</UU-id-9bf013169c>
<V-id-9bf013169c name="Northward Velocity" units="m/s" url="#V">
<link match="/lasdata/grids/grid-LONX-LATY-TIME-id-9bf013169c" />
</V-id-9bf013169c>
<VV-id-9bf013169c name="Northward Velocity" units="m/s" url="#VV">
<link match="/lasdata/grids/grid-LONX-LATY-TIME-id-9bf013169c" />
</VV-id-9bf013169c>
</variables>
<composite>
<U-id-9bf013169c_V-id-9bf013169c name="Vector of Eastward Velocity and Northward Velocity" units="m/s">
<properties>
<ui>
<default>file:ui.xml#VecVariable</default>
</ui>
<ferret>
<palette>light_centered</palette>
<fill_levels>c</fill_levels>
</ferret>
</properties>
<link match="../../variables/U-id-9bf013169c" />
<link match="../../variables/V-id-9bf013169c" />
</U-id-9bf013169c_V-id-9bf013169c>
</composite>
<composite>
<UU-id-9bf013169c_VV-id-9bf013169c name="Vector of Eastward Velocity and Northward Velocity" units="m/s">
<properties>
<ui>
<default>file:ui.xml#VecVariable</default>
</ui>
<ferret>
<palette>light_centered</palette>
<fill_levels>c</fill_levels>
</ferret>
</properties>
<link match="../../variables/UU-id-9bf013169c" />
<link match="../../variables/VV-id-9bf013169c" />
</UU-id-9bf013169c_VV-id-9bf013169c>
</composite>
</id-9bf013169c>
</datasets>
<grids>
...
One might decide to delete the unmasked variables from the XML for this dataset (also watching for and deleting any composite variables defined using these variables), so that only the masked variables are visible to the end-user of your LAS.
A further example is given in the section about sigma-z coordinates.