Ejemplo n.º 1
0
// Author & Date:   Ehsan Azar   Nov 13, 2012
// Purpose: Create type for BmiTrackingAttr_t and commit
// Inputs:
//  loc  - where to add the type
// Outputs:
//   Returns the type id
hid_t CreateTrackingAttrType(hid_t loc)
{
    herr_t ret;
    hid_t tid = -1;
    std::string strLink = "BmiTrackingAttr_t";
    // If already there return it
    if(H5Lexists(loc, strLink.c_str(), H5P_DEFAULT))
    {
        tid = H5Topen(loc, strLink.c_str(), H5P_DEFAULT);
        return tid;
    }
    hid_t tid_attr_label_str = H5Tcopy(H5T_C_S1);
    ret = H5Tset_size(tid_attr_label_str, 128);

    tid = H5Tcreate(H5T_COMPOUND, sizeof(BmiTrackingAttr_t));
    ret = H5Tinsert(tid, "Label", offsetof(BmiTrackingAttr_t, szLabel), tid_attr_label_str);
    ret = H5Tinsert(tid, "Type", offsetof(BmiTrackingAttr_t, type), H5T_NATIVE_UINT16);
    ret = H5Tinsert(tid, "TrackID", offsetof(BmiTrackingAttr_t, trackID), H5T_NATIVE_UINT16);
    ret = H5Tinsert(tid, "MaxPoints", offsetof(BmiTrackingAttr_t, maxPoints), H5T_NATIVE_UINT16);

    ret = H5Tcommit(loc, strLink.c_str(), tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);

    H5Tclose(tid_attr_label_str);
    return tid;
}
Ejemplo n.º 2
0
// Author & Date:   Ehsan Azar   Nov 13, 2012
// Purpose: Create type for BmiChanExt2Attr_t and commit
// Inputs:
//  loc  - where to add the type
// Outputs:
//   Returns the type id
hid_t CreateChanExt2AttrType(hid_t loc)
{
    herr_t ret;
    hid_t tid = -1;
    std::string strLink = "BmiChanExt2Attr_t";
    // If already there return it
    if(H5Lexists(loc, strLink.c_str(), H5P_DEFAULT))
    {
        tid = H5Topen(loc, strLink.c_str(), H5P_DEFAULT);
        return tid;
    }
    hid_t tid_attr_unit_str = H5Tcopy(H5T_C_S1);
    ret = H5Tset_size(tid_attr_unit_str, 16);

    tid = H5Tcreate(H5T_COMPOUND, sizeof(BmiChanExt2Attr_t));
    ret = H5Tinsert(tid, "DigitalMin", offsetof(BmiChanExt2Attr_t, digmin), H5T_NATIVE_INT32);
    ret = H5Tinsert(tid, "DigitalMax", offsetof(BmiChanExt2Attr_t, digmax), H5T_NATIVE_INT32);
    ret = H5Tinsert(tid, "AnalogMin", offsetof(BmiChanExt2Attr_t, anamin), H5T_NATIVE_INT32);
    ret = H5Tinsert(tid, "AnalogMax", offsetof(BmiChanExt2Attr_t, anamax), H5T_NATIVE_INT32);
    ret = H5Tinsert(tid, "AnalogUnit", offsetof(BmiChanExt2Attr_t, anaunit), tid_attr_unit_str);

    ret = H5Tcommit(loc, strLink.c_str(), tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);

    H5Tclose(tid_attr_unit_str);

    return tid;
}
Ejemplo n.º 3
0
// Author & Date:   Ehsan Azar   Nov 13, 2012
// Purpose: Create type for BmiSpike16_t and commit
//          Note: For performance reasons and because spike length is constant during
//           and experiment we use fixed-length array here instead of varible-length
// Inputs:
//  loc         - where to add the type
//  spikeLength - the spike length to use
// Outputs:
//   Returns the type id
hid_t CreateSpike16Type(hid_t loc, UINT16 spikeLength)
{
    herr_t ret;
    hid_t tid = -1;

    // e.g. for spike length of 48 type name will be "BmiSpike16_48_t"
    char szNum[4] = {'\0'};
    sprintf(szNum, "%u", spikeLength);
    std::string strLink = "BmiSpike16_";
    strLink += szNum;
    strLink += "_t";
    // If already there return it
    if(H5Lexists(loc, strLink.c_str(), H5P_DEFAULT))
    {
        tid = H5Topen(loc, strLink.c_str(), H5P_DEFAULT);
        return tid;
    }

    hsize_t     dims[1] = {spikeLength};
    hid_t tid_arr_wave = H5Tarray_create(H5T_NATIVE_INT16, 1, dims);

    tid = H5Tcreate(H5T_COMPOUND, offsetof(BmiSpike16_t, wave) + sizeof(INT16) * spikeLength);
    ret = H5Tinsert(tid, "TimeStamp", offsetof(BmiSpike16_t, dwTimestamp), H5T_NATIVE_UINT32);
    ret = H5Tinsert(tid, "Unit", offsetof(BmiSpike16_t, unit), H5T_NATIVE_UINT8);
    ret = H5Tinsert(tid, "Wave", offsetof(BmiSpike16_t, wave), tid_arr_wave);
    ret = H5Tcommit(loc, strLink.c_str(), tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);

    H5Tclose(tid_arr_wave);
    return tid;
}
Ejemplo n.º 4
0
// Author & Date:   Ehsan Azar   Nov 13, 2012
// Purpose: Create type for BmiRootAttr_t and commit
// Inputs:
//  loc  - where to add the type
// Outputs:
//   Returns the type id
hid_t CreateRootAttrType(hid_t loc)
{
    herr_t ret;
    hid_t tid = -1;
    std::string strLink = "BmiRootAttr_t";
    // If already there return it
    if(H5Lexists(loc, strLink.c_str(), H5P_DEFAULT))
    {
        tid = H5Topen(loc, strLink.c_str(), H5P_DEFAULT);
        return tid;
    }
    hid_t tid_attr_str = H5Tcopy(H5T_C_S1);
    ret = H5Tset_size(tid_attr_str, 64);
    hid_t tid_attr_comment_str = H5Tcopy(H5T_C_S1);
    ret = H5Tset_size(tid_attr_comment_str, 1024);

    tid = H5Tcreate(H5T_COMPOUND, sizeof(BmiRootAttr_t));
    ret = H5Tinsert(tid, "MajorVersion", offsetof(BmiRootAttr_t, nMajorVersion), H5T_NATIVE_UINT32);
    ret = H5Tinsert(tid, "MinorVersion", offsetof(BmiRootAttr_t, nMinorVersion), H5T_NATIVE_UINT32);
    ret = H5Tinsert(tid, "Flags", offsetof(BmiRootAttr_t, nFlags), H5T_NATIVE_UINT32);
    ret = H5Tinsert(tid, "GroupCount", offsetof(BmiRootAttr_t, nGroupCount), H5T_NATIVE_UINT32);
    ret = H5Tinsert(tid, "Date", offsetof(BmiRootAttr_t, szDate), tid_attr_str); // date of the file creation
    ret = H5Tinsert(tid, "Application", offsetof(BmiRootAttr_t, szApplication), tid_attr_str); // application that created the file
    ret = H5Tinsert(tid, "Comment", offsetof(BmiRootAttr_t, szComment), tid_attr_comment_str); // file comments

    ret = H5Tcommit(loc, strLink.c_str(), tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);

    H5Tclose(tid_attr_str);
    H5Tclose(tid_attr_comment_str);
    return tid;
}
Ejemplo n.º 5
0
int main(){
  hid_t fprop;
  hid_t fid;
  hid_t vol_id = H5VL_memvol_init();
  char name[1024];

  // create some datatypes

  hid_t tid = H5Tcreate (H5T_COMPOUND, sizeof(complex_type));
  H5Tinsert(tid, "re", HOFFSET(complex_type,re), H5T_NATIVE_DOUBLE);
  H5Tinsert(tid, "im", HOFFSET(complex_type,im), H5T_NATIVE_DOUBLE);
  hid_t s10 = H5Tcopy(H5T_C_S1);
  H5Tset_size(s10, 10);
  H5Tinsert(tid, "name", HOFFSET(complex_type,name), s10);
  H5Tinsert(tid, "val", HOFFSET(complex_type,val), H5T_NATIVE_INT);

  // packed version of the datatype
  hid_t disk_tid = H5Tcopy (tid);
  H5Tpack(disk_tid);

  fprop = H5Pcreate(H5P_FILE_ACCESS);
  H5Pset_vol(fprop, vol_id, &fprop);

  fid = H5Fcreate("test", H5F_ACC_TRUNC, H5P_DEFAULT, fprop);
  H5VLget_plugin_name(fid, name, 1024);
  printf ("%s using VOL %s\n", __FILE__ , name);

  assert(H5Tcommit(fid, "t_complex", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) >= 0);
  assert(H5Tcommit(fid, "t_complex_p", disk_tid,  H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) >= 0);

  hid_t tid_stored1 = H5Topen(fid, "t_complex", H5P_DEFAULT);
  hid_t tid_stored2 = H5Topen(fid, "t_complex_p", H5P_DEFAULT);
  // hid_t tid_stored3 = H5Topen(fid, "NotExisting", H5P_DEFAULT);
  // assert(tid_stored3 < 0);

  assert(H5Tequal(tid_stored1, tid));
  assert(H5Tequal(tid_stored2, disk_tid));

  H5Fclose(fid);

  H5Tclose(tid);
  H5Tclose(disk_tid);

  H5VL_memvol_finalize();

  return 0;
}
Ejemplo n.º 6
0
void SCIA_WR_H5_LADS( struct param_record param, unsigned int nr_lads,
		      const struct lads_scia *lads )
     /*@globals lads_size, lads_offs@*/
{
     hid_t   ads_id;
     hsize_t adim;
     hid_t   lads_type[NFIELDS];
     hid_t   type_id, temp_type00, temp_type01;

     const hbool_t compress = (param.flag_deflate == PARAM_SET) ? TRUE : FALSE;
     const char *lads_names[NFIELDS] = {
	  "dsr_time", "attach_flag", "corner_grd"
     };
/*
 * check number of LADS records
 */
     if ( nr_lads == 0 ) return;
/*
 * create/open group /ADS
 */
     ads_id = NADC_OPEN_HDF5_Group( param.hdf_file_id, "/ADS" );
     if ( ads_id < 0 ) NADC_RETURN_ERROR( NADC_ERR_HDF_GRP, "/ADS" );
/*
 * define user-defined data types of the Table-fields
 */
     temp_type00 = H5Topen( param.hdf_file_id, "mjd", H5P_DEFAULT );
     adim = NUM_CORNERS;
     type_id = H5Topen( param.hdf_file_id, "coord", H5P_DEFAULT );
     temp_type01 = H5Tarray_create( type_id, 1, &adim );

     lads_type[0] = temp_type00;
     lads_type[1] = H5T_NATIVE_UCHAR;
     lads_type[2] = temp_type01;
/*
 * create table
 */
     (void) H5TBmake_table( "lads", ads_id, TBL_NAME, NFIELDS,
			    nr_lads, lads_size, lads_names, lads_offs,
			    lads_type, nr_lads, NULL, compress, lads );
/*
 * close interface
 */
     (void) H5Tclose( type_id );
     (void) H5Tclose( temp_type00 );
     (void) H5Tclose( temp_type01 );
     (void) H5Gclose( ads_id );
}
Ejemplo n.º 7
0
// Author & Date:   Ehsan Azar   Nov 23, 2012
// Purpose: Create type for BmiDig16_t and commit
// Inputs:
//  loc         - where to add the type
// Outputs:
//   Returns the type id
hid_t CreateDig16Type(hid_t loc)
{
    herr_t ret;
    hid_t tid = -1;
    std::string strLink = "BmiDig16_t";
    // If already there return it
    if(H5Lexists(loc, strLink.c_str(), H5P_DEFAULT))
    {
        tid = H5Topen(loc, strLink.c_str(), H5P_DEFAULT);
        return tid;
    }

    tid = H5Tcreate(H5T_COMPOUND, sizeof(BmiDig16_t));
    ret = H5Tinsert(tid, "TimeStamp", offsetof(BmiDig16_t, dwTimestamp), H5T_NATIVE_UINT32);
    ret = H5Tinsert(tid, "Value", offsetof(BmiDig16_t, value), H5T_NATIVE_UINT16);
    ret = H5Tcommit(loc, strLink.c_str(), tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);

    return tid;
}
Ejemplo n.º 8
0
// Author & Date:   Ehsan Azar   Nov 13, 2012
// Purpose: Create type for BmiSamplingAttr_t and commit
// Inputs:
//  loc  - where to add the type
// Outputs:
//   Returns the type id
hid_t CreateSamplingAttrType(hid_t loc)
{
    herr_t ret;
    hid_t tid = -1;
    std::string strLink = "BmiSamplingAttr_t";
    // If already there return it
    if(H5Lexists(loc, strLink.c_str(), H5P_DEFAULT))
    {
        tid = H5Topen(loc, strLink.c_str(), H5P_DEFAULT);
        return tid;
    }
    tid = H5Tcreate(H5T_COMPOUND, sizeof(BmiSamplingAttr_t));
    ret = H5Tinsert(tid, "Clock", offsetof(BmiSamplingAttr_t, fClock), H5T_NATIVE_FLOAT);
    ret = H5Tinsert(tid, "SampleRate", offsetof(BmiSamplingAttr_t, fSampleRate), H5T_NATIVE_FLOAT);
    ret = H5Tinsert(tid, "SampleBits", offsetof(BmiSamplingAttr_t, nSampleBits), H5T_NATIVE_UINT8);

    ret = H5Tcommit(loc, strLink.c_str(), tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);

    return tid;
}
Ejemplo n.º 9
0
// Author & Date:   Ehsan Azar   Nov 13, 2012
// Purpose: Create type for BmiChanExt1Attr_t and commit
// Inputs:
//  loc  - where to add the type
// Outputs:
//   Returns the type id
hid_t CreateChanExt1AttrType(hid_t loc)
{
    herr_t ret;
    hid_t tid = -1;
    std::string strLink = "BmiChanExt1Attr_t";
    // If already there return it
    if(H5Lexists(loc, strLink.c_str(), H5P_DEFAULT))
    {
        tid = H5Topen(loc, strLink.c_str(), H5P_DEFAULT);
        return tid;
    }
    tid = H5Tcreate(H5T_COMPOUND, sizeof(BmiChanExt1Attr_t));
    ret = H5Tinsert(tid, "SortCount", offsetof(BmiChanExt1Attr_t, sortCount), H5T_NATIVE_UINT8);
    ret = H5Tinsert(tid, "EnergyThreshold", offsetof(BmiChanExt1Attr_t, energy_thresh), H5T_NATIVE_UINT32);
    ret = H5Tinsert(tid, "HighThreshold", offsetof(BmiChanExt1Attr_t, high_thresh), H5T_NATIVE_INT32);
    ret = H5Tinsert(tid, "LowThreshold", offsetof(BmiChanExt1Attr_t, low_thresh), H5T_NATIVE_INT32);

    ret = H5Tcommit(loc, strLink.c_str(), tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);

    return tid;
}
Ejemplo n.º 10
0
// Author & Date:   Ehsan Azar   Nov 13, 2012
// Purpose: Create type for BmiChanExtAttr_t and commit
// Inputs:
//  loc  - where to add the type
// Outputs:
//   Returns the type id
hid_t CreateChanExtAttrType(hid_t loc)
{
    herr_t ret;
    hid_t tid = -1;
    std::string strLink = "BmiChanExtAttr_t";
    // If already there return it
    if(H5Lexists(loc, strLink.c_str(), H5P_DEFAULT))
    {
        tid = H5Topen(loc, strLink.c_str(), H5P_DEFAULT);
        return tid;
    }

    tid = H5Tcreate(H5T_COMPOUND, sizeof(BmiChanExtAttr_t));
    ret = H5Tinsert(tid, "NanoVoltsPerLSB", offsetof(BmiChanExtAttr_t, dFactor), H5T_NATIVE_DOUBLE);
    ret = H5Tinsert(tid, "PhysicalConnector", offsetof(BmiChanExtAttr_t, phys_connector), H5T_NATIVE_UINT8);
    ret = H5Tinsert(tid, "ConnectorPin", offsetof(BmiChanExtAttr_t, connector_pin), H5T_NATIVE_UINT8);

    ret = H5Tcommit(loc, strLink.c_str(), tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);

    return tid;
}
Ejemplo n.º 11
0
// Author & Date:   Ehsan Azar   Nov 13, 2012
// Purpose: Create type for BmiFiltAttr_t and commit
// Inputs:
//  loc  - where to add the type
// Outputs:
//   Returns the type id
hid_t CreateFiltAttrType(hid_t loc)
{
    herr_t ret;
    hid_t tid = -1;
    std::string strLink = "BmiFiltAttr_t";
    // If already there return it
    if(H5Lexists(loc, strLink.c_str(), H5P_DEFAULT))
    {
        tid = H5Topen(loc, strLink.c_str(), H5P_DEFAULT);
        return tid;
    }
    tid = H5Tcreate(H5T_COMPOUND, sizeof(BmiFiltAttr_t));
    ret = H5Tinsert(tid, "HighPassFreq", offsetof(BmiFiltAttr_t, hpfreq), H5T_NATIVE_UINT32);
    ret = H5Tinsert(tid, "HighPassOrder", offsetof(BmiFiltAttr_t, hporder), H5T_NATIVE_UINT32);
    ret = H5Tinsert(tid, "HighPassType", offsetof(BmiFiltAttr_t, hptype), H5T_NATIVE_UINT16);
    ret = H5Tinsert(tid, "LowPassFreq", offsetof(BmiFiltAttr_t, lpfreq), H5T_NATIVE_UINT32);
    ret = H5Tinsert(tid, "LowPassOrder", offsetof(BmiFiltAttr_t, lporder), H5T_NATIVE_UINT32);
    ret = H5Tinsert(tid, "LowPassType", offsetof(BmiFiltAttr_t, lptype), H5T_NATIVE_UINT16);

    ret = H5Tcommit(loc, strLink.c_str(), tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);

    return tid;
}
Ejemplo n.º 12
0
// Author & Date:   Ehsan Azar   Nov 17, 2012
// Purpose: Create type for BmiSynchAttr_t and commit
// Inputs:
//  loc  - where to add the type
// Outputs:
//   Returns the type id
hid_t CreateSynchAttrType(hid_t loc)
{
    herr_t ret;
    hid_t tid = -1;
    std::string strLink = "BmiSynchAttr_t";
    // If already there return it
    if(H5Lexists(loc, strLink.c_str(), H5P_DEFAULT))
    {
        tid = H5Topen(loc, strLink.c_str(), H5P_DEFAULT);
        return tid;
    }
    hid_t tid_attr_label_str = H5Tcopy(H5T_C_S1);
    ret = H5Tset_size(tid_attr_label_str, 64);

    tid = H5Tcreate(H5T_COMPOUND, sizeof(BmiSynchAttr_t));
    ret = H5Tinsert(tid, "ID", offsetof(BmiSynchAttr_t, id), H5T_NATIVE_UINT16);
    ret = H5Tinsert(tid, "Label", offsetof(BmiSynchAttr_t, szLabel), tid_attr_label_str);
    ret = H5Tinsert(tid, "FPS", offsetof(BmiSynchAttr_t, fFps), H5T_NATIVE_FLOAT);

    ret = H5Tcommit(loc, strLink.c_str(), tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);

    H5Tclose(tid_attr_label_str);
    return tid;
}
Ejemplo n.º 13
0
// Author & Date:   Ehsan Azar   Nov 20, 2012
// Purpose: Create type for BmiTracking_t and commit
// Inputs:
//  loc    - where to add the type
//  dim    - dimension (1D, 2D or 3D)
//  width  - datapoint width in bytes
// Outputs:
//   Returns the type id
hid_t CreateTrackingType(hid_t loc, int dim, int width)
{
    herr_t ret;
    hid_t tid_coords;
    std::string strLabel = "BmiTracking";
    // e.g. for 1D (32-bit) fixed-length, type name will be "BmiTracking32_1D_t"
    //      for 2D (16-bit) fixed-length, type name will be "BmiTracking16_2D_t"

    switch (width)
    {
    case 1:
        strLabel += "8";
        tid_coords = H5Tcopy(H5T_NATIVE_UINT8);
        break;
    case 2:
        strLabel += "16";
        tid_coords = H5Tcopy(H5T_NATIVE_UINT16);
        break;
    case 4:
        strLabel += "32";
        tid_coords = H5Tcopy(H5T_NATIVE_UINT32);
        break;
    default:
        return 0;
        // should not happen
        break;
    }
    switch (dim)
    {
    case 1:
        strLabel += "_1D";
        break;
    case 2:
        strLabel += "_2D";
        break;
    case 3:
        strLabel += "_3D";
        break;
    default:
        return 0;
        // should not happen
        break;
    }
    strLabel += "_t";

    hid_t tid = -1;
    if(H5Lexists(loc, strLabel.c_str(), H5P_DEFAULT))
    {
        tid = H5Topen(loc, strLabel.c_str(), H5P_DEFAULT);
    } else {
        tid = H5Tcreate(H5T_COMPOUND, offsetof(BmiTracking_fl_t, coords) + dim * width * 1);
        ret = H5Tinsert(tid, "TimeStamp", offsetof(BmiTracking_fl_t, dwTimestamp), H5T_NATIVE_UINT32);
        ret = H5Tinsert(tid, "ParentID", offsetof(BmiTracking_fl_t, parentID), H5T_NATIVE_UINT16);
        ret = H5Tinsert(tid, "NodeCount", offsetof(BmiTracking_fl_t, nodeCount), H5T_NATIVE_UINT16);
        ret = H5Tinsert(tid, "ElapsedTime", offsetof(BmiTracking_fl_t, etime), H5T_NATIVE_UINT32);
        char corrd_labels[3][2] = {"x", "y", "z"};
        for (int i = 0; i < dim; ++i)
            ret = H5Tinsert(tid, corrd_labels[i], offsetof(BmiTracking_fl_t, coords) + i * width, tid_coords);
        ret = H5Tcommit(loc, strLabel.c_str(), tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
    }

    H5Tclose(tid_coords);

    return tid;
}
Ejemplo n.º 14
0
/*+++++++++++++++++++++++++ Main Program or Function +++++++++++++++*/
void SCIA_LV1_WR_H5_SRSN( struct param_record param, unsigned int nr_srsn,
			  const struct srsn_scia *srsn )
{
     hid_t   ads_id;
     hsize_t adim;
     herr_t  stat;

     hid_t   srsn_type[NFIELDS];

     const hbool_t compress = (param.flag_deflate == PARAM_SET) ? TRUE : FALSE;
     const size_t srsn_size = sizeof( struct srsn_scia );
     const char *srsn_names[NFIELDS] = { 
	  "mjd", "flag_mds", "flag_neu", "sun_spec_id", "avg_asm", "avg_esm", 
	  "avg_elev_sun", "dopp_shift", "wvlen_sun", "mean_sun", 
	  "precision_sun", "accuracy_sun", "etalon", "pmd_mean", "pmd_out"
     };
     const size_t srsn_offs[NFIELDS] = {
	  HOFFSET( struct srsn_scia, mjd ),
	  HOFFSET( struct srsn_scia, flag_mds ),
	  HOFFSET( struct srsn_scia, flag_neu ),
	  HOFFSET( struct srsn_scia, sun_spec_id ),
	  HOFFSET( struct srsn_scia, avg_asm ),
	  HOFFSET( struct srsn_scia, avg_esm ),
	  HOFFSET( struct srsn_scia, avg_elev_sun ),
	  HOFFSET( struct srsn_scia, dopp_shift ),
	  HOFFSET( struct srsn_scia, wvlen_sun ),
	  HOFFSET( struct srsn_scia, mean_sun ),
	  HOFFSET( struct srsn_scia, precision_sun ),
	  HOFFSET( struct srsn_scia, accuracy_sun ),
	  HOFFSET( struct srsn_scia, etalon ),
	  HOFFSET( struct srsn_scia, pmd_mean ),
	  HOFFSET( struct srsn_scia, pmd_out )
     };
/*
 * check number of PMD records
 */
     if ( nr_srsn == 0 ) return;
/*
 * open/create group /ADS
 */
     ads_id = NADC_OPEN_HDF5_Group( param.hdf_file_id, "/ADS" );
     if ( ads_id < 0 ) NADC_RETURN_ERROR( NADC_ERR_HDF_GRP, "/ADS" );
/*
 * write SRSN data sets
 */
     adim = SCIENCE_PIXELS;
     srsn_type[0] = H5Topen( param.hdf_file_id, "mjd", H5P_DEFAULT );
     srsn_type[1] = H5Tcopy( H5T_NATIVE_UCHAR );
     srsn_type[2] = H5Tcopy( H5T_NATIVE_UCHAR );
     srsn_type[3] = H5Tcopy( H5T_C_S1 );
     (void) H5Tset_size( srsn_type[3], (size_t) 3 );
     srsn_type[4] = H5Tcopy( H5T_NATIVE_FLOAT );
     srsn_type[5] = H5Tcopy( H5T_NATIVE_FLOAT );
     srsn_type[6] = H5Tcopy( H5T_NATIVE_FLOAT );
     srsn_type[7] = H5Tcopy( H5T_NATIVE_FLOAT );
     adim = SCIENCE_PIXELS;
     srsn_type[8] = H5Tarray_create( H5T_NATIVE_FLOAT, 1, &adim );
     srsn_type[9] = H5Tarray_create( H5T_NATIVE_FLOAT, 1, &adim );
     srsn_type[10] = H5Tarray_create( H5T_NATIVE_FLOAT, 1, &adim );
     srsn_type[11] = H5Tarray_create( H5T_NATIVE_FLOAT, 1, &adim );
     srsn_type[12] = H5Tarray_create( H5T_NATIVE_FLOAT, 1, &adim );
     adim = PMD_NUMBER;
     srsn_type[13] = H5Tarray_create( H5T_NATIVE_FLOAT, 1, &adim );
     srsn_type[14] = H5Tarray_create( H5T_NATIVE_FLOAT, 1, &adim );

     stat = H5TBmake_table( "srsn", ads_id, "NEW_SUN_REFERENCE", 
                            NFIELDS, 1, srsn_size, srsn_names,
                            srsn_offs, srsn_type, 1,
                            NULL, compress, srsn );
     if ( stat < 0 ) NADC_GOTO_ERROR( NADC_ERR_HDF_DATA, "srsn" );
/*
 * close interface
 */
 done:
     (void) H5Tclose( srsn_type[0] );
     (void) H5Tclose( srsn_type[1] );
     (void) H5Tclose( srsn_type[2] );
     (void) H5Tclose( srsn_type[3] );
     (void) H5Tclose( srsn_type[4] );
     (void) H5Tclose( srsn_type[5] );
     (void) H5Tclose( srsn_type[6] );
     (void) H5Tclose( srsn_type[7] );
     (void) H5Tclose( srsn_type[8] );
     (void) H5Tclose( srsn_type[9] );
     (void) H5Tclose( srsn_type[10] );
     (void) H5Tclose( srsn_type[11] );
     (void) H5Tclose( srsn_type[12] );
     (void) H5Tclose( srsn_type[13] );
     (void) H5Tclose( srsn_type[14] );
     (void) H5Gclose( ads_id );
}
Ejemplo n.º 15
0
/*+++++++++++++++++++++++++ Main Program or Function +++++++++++++++*/
void GOME_LV1_WR_H5_PCD( struct param_record param, short nr_pcd, 
			 const short *indx_pcd, const struct pcd_gome *pcd )
{
     register hsize_t ni, nr, nx, ny;

     unsigned short *usbuff;
     short          *sbuff;
     float          *rbuff;

     hid_t    type_id;
     hid_t    grp_id;
     hbool_t  compress;
     hsize_t  nrpix, dims[2];

     struct   glr1_gome *glr;
     struct   cr1_gome  *cld;
/*
 * check number of PCD records
 */
     if ( nr_pcd == 0 || indx_pcd == NULL || pcd == NULL ) return;
/*
 * set HDF5 boolean variable for compression
 */
     if ( param.flag_deflate == PARAM_SET )
          compress = TRUE;
     else
          compress = FALSE;
/*
 * open or create group Earth
 */
     grp_id = NADC_OPEN_HDF5_Group( param.hdf_file_id, "/EARTH" );
     if ( grp_id < 0 ) NADC_RETURN_ERROR( NADC_ERR_HDF_GRP, "/EARTH" );
     (void) H5Gclose( grp_id );
/*
 * create group /EARTH/PCD
 */
     grp_id = H5Gcreate( param.hdf_file_id, "/EARTH/PCD", 
			 H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT );
     if ( grp_id < 0 ) 
	  NADC_RETURN_ERROR( NADC_ERR_HDF_GRP, "/EARTH/PCD" );
/*
 * +++++ create datasets in the /EARTH/PCD group
 */
     dims[0] = (size_t) nr_pcd;
/*
 * Write geolocation information
 */
     type_id = H5Topen( param.hdf_file_id, "glr", H5P_DEFAULT );
     glr = (struct glr1_gome *)
	  malloc( dims[0] * sizeof( struct glr1_gome ));
     if ( glr == NULL ) NADC_RETURN_ERROR( NADC_ERR_ALLOC, "glr" );
     for ( nr = 0; nr < dims[0]; nr++ )
	  (void) memcpy( glr+nr, &pcd[nr].glr, sizeof( struct glr1_gome ) );
     NADC_WR_HDF5_Dataset( compress, grp_id, "glr", 
			  type_id, 1, dims, glr );
     free( glr );
     (void) H5Tclose( type_id );
     if ( IS_ERR_STAT_FATAL )
	  NADC_RETURN_ERROR( NADC_ERR_HDF_WR, "glr" );
/*
 * Write geolocation information
 */
     type_id = H5Topen( param.hdf_file_id, "cld", H5P_DEFAULT );
     cld = (struct cr1_gome *)
	  malloc( dims[0] * sizeof( struct cr1_gome ));
     if ( cld == NULL ) NADC_RETURN_ERROR( NADC_ERR_ALLOC, "cld" );
     for ( nr = 0; nr < dims[0]; nr++ )
	  (void) memcpy( cld+nr, &pcd[nr].cld, sizeof( struct cr1_gome ) );
     NADC_WR_HDF5_Dataset( compress, grp_id, "cld", 
			   type_id, 1, dims, cld );
     free( cld );
     (void) H5Tclose( type_id );
     if ( IS_ERR_STAT_FATAL )
	  NADC_RETURN_ERROR( NADC_ERR_HDF_WR, "cld" );
/*
 * Dark current and Noise Correction Factor
 */
     rbuff = (float *) malloc( dims[0] * sizeof( float ));
     if ( rbuff == NULL ) NADC_RETURN_ERROR( NADC_ERR_ALLOC, "rbuff" );
     for ( ny = 0; ny < dims[0]; ny++ )
	  rbuff[ny] = pcd[indx_pcd[ny]].dark_current;
     NADC_WR_HDF5_Dataset( compress, grp_id, "DarkCurrent", 
			  H5T_NATIVE_FLOAT, 1, dims, rbuff );
     for ( ny = 0; ny < dims[0]; ny++ )
	  rbuff[ny] = pcd[indx_pcd[ny]].noise_factor;
     NADC_WR_HDF5_Dataset( compress, grp_id, "NoiseCorrection", 
			  H5T_NATIVE_FLOAT, 1, dims, rbuff );
/*
 * Plane of the Polarisation
 */
     for ( ny = 0; ny < dims[0]; ny++ )
	  rbuff[ny] = pcd[indx_pcd[ny]].polar.chi;
     NADC_WR_HDF5_Dataset( compress, grp_id, "PolarisationPlaneAngle",
			  H5T_NATIVE_FLOAT, 1, dims, rbuff );
     free( rbuff );
/*
 * Indices
 */
     sbuff = (short *) malloc( dims[0] * sizeof( short ));
     if ( sbuff == NULL ) NADC_RETURN_ERROR( NADC_ERR_ALLOC, "sbuff" );
     for ( ny = 0; ny < dims[0]; ny++ )
	  sbuff[ny] = pcd[indx_pcd[ny]].indx_spec;
     NADC_WR_HDF5_Dataset( compress, grp_id, "SpectralCalibrationIndex",
			  H5T_NATIVE_SHORT, 1, dims, sbuff );

     for ( ny = 0; ny < dims[0]; ny++ )
	  sbuff[ny] = pcd[indx_pcd[ny]].indx_leak;
     NADC_WR_HDF5_Dataset( compress, grp_id, "LeakageCorrectionIndex",
			  H5T_NATIVE_SHORT, 1, dims, sbuff );
     free( sbuff );
/*
 * Polarisation parameters
 */
     dims[0] = nr_pcd; dims[1] = NUM_POLAR_COEFFS;
     nrpix = dims[0] * dims[1];
     rbuff = (float *) malloc( nrpix * sizeof( float ));
     if ( rbuff == NULL ) NADC_RETURN_ERROR( NADC_ERR_ALLOC, "rbuff" );
     for ( nr = ny = 0; ny < dims[0]; ny++ )
	  for ( nx = 0; nx < dims[1]; nx++ )
	       rbuff[nr++] = pcd[indx_pcd[ny]].polar.wv[nx];
     NADC_WR_HDF5_Dataset( compress, grp_id, "PolarisationWavelength",
			  H5T_NATIVE_FLOAT, 2, dims, rbuff );
     for ( nr = ny = 0; ny < dims[0]; ny++ )
	  for ( nx = 0; nx < dims[1]; nx++ )
	       rbuff[nr++] = pcd[indx_pcd[ny]].polar.coeff[nx];
     NADC_WR_HDF5_Dataset( compress, grp_id, "PolarisationCoefficient",
			  H5T_NATIVE_FLOAT, 2, dims, rbuff );

     for ( nr = ny = 0; ny < dims[0]; ny++ )
	  for ( nx = 0; nx < dims[1]; nx++ )
	       rbuff[nr++] = pcd[indx_pcd[ny]].polar.error[nx];
     NADC_WR_HDF5_Dataset( compress, grp_id, "PolarisationError",
			  H5T_NATIVE_FLOAT, 2, dims, rbuff );
     free( rbuff );
/*
 * ------------------------- Instrument Header Structure
 * Sub set counter
 */
     usbuff = (unsigned short *) malloc( dims[0] * sizeof( short ));
     if ( usbuff == NULL ) 
	  NADC_RETURN_ERROR( NADC_ERR_ALLOC, "usbuff" );
     for ( ny = 0; ny < dims[0]; ny++ )
	  usbuff[ny] = pcd[indx_pcd[ny]].ihr.subsetcounter;
     NADC_WR_HDF5_Dataset( compress, grp_id, "SubSetCounter",
			  H5T_NATIVE_USHORT, 1, dims, usbuff );
/*
 * Average Mode
 */
     for ( ny = 0; ny < dims[0]; ny++ )
	  usbuff[ny] = pcd[indx_pcd[ny]].ihr.averagemode;
     NADC_WR_HDF5_Dataset( compress, grp_id, "AverageMode",
			  H5T_NATIVE_USHORT, 1, dims, usbuff );
     free( usbuff );
/*
 * Peltier values
 */
     dims[0] = nr_pcd; 
     dims[1] = SCIENCE_CHANNELS; 
     nrpix = dims[0] * dims[1];
     sbuff = (short *) malloc( nrpix * sizeof( short ));
     if ( sbuff == NULL ) NADC_RETURN_ERROR( NADC_ERR_ALLOC, "sbuff" );
     for ( nr = ny = 0; ny < dims[0]; ny++)
	  for ( nx = 0; nx < dims[1]; nx++ )
	       sbuff[nr++] = pcd[indx_pcd[ny]].ihr.peltier[nx];
     NADC_WR_HDF5_Dataset( compress, grp_id, "Peltier",
			  H5T_NATIVE_SHORT, 2, dims, sbuff );
     free( sbuff );
/*
 * Pre-disperser prism temperature
 */
     rbuff = (float *) malloc( dims[0] * sizeof( float ));
     if ( rbuff == NULL ) NADC_RETURN_ERROR( NADC_ERR_ALLOC, "rbuff" );
     for ( ny = 0; ny < dims[0]; ny++ )
	  rbuff[ny] = (float) (-1.721 + 6.104e-3 * 
			       pcd[indx_pcd[ny]].ihr.prism_temp);
     NADC_WR_HDF5_Dataset( compress, grp_id, "PrismTemperature",
			  H5T_NATIVE_FLOAT, 1, dims, rbuff );
     free( rbuff );
     (void) H5Gclose( grp_id );
/*
 * create group /EARTH/PCD
 */
     grp_id = H5Gcreate( param.hdf_file_id, "/EARTH/PMD", 
			 H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT );
     if ( grp_id < 0 ) 
	  NADC_RETURN_ERROR( NADC_ERR_HDF_GRP, "/EARTH/PMD" );
/*
 * write PMD geolocations (only for Earth observations)
 */
     dims[0] = nr_pcd * PMD_IN_GRID;
     if ( param.write_pmd_geo == PARAM_SET ) {
          type_id = H5Topen( param.hdf_file_id, "glr", H5P_DEFAULT );
          glr = (struct glr1_gome *)
               malloc( dims[0] * sizeof( struct glr1_gome ));
          if ( glr == NULL )
               NADC_RETURN_ERROR( NADC_ERR_ALLOC, "glr" );
          for ( nr = ny = 0; ny < (hsize_t) nr_pcd; ny++ ) {
	       for ( nx = 0; nx < PMD_IN_GRID; nx++ )
		    (void) memcpy( &glr[nr++], &pcd[indx_pcd[ny]].pmd[nx].glr,
				   sizeof( struct glr1_gome ) );
	  }
          NADC_WR_HDF5_Dataset( compress, grp_id, "glr",
                                type_id, 1, dims, glr );
          free( glr );
          (void) H5Tclose( type_id );
          if ( IS_ERR_STAT_FATAL )
               NADC_RETURN_ERROR( NADC_ERR_HDF_WR, "glr" );
     }
/*
 * write PMD values
 */
     dims[1] = PMD_NUMBER;
     nrpix = (size_t) (dims[0] * dims[1]);
     rbuff = (float *) malloc( nrpix * sizeof( float ));
     if ( rbuff == NULL ) NADC_RETURN_ERROR( NADC_ERR_ALLOC, "rbuff" );
     ni = 0; nr = 0;
     do {
	  ny = 0;
	  do {
	       nx = 0;
	       do {
		    rbuff[ni++] = pcd[indx_pcd[nr]].pmd[ny].value[nx];
	       } while ( ++nx < PMD_NUMBER );
	  } while ( ++ny < PMD_IN_GRID );
     } while ( ++nr < (hsize_t) nr_pcd );
     NADC_WR_HDF5_Dataset( compress, grp_id, "value",
                           H5T_NATIVE_FLOAT, 2, dims, rbuff );
     free( rbuff );
/*
 * close interface
 */
     (void) H5Gclose( grp_id );
}
Ejemplo n.º 16
0
/*+++++++++++++++++++++++++ Main Program or Function +++++++++++++++*/
void SCIA_LV1_WR_H5_SCPN( struct param_record param, unsigned int nr_scpn,
			  const struct scpn_scia *scpn )
{
     hid_t   ads_id;
     hsize_t adim;
     herr_t  stat;

     hid_t   scpn_type[NFIELDS];

     const hbool_t compress = (param.flag_deflate == PARAM_SET) ? TRUE : FALSE;
     const size_t scpn_size = sizeof( struct scpn_scia );
     const char *scpn_names[NFIELDS] = { 
	  "mjd", "flag_mds", "orbit_phase", "srs_param", "num_lines", 
	  "wv_error_calib", "sol_spec", "line_pos", "coeffs"
     };
     const size_t scpn_offs[NFIELDS] = {
	  HOFFSET( struct scpn_scia, mjd ),
	  HOFFSET( struct scpn_scia, flag_mds ),
	  HOFFSET( struct scpn_scia, orbit_phase ),
	  HOFFSET( struct scpn_scia, srs_param ),
	  HOFFSET( struct scpn_scia, num_lines ),
	  HOFFSET( struct scpn_scia, wv_error_calib ),
	  HOFFSET( struct scpn_scia, sol_spec ),
	  HOFFSET( struct scpn_scia, line_pos ),
	  HOFFSET( struct scpn_scia, coeffs )
     };
/*
 * check number of PMD records
 */
     if ( nr_scpn == 0 ) return;
/*
 * open/create group /ADS
 */
     ads_id = NADC_OPEN_HDF5_Group( param.hdf_file_id, "/ADS" );
     if ( ads_id < 0 ) NADC_RETURN_ERROR( NADC_ERR_HDF_GRP, "/ADS" );
/*
 * write SCPN data sets
 */
     adim = SCIENCE_PIXELS;
     scpn_type[0] = H5Topen( param.hdf_file_id, "mjd", H5P_DEFAULT );
     scpn_type[1] = H5Tcopy( H5T_NATIVE_UCHAR );
     scpn_type[2] = H5Tcopy( H5T_NATIVE_FLOAT );
     adim = SCIENCE_CHANNELS;
     scpn_type[3] = H5Tarray_create( H5T_NATIVE_UCHAR, 1, &adim );
     scpn_type[4] = H5Tarray_create( H5T_NATIVE_USHORT, 1, &adim );
     scpn_type[5] = H5Tarray_create( H5T_NATIVE_FLOAT, 1, &adim );
     adim = SCIENCE_PIXELS;
     scpn_type[6] = H5Tarray_create( H5T_NATIVE_FLOAT, 1, &adim );
     adim = 3 * SCIENCE_CHANNELS;
     scpn_type[7] = H5Tarray_create( H5T_NATIVE_FLOAT, 1, &adim );
     adim = NUM_SPEC_COEFFS * SCIENCE_CHANNELS;
     scpn_type[8] = H5Tarray_create( H5T_NATIVE_DOUBLE, 1, &adim );

     stat = H5TBmake_table( "scpn", ads_id, "NEW_SPECTRAL_CALIBRATION", 
                            NFIELDS, 1, scpn_size, scpn_names,
                            scpn_offs, scpn_type, 1,
                            NULL, compress, scpn );
     if ( stat < 0 ) NADC_GOTO_ERROR( NADC_ERR_HDF_DATA, "scpn" );
/*
 * close interface
 */
 done:
     (void) H5Tclose( scpn_type[0] );
     (void) H5Tclose( scpn_type[1] );
     (void) H5Tclose( scpn_type[2] );
     (void) H5Tclose( scpn_type[3] );
     (void) H5Tclose( scpn_type[4] );
     (void) H5Tclose( scpn_type[5] );
     (void) H5Tclose( scpn_type[6] );
     (void) H5Tclose( scpn_type[7] );
     (void) H5Tclose( scpn_type[8] );
     (void) H5Gclose( ads_id );
}
Ejemplo n.º 17
0
/*+++++++++++++++++++++++++ Main Program or Function +++++++++++++++*/
void SCIA_OL2_WR_H5_CLD( struct param_record param, unsigned int nr_cld,
			 const struct cld_sci_ol *cld )
{
     register unsigned int  nr;

     hid_t   grp_id;
     hbool_t compress;
     hsize_t adim;
     hvl_t   *vdata;
     hid_t   cld_type[NFIELDS];

     const char *cld_names[NFIELDS] = {
          "dsr_time", "quality_flag", "integr_time", "pmd_read", 
	  "cl_type_flags", "cloud_flags", "flag_output_flags", 
	  "num_aero_param", "pmd_read_cl", "dsr_length",
	  "surface_pres", "cl_frac", "cl_frac_err", "cl_top_pres", 
	  "cl_top_pres_err", "cl_opt_depth", "cl_opt_depth_err", 
	  "cl_reflectance", "cl_reflectance_err", 
	  "surface_reflectance", "surface_reflectance_err", 
	  "aero_abso_ind", "aero_ind_diag"
     };
/*
 * check number of CLD records
 */
     if ( nr_cld == 0 ) return;
/*
 * set HDF5 boolean variable for compression
 */
     if ( param.flag_deflate == PARAM_SET )
          compress = TRUE;
     else
          compress = FALSE;
/*
 * create group /MDS
 */
     grp_id = NADC_OPEN_HDF5_Group( param.hdf_file_id, "/MDS" );
     if ( grp_id < 0 ) NADC_RETURN_ERROR( NADC_ERR_HDF_GRP, "/MDS" );
/*
 * define user-defined data types of the Table-fields
 */
     cld_type[0] = H5Topen( param.hdf_file_id, "mjd", H5P_DEFAULT );
     cld_type[1] = H5Tcopy( H5T_NATIVE_CHAR );
     cld_type[2] = H5Tcopy( H5T_NATIVE_USHORT );
     cld_type[3] = H5Tcopy( H5T_NATIVE_USHORT );
     cld_type[4] = H5Tcopy( H5T_NATIVE_USHORT );
     cld_type[5] = H5Tcopy( H5T_NATIVE_USHORT );
     cld_type[6] = H5Tcopy( H5T_NATIVE_USHORT );
     cld_type[7] = H5Tcopy( H5T_NATIVE_USHORT );
     adim = 2;
     cld_type[8] = H5Tarray_create( H5T_NATIVE_USHORT, 1, &adim );
     cld_type[9] = H5Tcopy( H5T_NATIVE_UINT );
     cld_type[10] = H5Tcopy( H5T_NATIVE_FLOAT );
     cld_type[11] = H5Tcopy( H5T_NATIVE_FLOAT );
     cld_type[12] = H5Tcopy( H5T_NATIVE_FLOAT );
     cld_type[13] = H5Tcopy( H5T_NATIVE_FLOAT );
     cld_type[14] = H5Tcopy( H5T_NATIVE_FLOAT );
     cld_type[15] = H5Tcopy( H5T_NATIVE_FLOAT );
     cld_type[16] = H5Tcopy( H5T_NATIVE_FLOAT );
     cld_type[17] = H5Tcopy( H5T_NATIVE_FLOAT );
     cld_type[18] = H5Tcopy( H5T_NATIVE_FLOAT );
     cld_type[19] = H5Tcopy( H5T_NATIVE_FLOAT );
     cld_type[20] = H5Tcopy( H5T_NATIVE_FLOAT );
     cld_type[21] = H5Tcopy( H5T_NATIVE_FLOAT );
     cld_type[22] = H5Tcopy( H5T_NATIVE_FLOAT );
/*
 * create table
 */
     (void) H5TBmake_table( "Cloud end Aerosol MDS", grp_id, "cld", NFIELDS, 
			    nr_cld, cld_size, cld_names, cld_offs, 
			    cld_type, nr_cld, NULL, compress, cld );
/*
 * close interface
 */
     for ( nr = 0; nr < NFIELDS; nr++ ) (void) H5Tclose( cld_type[nr] );
/*
 * +++++ create/write variable part of the CLOUDS_AEROSOL record
 */
     adim = (hsize_t) nr_cld;
/*
 * Additional aerosol parameters
 */
     vdata = (hvl_t *) malloc( nr_cld * sizeof(hvl_t) );
     if ( vdata == NULL ) NADC_RETURN_ERROR( NADC_ERR_ALLOC, "vdata" );
     nr = 0;
     do {
	  vdata[nr].len = (size_t) cld[nr].numaeropars;
	  if ( cld[nr].numaeropars > 0 ) {
	       vdata[nr].p = malloc( vdata[nr].len * sizeof(float) );
	       if ( vdata[nr].p == NULL ) {
		    free( vdata );
		    NADC_RETURN_ERROR( NADC_ERR_ALLOC, "vdata.p" );
	       }
	       (void) memcpy( vdata[nr].p , cld[nr].aeropars,
			      vdata[nr].len * sizeof(float) );
	  }
     } while ( ++nr < nr_cld );
     NADC_WR_HDF5_Vlen_Dataset( compress, grp_id, "aeropars",
				H5T_NATIVE_FLOAT, 1, &adim, vdata );
/*
 * close interface
 */
     (void) H5Gclose( grp_id );
}