Scenario
Create a PDS4 label that describes the data in a CDF file.
Our CDF file contains a time series of data.
It has a magnetic field vector in HDZ coordinates and time stamp for each vector.
The magnetic field vector is stored as a 2D array with the dimension of 3 by 1440.
The time stamp is a 1D array with 1440 elements (one for each HDZ vector).
We want to create an PDS4 label that describes the data in the CDF file.
We will use the data file with the name thg_l2_mag_and_20121226_v01.cdf.
Our velocity template will be a PDS4 label with some information already filled in.
Information specific to the contents of the CDF file (data arrays, record count, file size, etc.) will be generated
using igpp.docgen. Our template looks like:
urn:nasa:pds:themis:fgm:$cdf.getAttributeValue('Logical_file_id')::v0$cdf.getAttributeValue('Data_version')
1.0
$cdf.getAttributeValue('Logical_source_description')
1.1.0.0
Product_Observational
Unknown
Unknown
Science
Magnetopshere
Calibrated
$cdf.getAttributeValue("Mission_group") $cdf.getAttributeValue("TITLE")
Observing Campaign
urn:nasa:pds:themis:fgm
data_to_investigation
THEMIS-A
Spacecraft
Earth
WhoKnows
$cdf.pathName
CDF Header
0
404
CDF 3.4 ISTP/IACG
#foreach ($variable in $cdf.variables)
#set($var_type = $variable.getAttributeValue("VAR_TYPE"))
#set($funct = $variable.getAttributeValue("FUNCT"))
#if( ! $funct.isEmpty() || $var_type.compareTo("metadata") == 0)
## Don't output functions or metadata
#else
#if($variable.getDimCount() == 1)
#if($variable.getDim(0) == 1)
#set($arrayTag="Array_1D")
#set($axis=1)
#else
#set($arrayTag="Array_2D")
#set($axis=2)
#{end}## dim()
#{end}## dimCount()
<$arrayTag>
$variable.getAttributeValue('FIELDNAM')
$variable.name
$variable.startByte
$axis
#foreach($a in [1..$axis])$a #end
$variable.getAttributeValue("CATDESC")
$variable.getAttributeValue("VAR_NOTES")
$cdf.getDataTypePDS($variable.dataType)
#foreach($a in [1..$axis])
#set($i = $a - 2) ## CDF indexing of dims does not include rows dimension and indexing starts at 0.
#if($a == 1)
Record
$variable.recordCount
#else
$variable.name
$variable.getDim($i)
#{end}## if $a == 1
$a
#{end}## foreach($a)
$arrayTag>
#{end}## If data or func
#{end}## foreach variable
We will store this in a file called pds4label.vm.
A CDF file contains attributes and variables. An attribute can contain descriptive information
which is transferred into the appropriate PDS4 element. A varaible can contain data or sets of metadata
In the template conditional statements (if/else) make sure that we only write the variables
in the CDF file which are designated as "data".
Running igpp.docgen with the command:
java -jar igpp-docgen.jar cdf:thg_l2_mag_and_20121226_v01.cdf testcase/cdf/pds4label.vm
Instructs igpp.docgen to parse the file "thg_l2_mag_and_20121226_v01.cdf" and place the results in a context
named "cdf". Since the extension on "thg_l2_mag_and_20121226_v01.cdf" is ".cdf" igpp.docgen will parse the
file a CDF file, creating arrays to contian the attribute and variable information in the file.
Running this command will generate an XML document that looks like:
urn:nasa:pds:themis:fgm:thg_l2_mag_and_20121226_v01::v01
1.0
Ground-based Vector Magnetic Field at Andenes, Norway, 1 minute time Resolution.
1.1.0.0
Product_Observational
Unknown
Unknown
Science
Magnetopshere
Calibrated
THEMIS
Observing Campaign
urn:nasa:pds:themis:fgm
data_to_investigation
THEMIS-A
Spacecraft
Earth
WhoKnows
thg_l2_mag_and_20121226_v01.cdf
CDF Header
0
404
CDF 3.4 ISTP/IACG
B in HDZ Components
thg_mag_and
20031
2
1 2
Magnetic field B in HDZ vector components
Rotated from geographic XYZ components using declination provided by TGU.
IEEE754MSBSingle
Record
1440
1
thg_mag_and
3
2
HDZ Component Number
thg_mag_and_compno
40541
2
1 2
HDZ Component Number
SignedMSB4
Record
1
1
thg_mag_and_compno
3
2
thg_mag_and_time
thg_mag_and_time
42468
1
1
thg_mag_and_time,.UTC, in seconds since 01-Jan-1970 00:00:00
Unleaped seconds
IEEE754MSBDouble
Record
1440
1
thg_mag_and_epoch0
thg_mag_and_epoch0
57492
1
1
EPOCH0 of THEMIS TIME BASE
EPOCH of 01-Jan-1970 00:00:00
IEEE754MSBDouble
Record
1
1
range_epoch
range_epoch
58508
1
1
range_epoch
IEEE754MSBDouble
Record
2
1