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

The class Data2D_extra. More...

#include <Data2D_extra.h>

Inheritance diagram for cbl::data::Data2D_extra:
Collaboration diagram for cbl::data::Data2D_extra:

Public Member Functions

Constructors/destructors
 Data2D_extra ()
 default constructor
 
 Data2D_extra (const int n_extra_info, const std::string input_file, const int skip_nlines=0, const std::vector< int > column={1, 2}, const std::vector< int > column_data={}, const std::vector< int > column_errors={}, const std::vector< int > column_edges={})
 constructor which reads the data from file More...
 
 Data2D_extra (const std::vector< double > x, const std::vector< double > y, const std::vector< std::vector< double >> data, const std::vector< std::vector< double >> extra_info, const std::vector< double > bin_edges_x={}, const std::vector< double > bin_edges_y={})
 constructor which gets the data from an input matrix More...
 
 Data2D_extra (const std::vector< double > x, const std::vector< double > y, const std::vector< double > data, const std::vector< double > error, const std::vector< std::vector< double >> extra_info, const std::vector< double > bin_edges_x={}, const std::vector< double > bin_edges_y={})
 constructor which gets both the data and the errors from input matrices More...
 
 Data2D_extra (const std::vector< double > x, const std::vector< double > y, const std::vector< std::vector< double >> data, const std::vector< std::vector< double >> covariance, const std::vector< std::vector< double >> extra_info, const std::vector< double > bin_edges_x={}, const std::vector< double > bin_edges_y={})
 constructor which gets both the data and the covariance matrix from input matrices More...
 
 Data2D_extra (const std::vector< double > x, const std::vector< double > y, const std::vector< double > data, const std::vector< std::vector< double >> covariance, const std::vector< std::vector< double >> extra_info, const std::vector< double > bin_edges_x={}, const std::vector< double > bin_edges_y={})
 constructor which gets both the data and the covariance matrix from input matrices More...
 
virtual ~Data2D_extra ()=default
 default destructor
 
std::shared_ptr< Dataas_factory ()
 static factory used to construct objects of class Data2D_extra More...
 
Member functions used to get the private members
double extra_info (const int i, const int j) const
 return the value of the extra information at index i,j More...
 
std::vector< std::vector< double > > extra_info () const
 return the m_exta_info vector 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...
 
Member functions used to set the private members
void set_extra_info (const std::vector< std::vector< double >> extra_info)
 set the extra info More...
 
Input/Output member functions
virtual void read (const std::string input_file, const int skip_nlines=0, const std::vector< int > column={1, 2}, 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...
 
virtual void write (const std::string dir, const std::string file, const std::string header, const bool full, const int prec=4, const int ww=8, const int rank=0) const override
 write the data More...
 
Member functions for data cut
std::shared_ptr< Datacut (const double xmin, const double xmax, const double ymin, const double ymax) const
 cut the data More...
 
- Public Member Functions inherited from cbl::data::Data2D
 Data2D ()
 default constructor
 
 Data2D (const std::string input_file, const int skip_nlines=0, const std::vector< int > column={1, 2}, const std::vector< int > column_data={}, const std::vector< int > column_errors={}, const std::vector< int > column_edges={})
 constructor which reads the data from file More...
 
 Data2D (const std::vector< double > x, const std::vector< double > y, const std::vector< std::vector< double >> data, const std::vector< double > bin_edges_x={}, const std::vector< double > bin_edges_y={})
 constructor which gets the data from an input matrix More...
 
 Data2D (const std::vector< double > x, const std::vector< double > y, const std::vector< std::vector< double >> data, const std::vector< std::vector< double >> error, const std::vector< double > bin_edges_x={}, const std::vector< double > bin_edges_y={})
 constructor which gets both the data and the errors from input matrices More...
 
 Data2D (const std::vector< double > x, const std::vector< double > y, const std::vector< double > data, const std::vector< double > error, const std::vector< double > bin_edges_x={}, const std::vector< double > bin_edges_y={})
 constructor which gets both the data and the covariance matrix from input vectors More...
 
 Data2D (const std::vector< double > x, const std::vector< double > y, const std::vector< double > data, const std::vector< std::vector< double >> covariance, const std::vector< double > bin_edges_x={}, const std::vector< double > bin_edges_y={})
 constructor which gets both the data and the covariance matrix from input matrices More...
 
 ~Data2D ()=default
 default destructor
 
int xsize () const override
 get the number of points along x More...
 
int ysize () const override
 get the number of points along y More...
 
double xx (const int i) const override
 get the value of x at index i More...
 
std::vector< double > xx () const override
 get the x vector More...
 
double yy (const int i) const override
 get the value of y at index i More...
 
std::vector< double > yy () const override
 get the y vector More...
 
double data (const int i, const int j) const override
 get data at index i,j More...
 
void get_data (std::vector< std::vector< double >> &data) const override
 get data More...
 
double error (const int i, const int j) const override
 get error at index i,j More...
 
void get_error (std::vector< std::vector< double >> &error) const override
 get error More...
 
void set_xx (const std::vector< double > x) override
 set interval variable m_x More...
 
void set_yy (const std::vector< double > y) override
 set interval variable m_y More...
 
void set_edges_xx (const std::vector< double > edges) override
 set interval variable m_edges_xx More...
 
void set_edges_yy (const std::vector< double > edges) override
 set interval variable m_edges_yy More...
 
void write_covariance (const std::string dir, const std::string file, const int precision=10) const override
 write the covariance 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 int j) const
 get value of x at position i,j, for Data1D_collection 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_error (std::vector< double > &error) const
 get standard deviation for Data1D More...
 
virtual void set_xx (const int i, const std::vector< double > x)
 set interval variable m_x in the i-th dataset, for Data1D_collection More...
 
virtual void set_xx (const std::vector< std::vector< double >> x)
 set interval variable m_x, for Data1D_collection More...
 
virtual void set_data (const std::vector< std::vector< double >> data)
 set interval variable m_data, for Data1D_collection, Data2D 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 ndataset () const
 function that returns total number of datasets More...
 
virtual int xsize (const int i) const
 get the number of points along x More...
 
virtual void read (const std::vector< std::string > input_file, const int skip_nlines=0, const std::vector< int > column={0}, const std::vector< int > column_data={}, const std::vector< int > column_errors={}, const std::vector< int > column_edges={})
 read the data from a set of input files More...
 
virtual 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
 write the data More...
 
virtual void write (const std::string dir, const std::vector< std::string > files, const std::string header, 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 int dataset, const double xmin, const double xmax) const
 cut the data, for Data1D_collection More...
 
virtual std::shared_ptr< Datacut (const std::vector< double > xmin, const std::vector< double > xmax) const
 cut the data, for Data1D_collection type 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
std::vector< std::vector< double > > m_extra_info
 extra information
 
- Protected Attributes inherited from cbl::data::Data2D
std::vector< double > m_x
 ordered x axis points
 
std::vector< double > m_y
 ordered y axis points
 
int m_xsize
 number of points along x
 
int m_ysize
 number of points along y
 
- 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 Data2D_extra.

"Headers/Data2D_extra.h"

This is the base class used to manage 2D data with extra information

Definition at line 51 of file Data2D_extra.h.

Constructor & Destructor Documentation

◆ Data2D_extra() [1/5]

cbl::data::Data2D_extra::Data2D_extra ( const int  n_extra_info,
const std::string  input_file,
const int  skip_nlines = 0,
const std::vector< int >  column = {1, 2},
const std::vector< int >  column_data = {},
const std::vector< int >  column_errors = {},
const std::vector< int >  column_edges = {} 
)
inline

constructor which reads the data from file

Parameters
n_extra_infonumber of extra info
input_filethe input data file
skip_nlinesthe header lines to be skipped
columnvector containing the column(s) of x (and y) 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 first column after 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 second column after column will be used by default, assuming that only 1 random vector has to be read; if the input file has less than 4 columns, the errors will be set to 1
column_edgesvector containing the columns of x and y 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

Definition at line 117 of file Data2D_extra.h.

◆ Data2D_extra() [2/5]

cbl::data::Data2D_extra::Data2D_extra ( const std::vector< double >  x,
const std::vector< double >  y,
const std::vector< std::vector< double >>  data,
const std::vector< std::vector< double >>  extra_info,
const std::vector< double >  bin_edges_x = {},
const std::vector< double >  bin_edges_y = {} 
)
inline

constructor which gets the data from an input matrix

Parameters
xvector containing the x values
yvector containing the y values
datamatrix containing the f(x,y) values
extra_infovector containing vectors of extra generic information
bin_edges_xthe x variable bin edges
bin_edges_ythe y variable bin edges

Definition at line 137 of file Data2D_extra.h.

◆ Data2D_extra() [3/5]

cbl::data::Data2D_extra::Data2D_extra ( const std::vector< double >  x,
const std::vector< double >  y,
const std::vector< double >  data,
const std::vector< double >  error,
const std::vector< std::vector< double >>  extra_info,
const std::vector< double >  bin_edges_x = {},
const std::vector< double >  bin_edges_y = {} 
)
inline

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

Parameters
xvector containing the x values
yvector containing the y values
datavector containing the data
errorvector containing the errors
extra_infovector containing vectors of extra generic information
bin_edges_xthe x variable bin edges
bin_edges_ythe y variable bin edges

Definition at line 159 of file Data2D_extra.h.

◆ Data2D_extra() [4/5]

cbl::data::Data2D_extra::Data2D_extra ( const std::vector< double >  x,
const std::vector< double >  y,
const std::vector< std::vector< double >>  data,
const std::vector< std::vector< double >>  covariance,
const std::vector< std::vector< double >>  extra_info,
const std::vector< double >  bin_edges_x = {},
const std::vector< double >  bin_edges_y = {} 
)
inline

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

Parameters
xvector containing the x values
yvector containing the y values
datamatrix containing the data
covariancematrix containing the covariance
extra_infovector containing vectors of extra generic information
bin_edges_xthe x variable bin edges
bin_edges_ythe y variable bin edges

Definition at line 180 of file Data2D_extra.h.

◆ Data2D_extra() [5/5]

cbl::data::Data2D_extra::Data2D_extra ( const std::vector< double >  x,
const std::vector< double >  y,
const std::vector< double >  data,
const std::vector< std::vector< double >>  covariance,
const std::vector< std::vector< double >>  extra_info,
const std::vector< double >  bin_edges_x = {},
const std::vector< double >  bin_edges_y = {} 
)
inline

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

Parameters
xvector containing the x values
yvector containing the y values
datamatrix containing the data
covariancematrix containing the covariance
extra_infovector containing vectors of extra generic information
bin_edges_xthe x variable bin edges
bin_edges_ythe y variable bin edges

Definition at line 201 of file Data2D_extra.h.

Member Function Documentation

◆ as_factory()

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

static factory used to construct objects of class Data2D_extra

Returns
a shared pointer to an object of class Data2D_extra

Reimplemented from cbl::data::Data2D.

Definition at line 214 of file Data2D_extra.h.

◆ cut()

shared_ptr< Data > cbl::data::Data2D_extra::cut ( const double  xmin,
const double  xmax,
const double  ymin,
const double  ymax 
) const
virtual

cut the data

Parameters
xminminumum value for the independent variable x
xmaxmaximum value for the independent variable x
yminminumum value for the independent variable y
ymaxmaximum value for the independent variable y
Returns
pointer to an object of type Data2D

Reimplemented from cbl::data::Data2D.

Definition at line 267 of file Data2D_extra.cpp.

◆ extra_info() [1/2]

std::vector<std::vector<double> > cbl::data::Data2D_extra::extra_info ( ) const
inlinevirtual

return the m_exta_info vector

Returns
vector containing the extra information

Reimplemented from cbl::data::Data.

Definition at line 236 of file Data2D_extra.h.

◆ extra_info() [2/2]

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

return the value of the extra information at index i,j

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

Reimplemented from cbl::data::Data.

Definition at line 230 of file Data2D_extra.h.

◆ IndipendentVariable()

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

get the independet variable, to be used in model computation

Parameters
iindex of the extra_info containing the first independent variable
jindex of the extra_info containing the second independent variable
Returns
the independent variable

Reimplemented from cbl::data::Data2D.

Definition at line 250 of file Data2D_extra.h.

◆ Print()

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

print the data on screen

Parameters
precisionthe float precision

Reimplemented from cbl::data::Data2D.

Definition at line 175 of file Data2D_extra.cpp.

◆ read()

void cbl::data::Data2D_extra::read ( const std::string  input_file,
const int  skip_nlines = 0,
const std::vector< int >  column = {1, 2},
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(s) of x (and y) 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 first column after 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 second column after column will be used by default, assuming that only 1 random vector has to be read; if the input file has less than 4 columns, the errors will be set to 1
column_edgesvector containing the columns of x and y 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

Reimplemented from cbl::data::Data2D.

Definition at line 46 of file Data2D_extra.cpp.

◆ set_extra_info()

void cbl::data::Data2D_extra::set_extra_info ( const std::vector< std::vector< double >>  extra_info)
inlinevirtual

set the extra info

Parameters
extra_infovector containing vectors with extra info

Reimplemented from cbl::data::Data.

Definition at line 270 of file Data2D_extra.h.

◆ write()

void cbl::data::Data2D_extra::write ( const std::string  dir,
const std::string  file,
const std::string  header,
const bool  full,
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
fullfalse → simply store the data; true → duplicate the data in the other three quadrands (usefull e.g. when storing the 2D correlation function)
precthe floating point precision for the output file
wwnumber of characters to be used as field width
rankcpu index (for MPI usage)

Reimplemented from cbl::data::Data2D.

Definition at line 195 of file Data2D_extra.cpp.


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