Previous: Cross Boundary Subset of Grid Coverage Data Next: Displaying Satellite and Level III Radar Imagery Table of contents Frames User guide
Unidata IDV Workshop for version 6.2u2 > Accessing and Displaying Data > Working with Gridded Data

3.2.17 Working with NcML

NcML is an XML representation of netCDF metadata, NcML is similar to the netCDF CDL (network Common data form Description Language), except, of course, it uses XML syntax..

  1. A more advanced use of NcML is to modify existing NetCDF files. Displaying a bad netCDF grid dataset in the IDV can be frustrated. I am giving a example here that shows how to fix a bad nc file before loading it to the IDV.
            netcdf X:/example/ecmf_2011032700_rh.nc {
             dimensions:
               x = 141;
               y = 61;
               z = UNLIMITED;   // (29 currently)
             variables:
               short ForecastHour(z=29);
                 :units = "Degrees";
               float Longitude(x=141);
                 :units = "Degrees";
               float Latitude(y=61);
                 :units = "Hours";
               float RelativeHumidity_q25(z=29, y=61, x=141);
                 :units = "Percent";
               float RelativeHumidity_q50(z=29, y=61, x=141);
                 :units = "Percent";
               float RelativeHumidity_q75(z=29, y=61, x=141);
                 :units = "Percent";
    
             :Title = "Relative Humidity Forecasts";
            }
        

    There are several issues in the above netCDF file, the unit of the variable Latitude and the the variable ForecastHour are switched, and dimension Z should be time dimension. The following NcML file will do correction of naming and unit.

         
    <?xml version="1.0" encoding="UTF-8"?>
    <netcdf xmlns="https://www.unidata.ucar.edu/namespaces/netcdf/ncml-2.2" location="./ecmf_2011032700_rh.nc">
      <dimension name="time" orgName="z" length="29" isUnlimited="true" />
    
      <variable name="Time" orgName="ForecastHour" shape="time" type="short">
        <attribute name="units" value="hours since 2011-3-27 00:00:00 UTC" />
      </variable>
      <variable name="Latitude" shape="y" type="float">
        <attribute name="units" value="Degrees" />
      </variable>
    </netcdf>
    NcMLExample.ncml

    What has been modified here is the name of dimension z and variable ForecastHour. The unit of Latitude is also corrected, and the unit of new variable Time is hours since 2011-3-27 00:00:00 UTC which includes the information from the original file name. The above xml syntax is save in a file with an ncml file extension ecmf_2011032700_rh.ncml, and we can load this ncml file into the IDV for display. This is a very simple example, please visit NcML for complete information.

  2. Another advanced use of NcML is to create virtual NetCDF datasets through aggregation. There are two Data Source Type in the IDV, Aggregate Grids by Time and Aggregate WRF netCDF Grids by Time, both using the built-in ncml to do the aggregation on the fly.

 


Previous: Cross Boundary Subset of Grid Coverage Data Next: Displaying Satellite and Level III Radar Imagery Table of contents Frames User guide
Unidata IDV Workshop for version 6.2u2 > Accessing and Displaying Data > Working with Gridded Data