当前位置: 首页>>代码示例>>C++>>正文


C++ DSetCreatPropList::setFillValue方法代码示例

本文整理汇总了C++中DSetCreatPropList::setFillValue方法的典型用法代码示例。如果您正苦于以下问题:C++ DSetCreatPropList::setFillValue方法的具体用法?C++ DSetCreatPropList::setFillValue怎么用?C++ DSetCreatPropList::setFillValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DSetCreatPropList的用法示例。


在下文中一共展示了DSetCreatPropList::setFillValue方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: datatype

// * * * * * * * * * * * * * * * * * * * * * * * * * *
void H5_C3PO_NS::createExtendibleDataset(std::string FILE_NAME,const char* datasetName_)
{

   hsize_t dims[2] = { 0, 1}; // dataset dimensions at creation
   hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED};
   DataSpace mspace1( RANK, dims, maxdims);

  H5File* file=new H5File( FILE_NAME.c_str(),H5F_ACC_RDWR );
  IntType datatype( PredType::NATIVE_DOUBLE );         //Define datatype for the data
  datatype.setOrder( H5T_ORDER_LE );
  
  DSetCreatPropList cparms;
  hsize_t chunk_dims[2] ={6, 1};
  cparms.setChunk( RANK, chunk_dims );
  
  //Set fill value for the dataset
  
  int fill_val = 1.0;
  cparms.setFillValue( PredType::NATIVE_DOUBLE, &fill_val);
  
  DataSet dataset = file->createDataSet( datasetName_, PredType::NATIVE_DOUBLE, mspace1, cparms);
  
  file->close();
  
  delete file;

}
开发者ID:CFDEMproject,项目名称:C3PO-PUBLIC,代码行数:28,代码来源:h5_c3po.cpp

示例2: test_vlstrings_special

/*-------------------------------------------------------------------------
 * Function:	test_vlstrings_special
 *
 * Purpose:	Test VL string code for special string cases, nil and
 *		zero-sized.
 *
 * Return:	None
 *
 * Programmer:	Binh-Minh Ribler (use C version)
 *		January, 2007
 *
 *-------------------------------------------------------------------------
 */
static void test_vlstrings_special()
{
    const char *wdata[SPACE1_DIM1] = {"one", "two", "", "four"};
    const char *wdata2[SPACE1_DIM1] = {NULL, NULL, NULL, NULL};
    char *rdata[SPACE1_DIM1];   // Information read in

    // Output message about test being performed.
    SUBTEST("Special VL Strings");

    try {
	// Create file.
	H5File file1(FILENAME, H5F_ACC_TRUNC);

        // Create dataspace for datasets.
        hsize_t dims1[] = {SPACE1_DIM1};
        DataSpace sid1(SPACE1_RANK, dims1);

	// Create a datatype to refer to.
	StrType vlst(0, H5T_VARIABLE);

	// Create a dataset.
	DataSet dataset(file1.createDataSet("Dataset3", vlst, sid1));

	// Read from the dataset before writing data.
	dataset.read(rdata, vlst);

	// Check data read in.
	hsize_t i;      	// counting variable
	for (i=0; i<SPACE1_DIM1; i++)
	    if(rdata[i]!=NULL)
		TestErrPrintf("VL doesn't match!, rdata[%d]=%p\n",(int)i,rdata[i]);

	// Write dataset to disk, then read it back.
	dataset.write(wdata, vlst);
	dataset.read(rdata, vlst);

	// Compare data read in.
	for (i = 0; i < SPACE1_DIM1; i++) {
	    size_t wlen = HDstrlen(wdata[i]);
	    size_t rlen = HDstrlen(rdata[i]);
	    if(wlen != rlen) {
		TestErrPrintf("VL data lengths don't match!, strlen(wdata[%d])=%u, strlen(rdata[%d])=%u\n", (int)i, (unsigned)wlen, (int)i, (unsigned)rlen);
		continue;
	    } // end if
	    if(HDstrcmp(wdata[i],rdata[i]) != 0) {
		TestErrPrintf("VL data values don't match!, wdata[%d]=%s, rdata[%d]=%s\n", (int)i, wdata[i], (int)i, rdata[i]);
		continue;
	    } // end if
	} // end for

	// Reclaim the read VL data.
	DataSet::vlenReclaim((void *)rdata, vlst, sid1);

	// Close Dataset.
	dataset.close();

	/*
	 * Create another dataset to test nil strings.
	 */

	// Create the property list and set the fill value for the second
	// dataset.
	DSetCreatPropList dcpl;
	char *fill = NULL;	// Fill value
	dcpl.setFillValue(vlst, &fill);
	dataset = file1.createDataSet("Dataset4", vlst, sid1, dcpl);

	// Close dataset creation property list.
	dcpl.close();

	// Read from dataset before writing data.
	dataset.read(rdata, vlst);

	// Check data read in.
	for (i=0; i<SPACE1_DIM1; i++)
	  if(rdata[i]!=NULL)
	    TestErrPrintf("VL doesn't match!, rdata[%d]=%p\n",(int)i,rdata[i]);

	// Try to write nil strings to disk.
	dataset.write(wdata2, vlst);

	// Read nil strings back from disk.
	dataset.read(rdata, vlst);

	// Check data read in.
	for (i=0; i<SPACE1_DIM1; i++)
	  if(rdata[i]!=NULL)
//.........这里部分代码省略.........
开发者ID:BlackGinger,项目名称:ExocortexCrate,代码行数:101,代码来源:tvlstr.cpp

示例3: dsBurstHist

/*
 *  Create data spaces and data sets of the hdf5 for recording histories.
 */
void Hdf5Recorder::initDataSet()
{
    // create the data space & dataset for burstiness history
    hsize_t dims[2];
    dims[0] = static_cast<hsize_t>(m_sim_info->epochDuration * m_sim_info->maxSteps);
    DataSpace dsBurstHist(1, dims);
    dataSetBurstHist = new DataSet(stateOut->createDataSet(nameBurstHist, PredType::NATIVE_INT, dsBurstHist));

    // create the data space & dataset for spikes history
    dims[0] = static_cast<hsize_t>(m_sim_info->epochDuration * m_sim_info->maxSteps * 100);
    DataSpace dsSpikesHist(1, dims);
    dataSetSpikesHist = new DataSet(stateOut->createDataSet(nameSpikesHist, PredType::NATIVE_INT, dsSpikesHist));

    // create the data space & dataset for xloc & ylo c
    dims[0] = static_cast<hsize_t>(m_sim_info->totalNeurons);
    DataSpace dsXYloc(1, dims);
    dataSetXloc = new DataSet(stateOut->createDataSet(nameXloc, PredType::NATIVE_INT, dsXYloc));
    dataSetYloc = new DataSet(stateOut->createDataSet(nameYloc, PredType::NATIVE_INT, dsXYloc));

    // create the data space & dataset for neuron types
    dims[0] = static_cast<hsize_t>(m_sim_info->totalNeurons);
    DataSpace dsNeuronTypes(1, dims);
    dataSetNeuronTypes = new DataSet(stateOut->createDataSet(nameNeuronTypes, PredType::NATIVE_INT, dsNeuronTypes));

    // create the data space & dataset for neuron threashold
    dims[0] = static_cast<hsize_t>(m_sim_info->totalNeurons);
    DataSpace dsNeuronThresh(1, dims);
    dataSetNeuronThresh = new DataSet(stateOut->createDataSet(nameNeuronThresh, H5_FLOAT, dsNeuronThresh));

    // create the data space & dataset for simulation step duration
    dims[0] = static_cast<hsize_t>(1);
    DataSpace dsTsim(1, dims);
    dataSetTsim = new DataSet(stateOut->createDataSet(nameTsim, H5_FLOAT, dsTsim));

    // create the data space & dataset for simulation end time
    dims[0] = static_cast<hsize_t>(1);
    DataSpace dsSimulationEndTime(1, dims);
    dataSetSimulationEndTime = new DataSet(stateOut->createDataSet(nameSimulationEndTime, H5_FLOAT, dsSimulationEndTime));

    // probed neurons
    if (m_model->getLayout()->m_probed_neuron_list.size() > 0)
    {
        // create the data space & dataset for probed neurons
        dims[0] = static_cast<hsize_t>(m_model->getLayout()->m_probed_neuron_list.size());
        DataSpace dsProbedNeurons(1, dims);
        dataSetProbedNeurons = new DataSet(stateOut->createDataSet(nameProbedNeurons, PredType::NATIVE_INT, dsProbedNeurons));

        // create the data space & dataset for spikes of probed neurons

        // the data space with unlimited dimensions
        hsize_t maxdims[2];
        maxdims[0] = H5S_UNLIMITED;
        maxdims[1] = static_cast<hsize_t>(m_model->getLayout()->m_probed_neuron_list.size());

        // dataset dimensions at creation
        dims[0] = static_cast<hsize_t>(1);
        dims[1] = static_cast<hsize_t>(m_model->getLayout()->m_probed_neuron_list.size());
        DataSpace dsSpikesProbedNeurons(2, dims, maxdims);

        // set fill value for the dataset
        DSetCreatPropList cparms;
        uint64_t fill_val = 0;
        cparms.setFillValue( PredType::NATIVE_UINT64, &fill_val);

        // modify dataset creation properties, enable chunking
        hsize_t      chunk_dims[2];
        chunk_dims[0] = static_cast<hsize_t>(100);
        chunk_dims[1] = static_cast<hsize_t>(m_model->getLayout()->m_probed_neuron_list.size());
        cparms.setChunk( 2, chunk_dims );

        dataSetSpikesProbedNeurons = new DataSet(stateOut->createDataSet(nameSpikesProbedNeurons, PredType::NATIVE_UINT64, dsSpikesProbedNeurons, cparms));
    }

    // allocate data memories
    burstinessHist = new int[static_cast<int>(m_sim_info->epochDuration)];
    spikesHistory = new int[static_cast<int>(m_sim_info->epochDuration * 100)]; 
    memset(burstinessHist, 0, static_cast<int>(m_sim_info->epochDuration * sizeof(int)));
    memset(spikesHistory, 0, static_cast<int>(m_sim_info->epochDuration * 100 * sizeof(int)));

    // create the data space & dataset for spikes history of probed neurons
    if (m_model->getLayout()->m_probed_neuron_list.size() > 0)
    {
        // allocate data for spikesProbedNeurons
        spikesProbedNeurons = new vector<uint64_t>[m_model->getLayout()->m_probed_neuron_list.size()];

        // allocate memory to save offset
        offsetSpikesProbedNeurons = new hsize_t[m_model->getLayout()->m_probed_neuron_list.size()];
        memset(offsetSpikesProbedNeurons, 0, static_cast<int>(m_model->getLayout()->m_probed_neuron_list.size() * sizeof(hsize_t)));
    }
}
开发者ID:UWB-Biocomputing,项目名称:BrainGrid,代码行数:93,代码来源:Hdf5Recorder.cpp

示例4: main

int main (void)
{
    int   i,j; // loop indices */

    /*
     * Try block to detect exceptions raised by any of the calls inside it
     */
    try
    {
	/*
	 * Turn off the auto-printing when failure occurs so that we can
	 * handle the errors appropriately
	 */
	Exception::dontPrint();

	/*
	 * Create a file.
	 */
	H5File* file = new H5File( FILE_NAME, H5F_ACC_TRUNC );

	/*
	* Create property list for a dataset and set up fill values.
	*/
	int fillvalue = 0;   /* Fill value for the dataset */
	DSetCreatPropList plist;
	plist.setFillValue(PredType::NATIVE_INT, &fillvalue);

	/*
	 * Create dataspace for the dataset in the file.
	 */
	hsize_t fdim[] = {FSPACE_DIM1, FSPACE_DIM2}; // dim sizes of ds (on disk)
	DataSpace fspace( FSPACE_RANK, fdim );

	/*
	 * Create dataset and write it into the file.
	 */
	DataSet* dataset = new DataSet(file->createDataSet(
		DATASET_NAME, PredType::NATIVE_INT, fspace, plist));

	/*
	 * Select hyperslab for the dataset in the file, using 3x2 blocks,
	 * (4,3) stride and (2,4) count starting at the position (0,1).
	 */
	hsize_t start[2]; // Start of hyperslab
	hsize_t stride[2]; // Stride of hyperslab
	hsize_t count[2];  // Block count
	hsize_t block[2];  // Block sizes
	start[0]  = 0; start[1]  = 1;
	stride[0] = 4; stride[1] = 3;
	count[0]  = 2; count[1]  = 4;
	block[0]  = 3; block[1]  = 2;
	fspace.selectHyperslab( H5S_SELECT_SET, count, start, stride, block);

	/*
	 * Create dataspace for the first dataset.
	 */
	hsize_t dim1[] = {MSPACE1_DIM};  /* Dimension size of the first dataset
	                                   (in memory) */
	DataSpace mspace1( MSPACE1_RANK, dim1 );

	/*
	 * Select hyperslab.
	 * We will use 48 elements of the vector buffer starting at the
	 * second element.  Selected elements are 1 2 3 . . . 48
	 */
	start[0]  = 1;
	stride[0] = 1;
	count[0]  = 48;
	block[0]  = 1;
	mspace1.selectHyperslab( H5S_SELECT_SET, count, start, stride, block);

	/*
	 * Write selection from the vector buffer to the dataset in the file.
	 *
	 * File dataset should look like this:
	 *                    0  1  2  0  3  4  0  5  6  0  7  8
	 *                    0  9 10  0 11 12  0 13 14  0 15 16
	 *                    0 17 18  0 19 20  0 21 22  0 23 24
	 *                    0  0  0  0  0  0  0  0  0  0  0  0
	 *                    0 25 26  0 27 28  0 29 30  0 31 32
	 *                    0 33 34  0 35 36  0 37 38  0 39 40
	 *                    0 41 42  0 43 44  0 45 46  0 47 48
	 *                    0  0  0  0  0  0  0  0  0  0  0  0
	 */
	int    vector[MSPACE1_DIM];	// vector buffer for dset

	/*
	 * Buffer initialization.
	 */
	vector[0] = vector[MSPACE1_DIM - 1] = -1;
	for (i = 1; i < MSPACE1_DIM - 1; i++)
	    vector[i] = i;

	dataset->write( vector, PredType::NATIVE_INT, mspace1, fspace );

	/*
	 * Reset the selection for the file dataspace fid.
	 */
	fspace.selectNone();

//.........这里部分代码省略.........
开发者ID:Starlink,项目名称:hdf5,代码行数:101,代码来源:writedata.cpp

示例5: add_dset

void Generic_wrapper_hdf::add_dset(int rank, const unsigned int * dims, V_TYPE type, const void * data,
				   const std::string & name  )
{
  if (!(wrapper_open_))
    throw runtime_error("wrapper must be open to add a dataset");
  

  hsize_t hdims[rank];
  for(int j = 0;j<rank;++j)
    hdims[j] = dims[j];

  // make dspace
  DataSpace dspace(rank,hdims);

  

  
  // sort out type


  DataType hdf_type,mem_type;
  DSetCreatPropList plist;
  int fill_value_i = -31415;
  unsigned int fill_value_ui = 0;
  float fill_value_f = -3.1415;
  switch(type)
  {
  case V_INT:
  
    hdf_type = PredType::NATIVE_INT;
    mem_type = PredType::NATIVE_INT;
    plist.setFillValue(hdf_type,&fill_value_i);
    break;
  case V_FLOAT:
    
    hdf_type = PredType::NATIVE_FLOAT;
    mem_type = PredType::NATIVE_FLOAT;
    plist.setFillValue(hdf_type,&fill_value_f);
    break;
  case V_UINT:
    hdf_type = PredType::NATIVE_UINT;
    mem_type = PredType::NATIVE_UINT;
    plist.setFillValue(hdf_type,&fill_value_ui);
    break;
  case V_BOOL:
  case V_TIME:
  case V_GUID:
  case V_ERROR:
  case V_COMPLEX:
  case V_STRING:
    throw logic_error("generic_wrapper_hdf: un implemented types");
  }
  
  /// @todo add compression logic for higher sizes
  // if the list is big enough, us compression
  if(rank ==1 && *hdims > CSIZE*5)
  {
    hsize_t csize = CSIZE;
    plist.setChunk(1,&csize);
    plist.setSzip(H5_SZIP_NN_OPTION_MASK,10);
  }
  

  // make data set
  DataSet dset;
  if(!group_open_ || name[0] == '/')
  {
    dset = file_ ->createDataSet(name,hdf_type,dspace,plist);  
  }
  else if(group_)
  {
    dset = group_ ->createDataSet(name,hdf_type,dspace,plist);  
  }
  else
  {
    throw runtime_error("gave relative path name with no open group");
  }
  
  
  
  
  // shove in data
  dset.write(data,mem_type,dspace,dspace);
  
  // close everything is taken care of as all variables on stack

}
开发者ID:nanjiye123,项目名称:tracking,代码行数:87,代码来源:generic_wrapper_hdf.cpp

示例6: main

int main (void)
{
   /*
    * Try block to detect exceptions raised by any of the calls inside it
    */
   try
   {
      /*
       * Turn off the auto-printing when failure occurs so that we can
       * handle the errors appropriately
       */
      Exception::dontPrint();

      /*
       * Create the data space with unlimited dimensions.
       */
      hsize_t      dims[2]  = { 3, 3};  // dataset dimensions at creation
      hsize_t      maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED};
      DataSpace mspace1( RANK, dims, maxdims);

      /*
       * Create a new file. If file exists its contents will be overwritten.
       */
      H5File file( FILE_NAME, H5F_ACC_TRUNC );

      /*
       * Modify dataset creation properties, i.e. enable chunking.
       */
      DSetCreatPropList cparms;

      hsize_t      chunk_dims[2] ={2, 5};
      cparms.setChunk( RANK, chunk_dims );

      /*
       * Set fill value for the dataset
       */
      int fill_val = 0;
      cparms.setFillValue( PredType::NATIVE_INT, &fill_val);

      /*
       * Create a new dataset within the file using cparms
       * creation properties.
       */
      DataSet dataset = file.createDataSet( DATASET_NAME, PredType::NATIVE_INT, mspace1, cparms);

      /*
       * Extend the dataset. This call assures that dataset is at least 3 x 3.
       */
      hsize_t      size[2];
      size[0]   = 3;
      size[1]   = 3;
      dataset.extend( size );

      /*
       * Select a hyperslab.
       */
      DataSpace fspace1 = dataset.getSpace ();
      hsize_t     offset[2];
      offset[0] = 0;
      offset[1] = 0;
      hsize_t      dims1[2] = { 3, 3};            /* data1 dimensions */
      fspace1.selectHyperslab( H5S_SELECT_SET, dims1, offset );

      /*
       * Write the data to the hyperslab.
       */
      int       data1[3][3] = { {1, 1, 1},       /* data to write */
				{1, 1, 1},
				{1, 1, 1} };
      dataset.write( data1, PredType::NATIVE_INT, mspace1, fspace1 );

      /*
       * Extend the dataset. Dataset becomes 10 x 3.
       */
      hsize_t   dims2[2] = { 7, 1};            /* data2 dimensions */
      dims[0]   = dims1[0] + dims2[0];
      size[0]   = dims[0];
      size[1]   = dims[1];
      dataset.extend( size );

      /*
       * Select a hyperslab.
       */
      DataSpace fspace2 = dataset.getSpace ();
      offset[0] = 3;
      offset[1] = 0;
      fspace2.selectHyperslab( H5S_SELECT_SET, dims2, offset );

      /*
       * Define memory space
       */
      DataSpace mspace2( RANK, dims2 );

      /*
       * Write the data to the hyperslab.
       */
      int  data2[7]    = { 2, 2, 2, 2, 2, 2, 2};
      dataset.write( data2, PredType::NATIVE_INT, mspace2, fspace2 );

      /*
//.........这里部分代码省略.........
开发者ID:Starlink,项目名称:hdf5,代码行数:101,代码来源:extend_ds.cpp


注:本文中的DSetCreatPropList::setFillValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。