NetCDF  4.6.1
Accessing OPeNDAP Data

In order to access an OPeNDAP data source through the netCDF API, the file name normally used is replaced with a URL with a specific format.

The URL is composed of three parts.

  • URL - this is a standard form URL such as http://remotetest.unidata.ucar.edu/dts/test.01
  • Constraints - these are suffixed to the URL and take the form “?<projections>&<selections>”. The meaning of the terms projection and selection is somewhat complicated; and the OPeNDAP web site, http://www.opendap.org , should be consulted. The interaction of DAP constraints with netCDF is complex and at the moment requires an understanding of how DAP is translated to netCDF.
  • Client parameters - these may be specified in either of two ways. The older, deprecated form prefixes text to the front of the url and is of the the general form [<name>] or [<name>=value]. Examples include [show=fetch] and [noprefetch]. The newer, preferred form prefixes the parameters to the end of the url using the semi-standard '#' format: e.g. http://....#show=fetch&noprefetch.

It is possible to see what the translation does to a particular DAP data source in either of two ways. First, one can examine the DDS source through a web browser and then examine the translation using the ncdump -h command to see the netCDF Classic translation. The ncdump output will actually be the union of the DDS with the DAS, so to see the complete translation, it is necessary to view both.

For example, if a web browser is given the following, the first URL will return the DDS for the specified dataset, and the second URL will return the DAS for the specified dataset.

http://remotetest.unidata.ucar.edu/dts/test.01.dds
http://remotetest.unidata.ucar.edu/dts/test.01.das

Then by using the following ncdump command, it is possible to see the equivalent netCDF Classic translation.

ncdump -h http://remotetest.unidata.ucar.edu/dts/test.01

The DDS output from the web server should look like this.

Dataset {
Byte b;
Int32 i32;
UInt32 ui32;
Int16 i16;
UInt16 ui16;
Float32 f32;
Float64 f64;
String s;
Url u;
} SimpleTypes;

The DAS output from the web server should look like this.

Attributes {
Facility {
String PrincipleInvestigator ``Mark Abbott'', ``Ph.D'';
String DataCenter ``COAS Environmental Computer Facility'';
String DrifterType ``MetOcean WOCE/OCM'';
}
b {
String Description ``A test byte'';
String units ``unknown'';
}
i32 {
String Description ``A 32 bit test server int'';
String units ``unknown'';
}
}

The output from ncdump should look like this.

netcdf test {
dimensions:
stringdim64 = 64 ;
variables:
byte b ;
b:Description = "A test byte" ;
b:units = "unknown" ;
int i32 ;
i32:Description = "A 32 bit test server int" ;
i32:units = "unknown" ;
int ui32 ;
short i16 ;
short ui16 ;
float f32 ;
double f64 ;
char s(stringdim64) ;
char u(stringdim64) ;
}

Note that the fields of type String and type URL have suddenly acquired a dimension. This is because strings are translated to arrays of char, which requires adding an extra dimension. The size of the dimension is determined in a variety of ways and can be specified. It defaults to 64 and when read, the underlying string is either padded or truncated to that length.

Also note that the Facility attributes do not appear in the translation because they are neither global nor associated with a variable in the DDS.

Alternately, one can get the text of the DDS as a global attribute by using the client parameters mechanism . In this case, the parameter “show=dds” can be used, and the data retrieved using the following command

ncdump -h http://remotetest.unidata.ucar.edu/dts/test.01.dds#show=dds

The ncdump -h command will then show both the translation and the original DDS. In the above example, the DDS would appear as the global attribute “_DDS” as follows.

netcdf test {
...
variables:
:_DDS = "Dataset { Byte b; Int32 i32; UInt32 ui32; Int16 i16;
UInt16 ui16; Float32 f32; Float64 f64;
Strings; Url u; } SimpleTypes;"
byte b ;
...
}

Return to the Main Unidata NetCDF page.
Generated on Wed Aug 1 2018 05:36:48 for NetCDF. NetCDF is a Unidata library.