#include <NDArrIOV1.h>
Public Types | |
typedef TDATA | data_t |
typedef unsigned | shape_t |
LOADED = 1 | |
DEFAULT | |
UNREADABLE | |
UNDEFINED | |
enum | STATUS { LOADED = 1, DEFAULT, UNREADABLE, UNDEFINED } |
Public Member Functions | |
NDArrIOV1 (const std::string &fname, const unsigned print_bits=0377) | |
Three constructors provide different default initialization. Each of them create an object which holds the file name and pointer (0 before load) to ndarray. File name can be specified later in the get_ndarray(fname) method, but print_file() and print_ndarray() methods will complain about missing file name until it is specified. Constructor with missing default initialization. Empty ndarray will be returned if constants from file can not be loaded. | |
NDArrIOV1 (const std::string &fname, const shape_t *shape_def, const TDATA &val_def=TDATA(0), const unsigned print_bits=0377) | |
Constructor with default ndarray of specified shape filled by a single value. | |
NDArrIOV1 (const std::string &fname, const ndarray< const TDATA, NDIM > &nda_def, const unsigned print_bits=0377) | |
Constructor with externally defined default ndarray. | |
~NDArrIOV1 () | |
Destructor. | |
unsigned int | ndim () const |
Returns number of dimensions of ndarray. | |
void | print () |
void | print_file () |
Prints input file line-by-line. | |
void | print_ndarray () |
Loads (if necessary) ndarray from file and print it. | |
ndarray< TDATA, NDIM > & | get_ndarray (const std::string &fname=std::string()) |
Loads (if necessary) ndarray from file and returns it. | |
std::string | str_status () |
Returns string with status of calibration constants. | |
STATUS | status () |
Returns enumerated status of calibration constants. | |
std::string | str_ndarray_info () |
Returns string with info about ndarray. | |
std::string | str_shape () |
Returns string of shape. | |
Static Public Member Functions | |
static void | save_ndarray (const ndarray< const TDATA, NDIM > &nda, const std::string &fname, const std::vector< std::string > &vcoms=std::vector< std::string >(), const unsigned &print_bits=0377) |
Static method to save ndarray in file with internal metadata and external comments. |
# line of comment always begins with # # Mandatory fields to define the ndarray<TYPE,NDIM> and its shape as unsigned shape[NDIM] = {DIM:1,DIM:2,DIM:3} # TYPE float # NDIM 3 # DIM:1 3 # DIM:2 4 # DIM:3 8 21757 21769 33464 10769 68489 68561 77637 54810 ... other data lines 21757 21773 33430 10628 68349 68345 77454 54729
#include "pdscalibdata/NDArrIOV1.h" typedef pdscalibdata::NDArrIOV1<float,3> NDAIO;
std::string fname("path/pedestals/0-end.data"); // mandatory parameter unsigned print_bits(0377); // optional parameter ARRIO* arrio = new ARRIO(fname, print_bits);
std::string fname("path/pedestals/0-end.data"); // mandatory parameter unsigned shape[] = {2,3,4}; // mandatory parameter TYPE val_def = 123; // optional parameter unsigned print_bits(0377); // optional parameter ARRIO* arrio = new ARRIO(fname, shape, data_def, print_bits);
CalibPars::common_mode_t data_def[] = {1, 50, 10, Size};
ndarray<CalibPars::common_mode_t,1> nda = make_ndarray(&data_def[0], 4);
ARRIO* arrio = new ARRIO(fname, nda, print_bits);
const ndarray<const float,3>& nda = arrio -> get_ndarray(); // returns ndarray // or const ndarray<const float,3>& nda = arrio -> get_ndarray(fname); // returns ndarray std::string& str_status = arrio -> status(); // returns status comment
arrio -> print(); // prints recognized templated parameters arrio -> print_file(); // prints input file line-by-line arrio -> print_ndarray(); // prints ndarray
NDAIO::save_ndarray(nda, fname);
std::vector<std::string> comments; comments.push_back("TITLE File to load ndarray of calibration parameters"); comments.push_back("EXPERIMENT amo12345"); comments.push_back("DETECTOR Camp.0:pnCCD.1"); comments.push_back("CALIB_TYPE pedestals"); unsigned print_bits=1; NDAIO::save_ndarray(nda, fname, comments, print_bits);
# TITLE File to load ndarray of calibration parameters # # EXPERIMENT amo12345 # DETECTOR Camp.0:pnCCD.1 # CALIB_TYPE pedestals # DATE_TIME 2014-05-06 15:24:10 # AUTHOR <user-login-name> # Metadata for ndarray<float,3> # TYPE float # NDIM 3 # DIM:0 3 # DIM:1 4 # DIM:2 8 21757 21769 33464 10769 68489 68561 77637 54810 ... 102 40 272 270 194 246 60 118
Definition at line 179 of file NDArrIOV1.h.
typedef TDATA pdscalibdata::NDArrIOV1< TDATA, NDIM >::data_t |
Definition at line 185 of file NDArrIOV1.h.
typedef unsigned pdscalibdata::NDArrIOV1< TDATA, NDIM >::shape_t |
Definition at line 186 of file NDArrIOV1.h.
enum pdscalibdata::NDArrIOV1::STATUS |
pdscalibdata::NDArrIOV1< TDATA, NDIM >::NDArrIOV1 | ( | const std::string & | fname, | |
const unsigned | print_bits = 0377 | |||
) |
Three constructors provide different default initialization. Each of them create an object which holds the file name and pointer (0 before load) to ndarray. File name can be specified later in the get_ndarray(fname) method, but print_file() and print_ndarray() methods will complain about missing file name until it is specified. Constructor with missing default initialization. Empty ndarray will be returned if constants from file can not be loaded.
[in] | fname | - std::string file name |
[in] | print_bits | - unsigned bit-word to control verbosity |
Definition at line 35 of file NDArrIOV1.cpp.
pdscalibdata::NDArrIOV1< TDATA, NDIM >::NDArrIOV1 | ( | const std::string & | fname, | |
const shape_t * | shape_def, | |||
const TDATA & | val_def = TDATA(0) , |
|||
const unsigned | print_bits = 0377 | |||
) |
Constructor with default ndarray of specified shape filled by a single value.
[in] | fname | - std::string file name |
[in] | shape_def | - default shape of the ndarray (is used for shape crosscheck at readout and in case of missing file or metadata) |
[in] | val_def | - value to fill all data elements by default(in case of missing file or metadata) |
[in] | print_bits | - unsigned bit-word to control verbosity |
Definition at line 51 of file NDArrIOV1.cpp.
pdscalibdata::NDArrIOV1< TDATA, NDIM >::NDArrIOV1 | ( | const std::string & | fname, | |
const ndarray< const TDATA, NDIM > & | nda_def, | |||
const unsigned | print_bits = 0377 | |||
) |
Constructor with externally defined default ndarray.
[in] | fname | - std::string file name |
[in] | nda_def | - default ndarray, which will be returned if file is missing |
[in] | print_bits | - unsigned bit-word to control verbosity |
Definition at line 72 of file NDArrIOV1.cpp.
pdscalibdata::NDArrIOV1< TDATA, NDIM >::~NDArrIOV1 | ( | ) |
ndarray< TDATA, NDIM > & pdscalibdata::NDArrIOV1< TDATA, NDIM >::get_ndarray | ( | const std::string & | fname = std::string() |
) |
Loads (if necessary) ndarray from file and returns it.
[in] | fname | std::string file name |
Definition at line 324 of file NDArrIOV1.cpp.
Referenced by PSCalib::GenericCalibPars< TBASE >::common_mode(), main(), PSCalib::GenericCalibPars< TBASE >::pedestals(), PSCalib::GenericCalibPars< TBASE >::pixel_bkgd(), PSCalib::GenericCalibPars< TBASE >::pixel_gain(), PSCalib::GenericCalibPars< TBASE >::pixel_mask(), PSCalib::GenericCalibPars< TBASE >::pixel_rms(), PSCalib::GenericCalibPars< TBASE >::pixel_status(), PSCalib::GenericCalibPars< TBASE >::shape_of_ndarray(), PSCalib::GenericCalibPars< TBASE >::size_of_ndarray(), and test_cspad2x2().
unsigned int pdscalibdata::NDArrIOV1< TDATA, NDIM >::ndim | ( | ) | const [inline] |
Returns number of dimensions of ndarray.
Definition at line 232 of file NDArrIOV1.h.
Referenced by pdscalibdata::NDArrIOV1< TDATA, NDIM >::print(), pdscalibdata::NDArrIOV1< TDATA, NDIM >::print_ndarray(), pdscalibdata::NDArrIOV1< TDATA, NDIM >::save_ndarray(), pdscalibdata::NDArrIOV1< TDATA, NDIM >::str_ndarray_info(), and pdscalibdata::NDArrIOV1< TDATA, NDIM >::str_shape().
void pdscalibdata::NDArrIOV1< TDATA, NDIM >::print | ( | ) |
Access methods prints recognized templated parameters.
Definition at line 345 of file NDArrIOV1.cpp.
References pdscalibdata::NDArrIOV1< TDATA, NDIM >::ndim().
Referenced by main().
void pdscalibdata::NDArrIOV1< TDATA, NDIM >::print_file | ( | ) |
void pdscalibdata::NDArrIOV1< TDATA, NDIM >::print_ndarray | ( | ) |
Loads (if necessary) ndarray from file and print it.
Definition at line 388 of file NDArrIOV1.cpp.
References pdscalibdata::NDArrIOV1< TDATA, NDIM >::ndim().
Referenced by main().
void pdscalibdata::NDArrIOV1< TDATA, NDIM >::save_ndarray | ( | const ndarray< const TDATA, NDIM > & | nda, | |
const std::string & | fname, | |||
const std::vector< std::string > & | vcoms = std::vector< std::string >() , |
|||
const unsigned & | print_bits = 0377 | |||
) | [static] |
Static method to save ndarray in file with internal metadata and external comments.
[in] | nda | ndarray to save in file |
[in] | fname | std::string file name to save ndarray |
[in] | vcoms | std::vector<std::string> vector of strings with comments; one-string comment per vector entry |
[in] | print_bits | for output control; 0-print nothing, +1-info about saved files |
Definition at line 437 of file NDArrIOV1.cpp.
References pdscalibdata::NDArrIOV1< TDATA, NDIM >::ndim(), pdscalibdata::strEnvVar(), and pdscalibdata::strTimeStamp().
Referenced by main().
STATUS pdscalibdata::NDArrIOV1< TDATA, NDIM >::status | ( | ) | [inline] |
std::string pdscalibdata::NDArrIOV1< TDATA, NDIM >::str_ndarray_info | ( | ) |
Returns string with info about ndarray.
Definition at line 405 of file NDArrIOV1.cpp.
References pdscalibdata::NDArrIOV1< TDATA, NDIM >::ndim().
std::string pdscalibdata::NDArrIOV1< TDATA, NDIM >::str_shape | ( | ) |
Returns string of shape.
Definition at line 425 of file NDArrIOV1.cpp.
References pdscalibdata::NDArrIOV1< TDATA, NDIM >::ndim().
std::string pdscalibdata::NDArrIOV1< TDATA, NDIM >::str_status | ( | ) |