Our goal in this section is to enhance two sample datasets using NcML. The first dataset is an unknown gridded (we think) netCDF file. The second dataset is gridded output from the Weather Research and Forecasting (WRF) model, a very popular atmospheric model among educators and researchers. Our goal will be to make this file CF compliant.
Example 1: Remote Grid File (Unknown)
In this example, we will use NcML to modify a ‘remote’ dataset to fix it enough to work with viewers that can read “Grids” FeatureTypes (e.g., IDV).
-
Add the following to your
catalog.xml
file and restart Tomcat:<datasetRoot path="workshop_ncml" location="/machine/tds/data/ncmlExamples/simpleNcmlTwo/" /> <dataset name="ncml examples" ID="testNcmlDataset" serviceName="odap" urlPath="workshop_ncml/hwave_4D.nc"/>
-
In the ToolsUI
Viewer
tab, open http://localhost:8080/thredds/dodsC/workshop_ncml/hwave_4D.nc. Do you notice anything missing? -
In the ToolsUI
CoordSys
tab, open http://localhost:8080/thredds/dodsC/workshop_ncml/hwave_4D.nc. Now do you notice anything missing? (Hint: what coordinate variables do you expect to see?) -
Just for fun, let’s go to the ToolsUI
FeatureTypes → Grids
tab, and try to open http://localhost:8080/thredds/dodsC/workshop_ncml/hwave_4D.nc. Obviously, something isn’t right. Let’s try to fix things with NcML! -
In ToolsUI
NcML
tab, open http://localhost:8080/thredds/dodsC/workshop_ncml/hwave_4D.nc and save the resulting NcML file. Notice theConventions
global attribute? Hmmm… -
It appears that the file is missing
time
andlevel
coordinate variable. First, let’s add a time variable using NcML. Let’s assume that we were told that the file consists of four time steps going from2011-10-03 0000 UTC - 0900 UTC
. Add the following to the modified NcML file:<variable name="time" shape="time" type="int"> <attribute name="units" value="hours since 2011-10-03" /> <attribute name="standard_name" value="time" /> <values>0 3 6 9</values> </variable>
-
Next, let’s add a
level
variable, which in this case is actually a depth. We don’t know what the value should be, so we will put in a value of0
for now and contact the user to get more information. Add the following to your NcML file:<variable name="level" shape="level" type="int"> <attribute name="units" value="m" /> <attribute name="standard_name" value="depth" /> <attribute name="positive" value="down" /> <values>0</values> </variable>
-
Add standard_name attributes to the
latitude
andlongitude
variables, like so:<variable name="longitude"> <attribute name="standard_name" value="longitude" /> </variable> <variable name="latitude"> <attribute name="standard_name" value="latitude" /> </variable>
-
The variable
wave_height
needs an attribute calledcoordinates
that has a valuetime level latitude longitude
:<variable name="wave_height"> <attribute name="coordinates" value="time level latitude longitude"/> </variable>
-
Finally, remove any of the unmodified information, like the dimensions and global attributes.
-
Now, open the NcML file ToolsUI
FeatureTypes → Grids
tab and visualize the variablewave_height
.
Example 2: Local WRF output
-
In the ToolsUI
Viewer
tab, open/machine/tds/data/ncmlExamples/simpleNcmlOne/wrfout_d01_2005-08-27_00_00_00
.
Note that the model output are on an Arakawa C grid, so we haveregular
andstag
dimensions. -
Open the following link in your browser: WRF goes CF
-
In ToolsUI
NcML
tab, open/machine/tds/data/ncmlExamples/simpleNcmlOne/wrfout_d01_2005-08-27_00_00_00
, and save a copy of the resulting NcML. -
We will not be changing any of the dimensions or global attributes, so remove them from the NcML. Also, many of the variable attributes will not be changed, so they can be removed as well (e.g.,
FieldType
,MemoryOrder
,description
). -
Some variables (notably 2D) have an attribute called
coordinates
, while others do not. WRF goes CF on which variables need them and go ahead and add a few. -
Pay attention to units (for example, see the variable
XTIME
). -
To see a partial WRF NcML file, open
/machine/tds/data/ncmlExamples/simpleNcmlOne/wrf-cf.ncml
, which was provided by Rich Signell. Note the addition of theConventions
attribute.