wiki:ADAGUC

Version 5 (modified by maartenplieger, 16 years ago) ( diff )

--

ADAGUC netCDF - * CURRENTLY UNDER CONSTRUCTION *

The ADAGUC netCDF driver reads and writes files which comply with the ADAGUC Data Products Standard ADAGUC website (Atmospheric Data Access for the Geospatial User Community). ADAGUC files are created by using the NetCDF4 API. The NetCDF4 API has the ability to store files in the HDF5 file format while remaining backwards compatible with previous versions of netCDF. The ADAGUC driver supports the creation of NetCDF3 and NetCDF4 files. In NetCDF3 mode the driver writes NetCDF files, in NetCDF4 mode the driver writes HDF5 files. ADAGUC netCDF files follow the Climate and Forecast (CF) 1.2 and ISO:19115 metadata conventions. Besides these conventions the format provides space for specific product metadata.

The file structure

The ADAGUC internal file structure contains variables which can be subdivided in three types: variables to store the metadata, variables to store the dimension scales and variables to store the data. A schematic overview of the ADAGUC file structure for the different types is given in the figure of the file structure (figure below on the left). The three types of variables (metadata, dimension scales and data) are indicated with A, B and C respectively.

(A) Metadata - Metadata is stored in attributes which are assigned to a variable. The variables ‘product’, ‘iso_dataset’ and ‘projection’ are used to store the metadata.

(B) Dimension scales - Dimension scales are used as coordinate variables and time intervals. They provide information about geolocation and time to the data variables. The dimension scales follow the NetCDF Climate and Forecast (CF) Metadata Conventions. Dimension scales are lists containing coordinates or time intervals. The dimension scale figure shows geographic raster data with the dimensions time, lat and lon. Its size is, in this example, 4x6x12. This means that there are 4 indexes for time, 6 for latitude and 12 for longitude. According to the CF conventions the dimensions should have the order time, lat, lon. In case the raster data uses a geographic coordinate system, the required dimensions are time, lat and lon which represent the center of the pixel. When the raster data is projected the dimension scales x and y are included which represent the projected coordinates. The dimension scales lat and lon become a function of y and x (see the right part of the file structure), providing the latitude and longitude at the location of y and x, respectively. In this case y and x contain the projected coordinates, while lat and lon represent the geographic latitudes and longitudes in degrees at location y, x. For detailed information see the NetCDF Climate and Forecast (CF) Metadata Conventions.

(C) Data - This part contains the data in the file structure. The data is stored in variables which are functions of the dimension scales. For geographic raster data the variable is a function of time, lat and lon. For projected raster data the variable is a function of time, y and x, as can be seen in the illustration of the file structure. The ADAGUC format currently supports X, Y and time dimensions, stored as dimension scales in the file according the CF Conventions. The driver supports two ways of time sub-setting. The first is by making selections in time by choosing band numbers, the second is by providing the time in the file name. By using gdalinfo on the ADAGUC file the available band numbers and dimensions are listed. With this information a subset can be read with for example:

gdalinfo ADAGUC:thefile.nc:variable:time=20

Left: filestructure; Right: dimension scales


GDAL Creation options

Creation options can be used to provide additional metadata and set the behavior of the driver. Metadata attributes set as a creation option override already existing metadata attributes.

METANCML – It is possible to provide additional metadata which is stored in an NcML XML file. The attributes from the groups product, iso_dataset, projection and custom are copied. When the name of the dataset is specified in the product::variables attribute, specific dataset attributes can be placed under the group with the name of the dataset. For example: -co “METANCML=NcMLMetadataFile.xml”

FORCENC3 – When set to true, the NetCDF4 driver writes in NetCDF3 mode. When unspecified the value is FALSE, in this case the driver writes in NetCDF4 mode. For example: {{{-co “FORCENC3=TRUE”

VALSTART and VALSTOP – Overwrites the product validity_start and product validity_stop attributes in the product group. For example: –co “VALSTART=20080921T101900”

DATASETNAME - Specifies the name of the dataset

LONGNAME, STDNAME and UNITS – Sets the long_name, standard_name and units attributes of the dataset.

NAN – Sets the no data value of the dataset. The _FillValue attribute of the dataset is filled with the NAN number.


Building the driver

Download the required libraries
The ADAGUC netCDF driver requires at least the netCDF-4.0, HDF-1.8.1 and UDUNITS-1 packages to be installed.

Configuring the libraries

  • HDF5 library:
    ./configure --prefix=<installdir> --with-default-api-version=v16
  • netCDF4 library:
    ./configure --prefix=<installdir> --with-hdf5=<installdir> --enable-netcdf-4 --enable-cxx-4 --enable-shared
  • UDUNITS library:
    Un SUSE I had to export several environment variables to make it work:
    export FC=g77
    export CPPFLAGS=-Df2cFortran
    export CC=gcc
    export CXX=g++
    export LD_MATH=-lm
    ./configure --prefix=<installdir>

Installing the GDAL ADAGUC driver

The driver consists of two files, adagucdataset.h and adagucdataset.cpp. These should be copied to the gdal/frmts/netcdf/ directory, so they reside besides the netCDF and GMT driver.

  • 1. Copy adagucdataset.h and adagucdataset.cpp to the ./<gdaldir>/frmts/netcdf/ directory
  • 2. Update the GNUmakefile and makefile.vc in the ./<gdaldir>/frmts/netCDF/ directory by adding the object with name: adagucdataset.o to the already existing objects.
  • 3. Add the registration entry point declaration GDALRegister_ADAGUC() to gdal/gcore/gdal_frmts.h, at the location above the already existing netCDF driver:
…
void CPL_DLL GDALRegister_GMT(void);
void CPL_DLL GDALRegister_ADAGUC(void);
void CPL_DLL GDALRegister_netCDF(void);
…
  • 4. Add a call to the registration function to frmts/gdalallregister.c, in the already existing netcdf ifdef:
…
#ifdef FRMT_netcdf
GDALRegister_GMT();
GDALRegister_ADAGUC();
GDALRegister_netCDF();
#endif
…

In step 3 and 4 the ADAGUC register entries should be put above the netCDF register entry, to make sure that ADAGUC files are not opened by the netCDF driver. The ADAGUC driver will only open ADAGUC files, by checking the existence of the iso_dataset and product variables.

Configuring GDAL
To make sure that the libraries are found during the compilation process you can use ./configure LIBS="-lhdf5 -lhdf5_hl -ludunits $LIBS".
Use --with-netcdf=<path to install tree> to build GDAL with the NetCDF library.


Sample ADAGUC files


Attachments (7)

Download all attachments as: .zip

Note: See TracWiki for help on using the wiki.