OSHUN  beta
Arbitrary Order Spherical-Harmonic 1D-3P Vlasov-Fokker-Planck-Maxwell code
Export_Files::Xport Class Reference

#include <export.h>

Public Member Functions

 Xport (const Algorithms::AxisBundle< double > &_axis, const vector< string > oTags, string homedir="")
 
void Export_h5 (const std::string tag, std::valarray< float > ex, const size_t &step, const int spec=-1)
 
void Export_h5 (const std::string tag, Array2D< float > ex, const size_t &step, const int spec=-1)
 
void Export_h5 (const std::string tag, Array3D< float > ex, const size_t &step, const int spec=-1)
 
H5::H5File hmake_file (string ofilename)
 
void hclose_file (H5::H5File &file)
 
void hinit_attr (H5::H5File &hfilehandle, const std::string tag, size_t step, float xmax, float xmin)
 
void hinit_attr2 (H5::H5File &hfilehandle, const std::string tag, size_t step, float xmax[], float xmin[])
 
void haxis (H5::Group &hgrouphandle, string axismainname, float axisrange[2], string axislongname, string axisname, string axistype, string axisunits)
 
void hfile_add_attr (H5::H5File &hfilehandle, string attrname, int attrdata)
 
void hfile_add_attr2 (H5::H5File &hfilehandle, string attrname, int attrdata[2])
 
void hfile_add_attr (H5::H5File &hfilehandle, string attrname, float attrdata)
 
void hfile_add_attr2 (H5::H5File &hfilehandle, string attrname, float attrdata[2])
 
void hfile_add_attr (H5::H5File &hfilehandle, string attrname, string attrdata)
 
void hfile_add_attr_todataset (H5::DataSet &hdatasethandle, string attrname, string attrdata)
 

Private Member Functions

string oH5Fextension (size_t step, int species=-1)
 

Private Attributes

map< string, HeaderHdr
 

Detailed Description

Definition at line 173 of file export.h.

Constructor & Destructor Documentation

◆ Xport()

Export_Files::Xport::Xport ( const Algorithms::AxisBundle< double > &  _axis,
const vector< string >  oTags,
string  homedir = "" 
)

Definition at line 530 of file export.cpp.

References formulary(), Export_Files::Header::Header(), Formulary::Label(), Export_Files::Header::label(), Export_Files::Makefolder(), Algorithms::AxisBundle< T >::Np(), Algorithms::AxisBundle< T >::Npx(), Algorithms::AxisBundle< T >::Npy(), Algorithms::AxisBundle< T >::Npz(), Algorithms::AxisBundle< T >::Nxg(), Algorithms::AxisBundle< T >::pdim(), Algorithms::AxisBundle< T >::pmax(), Algorithms::AxisBundle< T >::pmin(), Export_Files::stringify(), Formulary::Uconv(), Algorithms::AxisBundle< T >::xgmax(), and Algorithms::AxisBundle< T >::xgmin().

532  {
533 
534  size_t species(_axis.pdim());
535  DefaultTags dTags(species);
536 
537  vector< oAxis > xyz, pxyz, imre, pr;
538  xyz.push_back( Export_Files::oAxis(_axis.xgmin(0), _axis.xgmax(0), _axis.Nxg(0)) );
539 
540  for (size_t s(0); s < species; ++s) {
541  pr.push_back( Export_Files::oAxis(_axis.pmin(s), _axis.pmax(s), _axis.Np(s)));
542  pxyz.push_back( Export_Files::oAxis( (-1.0)*float(_axis.pmax(s)), float(_axis.pmax(s)), _axis.Npx(s)) );
543  pxyz.push_back( Export_Files::oAxis( (-1.0)*float(_axis.pmax(s)), float(_axis.pmax(s)), _axis.Npy(s)) );
544  pxyz.push_back( Export_Files::oAxis( (-1.0)*float(_axis.pmax(s)), float(_axis.pmax(s)), _axis.Npz(s)) );
545  }
546  imre.push_back( Export_Files::oAxis(0,1,2) );
547 // Time
548  size_t tloc(0); // Find the location of the right tag
549  while ( ( tloc < dTags.time.size()-1 ) &&
550  ( find(oTags.begin(),oTags.end(), dTags.time[tloc]) == oTags.end() ) ) {
551  ++tloc;
552  }
553  string tlabel = "t[" +formulary().Label(dTags.time[tloc])+"]";
554  string tunits = formulary().Label(dTags.time[tloc]);
555  float tconv = formulary().Uconv(dTags.time[tloc]);
556 
557 // xyz Axis
558  size_t xloc(0); // Find the location of the right tag
559  while ( ( xloc < dTags.space.size()-1 ) &&
560  ( find(oTags.begin(),oTags.end(), dTags.space[xloc]) == oTags.end() ) ) {
561  ++xloc;
562  }
563  xyz[0].label = "x["+ formulary().Label(dTags.space[xloc]) +"]";
564  if ( xyz.size() > 1 ) xyz[1].label = "y["+ formulary().Label(dTags.space[xloc]) +"]";
565  if ( xyz.size() > 2 ) xyz[2].label = "z["+ formulary().Label(dTags.space[xloc]) +"]";
566  xyz[0].units = formulary().Label(dTags.space[xloc]);
567  if ( xyz.size() > 1 ) xyz[1].units = formulary().Label(dTags.space[xloc]);
568  if ( xyz.size() > 2 ) xyz[2].units = formulary().Label(dTags.space[xloc]);
569 
570 
571 // pxyz Axis
572  for (size_t i(0); i < species; ++i) {
573  pr[i].label = "p";
574  pr[i].units = "m_e c";
575 
576  pxyz[i].label = "px[mc]";
577  pxyz[i].units = "m_e c";
578  // if ( pxyz.size()/species > 1 )
579  pxyz[1+i].label = "py[mc]";
580  pxyz[1+i].units = "m_e c";
581  // if ( pxyz.size()/species > 2 )
582  pxyz[2+i].label = "pz[mc]";
583  pxyz[2+i].units = "m_e c";
584 
585  // if ( pxyz.size()/species > 1 )
586  // if ( pxyz.size()/species > 2 ) pxyz[2*species+i].units = "m_e c";
587  }
588 
589 // Tags for Fields -->
590  for (size_t i(0); i < dTags.fld.size(); ++i) {
591 
592  // If this tag is an output tag
593  if ( find(oTags.begin(),oTags.end(), dTags.fld[i]) != oTags.end() ) {
594 
595  string nounits = dTags.fld[i].substr(0, dTags.fld[i].find("_"));
596  string folder = homedir + "OUTPUT/FLD/" + nounits + "/";
597  // Generate a header file for this tag
598  Hdr[dTags.fld[i]] = Header(xyz,
599  nounits+"["+formulary().Label(dTags.fld[i])+"]",
600  formulary().Uconv(dTags.fld[i]),
601  tlabel, tunits, tconv, folder);
602  }
603  } // <--
604 
605 // Tags for Moments -->
606  for (size_t i(0); i < dTags.mom.size(); ++i) {
607 
608  // If this tag is an output tag
609  if ( find(oTags.begin(),oTags.end(), dTags.mom[i]) != oTags.end() ) {
610 
611  string nounits = dTags.mom[i].substr(0, dTags.mom[i].find("_"));
612  string folder = homedir + "OUTPUT/MOM/" + nounits + "/";
613  // Generate a header file for this tag
614  Hdr[dTags.mom[i]] = Header(xyz,
615  nounits+"["+formulary().Label(dTags.mom[i])+"]",
616  formulary().Uconv(dTags.mom[i]),
617  tlabel, tunits, tconv, folder);
618  }
619  } // <--
620 
621 // Tags for p-x -->
622  for (size_t i(0); i < dTags.pvsx.size(); ++i) {
623 
624  // for (size_t k(0); k < oTags.size(); ++k)
625  // std::cout << " \n \n k = " << oTags[k];
626 
627  // If this tag is an output tag
628  if ( find(oTags.begin(),oTags.end(), dTags.pvsx[i]) != oTags.end() ) {
629 
630  string folder = homedir + "OUTPUT/DISTR/" + dTags.pvsx[i] + "/";
631  Makefolder(folder);
632 
633 
634 // Generate a header file for this tag
635 // For each 9 you have a different species
636  Hdr[dTags.pvsx[i]] = Header( pr[i/3], xyz[0],
637  "f"+stringify(i/3), 1.0, tlabel, tunits, tconv, folder);
638  // std::cout << " \n k = " << dTags.pvsx[i] << "\n";
639  // std::cout << " \n \n 11 ";
640  }
641  } //<--
642 
643 // Tags for f-x -->
644  for (size_t i(0); i < dTags.fvsx.size(); ++i) {
645 
646  // If this tag is an output tag
647  if ( find(oTags.begin(),oTags.end(), dTags.fvsx[i]) != oTags.end() ) {
648 
649  string folder = homedir + "OUTPUT/DISTR/" + dTags.fvsx[i] + "/";
650  Makefolder(folder);
651 
652 // Generate a header file for this tag
653  Hdr[dTags.fvsx[i]] = Header( pr[i/5], xyz[0], imre[0],
654  "f", 1.0, tlabel, tunits, tconv, folder);
655 
656  }
657  } //<--
658 
659  // Tags for p-p-x -->
660  for (size_t i(0); i < dTags.pvspvsx.size(); ++i) {
661 
662  // If this tag is an output tag
663  if ( find(oTags.begin(),oTags.end(), dTags.pvspvsx[i]) != oTags.end() ) {
664 
665  string folder = homedir + "OUTPUT/DISTR/" + dTags.pvspvsx[i] + "/";
666  Makefolder(folder);
667 
668 // Generate a header file for this tag
669  Hdr[dTags.pvspvsx[i]] = Header( pxyz[i/1+species],pxyz[(i+1)/1+species], xyz[0],
670  "f"+stringify(i/1), 1.0, tlabel, tunits, tconv, folder);
671 
672  // std::cout << " \n \n 11 ";
673  }
674  } //<--
675 }
int Makefolder(string _name)
Definition: export.cpp:51
std::string stringify(T const &x)
Definition: export.h:30
T pmin(size_t i) const
size_t Npy(size_t i) const
double Uconv(string key)
Definition: formulary.h:78
T xgmin(size_t i) const
string Label(string key)
Definition: formulary.h:76
T xgmax(size_t i) const
size_t Np(size_t i) const
Formulary & formulary()
Definition: formulary.cpp:328
size_t Npx(size_t i) const
T pmax(size_t i) const
size_t Npz(size_t i) const
size_t Nxg(size_t i) const
map< string, Header > Hdr
Definition: export.h:206
Here is the call graph for this function:

Member Function Documentation

◆ Export_h5() [1/3]

void Export_Files::Xport::Export_h5 ( const std::string  tag,
std::valarray< float >  ex,
const size_t &  step,
const int  spec = -1 
)

Definition at line 3416 of file export.cpp.

References Export_Files::Header::dim(), Export_Files::Header::Directory(), and formulary().

3419  {
3420 //--------------------------------------------------------------
3421 // Export data to H5 file
3422 //--------------------------------------------------------------
3423 
3424  string filename(Hdr[tag].Directory());
3425 
3426 // Check Header file correctness
3427  if (Hdr[tag].dim() != 1) {
3428  cout << "ERROR "<< tag <<" : " << Hdr[tag].dim() << " dimensions != 1D structure\n";
3429  exit(1);
3430  }
3431 
3432 // Open File
3433  filename.append(tag).append(oH5Fextension(step,spec));
3434  H5::H5File file = hmake_file(filename);
3435 
3436  hsize_t dimsf[1] = {data.size()}; // dataset dimensions
3437  H5::DataSpace dataspace( 1, dimsf );
3438  H5::DataSet dataset = file.createDataSet( tag, H5::PredType::NATIVE_FLOAT, dataspace );
3439 
3440  float xmin = { static_cast<float>( Hdr[tag].min(0)) };
3441  float xmax = { static_cast<float>( Hdr[tag].max(0)) };
3442 
3443  hinit_attr(file, tag, step, xmax, xmin);
3444 
3445  H5::Group group = file.createGroup("/AXIS");
3446 
3447  std::size_t pos = Hdr[tag].label(0).find("[");
3448 
3449  string axismainname = "AXIS1";
3450  float axisrange[2];
3451  axisrange[0] = xmin;
3452  axisrange[1] = xmax;
3453  string axislongname = Hdr[tag].label(0).substr(0,pos);
3454  string axisname = Hdr[tag].label(0).substr(0,pos);
3455  string axistype = "linear";
3456  string axisunits = Hdr[tag].units(0);
3457 
3458  haxis(group, axismainname, axisrange, axislongname, axisname, axistype, axisunits);
3459 
3460  group.close();
3461 
3462  dataset.write( &(data[0]) , H5::PredType::NATIVE_FLOAT );
3463  hfile_add_attr_todataset(dataset, "LONG_NAME", tag);
3464  hfile_add_attr_todataset(dataset, "UNITS", formulary().Label(tag));
3465 
3466  dataset.close();
3467 
3468  hclose_file(file);
3469 
3470 }
void hinit_attr(H5::H5File &hfilehandle, const std::string tag, size_t step, float xmax, float xmin)
Definition: export.cpp:3658
H5::H5File hmake_file(string ofilename)
Definition: export.cpp:3632
void hclose_file(H5::H5File &file)
Definition: export.cpp:3646
void haxis(H5::Group &hgrouphandle, string axismainname, float axisrange[2], string axislongname, string axisname, string axistype, string axisunits)
Definition: export.cpp:3736
Formulary & formulary()
Definition: formulary.cpp:328
void hfile_add_attr_todataset(H5::DataSet &hdatasethandle, string attrname, string attrdata)
Definition: export.cpp:3862
string oH5Fextension(size_t step, int species=-1)
Definition: export.cpp:683
map< string, Header > Hdr
Definition: export.h:206
Here is the call graph for this function:

◆ Export_h5() [2/3]

void Export_Files::Xport::Export_h5 ( const std::string  tag,
Array2D< float >  ex,
const size_t &  step,
const int  spec = -1 
)

Definition at line 3475 of file export.cpp.

References Array2D< T >::array(), Export_Files::Header::dim(), Array2D< T >::dim1(), Array2D< T >::dim2(), Export_Files::Header::Directory(), formulary(), Export_Files::Header::max(), and Export_Files::Header::min().

3478  {
3479 //--------------------------------------------------------------
3480 // Export data to H5 file
3481 //--------------------------------------------------------------
3482 
3483  string filename(Hdr[tag].Directory());
3484 
3485 // Check Header file correctness
3486  if (Hdr[tag].dim() != 2) {
3487  cout << "ERROR "<< tag <<" : " << Hdr[tag].dim() << " dimensions != 2D structure\n";
3488  exit(1);
3489  }
3490 
3491 // Open File
3492  filename.append(tag).append(oH5Fextension(step,spec));
3493  H5::H5File file = hmake_file(filename);
3494 
3495  hsize_t dimsf[2] = { data.dim2(), data.dim1() }; // dataset dimensions
3496  H5::DataSpace dataspace( 2, dimsf );
3497  H5::DataSet dataset = file.createDataSet( tag, H5::PredType::NATIVE_FLOAT, dataspace );
3498 
3499  float xmin[2] = { static_cast<float>( Hdr[tag].min(0)),
3500  static_cast<float>( Hdr[tag].min(1)) };
3501 
3502  float xmax[2] = { static_cast<float>( Hdr[tag].max(0)),
3503  static_cast<float>( Hdr[tag].max(1)) };
3504 
3505  hinit_attr2(file, tag, step, xmax, xmin);
3506 
3507  H5::Group group = file.createGroup("/AXIS");
3508 
3509  std::size_t pos = Hdr[tag].label(1).find("[");
3510 
3511  string axismainname = "AXIS1";
3512  float axisrange[2];
3513  axisrange[0] = xmin[1];
3514  axisrange[1] = xmax[1];
3515  string axislongname = Hdr[tag].label(1).substr(0,pos);
3516  string axisname = Hdr[tag].label(1).substr(0,pos);
3517  string axistype = "linear";
3518  string axisunits = Hdr[tag].units(1);
3519 
3520  haxis(group, axismainname, axisrange, axislongname, axisname, axistype, axisunits);
3521 
3522  pos = Hdr[tag].label(0).find("[");
3523 
3524  axismainname = "AXIS2";
3525  axisrange[0] = xmin[0];
3526  axisrange[1] = xmax[0];
3527  axislongname = Hdr[tag].label(0).substr(0,pos);
3528  axisname = Hdr[tag].label(0).substr(0,pos);
3529  axisunits = Hdr[tag].units(0);
3530 
3531  haxis(group, axismainname, axisrange, axislongname, axisname, axistype, axisunits);
3532 
3533  group.close();
3534 
3535  dataset.write( &(data.array())[0] , H5::PredType::NATIVE_FLOAT );
3536  hfile_add_attr_todataset(dataset, "LONG_NAME", tag);
3537  hfile_add_attr_todataset(dataset, "UNITS", formulary().Label(tag));
3538 
3539  dataset.close();
3540 
3541  hclose_file(file);
3542 
3543 }
void hinit_attr2(H5::H5File &hfilehandle, const std::string tag, size_t step, float xmax[], float xmin[])
Definition: export.cpp:3698
H5::H5File hmake_file(string ofilename)
Definition: export.cpp:3632
void hclose_file(H5::H5File &file)
Definition: export.cpp:3646
void haxis(H5::Group &hgrouphandle, string axismainname, float axisrange[2], string axislongname, string axisname, string axistype, string axisunits)
Definition: export.cpp:3736
Formulary & formulary()
Definition: formulary.cpp:328
void hfile_add_attr_todataset(H5::DataSet &hdatasethandle, string attrname, string attrdata)
Definition: export.cpp:3862
string oH5Fextension(size_t step, int species=-1)
Definition: export.cpp:683
map< string, Header > Hdr
Definition: export.h:206
Here is the call graph for this function:

◆ Export_h5() [3/3]

void Export_Files::Xport::Export_h5 ( const std::string  tag,
Array3D< float >  ex,
const size_t &  step,
const int  spec = -1 
)

Definition at line 3548 of file export.cpp.

References Array3D< T >::array(), Export_Files::Header::dim(), Array3D< T >::dim1(), Array3D< T >::dim2(), Array3D< T >::dim3(), Export_Files::Header::Directory(), formulary(), Export_Files::Header::max(), and Export_Files::Header::min().

3551  {
3552 //--------------------------------------------------------------
3553 // Export data to H5 file
3554 //--------------------------------------------------------------
3555 
3556  string filename(Hdr[tag].Directory());
3557 
3558 // Check Header file correctness
3559  if (Hdr[tag].dim() != 3) {
3560  cout << "ERROR "<< tag <<" : " << Hdr[tag].dim() << " dimensions != 3D structure\n";
3561  exit(1);
3562  }
3563 
3564 // Open File
3565  filename.append(tag).append(oH5Fextension(step,spec));
3566  H5::H5File file = hmake_file(filename);
3567 
3568  hsize_t dimsf[3] = { data.dim3(), data.dim2(), data.dim1() }; // dataset dimensions
3569  H5::DataSpace dataspace( 3, dimsf );
3570  H5::DataSet dataset = file.createDataSet( tag, H5::PredType::NATIVE_FLOAT, dataspace );
3571 
3572  float xmin[3] = { static_cast<float>( Hdr[tag].min(0)),
3573  static_cast<float>( Hdr[tag].min(1)),
3574  static_cast<float>( Hdr[tag].min(2))};
3575  float xmax[3] = { static_cast<float>( Hdr[tag].max(0)),
3576  static_cast<float>( Hdr[tag].max(1)),
3577  static_cast<float>( Hdr[tag].max(2))};
3578 
3579  hinit_attr2(file, tag, step, xmax, xmin);
3580 
3581  H5::Group group = file.createGroup("/AXIS");
3582 
3583  std::size_t pos = Hdr[tag].label(1).find("[");
3584 
3585  string axismainname = "AXIS1";
3586  float axisrange[2];
3587  axisrange[0] = xmin[1];
3588  axisrange[1] = xmax[1];
3589  string axislongname = Hdr[tag].label(1).substr(0,pos);
3590  string axisname = Hdr[tag].label(1).substr(0,pos);
3591  string axistype = "linear";
3592  string axisunits = Hdr[tag].units(1);
3593 
3594  haxis(group, axismainname, axisrange, axislongname, axisname, axistype, axisunits);
3595 
3596  pos = Hdr[tag].label(0).find("[");
3597 
3598  axismainname = "AXIS2";
3599  axisrange[0] = xmin[0];
3600  axisrange[1] = xmax[0];
3601  axislongname = Hdr[tag].label(0).substr(0,pos);
3602  axisname = Hdr[tag].label(0).substr(0,pos);
3603  axisunits = Hdr[tag].units(0);
3604 
3605  haxis(group, axismainname, axisrange, axislongname, axisname, axistype, axisunits);
3606 
3607  pos = Hdr[tag].label(2).find("[");
3608 
3609  axismainname = "AXIS3";
3610  axisrange[0] = xmin[2];
3611  axisrange[1] = xmax[2];
3612  axislongname = Hdr[tag].label(2).substr(0,pos);
3613  axisname = Hdr[tag].label(2).substr(0,pos);
3614  axisunits = Hdr[tag].units(2);
3615 
3616  haxis(group, axismainname, axisrange, axislongname, axisname, axistype, axisunits);
3617 
3618  group.close();
3619 
3620  dataset.write( &(data.array())[0] , H5::PredType::NATIVE_FLOAT );
3621  hfile_add_attr_todataset(dataset, "LONG_NAME", tag);
3622  hfile_add_attr_todataset(dataset, "UNITS", formulary().Label(tag));
3623 
3624  dataset.close();
3625 
3626  hclose_file(file);
3627 
3628 }
void hinit_attr2(H5::H5File &hfilehandle, const std::string tag, size_t step, float xmax[], float xmin[])
Definition: export.cpp:3698
H5::H5File hmake_file(string ofilename)
Definition: export.cpp:3632
void hclose_file(H5::H5File &file)
Definition: export.cpp:3646
void haxis(H5::Group &hgrouphandle, string axismainname, float axisrange[2], string axislongname, string axisname, string axistype, string axisunits)
Definition: export.cpp:3736
Formulary & formulary()
Definition: formulary.cpp:328
void hfile_add_attr_todataset(H5::DataSet &hdatasethandle, string attrname, string attrdata)
Definition: export.cpp:3862
string oH5Fextension(size_t step, int species=-1)
Definition: export.cpp:683
map< string, Header > Hdr
Definition: export.h:206
Here is the call graph for this function:

◆ haxis()

void Export_Files::Xport::haxis ( H5::Group &  hgrouphandle,
string  axismainname,
float  axisrange[2],
string  axislongname,
string  axisname,
string  axistype,
string  axisunits 
)

Definition at line 3736 of file export.cpp.

3738  {
3739 //--------------------------------------------------------------
3740 // Add axis attributes
3741 //--------------------------------------------------------------
3742 
3743  hsize_t dims2[1] = { 2 };
3744  H5::DataSpace dataspaceg1( 1, dims2 );
3745  H5::DataSet datasetg1 = hgrouphandle.createDataSet(axismainname, H5::PredType::NATIVE_FLOAT,
3746  dataspaceg1);
3747  datasetg1.write( axisrange, H5::PredType::NATIVE_FLOAT );
3748  hfile_add_attr_todataset(datasetg1, "LONG_NAME", axislongname);
3749  hfile_add_attr_todataset(datasetg1, "NAME", axisname);
3750  hfile_add_attr_todataset(datasetg1, "TYPE", axistype);
3751  hfile_add_attr_todataset(datasetg1, "UNITS", axisunits);
3752 
3753  dataspaceg1.close();
3754  datasetg1.close();
3755 
3756 }
void hfile_add_attr_todataset(H5::DataSet &hdatasethandle, string attrname, string attrdata)
Definition: export.cpp:3862

◆ hclose_file()

void Export_Files::Xport::hclose_file ( H5::H5File &  file)

Definition at line 3646 of file export.cpp.

3646  {
3647 //--------------------------------------------------------------
3648 // Close HDF5 file
3649 //--------------------------------------------------------------
3650 
3651  file.close();
3652 
3653 }

◆ hfile_add_attr() [1/3]

void Export_Files::Xport::hfile_add_attr ( H5::H5File &  hfilehandle,
string  attrname,
int  attrdata 
)

Definition at line 3761 of file export.cpp.

3762  {
3763 //--------------------------------------------------------------
3764 // Add 1D integer attribute
3765 //--------------------------------------------------------------
3766 
3767  hsize_t dims1[1] = { 1 };
3768  H5::DataSpace attr_dataspace_1 = H5::DataSpace (1, dims1 );
3769  H5::Attribute attribute_int = hfilehandle.createAttribute( attrname, H5::PredType::NATIVE_INT,
3770  attr_dataspace_1);
3771  attribute_int.write( H5::PredType::NATIVE_INT, &attrdata);
3772  attr_dataspace_1.close();
3773  attribute_int.close();
3774 
3775 }

◆ hfile_add_attr() [2/3]

void Export_Files::Xport::hfile_add_attr ( H5::H5File &  hfilehandle,
string  attrname,
float  attrdata 
)

Definition at line 3801 of file export.cpp.

3802  {
3803 //--------------------------------------------------------------
3804 // Add 1D float attribute
3805 //--------------------------------------------------------------
3806 
3807  hsize_t dims1[1] = { 1 };
3808  H5::DataSpace attr_dataspace_1 = H5::DataSpace (1, dims1 );
3809  H5::Attribute attribute_float = hfilehandle.createAttribute( attrname, H5::PredType::NATIVE_FLOAT,
3810  attr_dataspace_1);
3811  attribute_float.write( H5::PredType::NATIVE_FLOAT, &attrdata);
3812  attr_dataspace_1.close();
3813  attribute_float.close();
3814 
3815 }

◆ hfile_add_attr() [3/3]

void Export_Files::Xport::hfile_add_attr ( H5::H5File &  hfilehandle,
string  attrname,
string  attrdata 
)

Definition at line 3841 of file export.cpp.

3842  {
3843 //--------------------------------------------------------------
3844 // Add string attribute
3845 //--------------------------------------------------------------
3846 
3847  hsize_t dims1[1] = { 1 };
3848  H5::DataSpace attr_dataspace_1 = H5::DataSpace (1, dims1 );
3849  H5::StrType strdatatype(H5::PredType::C_S1, 256); // of length 256 characters
3850  H5std_string strwritebuf ( attrdata );
3851  H5::Attribute attribute_string = hfilehandle.createAttribute( attrname, strdatatype, attr_dataspace_1);
3852  attribute_string.write(strdatatype, strwritebuf);
3853  attr_dataspace_1.close();
3854  attribute_string.close();
3855 
3856 }

◆ hfile_add_attr2() [1/2]

void Export_Files::Xport::hfile_add_attr2 ( H5::H5File &  hfilehandle,
string  attrname,
int  attrdata[2] 
)

Definition at line 3781 of file export.cpp.

3782  {
3783 //--------------------------------------------------------------
3784 // Add 2D integer attribute
3785 //--------------------------------------------------------------
3786 
3787  hsize_t dims1[1] = { 2 };
3788  H5::DataSpace attr_dataspace_2 = H5::DataSpace (1, dims1 );
3789  H5::Attribute attribute_int = hfilehandle.createAttribute( attrname, H5::PredType::NATIVE_INT,
3790  attr_dataspace_2);
3791  attribute_int.write( H5::PredType::NATIVE_INT, attrdata);
3792  attr_dataspace_2.close();
3793  attribute_int.close();
3794 
3795 }

◆ hfile_add_attr2() [2/2]

void Export_Files::Xport::hfile_add_attr2 ( H5::H5File &  hfilehandle,
string  attrname,
float  attrdata[2] 
)

Definition at line 3821 of file export.cpp.

3822  {
3823 //--------------------------------------------------------------
3824 // Add 2D float attribute
3825 //--------------------------------------------------------------
3826 
3827  hsize_t dims1[1] = { 2 };
3828  H5::DataSpace attr_dataspace_2 = H5::DataSpace (1, dims1 );
3829  H5::Attribute attribute_float = hfilehandle.createAttribute( attrname, H5::PredType::NATIVE_FLOAT,
3830  attr_dataspace_2);
3831  attribute_float.write( H5::PredType::NATIVE_FLOAT, attrdata);
3832  attr_dataspace_2.close();
3833  attribute_float.close();
3834 
3835 }

◆ hfile_add_attr_todataset()

void Export_Files::Xport::hfile_add_attr_todataset ( H5::DataSet &  hdatasethandle,
string  attrname,
string  attrdata 
)

Definition at line 3862 of file export.cpp.

3863  {
3864 //--------------------------------------------------------------
3865 // Add string attribute to a specific dataset
3866 //--------------------------------------------------------------
3867 
3868  hsize_t dims1[1] = { 1 };
3869  H5::DataSpace attr_dataspace_1 = H5::DataSpace (1, dims1 );
3870  H5::StrType strdatatype(H5::PredType::C_S1, 256); // of length 256 characters
3871  H5std_string strwritebuf ( attrdata );
3872  H5::Attribute attribute_string = hdatasethandle.createAttribute( attrname, strdatatype, attr_dataspace_1);
3873  attribute_string.write(strdatatype, strwritebuf);
3874  attr_dataspace_1.close();
3875  attribute_string.close();
3876 
3877 }

◆ hinit_attr()

void Export_Files::Xport::hinit_attr ( H5::H5File &  hfilehandle,
const std::string  tag,
size_t  step,
float  xmax,
float  xmin 
)

Definition at line 3658 of file export.cpp.

References Input::List(), and Export_Files::Header::time.

3660  {
3661 //--------------------------------------------------------------
3662 // Add initial attributes:
3663 // time step, iteration number, name of diagnostic,
3664 // physical time, time units, type, and max and min of axes ranges
3665 //--------------------------------------------------------------
3666 
3667  double dt_out(Input::List().t_stop / Input::List().n_outsteps);
3668 
3669  float dt = { static_cast<float>(
3670  dt_out/static_cast<double>(
3671  size_t(static_cast<int>(dt_out
3672  /Input::List().clf_dp))+1
3673  ))};
3674 
3675  hfile_add_attr(hfilehandle, "DT", dt);
3676 
3677  float time = { static_cast<float>(dt_out*step) };
3678  hfile_add_attr(hfilehandle, "TIME", time);
3679 
3680  hfile_add_attr(hfilehandle, "NAME", tag);
3681 
3682  // float time = { static_cast<float>(dt_out*step*dt) };
3683  // hfile_add_attr(hfilehandle, "TIME", time);
3684 
3685  string timeunits = "1/\\omega_p";
3686  hfile_add_attr(hfilehandle, "TIME UNITS", timeunits);
3687 
3688  string typegrid = "grid";
3689  hfile_add_attr(hfilehandle, "TYPE", typegrid);
3690 
3691  hfile_add_attr(hfilehandle, "XMAX", xmax);
3692 
3693  hfile_add_attr(hfilehandle, "XMIN", xmin);
3694 
3695 }
void hfile_add_attr(H5::H5File &hfilehandle, string attrname, int attrdata)
Definition: export.cpp:3761
Input_List & List()
Definition: input.cpp:1585
Here is the call graph for this function:

◆ hinit_attr2()

void Export_Files::Xport::hinit_attr2 ( H5::H5File &  hfilehandle,
const std::string  tag,
size_t  step,
float  xmax[],
float  xmin[] 
)

Definition at line 3698 of file export.cpp.

References Input::List(), and Export_Files::Header::time.

3700  {
3701 //--------------------------------------------------------------
3702 // Add initial attributes:
3703 // time step, iteration number, name of diagnostic,
3704 // physical time, time units, type, and max and min of axes ranges
3705 //--------------------------------------------------------------
3706 
3707  double dt_out(Input::List().t_stop / Input::List().n_outsteps);
3708 
3709  float dt = { static_cast<float>(
3710  dt_out/static_cast<double>(
3711  size_t(static_cast<int>(dt_out
3712  /Input::List().clf_dp))+1
3713  ))};
3714  hfile_add_attr(hfilehandle, "DT", dt);
3715 
3716  float time = { static_cast<float>(dt_out*step) };
3717  hfile_add_attr(hfilehandle, "TIME", time);
3718 
3719  hfile_add_attr(hfilehandle, "NAME", tag);
3720 
3721  string timeunits = "1/\\omega_p";
3722  hfile_add_attr(hfilehandle, "TIME UNITS", timeunits);
3723 
3724  string typegrid = "grid";
3725  hfile_add_attr(hfilehandle, "TYPE", typegrid);
3726 
3727  hfile_add_attr2(hfilehandle, "XMAX", xmax);
3728 
3729  hfile_add_attr2(hfilehandle, "XMIN", xmin);
3730 
3731 }
void hfile_add_attr(H5::H5File &hfilehandle, string attrname, int attrdata)
Definition: export.cpp:3761
void hfile_add_attr2(H5::H5File &hfilehandle, string attrname, int attrdata[2])
Definition: export.cpp:3781
Input_List & List()
Definition: input.cpp:1585
Here is the call graph for this function:

◆ hmake_file()

H5::H5File Export_Files::Xport::hmake_file ( string  ofilename)

Definition at line 3632 of file export.cpp.

3632  {
3633 //--------------------------------------------------------------
3634 // Create HDF5 file
3635 //--------------------------------------------------------------
3636 
3637  const H5std_string FILE_NAME( ofilename );
3638  H5::H5File file( FILE_NAME, H5F_ACC_TRUNC );
3639  return file;
3640 
3641 }

◆ oH5Fextension()

string Export_Files::Xport::oH5Fextension ( size_t  step,
int  species = -1 
)
private

Definition at line 683 of file export.cpp.

References Export_Files::ofconventions::h5file_extension, Export_Files::ofconventions::ofile_digits, and Export_Files::stringify().

683  {
684 
685  stringstream sFilename;
686 
687  if(species >= 0) sFilename << "_s" << species;
688 
689  sFilename << "_";
690 
691  // Number of zeros to add to the filename
692  int Nzeros(ofconventions::ofile_digits - stringify(step).length());
693  while (Nzeros-- > 0) {
694  sFilename << "0";
695  }
696 
697  sFilename << step << ofconventions::h5file_extension;
698 
699  return sFilename.str();
700 }
std::string stringify(T const &x)
Definition: export.h:30
const string h5file_extension
Definition: export.h:25
Here is the call graph for this function:

Field Documentation

◆ Hdr

map< string, Header > Export_Files::Xport::Hdr
private

Definition at line 206 of file export.h.


The documentation for this class was generated from the following files: