/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by The HDF Group * * All rights reserved. * * * * This file is part of h5augjpss. The full h5augjpss copyright notice, * * including terms governing use, modification, and redistribution, is * * contained in the file COPYING, which can be found at the root of the * * source code distribution tree. If you do not have access to this * * file, you may request a copy from help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * This file contains definitions for the HDF5 data structures * used to store information extracted from the NPOESS XML product file */ #include "hdf5.h" #include #ifndef _H5AUGJPSS_H #define _H5AUGJPSS_H #define H5AJ_MAX_DIMS 4 #define H5AJ_MAX_DATUMS 8 /* * XML Dim Type type corresponds to an HDF5 dimension; attributes on a dimension * are the attributes on the corresponding HDF5 dataset that represents dimension. */ typedef struct { char *name; /* Dimension name; corresponds to the HDF5 dataset of native integer datatype and size maxidx. Note: According to the *.xsd file it may be optional, so we will need to use some generated name if it is missing */ int *bound; /* If not NULL, attribute "GranuleBoundary" of the native integer type with the values 1 or 0 is created */ int dynamic; /* Attribute "Dynamic" of the native integer type with the values 1 or 0 is created */ int minidx; /* Min index */ int maxidx; /* Max index; should be equal to minidx, because otherwise we don't know what we are doing, and what should be size of the dimension dataset :-) */ } H5aj_dim_t; /* * XML Fill Value type; mapped as a simple attribute with the name FillValue_; attribute's * datatype should be the same as of the corresponding dataset (the one to which Field is mapped to) */ typedef struct { char *name; /* JPSS-XML Fill value name; is used to construct HDF5 attribute name */ double value; /* This should be written to HDF5 using the proper type, i.e., XML parser will read into double type and the HDF5 writer will cast it to the proper type */ } H5aj_fillval_t; /* * XML Legend Entry type; mapped as a simple attribute with the name LegenEntry_; attribute's * datatype should be double according to an *.xsd file. */ typedef struct { char *name; /* JPSS-XML Legend Entry name; is used to construct an HDF5 attribute name of the native double type */ double value; /* Attribute's value */ } H5aj_legent_t; /* * XML Datum Type corresponds to a set of attributes on the HDF5 dataset. */ typedef struct { char *description; /* String scalar attribute with the name "Description */ int datumoffset; /* Integer simple attribute with the name "DatumOffset" */ int scaled; /* Integer simple attribute with the name "Scaled", values can be 1 or 0 only */ char *sf_name; /* If not NULL, then string scalar attribute wuth the name "ScaleFactorName" */ char *m_units; /* If not NULL, then string scalar attribute wuth the name "MeasurementUnits" */ float *rng_min; /* If not NULL, then native floating-point simple attribute wiht the name "RangeMin" */ float *rng_max; /* If not NULL, then native floating-point simple attribute wiht the name "RangeMax" */ char *data_type_string; /* NOT MAPPED; for verification purposes only and for Quality Flags description */ int n_fill_val; /* Number of the fill value attributes and the size of the NP_fillval_t arrat */ H5aj_fillval_t *fv; /* Dynamiccaly allocated array of fill value structures; see the structure for more info. If NULL, no attributes will be written */ int n_legent; /* Number of the legend entry attributes and the size of the NP_legent_t array */ H5aj_legent_t *le; /* Dynamically allocated array of the legend entry structures; see the structure for more info. If NULL, no attributes will be written */ } H5aj_datum_t; /* * XML DataSizeType type; used to verify correctness of the dataset's datatype */ typedef struct { int count; /* Number of bytes */ char *type; /* Should be a string that contains "byte" substring; if not we should raise an error */ } H5aj_data_size_t; /* * XML Field type corresponds to an HDF5 dataset found under the * /All_Data/... group in an NPOESS product file */ typedef struct { const char *name; /* Name; corresponds to the name of a dataset */ uint8_t n_dims; /* Number of dimensions */ /* Note: I think we should use it for validation purposes; if number of the dimensions found during parsing XML file is not equal to the corresponding dataset rank, we should raise an error - EIP 2011/1/20 */ H5aj_dim_t dims[H5AJ_MAX_DIMS]; /* Array to hold information about dimensions */ /* Note: I used static array for simplicity, since HDF5 supports not more than 32 dimensions, and NPOESS deals with 3D arrays at most; we ecould use pointer and allocate array on a fly, but I don't think it worth it - EIP 2011/1/20 */ int n_datum; /* Number of datum instances; needed to allocate datum structure */ H5aj_datum_t *datum; /* Information about raw data of the dataset; mapped to dataset's attributes */ H5aj_data_size_t ds; /* Structure to hold information about datatype size in bytes */ /* Note: I decided to go ahead and use XML DataSize info for validation purposes. Writer should check that dataset's datatype has the same type size - EIP 2011/1/20 */ } H5aj_field_t; /* * A Description for a ProductData */ typedef struct productData { char *dataName; int nFields; H5aj_field_t* fields[50]; } productData, *productDataPtr; /* * a Description for a ProductName/DataProduct */ typedef struct DataProduct { char *productName; char *collectionShortName; char *category; int nproductDatas; productDataPtr productDatas[3]; } H5ajpd, *H5ajpdPtr; H5ajpdPtr parseJPSSDataProductFile(const char *filename); #endif /* _H5AUGJPSS_H */