Return to LAS FAQ
How can I use LAS and Ferret to provide access to 'virtual' variables that are functions of one or more other variables?
Ferret gives you the ability to define new variables which are functions of other variables. This power can be harnessed in LAS to provide access to derived variables alongside the variables they are derived from.
In order to create a virtual variable that will be displayed by LAS you need to hand edit the .xml file for a particular dataset. You will create an additional variable and assign an initialization script to it as one of the ferret properties.. Here are a few lines from an example Xml file which create the virtual variable "air_sea":
<airt name="AIR TEMPERATURE" units="DEG C"> <link match="/lasdata/grids/coads_climatology_nc_grid"/> </airt> <sst name="SEA SURFACE TEMPERATURE" units="Deg C"> <link match="/lasdata/grids/coads_climatology_nc_grid"/> </SST> <air_sea name="Air-Sea difference" units="Deg C"> <link match="/lasdata/grids/coads_climatology_nc_grid"/> <properties> <ferret> <init_script>air_sea_diff_init</init_script> </ferret> </properties> </air_sea>
The LAS interface generated from this Xml file will display "Air-Sea difference"
as one of the variables. When a request for the variable "air_sea"
is sent to the server, Ferret will begin by running the script named
instead of the usual
std_initialize.jnl. These files should reside
in the lasxml/server/jnls/ directory. It is up to this new journal file
to define a Ferret variable named "air_sea". You should use
as a template, adding your variable definition where the comments tell you to.
Here is the pertinent section with your changes hilighted.
! We must define var$2_grid for use in differencing. ! This grid must reference a file variable: one that actually ! exists in dataset 'dset' as opposed to a virtual variable ! created with an expression involving other variables. define grid/like=airt[d=$3] var$2_grid_
! Any extra work: defining virtual variables, regridding, etc ! should be done at this time. let/title="Air-Sea Temperature Difference"/units="Deg C" air_sea = airt - SST
Don't forget to include a carriage return after typing that last line! Lastly, you should make sure that the permissions are set so that the http daemon can read this journal file.
Jonathan Callahan: Jonathan.S.Callahan@noaa.gov
Last modified: August 10, 2000