Scenario

Create a SPASE description of 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 SPASE description 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:

<?xml version="1.0" encoding="UTF-8"?> <Spase xmlns="http://www.spase-group.org/data/schema"> <Version>2.2.6</Version> <NumericalData> <ResourceID>spase://noaa/NumericalData/$cdf.getAttributeValue('Logical_file_id')</ResourceID> <ResourceHeader> <ResourceName>$cdf.getAttributeValue("TITLE")</ResourceName> <ReleaseDate>2016-12-08T08:40:00.000</ReleaseDate> <Description>$cdf.getAttributeValue('Logical_source_description') $cdf.getAttributeValue('TEXT')</Description> <Acknowledgement/> <!-- Insert contacts for P.I. and/or provider --> <Contact> <PersonID>spase://SMWG/Person/$cdf.getAttributeValue('PI_name')</PersonID> <Role>PrincipalInvestigator</Role> </Contact> <Contact> <PersonID>spase://SMWG/Person/Todd.A.King</PersonID> <Role>MetadataContact</Role> </Contact> <InformationURL> <Name>Product Description</Name> <URL><!-- Build out with attributes? --></URL> </InformationURL> </ResourceHeader> <AccessInformation> <RepositoryID>spase://SMWG/Repository/NSSDC</RepositoryID> <Availability>Online</Availability> <AccessRights>Open</AccessRights> <AccessURL> <URL><!-- Build out with attributes? --></URL> </AccessURL> <Format>CDF</Format> </AccessInformation> <ProcessingLevel>Calibrated</ProcessingLevel> <ProviderVersion>$cdf.getAttributeValue('Data_version')</ProviderVersion> <InstrumentID>spase://SMWG/Instrument/$cdf.getAttributeValue('Mission_group')/$cdf.getAttributeValue('Logical_source')<!-- Need to set --> </InstrumentID> <MeasurementType><!-- Need to set --></MeasurementType> <TemporalDescription> <TimeSpan> <StartDate><!-- Need to set --></StartDate> <StopDate><!-- Need to set --></StopDate> <Cadence><!-- Need to set --></Cadence> </TimeSpan> </TemporalDescription> <ObservedRegion><!-- Need to set --></ObservedRegion> <Caveats><!-- Need to set --></Caveats> #foreach ($variable in $cdf.variables) <Parameter> <Name>$variable.getAttributeValue('FIELDNAM')</Name> <Description>$variable.getAttributeValue('CATDESC') $variable.getAttributeValue('VAR_NOTES') $variable.getDataSample(0)</Description> <Units>$variable.getAttributeValue('UNITS')</Units> <ValidMin>$variable.getAttributeValue('VALIDMIN')</ValidMin> <ValidMax>$variable.getAttributeValue('VALIDMAX')</ValidMax> <FillValue>$variable.getAttributeValue('FILLVAL')</FillValue> #if( ! $variable.getAttributeValue('SCALEMIN').isEmpty() ) <RenderingHints> <ScaleMin>$variable.getAttributeValue('SCALEMIN')</ScaleMin> <ScaleMax>$variable.getAttributeValue('SCALEMAX')</ScaleMax> </RenderingHints> #end ## if() #if( $variable.getDimCount() == 1 ) <Structure> <Size>$variable.getDim(0)</Size> </Structure> #end ## if() #if( $variable.getDimCount() == 2 ) <Structure> <Size>$variable.getDim(0) $variable.getDim(1)</Size> </Structure> #end ## if() #set( $var_type = $variable.getAttributeValue("VAR_TYPE") ) #set( $funct = $variable.getAttributeValue("FUNCT") ) #if( ! $funct.isEmpty() || $var_type.compareTo("support_data") == 0) <Support> <Qualifier><!-- Need to set --></Qualifier> <SupportQuantity><!-- Need to set --></SupportQuantity> </Support> #end ## if() #if( ! $funct.isEmpty() || $var_type.compareTo("data") == 0) <Field> <Qualifier><!-- Need to set --></Qualifier> <FieldQuantity><!-- Need to set --></FieldQuantity> </Field> #end ## if </Parameter> #{end}## foreach variable </NumericalData> </Spase>

We will store this in a file called spase.vm.

A CDF file contains attributes and variables. An attribute can contain descriptive information which is transferred into the appropriate SPASE 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/spase.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:

<?xml version="1.0" encoding="UTF-8"?> <Spase xmlns="http://www.spase-group.org/data/schema"> <Version>2.2.6</Version> <NumericalData> <ResourceID>spase://VMO/NumericalData/thg_l2_mag_and_20121226_v01</ResourceID> <ResourceHeader> <ResourceName/> <ReleaseDate>2017-02-02T12:59:34.457Z</ReleaseDate> <Description>Ground-based Vector Magnetic Field at Andenes, Norway, 1 minute time Resolution. Part of the Tromso Geophysical Observatory ground magnetometer network</Description> <Acknowledgement/> <!-- Insert contacts for P.I. and/or provider --> <Contact> <PersonID>spase://SMWG/Person/Truls Lynne Hansen</PersonID> <Role>PrincipalInvestigator</Role> </Contact> <Contact> <PersonID>spase://SMWG/Person/Todd.A.King</PersonID> <Role>MetadataContact</Role> </Contact> <InformationURL> <Name>Product Description</Name> <URL><!-- Build out with attributes? --></URL> </InformationURL> </ResourceHeader> <AccessInformation> <RepositoryID>spase://SMWG/Repository/NSSDC</RepositoryID> <Availability>Online</Availability> <AccessRights>Open</AccessRights> <AccessURL> <URL><!-- Build out with attributes? --></URL> </AccessURL> <Format>CDF</Format> </AccessInformation> <ProcessingLevel>Calibrated</ProcessingLevel> <ProviderVersion>1</ProviderVersion> <InstrumentID>spase://SMWG/Instrument/THEMIS/thg_l2_mag_and<!-- Need to set --></InstrumentID> <MeasurementType><!-- Need to set --></MeasurementType> <TemporalDescription> <TimeSpan> <StartDate><!-- Need to set --></StartDate> <StopDate><!-- Need to set --></StopDate> <Cadence><!-- Need to set --></Cadence> </TimeSpan> </TemporalDescription> <ObservedRegion><!-- Need to set --></ObservedRegion> <Caveats><!-- Need to set --></Caveats> <Parameter> <Name>B in HDZ Components</Name> <Description>Magnetic field B in HDZ vector components</Description> <Units/> <ValidMin>-60000.0 6.7700764E25 3.711801E19</ValidMin> <ValidMax>60000.0 6.7700173E25 3.6973893E19</ValidMax> <FillValue>NaN</FillValue> <Structure> <Size>3</Size> </Structure> <Field> <Qualifier><!-- Need to set --></Qualifier> <FieldQuantity><!-- Need to set --></FieldQuantity> </Field> </Parameter> <Parameter> <Name>thg_mag_and_unit</Name> <Description>thg_mag_and_unit</Description> <Units/> <ValidMin/> <ValidMax/> <FillValue/> <Structure> <Size>3</Size> </Structure> </Parameter> <Parameter> <Name>thg_mag_and_labl</Name> <Description>thg_mag_and_labl</Description> <Units/> <ValidMin/> <ValidMax/> <FillValue/> <Structure> <Size>3</Size> </Structure> </Parameter> <Parameter> <Name>HDZ Component Number</Name> <Description>HDZ Component Number</Description> <Units/> <ValidMin>1 256 65536</ValidMin> <ValidMax>3 768 196608</ValidMax> <FillValue>-2147483648</FillValue> <Structure> <Size>3</Size> </Structure> <Support> <Qualifier><!-- Need to set --></Qualifier> <SupportQuantity><!-- Need to set --></SupportQuantity> </Support> </Parameter> <Parameter> <Name>thg_mag_and_time</Name> <Description>thg_mag_and_time,.UTC, in seconds since 01-Jan-1970 00:00:00</Description> <Units>sec</Units> <ValidMin>0.0</ValidMin> <ValidMax>5.0E9</ValidMax> <FillValue>NaN</FillValue> <Structure> <Size>1</Size> </Structure> <Support> <Qualifier><!-- Need to set --></Qualifier> <SupportQuantity><!-- Need to set --></SupportQuantity> </Support> </Parameter> <Parameter> <Name>thg_mag_and_Epoch</Name> <Description>thg_mag_and_Epoch</Description> <Units/> <ValidMin>6.31455264E13</ValidMin> <ValidMax>6.6301199999999E13</ValidMax> <FillValue>-1.0E31</FillValue> <Structure> <Size>1</Size> </Structure> <Support> <Qualifier><!-- Need to set --></Qualifier> <SupportQuantity><!-- Need to set --></SupportQuantity> </Support> <Field> <Qualifier><!-- Need to set --></Qualifier> <FieldQuantity><!-- Need to set --></FieldQuantity> </Field> </Parameter> <Parameter> <Name>thg_mag_and_epoch0</Name> <Description>EPOCH0 of THEMIS TIME BASE</Description> <Units>msec</Units> <ValidMin>5.99582304E13</ValidMin> <ValidMax>6.4060675199999E13</ValidMax> <FillValue>-1.0E31</FillValue> <Structure> <Size>1</Size> </Structure> <Support> <Qualifier><!-- Need to set --></Qualifier> <SupportQuantity><!-- Need to set --></SupportQuantity> </Support> </Parameter> <Parameter> <Name>range_epoch</Name> <Description>range_epoch</Description> <Units>msec</Units> <ValidMin>6.31455264E13</ValidMin> <ValidMax>6.6301199999999E13</ValidMax> <FillValue>-1.0E31</FillValue> <Structure> <Size>1</Size> </Structure> <Support> <Qualifier><!-- Need to set --></Qualifier> <SupportQuantity><!-- Need to set --></SupportQuantity> </Support> </Parameter> </NumericalData> </Spase>