![]() |
CosmoBolognaLib
Free Software C++/Python libraries for cosmological calculations
|
#include <Data.h>

Public Member Functions | |
Non-virtual member functions | |
| 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... | |
Member functions to get the private/protected members | |
| 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 | xx (const int i, const int j) const |
| get value of x at position i,j, for Data1D_collection 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 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... | |
| virtual double | data (const int i, const int j) const |
| get data at index i,j for Data1D_collection, Data2D 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 double | error (const int i, const int j) const |
| get value of f(x) error at index i,j 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... | |
Member functions to set the private/protected members | |
| 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 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_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... | |
Member functions to compute data properties | |
| 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 |
| get the number of points along x More... | |
| virtual int | xsize (const int i) const |
| get the number of points along x More... | |
| virtual int | ysize () const |
| get the number of points along y More... | |
Member functions for Input/Output | |
| virtual void | read (const 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 one input file 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 | Print (const int prec=4) const |
| print the data on screen 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::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... | |
| 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... | |
| virtual void | write_covariance (const std::string dir, const std::string file, const int precision=10) const |
| write the interval variable m_covariance on a file, More... | |
Member functions for data cut | |
| 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< Data > | cut (const std::vector< bool > mask) const |
| cut the data, for Data1D More... | |
| virtual std::shared_ptr< Data > | cut (const double xmin, const double xmax) const |
| cut the data, for Data1D More... | |
| virtual std::shared_ptr< Data > | cut (const double xmin, const double xmax, const double ymin, const double ymax) const |
| cut the data, for Data2D More... | |
| virtual std::shared_ptr< Data > | cut (const int dataset, const double xmin, const double xmax) const |
| cut the data, for Data1D_collection More... | |
| virtual std::shared_ptr< Data > | cut (const std::vector< double > xmin, const std::vector< double > xmax) const |
| cut the data, for Data1D_collection type More... | |
Protected Member Functions | |
| void | set_dataType (const DataType dataType) |
| set the data type More... | |
Protected Attributes | |
| 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 | |
Constructors/destructors | |
| 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 | |
| virtual std::shared_ptr< Data > | as_factory () |
| static factory used to construct objects of class Data1D More... | |
| static std::shared_ptr< Data > | Create (const DataType dataType) |
| static factory used to construct objects of class Data1D More... | |
|
inline |
|
inline |
| cbl::data::Data::Data | ( | const DataType | dataType, |
| const std::vector< double > | data | ||
| ) |
| cbl::data::Data::Data | ( | const DataType | dataType, |
| const std::vector< double > | data, | ||
| const std::vector< double > | error | ||
| ) |
| cbl::data::Data::Data | ( | const DataType | dataType, |
| const std::vector< double > | data, | ||
| const std::vector< std::vector< double >> | covariance | ||
| ) |
|
inlinevirtual |
static factory used to construct objects of class Data1D
Reimplemented in cbl::data::Data2D_extra, cbl::data::Data2D, cbl::data::Data1D_extra, cbl::data::Data1D_collection, and cbl::data::Data1D.
| std::vector< std::vector< double > > cbl::data::Data::correlation | ( | ) | const |
|
inline |
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
cut the data, for Data1D
| xmin | minumum value for the independet variable x |
| xmax | maximum value for the independent variable x |
Reimplemented in cbl::data::Data1D_extra, and cbl::data::Data1D.
|
inlinevirtual |
cut the data, for Data2D
| xmin | minumum value for the independent variable x |
| xmax | maximum value for the independent variable x |
| ymin | minumum value for the independent variable y |
| ymax | maximum value for the independent variable y |
Reimplemented in cbl::data::Data2D_extra, and cbl::data::Data2D.
|
inlinevirtual |
cut the data, for Data1D_collection
| dataset | the dataset index |
| xmin | minumum value for the independet variable x |
| xmax | maximum value for the independent variable x |
Reimplemented in cbl::data::Data1D_collection.
|
inlinevirtual |
cut the data, for Data1D
| [in] | mask | std::vector containing values to be masked |
Reimplemented in cbl::data::Data1D_extra, and cbl::data::Data1D.
| void cbl::data::Data::cut | ( | const std::vector< bool > | mask, |
| std::vector< double > & | data, | ||
| std::vector< double > & | error, | ||
| std::vector< std::vector< double >> & | covariance_matrix | ||
| ) | const |
|
inlinevirtual |
cut the data, for Data1D_collection type
| xmin | std::vector containing minumum values for the independet variable x |
| xmax | std::vector containing maximum values for the independent variable x |
Reimplemented in cbl::data::Data1D_collection.
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
get data at index i,j for Data1D_collection, Data2D
| i | index |
| j | index |
Reimplemented in cbl::data::Data2D, and cbl::data::Data1D_collection.
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
get value of f(x) error at index i,j for Data1D_collection, Data2D
| i | index |
| j | index |
Reimplemented in cbl::data::Data2D, and cbl::data::Data1D_collection.
|
inlinevirtual |
return the m_exta_info std::vector
Reimplemented in cbl::data::Data1D_extra, and cbl::data::Data2D_extra.
|
inlinevirtual |
return the value of the extra information at index i,j
| i | index |
| j | index |
Reimplemented in cbl::data::Data1D_extra, and cbl::data::Data2D_extra.
|
inlinevirtual |
get data for Data1D
| [out] | data | std::vector containing the dataset |
Reimplemented in cbl::data::Data1D.
|
inlinevirtual |
get data for Data1D_collection, Data2D
| [out] | data | std::vector containing the dataset |
Reimplemented in cbl::data::Data2D.
|
inlinevirtual |
get standard deviation for Data1D
| [out] | error | std::vector containing the staandard deviation |
Reimplemented in cbl::data::Data1D.
|
inlinevirtual |
get standard deviation for Data1D_Collection, Data2D
| [out] | error | std::vector containing the staandard deviation |
Reimplemented in cbl::data::Data2D.
|
inlinevirtual |
get the independet variable, to be used in model computation
| i | first indipendent variable index |
| j | second indipendent variable index |
Reimplemented in cbl::data::Data2D, cbl::data::Data1D, cbl::data::Data2D_extra, cbl::data::Data1D_extra, and cbl::data::Data1D_collection.
|
inline |
|
inline |
|
inlinevirtual |
invert the covariance matrix
| prec | the precision required in the inversion of the covariance matrix |
| Nres | \(N_{res}\), the number of catalogue resamplings used to estimate the covariance matrix; \(N_{res}=-1\) if the covariance matrix has not been estimated with resampling methods |
|
inlinevirtual |
|
inlinevirtual |
function that returns number of data for one dataset, for Data1D_collection
| i | index to the i-th dataset |
|
inlinevirtual |
function that returns total number of datasets
Reimplemented in cbl::data::Data1D_collection.
|
inlinevirtual |
print the data on screen
| prec | the float precision |
Reimplemented in cbl::data::Data2D_extra, cbl::data::Data2D, cbl::data::Data1D_extra, cbl::data::Data1D_collection, and cbl::data::Data1D.
|
inlinevirtual |
read the data from one input file
| input_file | the input data file |
| skip_nlines | the header lines to be skipped |
| column | vector 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_data | the 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 the column of x values will be used by default, assuming that only 1 data vector has to be read |
| column_errors | the 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 the column of x values 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_edges | vector 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 in cbl::data::Data1D_extra, cbl::data::Data1D_collection, cbl::data::Data1D, cbl::data::Data2D_extra, and cbl::data::Data2D.
|
inlinevirtual |
read the data from a set of input files
| input_file | vector containing the input data files |
| skip_nlines | the header lines to be skipped |
| column | vector 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_data | the 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 the column of x values will be used by default, assuming that only 1 data vector has to be read |
| column_errors | the 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 the column of x values 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_edges | vector 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 in cbl::data::Data1D_collection.
| void cbl::data::Data::reset | ( | const int | ndata | ) |
|
inline |
| void cbl::data::Data::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
| filename | file containing the covariance matrix in the format: column 0 \( \rightarrow \) xi, column 1 \( \rightarrow \) xj, column cov_col → cov(xi,xj) |
| cov_col | covariance matrix column, starting from 0 |
| skipped_lines | comment lines to be skipped |
| void cbl::data::Data::set_covariance | ( | const std::vector< double > | error | ) |
| void cbl::data::Data::set_covariance | ( | const std::vector< std::vector< double >> | covariance | ) |
| void cbl::data::Data::set_data | ( | const std::vector< double > | data | ) |
|
inlinevirtual |
set interval variable m_data, for Data1D_collection, Data2D
| data | std::vector containing data points |
|
inlineprotected |
|
inlinevirtual |
set interval variable m_edges_xx
| edges | std::vector containing the x bin edges |
Reimplemented in cbl::data::Data2D, and cbl::data::Data1D.
|
inlinevirtual |
set interval variable m_edges_yy
| edges | std::vector containing the y bin edges |
Reimplemented in cbl::data::Data2D.
| void cbl::data::Data::set_error | ( | const std::vector< double > | error | ) |
| void cbl::data::Data::set_error | ( | const std::vector< std::vector< double >> | covariance | ) |
|
inlinevirtual |
set interval variable m_error_fx
| extra_info | std::vector containing std::vectors with extra information |
Reimplemented in cbl::data::Data1D_extra, and cbl::data::Data2D_extra.
|
inlinevirtual |
set interval variable m_x in the i-th dataset, for Data1D_collection
| i | index to the i-th dataset |
| x | std::vector containing x points |
Reimplemented in cbl::data::Data1D_collection.
|
inlinevirtual |
set interval variable m_x
| x | std::vector containing x points |
Reimplemented in cbl::data::Data2D, and cbl::data::Data1D.
|
inlinevirtual |
set interval variable m_x, for Data1D_collection
| x | std::vector containing x points |
|
inlinevirtual |
set interval variable m_y, for Data2D
| y | std::vector containing y points |
Reimplemented in cbl::data::Data2D.
|
inlinevirtual |
write the data
| dir | output directory |
| file | output file |
| header | text with the variable names to be written at the first line of the output file |
| full | false → simply store the data; true → duplicate the data in the other three quadrands (usefull e.g. when storing the 2D correlation function) |
| prec | the float precision |
| ww | number of characters to be used as field width |
| rank | cpu index (for MPI usage) |
Reimplemented in cbl::data::Data2D_extra, and cbl::data::Data2D.
|
inlinevirtual |
write the data
| dir | output directory |
| file | output file |
| header | text with the variable names to be written at the first line of the output file |
| prec | the float precision |
| ww | number of characters to be used as field width |
| rank | cpu index (for MPI usage) |
Reimplemented in cbl::data::Data1D_extra, cbl::data::Data1D_collection, and cbl::data::Data1D.
|
inlinevirtual |
write the data
| dir | output directory |
| files | output file |
| header | text with the variable names to be written at the first line of the output file |
| prec | the float precision |
| ww | number of characters to be used as field width |
| rank | cpu index (for MPI usage) |
Reimplemented in cbl::data::Data1D_collection.
|
inlinevirtual |
write the interval variable m_covariance on a file,
| dir | the output directory |
| file | the output file |
| precision | the float precision |
Reimplemented in cbl::data::Data2D, cbl::data::Data1D_collection, and cbl::data::Data1D.
|
inlinevirtual |
get the number of points along x
Reimplemented in cbl::data::Data2D, and cbl::data::Data1D.
|
inlinevirtual |
get the number of points along x
| i | index to the i-th dataset |
Reimplemented in cbl::data::Data1D_collection.
|
inlinevirtual |
get the x std::vector
Reimplemented in cbl::data::Data2D, and cbl::data::Data1D.
|
inlinevirtual |
get value of x at index i
| i | index |
Reimplemented in cbl::data::Data2D, and cbl::data::Data1D.
|
inlinevirtual |
get value of x at position i,j, for Data1D_collection
| i | index |
| j | index |
Reimplemented in cbl::data::Data1D_collection.
|
inlinevirtual |
get the number of points along y
Reimplemented in cbl::data::Data2D.
|
inlinevirtual |
|
inlinevirtual |
get value of y at index i, for Data2D
| i | index |
Reimplemented in cbl::data::Data2D.