CosmoBolognaLib
Free Software C++/Python libraries for cosmological calculations
cbl::data::Data1D_collection Class Reference

The class Data1D_collection. More...

#include <Data1D_collection.h>

Inheritance diagram for cbl::data::Data1D_collection:
Collaboration diagram for cbl::data::Data1D_collection:

Public Member Functions

Constructors/destructors
 Data1D_collection ()
 default constructor More...
 
 Data1D_collection (const std::string input_file, const int skip_header=0)
 constructor which reads the data from file More...
 
 Data1D_collection (const std::vector< std::string > input_files, const int skip_header=0)
 constructor which reads the data from a vector of input files More...
 
 Data1D_collection (const std::vector< std::vector< double >> xx, const std::vector< std::vector< double >> data)
 constructor which gets the data from input matrices More...
 
 Data1D_collection (const std::vector< std::vector< double >> xx, const std::vector< std::vector< double >> data, const std::vector< std::vector< double >> covariance)
 constructor which gets both the data and the covariance matrix from input matrices More...
 
 Data1D_collection (const std::vector< std::vector< double >> xx, const std::vector< double > data, const std::vector< double > error)
 constructor which gets both the data and the errors from input vectors More...
 
 Data1D_collection (const std::vector< std::vector< double >> xx, const std::vector< double > data, const std::vector< std::vector< double >> covariance)
 constructor which gets both the data and the covariance matrix from input vectors More...
 
virtual ~Data1D_collection ()=default
 default destructor
 
std::shared_ptr< Dataas_factory ()
 static factory used to construct objects of class Data1D More...
 
Member functions used to get the private members
int xsize (const int i) const
 get the number of points along x More...
 
double xx (const int i, const int j) const
 get value of x at index j in the i-th dataset More...
 
void xx (std::vector< std::vector< double > > x) const
 get x values More...
 
std::vector< std::vector< double > > IndipendentVariable (const int i=-1, const int j=-1) const
 get the independet variable, to be used in model computation More...
 
double data (const int i, const int j) const
 get data at index i,j More...
 
void data (std::vector< std::vector< double >> &data) const
 get data More...
 
double error (const int i, const int j) const
 get value of f(x) error at index i,j More...
 
void error (std::vector< std::vector< double >> &error) const
 get standard deviation More...
 
Member functions used to set the private members
void set_xx (const int i, const std::vector< double > x)
 set interval variable m_x in the i-th dataset More...
 
Member functions to compute data properties
int ndataset () const
 function that returns total number of datasets More...
 
void read (const std::string input_file, const int skip_nlines=0, const std::vector< int > column={1}, const std::vector< int > column_data={}, const std::vector< int > column_errors={}, const std::vector< int > column_edges={}) override
 read the data More...
 
void read (const std::vector< std::string > input_files, const int skip_nlines=0, const std::vector< int > column={1}, const std::vector< int > column_data={}, const std::vector< int > column_errors={}, const std::vector< int > column_edges={}) override
 read the data More...
 
virtual void Print (const int precision=4) const override
 print the data on screen More...
 
void write (const std::string dir, const std::string file, const std::string header, const int prec=4, const int ww=8, const int rank=0) const override
 write the data More...
 
void write (const std::string dir, const std::vector< std::string > files, const std::string header, const int precision=10, const int ww=8, const int rank=0) const override
 write the data More...
 
void write_covariance (const std::string dir, const std::string file, const int precision=10) const override
 write the interval variable m_covariance on a file, More...
 
Member functions for data cut
std::shared_ptr< Datacut (const int dataset, const double xmin, const double xmax) const override
 cut the data, for Data1D_collection More...
 
std::shared_ptr< Datacut (const std::vector< double > xmin, const std::vector< double > xmax) const override
 cut the data, for Data1D_collection type More...
 
- Public Member Functions inherited from cbl::data::Data
double correlation (const int i, const int j) const
 get the value of the data correlation at index i,j More...
 
std::vector< std::vector< double > > correlation () const
 get the value of the data correlation at index i,j More...
 
double inverse_covariance (const int i, const int j) const
 get the value of data inverse_covariance at index i,j More...
 
std::vector< std::vector< double > > inverse_covariance () const
 get the m_inverse_covariance std::vector More...
 
void reset (const int ndata)
 reset data object with new empty arrays large enough to store ndata data More...
 
virtual void invert_covariance (const double prec, const int Nres)
 invert the covariance matrix More...
 
virtual double xx (const int i) const
 get value of x at index i More...
 
virtual std::vector< double > xx () const
 get the x std::vector More...
 
virtual double yy (const int i) const
 get value of y at index i, for Data2D More...
 
virtual std::vector< double > yy () const
 get the y std::vector More...
 
virtual void get_data (std::vector< double > &data) const
 get data for Data1D More...
 
virtual DataType dataType () const
 get the data type More...
 
virtual int ndata () const
 the total number of data More...
 
virtual double data (const int i) const
 get data at index i More...
 
virtual std::vector< double > data () const
 get data More...
 
virtual double error (const int i) const
 get value of data standard deviation at index i More...
 
virtual std::vector< double > error () const
 get standard deviation More...
 
virtual double covariance (const int i, const int j) const
 get the value of the data covariance at index i,j More...
 
virtual std::vector< std::vector< double > > covariance () const
 get the m_covariance vector More...
 
virtual double edges_xx (const int i) const
 get value of x variable bin edge at index i More...
 
virtual std::vector< double > edges_xx () const
 get x variable bin edges More...
 
virtual double edges_yy (const int i) const
 get value of y variable bin edge at index i More...
 
virtual std::vector< double > edges_yy () const
 get y variable bin edges More...
 
virtual void get_data (std::vector< std::vector< double >> &data) const
 get data for Data1D_collection, Data2D More...
 
virtual void get_error (std::vector< double > &error) const
 get standard deviation for Data1D More...
 
virtual void get_error (std::vector< std::vector< double >> &error) const
 get standard deviation for Data1D_Collection, Data2D More...
 
virtual double extra_info (const int i, const int j) const
 return the value of the extra information at index i,j More...
 
virtual std::vector< std::vector< double > > extra_info () const
 return the m_exta_info std::vector More...
 
virtual void set_xx (const std::vector< double > x)
 set interval variable m_x More...
 
virtual void set_yy (const std::vector< double > y)
 set interval variable m_y, for Data2D More...
 
virtual void set_xx (const std::vector< std::vector< double >> x)
 set interval variable m_x, for Data1D_collection More...
 
virtual void set_edges_xx (const std::vector< double > edges)
 set interval variable m_edges_xx More...
 
virtual void set_edges_yy (const std::vector< double > edges)
 set interval variable m_edges_yy More...
 
virtual void set_data (const std::vector< std::vector< double >> data)
 set interval variable m_data, for Data1D_collection, Data2D More...
 
virtual void set_extra_info (const std::vector< std::vector< double >> extra_info)
 set interval variable m_error_fx More...
 
void set_data (const std::vector< double > data)
 set interval variable data More...
 
void set_error (const std::vector< double > error)
 set interval variable m_error_fx More...
 
void set_error (const std::vector< std::vector< double >> covariance)
 set interval variable m_error_fx More...
 
void set_covariance (const std::string filename, const int cov_col=2, const int skipped_lines=0)
 set the interval variable m_covariance, reading from an input file More...
 
void set_covariance (const double value, const int i, const int j)
 set interval the variable m_covariance More...
 
void set_covariance (const std::vector< std::vector< double >> covariance)
 set interval the variable m_covariance More...
 
void set_covariance (const std::vector< double > error)
 set interval the variable m_covariance More...
 
virtual int ndata (const int i) const
 function that returns number of data for one dataset, for Data1D_collection More...
 
virtual int xsize () const
 get the number of points along x More...
 
virtual int ysize () const
 get the number of points along y More...
 
virtual void write (const std::string dir, const std::string file, const std::string header, const bool full, const int prec=10, const int ww=8, const int rank=0) const
 write the data More...
 
void cut (const std::vector< bool > mask, std::vector< double > &data, std::vector< double > &error, std::vector< std::vector< double >> &covariance_matrix) const
 cut the dataset using a mask More...
 
virtual std::shared_ptr< Datacut (const std::vector< bool > mask) const
 cut the data, for Data1D More...
 
virtual std::shared_ptr< Datacut (const double xmin, const double xmax) const
 cut the data, for Data1D More...
 
virtual std::shared_ptr< Datacut (const double xmin, const double xmax, const double ymin, const double ymax) const
 cut the data, for Data2D More...
 
 Data ()=default
 default constructor
 
 Data (const DataType dataType)
 constructor which sets only the data type More...
 
 Data (const DataType dataType, const int ndata)
 constructor which sets both the data type and the number of data More...
 
 Data (const DataType dataType, const std::vector< double > data)
 constructor which gets the data from an input vector More...
 
 Data (const DataType dataType, const std::vector< double > data, const std::vector< double > error)
 constructor which gets both the data and the errors from input vectors More...
 
 Data (const DataType dataType, const std::vector< double > data, const std::vector< std::vector< double >> covariance)
 constructor which gets both the data and the covariance matrix from input vectors More...
 
virtual ~Data ()=default
 default destructor
 

Protected Attributes

Data input
int m_ndataset
 The number of datasets.
 
std::vector< int > m_xsize
 vector containing the number of data in each dataset
 
std::vector< std::vector< double > > m_x
 vector containing indipendent variables
 
std::vector< std::vector< int > > m_index
 vector containing matrix-to-vector indexes
 
- Protected Attributes inherited from cbl::data::Data
DataType m_dataType
 type of data
 
int m_ndata
 number of data
 
std::vector< double > m_data
 data values
 
std::vector< double > m_error
 standard deviations
 
std::vector< double > m_edges_xx
 bin edges for the x variable
 
std::vector< double > m_edges_yy
 bin edges for the y variable
 
std::vector< std::vector< double > > m_covariance
 covariance matrix
 
std::vector< std::vector< double > > m_inverse_covariance
 inverse covariance matrix
 

Additional Inherited Members

- Static Public Member Functions inherited from cbl::data::Data
static std::shared_ptr< DataCreate (const DataType dataType)
 static factory used to construct objects of class Data1D More...
 
- Protected Member Functions inherited from cbl::data::Data
void set_dataType (const DataType dataType)
 set the data type More...
 

Detailed Description

The class Data1D_collection.

"Headers/Data1D_collection.h"

This is the base class used to manage collections of 1D data

Definition at line 50 of file Data1D_collection.h.

Constructor & Destructor Documentation

◆ Data1D_collection() [1/7]

cbl::data::Data1D_collection::Data1D_collection ( )
inline

default constructor

1D

Definition at line 85 of file Data1D_collection.h.

◆ Data1D_collection() [2/7]

cbl::data::Data1D_collection::Data1D_collection ( const std::string  input_file,
const int  skip_header = 0 
)

constructor which reads the data from file

Parameters
input_filefile with datasets
skip_headernumber of lines to be skipped

1D_collection

Definition at line 45 of file Data1D_collection.cpp.

◆ Data1D_collection() [3/7]

cbl::data::Data1D_collection::Data1D_collection ( const std::vector< std::string >  input_files,
const int  skip_header = 0 
)

constructor which reads the data from a vector of input files

Parameters
input_filesfiles with datasets
skip_headernumber of lines to be skipped

1D_collection

Definition at line 55 of file Data1D_collection.cpp.

◆ Data1D_collection() [4/7]

cbl::data::Data1D_collection::Data1D_collection ( const std::vector< std::vector< double >>  xx,
const std::vector< std::vector< double >>  data 
)

constructor which gets the data from input matrices

Parameters
xxvector containing the independent variable xx for each dataset
datavector containing the data for each dataset

1D_collection

Definition at line 65 of file Data1D_collection.cpp.

◆ Data1D_collection() [5/7]

cbl::data::Data1D_collection::Data1D_collection ( const std::vector< std::vector< double >>  xx,
const std::vector< std::vector< double >>  data,
const std::vector< std::vector< double >>  covariance 
)

constructor which gets both the data and the covariance matrix from input matrices

Parameters
xxvector containing the independent variable xx for each dataset
datavector containing the data for each dataset
covariancevector containing the data covariance

1D_collection

Definition at line 100 of file Data1D_collection.cpp.

◆ Data1D_collection() [6/7]

cbl::data::Data1D_collection::Data1D_collection ( const std::vector< std::vector< double >>  xx,
const std::vector< double >  data,
const std::vector< double >  error 
)

constructor which gets both the data and the errors from input vectors

Parameters
xxvector containing the independent variable xx for each dataset
datavector containing the data for each dataset
errorvector containing the data error

1D_collection

Definition at line 144 of file Data1D_collection.cpp.

◆ Data1D_collection() [7/7]

cbl::data::Data1D_collection::Data1D_collection ( const std::vector< std::vector< double >>  xx,
const std::vector< double >  data,
const std::vector< std::vector< double >>  covariance 
)

constructor which gets both the data and the covariance matrix from input vectors

Parameters
xxvector containing the independent variable xx for each dataset
datavector containing the data for each dataset
covariancevector containing the data covariance

1D_collection

Definition at line 174 of file Data1D_collection.cpp.

Member Function Documentation

◆ as_factory()

std::shared_ptr<Data> cbl::data::Data1D_collection::as_factory ( )
inlinevirtual

static factory used to construct objects of class Data1D

Returns
a shared pointer to an object of class Data

Reimplemented from cbl::data::Data.

Definition at line 178 of file Data1D_collection.h.

◆ cut() [1/2]

shared_ptr< Data > cbl::data::Data1D_collection::cut ( const int  dataset,
const double  xmin,
const double  xmax 
) const
overridevirtual

cut the data, for Data1D_collection

Parameters
datasetthe i-th dataset
xminminumum value for the independet variable x
xmaxmaximum value for the independent variable x
Returns
pointer to an object of type Data1D

Reimplemented from cbl::data::Data.

Definition at line 444 of file Data1D_collection.cpp.

◆ cut() [2/2]

shared_ptr< Data > cbl::data::Data1D_collection::cut ( const std::vector< double >  xmin,
const std::vector< double >  xmax 
) const
overridevirtual

cut the data, for Data1D_collection type

Parameters
xminvector containing minumum values for the independet variable x
xmaxvector containing maximum values for the independent variable x
Returns
pointer to an object of type Data1D_collection

Reimplemented from cbl::data::Data.

Definition at line 482 of file Data1D_collection.cpp.

◆ data() [1/2]

double cbl::data::Data1D_collection::data ( const int  i,
const int  j 
) const
inlinevirtual

get data at index i,j

Parameters
iindex
jindex
Returns
the value of the m_data vector at position i,j

Reimplemented from cbl::data::Data.

Definition at line 230 of file Data1D_collection.h.

◆ data() [2/2]

void cbl::data::Data1D_collection::data ( std::vector< std::vector< double >> &  data) const

get data

Parameters
[out]datavector containing the dataset

Definition at line 207 of file Data1D_collection.cpp.

◆ error() [1/2]

double cbl::data::Data1D_collection::error ( const int  i,
const int  j 
) const
inlinevirtual

get value of f(x) error at index i,j

Parameters
iindex
jindex
Returns
the value of the m_error vector at position i,j

Reimplemented from cbl::data::Data.

Definition at line 248 of file Data1D_collection.h.

◆ error() [2/2]

void cbl::data::Data1D_collection::error ( std::vector< std::vector< double >> &  error) const

get standard deviation

Parameters
[out]errorvector containing the error

Definition at line 224 of file Data1D_collection.cpp.

◆ IndipendentVariable()

std::vector<std::vector<double> > cbl::data::Data1D_collection::IndipendentVariable ( const int  i = -1,
const int  j = -1 
) const
inlinevirtual

get the independet variable, to be used in model computation

Parameters
iindex (not used)
jindex (not used)
Returns
the independent variable

Reimplemented from cbl::data::Data.

Definition at line 219 of file Data1D_collection.h.

◆ ndataset()

int cbl::data::Data1D_collection::ndataset ( ) const
inlinevirtual

function that returns total number of datasets

Returns
total number of dataset

Reimplemented from cbl::data::Data.

Definition at line 284 of file Data1D_collection.h.

◆ Print()

void cbl::data::Data1D_collection::Print ( const int  precision = 4) const
overridevirtual

print the data on screen

Parameters
precisionthe float precision

Reimplemented from cbl::data::Data.

Definition at line 360 of file Data1D_collection.cpp.

◆ read() [1/2]

void cbl::data::Data1D_collection::read ( const std::string  input_file,
const int  skip_nlines = 0,
const std::vector< int >  column = {1},
const std::vector< int >  column_data = {},
const std::vector< int >  column_errors = {},
const std::vector< int >  column_edges = {} 
)
overridevirtual

read the data

Parameters
input_fileinput data file
skip_nlinesthe header lines to be skipped
columnvector containing the column of x values in the input file; if it is not provided, the first column will be used by default
column_datathe column of data values in the input file; the size of column_data is the number of data to be read (e.g. the size should be 3 in the case of the 3 multipole moments of the two-point correlation function); if the size of column_data is larger than 1, more than 1 data vectors are read and then added one after the other in a single data object; if column_data is not provided, the second column will be used by default, assuming that only 1 data vector has to be read
column_errorsthe column of error values in the input file; the size of column_error must be equal to the size of column_data; if the size of column_error is larger than 1, more than 1 error vectors are read and then added one after the other in a single data object; if column_random is not provided, the third column will be used by default, assuming that only 1 random vector has to be read; if the input file has only 2 columns, the errors will be set to 1
column_edgesvector containing the columns of x bin edge values in the input file; if it is not provided, the third and four columns after the column of x values will be used; if these columns do no exist the edges are not read
Warning
column, column_data, column_errors, column_edges are not used in the current implementation: work in progress!

Reimplemented from cbl::data::Data.

Definition at line 241 of file Data1D_collection.cpp.

◆ read() [2/2]

void cbl::data::Data1D_collection::read ( const std::vector< std::string >  input_files,
const int  skip_nlines = 0,
const std::vector< int >  column = {1},
const std::vector< int >  column_data = {},
const std::vector< int >  column_errors = {},
const std::vector< int >  column_edges = {} 
)
overridevirtual

read the data

Parameters
input_filesinput data files
skip_nlinesthe header lines to be skipped
columnvector containing the column of x values in the input file; if it is not provided, the first column will be used by default
column_datathe column of data values in the input file; the size of column_data is the number of data to be read (e.g. the size should be 3 in the case of the 3 multipole moments of the two-point correlation function); if the size of column_data is larger than 1, more than 1 data vectors are read and then added one after the other in a single data object; if column_data is not provided, the second column will be used by default, assuming that only 1 data vector has to be read
column_errorsthe column of error values in the input file; the size of column_error must be equal to the size of column_data; if the size of column_error is larger than 1, more than 1 error vectors are read and then added one after the other in a single data object; if column_random is not provided, the third column will be used by default, assuming that only 1 random vector has to be read; if the input file has only 2 columns, the errors will be set to 1
column_edgesvector containing the columns of x bin edge values in the input file; if it is not provided, the third and four columns after the column of x values will be used; if these columns do no exist the edges are not read
Warning
column, column_data, column_errors, column_edges are not used in the current implementation: work in progress!

Reimplemented from cbl::data::Data.

Definition at line 304 of file Data1D_collection.cpp.

◆ set_xx()

void cbl::data::Data1D_collection::set_xx ( const int  i,
const std::vector< double >  x 
)
inlinevirtual

set interval variable m_x in the i-th dataset

Parameters
iindex to the i-th dataset
xvector containing x points

Reimplemented from cbl::data::Data.

Definition at line 271 of file Data1D_collection.h.

◆ write() [1/2]

void cbl::data::Data1D_collection::write ( const std::string  dir,
const std::string  file,
const std::string  header,
const int  prec = 4,
const int  ww = 8,
const int  rank = 0 
) const
overridevirtual

write the data

Parameters
diroutput directory
fileoutput file
headertext with the variable names to be written at the first line of the output file
precthe float precision
wwnumber of characters to be used as field width
rankcpu index (for MPI usage)

Reimplemented from cbl::data::Data.

Definition at line 380 of file Data1D_collection.cpp.

◆ write() [2/2]

void cbl::data::Data1D_collection::write ( const std::string  dir,
const std::vector< std::string >  files,
const std::string  header,
const int  precision = 10,
const int  ww = 8,
const int  rank = 0 
) const
overridevirtual

write the data

Parameters
diroutput directory
filesoutput files
headertext with the variable names to be written at the first line of the output file
precisionthe float precision
wwnumber of characters to be used as field width
rankcpu index (for MPI usage)

Reimplemented from cbl::data::Data.

Definition at line 413 of file Data1D_collection.cpp.

◆ write_covariance()

void cbl::data::Data1D_collection::write_covariance ( const std::string  dir,
const std::string  file,
const int  precision = 10 
) const
overridevirtual

write the interval variable m_covariance on a file,

Parameters
dirthe output directory
filethe output file
precisionthe float precision

Reimplemented from cbl::data::Data.

Definition at line 527 of file Data1D_collection.cpp.

◆ xsize()

int cbl::data::Data1D_collection::xsize ( const int  i) const
inlinevirtual

get the number of points along x

Parameters
iindex to the i-th dataset
Returns
the number of points along x

Reimplemented from cbl::data::Data.

Definition at line 188 of file Data1D_collection.h.

◆ xx() [1/2]

double cbl::data::Data1D_collection::xx ( const int  i,
const int  j 
) const
inlinevirtual

get value of x at index j in the i-th dataset

Parameters
ithe i-th dataset
jindex
Returns
the value of the x vector at position j in the i-th dataset

Reimplemented from cbl::data::Data.

Definition at line 200 of file Data1D_collection.h.

◆ xx() [2/2]

void cbl::data::Data1D_collection::xx ( std::vector< std::vector< double > >  x) const
inline

get x values

Parameters
x[out] the x values

Definition at line 207 of file Data1D_collection.h.


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