CosmoBolognaLib
Free Software C++/Python libraries for cosmological calculations
TwoPointCorrelation_wedges.h
Go to the documentation of this file.
1 /********************************************************************
2  * Copyright (C) 2010 by Federico Marulli and Alfonso Veropalumbo *
3  * federico.marulli3@unibo.it *
4  * *
5  * This program is free software; you can redistribute it and/or *
6  * modify it under the terms of the GNU General Public License as *
7  * published by the Free Software Foundation; either version 2 of *
8  * the License, or (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public *
16  * License along with this program; if not, write to the Free *
17  * Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ********************************************************************/
20 
35 #ifndef __TWOPOINTWED__
36 #define __TWOPOINTWED__
37 
38 
40 
41 
42 // ===================================================================================================
43 
44 
45 namespace cbl {
46 
47  namespace measure {
48 
49  namespace twopt {
50 
70 
71  protected:
72 
74  int m_nWedges;
75 
77  std::vector<std::vector<double>> m_mu_integral_limits;
78 
103  std::shared_ptr<data::Data> Wedges (const std::vector<double> rr, const std::vector<double> mu, const std::vector<std::vector<double> > xi, const std::vector<std::vector<double> > error_xi) override;
104 
118  std::shared_ptr<data::Data> data_with_extra_info (const std::vector<double> rad, const std::vector<double> wedges, const std::vector<double> error) const;
119 
154  void measurePoisson (const std::string dir_output_pairs = par::defaultString, const std::vector<std::string> dir_input_pairs={}, const bool count_dd=true, const bool count_rr=true, const bool count_dr=true, const bool tcount=true, const Estimator estimator=Estimator::_LandySzalay_, const double fact=0.1) override;
155 
195  void measureJackknife (const std::string dir_output_pairs = par::defaultString, const std::vector<std::string> dir_input_pairs={}, const std::string dir_output_resample = par::defaultString, const bool count_dd=true, const bool count_rr=true, const bool count_dr=true, const bool tcount=true, const Estimator estimator=Estimator::_LandySzalay_, const double fact=0.1) override;
196 
243  void measureBootstrap (const int nMocks, const std::string dir_output_pairs = par::defaultString, const std::vector<std::string> dir_input_pairs={}, const std::string dir_output_resample = par::defaultString, const bool count_dd=true, const bool count_rr=true, const bool count_dr=true, const bool tcount=true, const Estimator estimator=Estimator::_LandySzalay_, const double fact=0.1, const int seed=3213) override;
244 
255  std::vector<std::shared_ptr<data::Data> > XiJackknife (const std::vector<std::shared_ptr<pairs::Pair> > dd, const std::vector<std::shared_ptr<pairs::Pair> > rr) override;
256 
269  std::vector<std::shared_ptr<data::Data> > XiJackknife (const std::vector<std::shared_ptr<pairs::Pair> > dd, const std::vector<std::shared_ptr<pairs::Pair> > rr, const std::vector<std::shared_ptr<pairs::Pair> > dr) override;
270 
285  std::vector<std::shared_ptr<data::Data> > XiBootstrap (const int nMocks, const std::vector<std::shared_ptr<pairs::Pair> > dd, const std::vector<std::shared_ptr<pairs::Pair> > rr, const int seed=3213) override;
286 
304  std::vector<std::shared_ptr<data::Data> > XiBootstrap (const int nMocks, const std::vector<std::shared_ptr<pairs::Pair> > dd, const std::vector<std::shared_ptr<pairs::Pair> > rr, const std::vector<std::shared_ptr<pairs::Pair> > dr, const int seed=3213) override;
305 
306  public:
307 
312 
318 
382  TwoPointCorrelation_wedges (catalogue::Catalogue data, catalogue::Catalogue random, const BinType binType_rad, const double rMin, const double rMax, const int nbins_rad, const double shift_rad, const int nWedges=2, const int nbins_mu=50, const double shift_mu=0.5, const std::vector<std::vector<double>> mu_integral_limits={{0., 0.5}, {0.5, 1.}}, const CoordinateUnits angularUnits=CoordinateUnits::_radians_, std::function<double(double)> angularWeight=nullptr, const bool compute_extra_info=false, const double random_dilution_fraction=1.)
383  : TwoPointCorrelation2D_polar(data, random, binType_rad, rMin, rMax, nbins_rad, shift_rad, BinType::_linear_, 0., 1., nbins_mu, shift_mu, angularUnits, angularWeight, compute_extra_info, random_dilution_fraction)
384  {
386 
387  if (nWedges<2)
388  cbl::ErrorCBL("nWedges must be larger than 2!", "TwoPointCorrelation_wedges", "TwoPointCorrelation_wedges.h");
389 
390  if (int(mu_integral_limits.size())!=nWedges)
391  cbl::ErrorCBL("mu_integral_limits.size()="+cbl::conv(mu_integral_limits.size(), cbl::par::fINT)+" must be equal to nWedges="+cbl::conv(nWedges, cbl::par::fINT), "TwoPointCorrelation_wedges", "TwoPointCorrelation_wedges.h");
392 
393  m_nWedges = nWedges;
395  }
396 
458  TwoPointCorrelation_wedges (catalogue::Catalogue data, catalogue::Catalogue random, const BinType binType_rad, const double rMin, const double rMax, const double binSize_rad, const double shift_rad, const int nWedges=2, const double binSize_mu=1., const double shift_mu=0.5, const std::vector<std::vector<double>> mu_integral_limits={{0., 0.5}, {0.5, 1.}}, const CoordinateUnits angularUnits=CoordinateUnits::_radians_, std::function<double(double)> angularWeight=nullptr, const bool compute_extra_info=false, const double random_dilution_fraction=1.)
459  : TwoPointCorrelation2D_polar(data, random, binType_rad, rMin, rMax, binSize_rad, shift_rad, BinType::_linear_, 0., 1., binSize_mu, shift_mu, angularUnits, angularWeight, compute_extra_info, random_dilution_fraction)
460  {
462 
463  if (nWedges<2)
464  cbl::ErrorCBL("nWedges must be larger than 2!", "TwoPointCorrelation_wedges", "TwoPointCorrelation_wedges.h");
465 
466  if (int(mu_integral_limits.size())!=nWedges)
467  cbl::ErrorCBL("mu_integral_limits.size()="+cbl::conv(mu_integral_limits.size(), cbl::par::fINT)+" must be equal to nWedges="+cbl::conv(nWedges, cbl::par::fINT), "TwoPointCorrelation_wedges", "TwoPointCorrelation_wedges.h");
468 
469  m_nWedges = nWedges;
471  }
472 
478 
480 
486 
491  int nWedges () const
492  { return m_nWedges; }
493 
498  std::vector<std::vector<double>> mu_integral_limits () const
499  { return m_mu_integral_limits; }
500 
505  std::vector<double> xx () const override;
506 
511  std::vector<double> xiPerpendicular () const override;
512 
517  std::vector<double> errorPerpendicular () const override;
518 
523  std::vector<double> xiParallel () const override;
524 
529  std::vector<double> errorParallel () const override;
530 
535  std::vector<double> yy () const
536  { cbl::ErrorCBL("", "yy", "TwoPointCorrelation_wedges.h"); std::vector<double> vv; return vv; }
537 
542  std::vector<double> xi1D () const
543  { cbl::ErrorCBL("", "xi1D", "TwoPointCorrelation_wedges.h"); std::vector<double> vv; return vv; }
544 
551  std::vector<double> error1D () const
552  { cbl::ErrorCBL("", "error1D", "TwoPointCorrelation_wedges.h"); std::vector<double> vv; return vv; }
553 
558  std::vector<std::vector<double> > xi2D () const
559  { cbl::ErrorCBL("", "xi2D", "TwoPointCorrelation_wedges.h"); std::vector<std::vector<double> > vv; return vv; }
560 
567  std::vector<std::vector<double> > error2D () const
568  { cbl::ErrorCBL("", "error2D", "TwoPointCorrelation_wedges.h"); std::vector<std::vector<double> > vv; return vv; }
569 
571 
572 
577 
624  void measure (const ErrorType errorType=ErrorType::_Poisson_, const std::string dir_output_pairs=par::defaultString, const std::vector<std::string> dir_input_pairs={}, const std::string dir_output_resample=par::defaultString, const int nMocks=0, const bool count_dd=true, const bool count_rr=true, const bool count_dr=true, const bool tcount=true, const Estimator estimator=Estimator::_LandySzalay_, const double fact=0.1, const int seed=3213) override;
625 
627 
628 
633 
640  void read (const std::string dir, const std::string file) override
641  { (void)dir; (void)file; ErrorCBL("", "read", "TwoPointCorrelation_wedges.h", glob::ExitCode::_workInProgress_); }
642 
651  void write (const std::string dir=par::defaultString, const std::string file=par::defaultString, const int rank=0) const override;
652 
654 
655 
660 
667  void read_covariance (const std::string dir, const std::string file) override;
668 
675  void write_covariance (const std::string dir, const std::string file) const override;
676 
685  void compute_covariance (const std::vector<std::shared_ptr<data::Data>> xi, const bool JK) override;
686 
696  void compute_covariance (const std::vector<std::string> file, const bool JK) override;
697 
699 
700  };
701  }
702  }
703 }
704 
705 #endif
The class TwoPointCorrelation2D_polar.
The class Catalogue.
Definition: Catalogue.h:654
void measure(const ErrorType errorType=ErrorType::_Poisson_, const std::string dir_output_pairs=par::defaultString, const std::vector< std::string > dir_input_pairs={}, const std::string dir_output_resample=par::defaultString, const int nMocks=0, const bool count_dd=true, const bool count_rr=true, const bool count_dr=true, const bool tcount=true, const Estimator estimator=Estimator::_LandySzalay_, const double fact=0.1, const int seed=3213) override
measure the wedges of the two-point correlation function
std::vector< double > yy() const
get the y coordinates
int nWedges() const
get the number of measured wedges
void write(const std::string dir=par::defaultString, const std::string file=par::defaultString, const int rank=0) const override
write the wedges of the two-point correlation function
std::vector< double > xiParallel() const override
get the parallel wedge
void write_covariance(const std::string dir, const std::string file) const override
write the measured two-point correlation
void measureBootstrap(const int nMocks, const std::string dir_output_pairs=par::defaultString, const std::vector< std::string > dir_input_pairs={}, const std::string dir_output_resample=par::defaultString, const bool count_dd=true, const bool count_rr=true, const bool count_dr=true, const bool tcount=true, const Estimator estimator=Estimator::_LandySzalay_, const double fact=0.1, const int seed=3213) override
measure the wedges of the two-point correlation function estimating the covariance with Bootstrap res...
std::vector< std::shared_ptr< data::Data > > XiBootstrap(const int nMocks, const std::vector< std::shared_ptr< pairs::Pair > > dd, const std::vector< std::shared_ptr< pairs::Pair > > rr, const int seed=3213) override
measure the bootstrap resampling of the wedges of the two-point correlation function
void read_covariance(const std::string dir, const std::string file) override
read the measured covariance matrix
std::shared_ptr< data::Data > Wedges(const std::vector< double > rr, const std::vector< double > mu, const std::vector< std::vector< double > > xi, const std::vector< std::vector< double > > error_xi) override
pointer to the data containing the wedges of the two-point correlation function
void compute_covariance(const std::vector< std::shared_ptr< data::Data >> xi, const bool JK) override
compute the covariance matrix
std::vector< std::vector< double > > m_mu_integral_limits
integral limits used to measure the wedges
std::shared_ptr< data::Data > data_with_extra_info(const std::vector< double > rad, const std::vector< double > wedges, const std::vector< double > error) const
pointer to the data object containing the values of the wedges with the extra info retrieved from the...
~TwoPointCorrelation_wedges()=default
default destructor
std::vector< double > xx() const override
get the x coordinates
std::vector< double > xi1D() const
get the the binned correlation function
void measurePoisson(const std::string dir_output_pairs=par::defaultString, const std::vector< std::string > dir_input_pairs={}, const bool count_dd=true, const bool count_rr=true, const bool count_dr=true, const bool tcount=true, const Estimator estimator=Estimator::_LandySzalay_, const double fact=0.1) override
measure the wedges of the two-point correlation function with Poisson errors
std::vector< std::vector< double > > mu_integral_limits() const
get the integral limits used to measure the wedges
std::vector< std::vector< double > > error2D() const
get the errors on the binned 2D correlation function function
void read(const std::string dir, const std::string file) override
read the wedges of the two-point correlation function
TwoPointCorrelation_wedges(catalogue::Catalogue data, catalogue::Catalogue random, const BinType binType_rad, const double rMin, const double rMax, const int nbins_rad, const double shift_rad, const int nWedges=2, const int nbins_mu=50, const double shift_mu=0.5, const std::vector< std::vector< double >> mu_integral_limits={{0., 0.5}, {0.5, 1.}}, const CoordinateUnits angularUnits=CoordinateUnits::_radians_, std::function< double(double)> angularWeight=nullptr, const bool compute_extra_info=false, const double random_dilution_fraction=1.)
constructor, using the number of bins
std::vector< double > error1D() const
get the error on the binned correlation function function
void measureJackknife(const std::string dir_output_pairs=par::defaultString, const std::vector< std::string > dir_input_pairs={}, const std::string dir_output_resample=par::defaultString, const bool count_dd=true, const bool count_rr=true, const bool count_dr=true, const bool tcount=true, const Estimator estimator=Estimator::_LandySzalay_, const double fact=0.1) override
measure the wedges of the two-point correlation function estimating the covariance with Jackknife res...
std::vector< double > xiPerpendicular() const override
get the perpendicular wedge
std::vector< std::shared_ptr< data::Data > > XiJackknife(const std::vector< std::shared_ptr< pairs::Pair > > dd, const std::vector< std::shared_ptr< pairs::Pair > > rr) override
measure the jackknife resampling of the wedges of the two-point correlation function
TwoPointCorrelation_wedges(catalogue::Catalogue data, catalogue::Catalogue random, const BinType binType_rad, const double rMin, const double rMax, const double binSize_rad, const double shift_rad, const int nWedges=2, const double binSize_mu=1., const double shift_mu=0.5, const std::vector< std::vector< double >> mu_integral_limits={{0., 0.5}, {0.5, 1.}}, const CoordinateUnits angularUnits=CoordinateUnits::_radians_, std::function< double(double)> angularWeight=nullptr, const bool compute_extra_info=false, const double random_dilution_fraction=1.)
constructor, using the bin size
std::vector< std::vector< double > > xi2D() const
get the the binned 2D correlation function
std::vector< double > errorParallel() const override
get the errors on the parallel wedge
std::vector< double > errorPerpendicular() const override
get the errors on the perpendicular wedge
std::shared_ptr< pairs::Pair > dr() const
get the protected member m_dr
std::shared_ptr< catalogue::Catalogue > random() const
get the protected member m_random
bool compute_extra_info() const
get the protected member m_compute_extra_info
bool random_dilution_fraction() const
get the protected member m_random_dilution_fraction
std::shared_ptr< pairs::Pair > rr() const
get the protected member m_rr
std::shared_ptr< pairs::Pair > dd() const
get the protected member m_dd
std::shared_ptr< catalogue::Catalogue > data() const
get the protected member m_data
TwoPType m_twoPType
two-point correlation function type
static const char fINT[]
conversion symbol for: int -> std::string
Definition: Constants.h:121
static const std::string defaultString
default std::string value
Definition: Constants.h:336
@ _workInProgress_
error due to work in progress
Estimator
the two-point correlation estimator
@ _LandySzalay_
Landy&Szalay estimator.
@ _wedges_
the wedges of the two-point correlation function, ξi(r)
ErrorType
the two-point correlation function error type
Definition: Measure.h:59
@ _Poisson_
Poissonian error.
The global namespace of the CosmoBolognaLib
Definition: CAMB.h:38
std::string conv(const T val, const char *fact)
convert a number to a std::string
Definition: Kernel.h:903
int ErrorCBL(const std::string msg, const std::string functionCBL, const std::string fileCBL, const cbl::glob::ExitCode exitCode=cbl::glob::ExitCode::_error_)
throw an exception: it is used for handling exceptions inside the CosmoBolognaLib
Definition: Kernel.h:780
CoordinateUnits
the coordinate units
Definition: Kernel.h:562
@ _radians_
angle in radians
BinType
the binning type
Definition: Kernel.h:505
@ _linear_
linear binning