CosmoBolognaLib
Free Software C++/Python libraries for cosmological calculations
Catalogue.h
Go to the documentation of this file.
1 /********************************************************************
2  * Copyright (C) 2015 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 __CATALOGUE__
36 #define __CATALOGUE__
37 
38 #include "Cosmology.h"
39 #include "Field3D.h"
40 #include "ChainMesh.h"
41 #include "Object.h"
42 #include "RandomObject.h"
43 #include "Halo.h"
44 #include "Mock.h"
45 #include "Galaxy.h"
46 #include "Cluster.h"
47 #include "Void.h"
48 #include "HostHalo.h"
49 #include "ChainMeshCell.h"
50 
51 // ============================================================================================
52 
53 
54 namespace cbl {
55 
64  namespace catalogue {
65 
70  enum class Var {
71 
73  _X_,
74 
76  _Y_,
77 
79  _Z_,
80 
82  _RA_,
83 
85  _Dec_,
86 
88  _TileRA_,
89 
91  _TileDec_,
92 
94  _SN_,
95 
97  _Redshift_,
98 
101 
104 
106  _Shear1_,
107 
109  _Shear2_,
110 
116  _ODDS_,
117 
120 
123 
125  _Dc_,
126 
128  _Weight_,
129 
131  _Mass_,
132 
134  _Magnitude_,
135 
137  _MagnitudeU_,
138 
140  _MagnitudeG_,
141 
143  _MagnitudeR_,
144 
146  _MagnitudeI_,
147 
149  _SFR_,
150 
152  _sSFR_,
153 
155  _MassProxy_,
156 
159 
161  _Mstar_,
162 
164  _MassInfall_,
165 
167  _IDHOST_,
168 
170  _GalaxyTag_,
171 
173  _Vx_,
174 
176  _Vy_,
177 
179  _Vz_,
180 
182  _Region_,
183 
185  _Radius_,
186 
189 
192 
195 
198 
201 
204 
207 
210 
212  _XCM_,
213 
215  _YCM_,
216 
218  _ZCM_,
219 
221  _XSpin_,
222 
224  _YSpin_,
225 
227  _ZSpin_,
228 
230  _VelDisp_,
231 
233  _Vmax_,
234 
236  _VmaxRad_,
237 
239  _TotMass_,
240 
242  _ID_,
243 
245  _Nsub_,
246 
248  _Parent_,
249 
251  _Generic_
252 
253  };
254 
266  typedef std::function<bool(const std::shared_ptr<Object> obj)> mask_function;
267 
277  struct MaskObject {
287  virtual bool operator() (const std::shared_ptr<Object> obj) const {(void) obj; return true;}
288 
292  virtual ~MaskObject () {}
293  };
294 
295 
302  inline std::vector<std::string> VarNames ()
303  { return {"X", "Y", "Z", "RA", "Dec", "SN", "Redshift", "RedshiftMin", "RedshiftMax", "Shear1", "Shear2", "ODDS", "LensingWeight", "LensingCalib", "Dc", "Weight", "Mass", "Magnitude", "MagnitudeU", "MagnitudeG", "MagnitudeR", "MagnitudeI", "SFR", "sSFR", "MassProxy", "MassProxyError", "Mstar", "MassInfall", "IDHOST", "GalaxyTag", "Vx", "Vy", "Vz", "Region", "Radius", "DensityContrast", "CentralDensity", "X_displacement", "Y_displacement", "Z_displacement", "MassGas", "MassHalo", "MassDisk", "MassBulge", "MassStars", "MassBndry", "MassEstimate", "RadiusEstimate", "VeldispEstimate", "XCM", "YCM", "ZCM", "XSpin", "YSpin", "ZSpin", "VelDisp", "Vmax", "VmaxRad", "TotMass", "Generic"}; }
304 
311  inline Var VarCast (const int varIndex)
312  { return castFromValue<Var>(varIndex); }
313 
320  inline Var VarCast (const std::string varName)
321  { return castFromName<Var>(varName, VarNames()); }
322 
329  inline std::vector<Var> VarCast (const std::vector<int> varIndeces)
330  { return castFromValues<Var>(varIndeces); }
331 
338  inline std::vector<Var> VarCast (const std::vector<std::string> varNames)
339  { return castFromNames<Var>(varNames, VarNames()); }
340 
345  enum class RandomType {
346 
349 
352 
355 
358 
361 
364 
367 
370 
373  };
374 
381  inline std::vector<std::string> RandomTypeNames ()
382  { return {"createRandom_box", "createRandom_square","createRandom_shuffle","createRandom_shuffleTOT","createRandom_cone","createRandom_MANGLE","createRandom_VIPERS", "createRandom_SDSS_stripes"}; }
383 
390  inline RandomType RandomTypeCast (const int randomTypeIndex)
391  { return castFromValue<RandomType>(randomTypeIndex); }
392 
399  inline RandomType RandomTypeCast (const std::string randomTypeName)
400  { return castFromName<RandomType>(randomTypeName, RandomTypeNames()); }
401 
408  inline std::vector<RandomType> RandomTypeCast (const std::vector<int> randomTypeIndeces)
409  { return castFromValues<RandomType>(randomTypeIndeces); }
410 
417  inline std::vector<RandomType> RandomTypeCast (const std::vector<std::string> randomTypeNames)
418  { return castFromNames<RandomType>(randomTypeNames, RandomTypeNames()); }
419 
426  enum class HODType {
427 
429  _Zehavi05_,
430 
432  _Zehavi11_,
433 
435  _Moster10_,
436 
437  };
438 
445  inline std::vector<std::string> HODTypeNames ()
446  { return {"Zehavi05", "Zehavi11", "Moster10"}; }
447 
452  enum class VoidAlgorithm {
453 
455  _LaZeVo_,
456 
459  _Exact_
460 
461  };
462 
469  inline std::vector<std::string> VoidAlgorithmNames ()
470  { return {"LaZeVo", "Exact"}; }
471 
476  enum class CharEncode {
477 
479  _ascii_,
480 
482  _binary_
483 
484  };
485 
492  inline std::vector<std::string> CharEncodeNames ()
493  { return {"ascii", "binary"}; }
494 
499  enum class EstimateCriterion {
500 
502  _m200_,
503 
505  _c200_,
506 
508  _t200_
509 
510  };
511 
518  inline std::vector<std::string> EstimateCriterionNames ()
519  { return {"m200", "c200", "t200"}; }
520 
527  inline EstimateCriterion EstimateCriterionCast (const int estimateCriterionIndex)
528  { return castFromValue<EstimateCriterion>(estimateCriterionIndex); }
529 
536  inline EstimateCriterion EstimateCriterionCast (const std::string estimateCriterionName)
537  { return castFromName<EstimateCriterion>(estimateCriterionName, EstimateCriterionNames()); }
538 
545  inline std::vector<EstimateCriterion> EstimateCriterionCast (const std::vector<int> estimateCriterionIndeces)
546  { return castFromValues<EstimateCriterion>(estimateCriterionIndeces); }
547 
554  inline std::vector<EstimateCriterion> EstimateCriterionCast (const std::vector<std::string> estimateCriterionNames)
555  { return castFromNames<EstimateCriterion>(estimateCriterionNames, EstimateCriterionNames()); }
556 
561  struct Gadget_Header {
562 
564  int npart[6];
565 
567  double massarr[6];
568 
570  double time;
571 
573  double redshift;
574 
576  int flag_sfr;
577 
580 
582  int npartTotal[6];
583 
586 
588  int nfiles;
589 
591  double boxsize;
592 
594  double omega0;
595 
597  double omegaLambda;
598 
600  double hubblePar;
601 
604 
607 
610 
613 
615  short la[40];
616  };
617 
623 
625  uint32_t Ngroups;
626 
628  uint32_t totNgroups;
629 
631  uint32_t Nids;
632 
634  uint64_t totNids;
635 
637  uint32_t Ntask;
638 
640  uint32_t Nsubs;
641 
643  uint32_t totNsubs;
644  };
645 
654  class Catalogue {
655 
656  private :
657 
659  std::vector<std::shared_ptr<Object>> m_object;
660 
662  std::vector<int> m_index;
663 
665  size_t m_nRegions = 0;
666 
671 
674 
684  SubFindTab_Header m_read_header (std::ifstream& finh, const bool swap=false);
685 
694 
703 
713  void m_check_it_in (std::ifstream& finr, const bool swap);
714 
724  void m_check_it_out (std::ifstream &finr, const bool swap);
725 
727 
728 
729  public :
730 
735 
739  Catalogue () = default;
740 
746  Catalogue (const Catalogue& obj)
747  {
748  // the copied object is emptied to avoid conflicts
749  // (e.g. for the subCatalogue function)
750  std::vector<bool> mask(m_object.size(), true);
751  remove_objects(mask);
752  // m_objects is copied through the use of the getShared()
753  // function that allows to copy also the variables of the derived Object classes
754  for (size_t i=0; i<obj.m_object.size(); ++i) {
755  m_object.emplace_back(obj.m_object[i]->getShared());
756  }
757  m_nRegions = obj.m_nRegions;
758  }
759 
766  {
767  // the copied object is emptied to avoid conflicts
768  // (e.g. for the subCatalogue function)
769  std::vector<bool> mask(m_object.size(), true);
770  remove_objects(mask);
771  // m_objects is copied through the use of the getShared()
772  // function that allows to copy also the variables of the derived Object classes
773  for (size_t i=0; i<obj.m_object.size(); ++i) {
774  m_object.emplace_back(obj.m_object[i]->getShared());
775  // Original object pointers are reset
776  obj.m_object[i].reset();
777  }
778  m_nRegions = std::move(obj.m_nRegions);
779  }
780 
787  {
788  // the copied object is emptied to avoid conflicts
789  // (e.g. for the subCatalogue function)
790  std::vector<bool> mask(m_object.size(), true);
791  remove_objects(mask);
792  // m_objects is copied through the use of the getShared()
793  // function that allows to copy also the variables of the derived Object classes
794  for (size_t i=0; i<obj.m_object.size(); ++i)
795  m_object.emplace_back(obj.m_object[i]->getShared());
796  m_nRegions = obj.m_nRegions;
797  return *this;
798  }
799 
805  Catalogue& operator=(Catalogue&& obj) noexcept
806  {
807  if (this == &obj) return *this;
808  // the copied object is emptied to avoid conflicts
809  // (e.g. for the subCatalogue function)
810  std::vector<bool> mask(m_object.size(), true);
811  remove_objects(mask);
812  // m_objects is copied through the use of the getShared()
813  // function that allows to copy also the variables of the derived Object classes
814  for (size_t i=0; i<obj.m_object.size(); ++i) {
815  // Original object pointers are reset
816  m_object.emplace_back(obj.m_object[i]->getShared());
817  obj.m_object[i].reset();
818  }
819  m_nRegions = std::move(obj.m_nRegions);
820  return *this;
821  }
822 
852  Catalogue (const ObjectType objectType, const CoordinateType coordinateType, const std::vector<double> coord1, const std::vector<double> coord2, const std::vector<double> coord3, const std::vector<double> weight={}, const cosmology::Cosmology &cosm={}, const CoordinateUnits inputUnits=CoordinateUnits::_radians_);
853 
881  Catalogue (const ObjectType objectType, const CoordinateType coordinateType, const std::vector<double> coord1, const std::vector<double> coord2, const std::vector<double> coord3, const cosmology::Cosmology &cosm, const CoordinateUnits inputUnits=CoordinateUnits::_radians_)
882  : Catalogue(objectType, coordinateType, coord1, coord2, coord3, {}, cosm, inputUnits) {}
883 
935  Catalogue (const ObjectType objectType, const CoordinateType coordinateType, const std::vector<std::string> file, const int col1=1, const int col2=2, const int col3=3, const int colWeight=-1, const int colRegion=-1, const double nSub=1.1, const double fact=1., const cosmology::Cosmology &cosm={}, const CoordinateUnits inputUnits=CoordinateUnits::_radians_, const CharEncode charEncode=CharEncode::_ascii_, const std::string comment="#", const int seed=3213);
936 
955  Catalogue (const ObjectType objectType, const CoordinateType coordinateType, const std::vector<std::string> file, const cosmology::Cosmology &cosm, const CoordinateUnits inputUnits=CoordinateUnits::_radians_)
956  : Catalogue(objectType, coordinateType, file, 1, 2, 3, -1, -1, 1.1, 1., cosm, inputUnits, CharEncode::_ascii_) {}
957 
1002  Catalogue (const ObjectType objectType, const CoordinateType coordinateType, const std::vector<Var> attribute, const std::vector<int> column, const std::vector<std::string> file, const int comments=0, const double nSub=1.1, const double fact=1, const cosmology::Cosmology &cosm={}, const CoordinateUnits inputUnits=CoordinateUnits::_radians_, const char delimiter='\t', const int seed=3213);
1003 
1044  Catalogue (const ObjectType objectType, const CoordinateType coordinateType, const std::vector<std::string> file, const std::vector<std::string> column_names, const bool read_weights, const bool read_regions, const double nSub, const double fact, const cosmology::Cosmology &cosm={}, const CoordinateUnits inputUnits=CoordinateUnits::_radians_, const int seed=3213);
1045 
1083  Catalogue (const ObjectType objectType, const CoordinateType coordinateType, const std::vector<std::string> file, const std::vector<std::string> column_names, const std::vector<Var> attribute, const double nSub, const double fact, const cosmology::Cosmology &cosm={}, const CoordinateUnits inputUnits=CoordinateUnits::_radians_, const int seed=3213);
1084 
1085 
1091  template<typename T> Catalogue (std::vector<T> object)
1092  {
1093  for (size_t i=0; i<object.size(); i++)
1094  m_object.push_back(move(std::make_shared<T>(T(object[i]))));
1095  }
1096 
1103  Catalogue (std::vector<std::shared_ptr<Object> > sample) {
1104  for (auto &&i : sample)
1105  m_object.push_back(move(i));
1106  }
1107 
1132  Catalogue (const ObjectType objectType, const std::vector<Var> attribute, const std::vector<int> column, const std::vector<std::string> file, const int comments=0, const double nSub=1.1, const int seed=3213);
1133 
1149  Catalogue (const Catalogue input_catalogue, const Catalogue target_catalogue, const Var var_name, const int nbin, const int seed=3213);
1150 
1171  Catalogue (const Catalogue input_catalogue, const Catalogue target_catalogue, const cbl::catalogue::Var var_name1, const int nbin1, const cbl::catalogue::Var var_name2, const int nbin2, const int seed=3213);
1172 
1268  Catalogue (const Catalogue halo_catalogue, const cosmology::Cosmology &cosm, const HODType HOD_Type, const double threshold, const bool substructures=true, std::vector<double> parameter={});
1269 
1273  ~Catalogue () = default;
1274 
1276 
1277 
1282 
1310  Catalogue (const RandomType type, const cosmology::Cosmology &real_cosm, const cosmology::Cosmology &test_cosm, const std::string dir_in, const double Zguess_min, const double Zguess_max);
1311 
1364  Catalogue (const RandomType type, const Catalogue catalogue, const double N_R, const int nbin=10, const cosmology::Cosmology &cosm={}, const bool conv=false, const double sigma=0., const std::vector<double> redshift={}, const std::vector<double> RA={}, const std::vector<double> Dec={}, int z_ndigits=10, const int seed=3213);
1365 
1463  Catalogue (const RandomType type, const int N_R, const double z_step, const Catalogue catalogue, const cosmology::Cosmology &cosm={}, const std::vector<double> RA={}, const std::vector<double> Dec={}, const double sigma_kernel=0.01, const int nbins=100, int z_ndigits=10, const int times_default = 5, double times_change = 0.5, const double tolerance = 0.05, const std::string out_path_nz=par::defaultString, const std::string out_file_nz=par::defaultString, const int seed=3213);
1464 
1499  Catalogue (const RandomType type, const Catalogue catalogue, const double N_R, const int nbin, const double Angle, const std::vector<double> redshift, const cosmology::Cosmology &cosm={}, const bool conv=false, const double sigma=0., const int seed=3213);
1500 
1534  Catalogue (const RandomType type, const std::vector<std::string> mangle_mask, const Catalogue catalogue, const double N_R, const int nbin, const cosmology::Cosmology cosm, const bool conv=false, const double sigma=0., const int seed=3213);
1535 
1571  Catalogue (const RandomType type, const Catalogue catalogue, const double N_R, const bool dndz_per_stripe, const int nbin, const cosmology::Cosmology cosm, const bool conv=false, const double sigma=0, const int seed=3213);
1572 
1573 
1598  Catalogue (const RandomType type, Catalogue catalogue, const double N_R, const cosmology::Cosmology cosm, const std::vector<double> RA_range, const std::vector<double> DEC_range, const unsigned int nbin, const int seed);
1599 
1601 
1602  Catalogue (const RandomType type, const std::string WField, const bool isSpectroscopic, const Catalogue catalogue, const Catalogue catalogue_for_nz, const double N_R, const cosmology::Cosmology &cosm, const int step_redshift, const std::vector<double> lim, const double redshift_min, const double redshift_max, const bool do_convol, const double sigma, const bool use_venice, const bool do_zdistr_with_venice, const std::string file_random, const std::string mask, const std::string pointing_file, const std::string dir_venice, const int seed);
1603 
1606 
1611 
1659  Catalogue (const VoidAlgorithm algorithm, Catalogue tracer_catalogue, Catalogue random_catalogue, const std::string dir_output, const std::string output, const double cellsize, const int n_rec=1, const double step_size=2.5/3., const double threshold=0., const std::vector<bool> print={true, true});
1660 
1712  Catalogue (const VoidAlgorithm algorithm, Catalogue tracer_catalogue, Catalogue random_catalogue, const std::string dir_output, const std::string output, const double cellsize, const cbl::cosmology::Cosmology cosm, const std::vector<double> RA_range, const std::vector<double> DEC_range, const int n_rec=1, const double step_size=2.5/3., const double threshold=0.);
1714 
1715 
1720 
1750  Catalogue (const ObjectType objectType, const std::string file_cn=par::defaultString, const bool snapformat=false, const bool swap=false, const double fact=0.001, const bool read_catalogue=true, const double nSub=1.1, const std::string component_to_read="ALL", const std::vector<std::vector<double>> edges={{par::defaultDouble,par::defaultDouble},{par::defaultDouble,par::defaultDouble},{par::defaultDouble,par::defaultDouble}});
1751 
1787  Catalogue (const int snap, const std::string basedir, const bool swap=false, const bool long_ids=false, const double scaleFact=1.0, const double massFact=1.0, const EstimateCriterion estimate_crit=EstimateCriterion::_m200_, const bool veldisp=false, const bool masstab=false, const bool add_satellites=false, const bool verbose=false);
1788 
1790 
1795 
1800  std::vector<std::shared_ptr<Object> > sample () const { return m_object; };
1801 
1807  double xx (const int i) const { return m_object[i]->xx(); };
1808 
1814  double yy (const int i) const { return m_object[i]->yy(); };
1815 
1821  double zz (const int i) const { return m_object[i]->zz(); };
1822 
1828  double vx (const int i) const { return m_object[i]->vx(); };
1829 
1835  double vy (const int i) const { return m_object[i]->vy(); };
1836 
1842  double vz (const int i) const { return m_object[i]->vz(); };
1843 
1849  double dc (const int i) const { return m_object[i]->dc(); };
1850 
1856  double ra (const int i) const { return m_object[i]->ra(); };
1857 
1863  double dec (const int i) const { return m_object[i]->dec(); };
1864 
1870  double ra_tile (const int i) const { return m_object[i]->ra_tile(); };
1871 
1877  double dec_tile (const int i) const { return m_object[i]->dec_tile(); };
1878 
1884  double sn (const int i) const { return m_object[i]->sn(); };
1885 
1891  double redshift (const int i) const { return m_object[i]->redshift(); };
1892 
1898  double redshiftMin (const int i) const { return m_object[i]->redshiftMin(); };
1899 
1905  double redshiftMax (const int i) const { return m_object[i]->redshiftMax(); };
1906 
1912  double shear1 (const int i) const { return m_object[i]->shear1(); };
1913 
1919  double shear2 (const int i) const { return m_object[i]->shear2(); };
1920 
1926  double odds (const int i) const { return m_object[i]->odds(); };
1927 
1933  double lensingWeight (const int i) const { return m_object[i]->lensingWeight(); };
1934 
1940  double lensingCalib (const int i) const { return m_object[i]->lensingCalib(); };
1941 
1947  double weight (const int i) const { return m_object[i]->weight(); };
1948 
1954  long region (const int i) const { return m_object[i]->region(); };
1955 
1961  std::string field (const int i) const { return m_object[i]->field(); };
1962 
1969  double x_displacement (const int i) const { return m_object[i]->x_displacement(); };
1970 
1977  double y_displacement (const int i) const { return m_object[i]->y_displacement(); };
1978 
1985  double z_displacement (const int i) const { return m_object[i]->z_displacement(); };
1986 
1992  size_t nRegions ();
1993 
2000  std::vector<long> region_list () const;
2001 
2008  std::vector<std::string> field_list () const { return different_elements(field()); }
2009 
2016  size_t nFields () const { return N_different_elements(field()); }
2017 
2023  double mass (const int i) const { return m_object[i]->mass(); }
2024 
2030  double magnitude (const int i) const { return m_object[i]->magnitude(); }
2031 
2037  double magnitudeU (const int i) const { return m_object[i]->magnitudeU(); }
2038 
2044  double magnitudeG (const int i) const { return m_object[i]->magnitudeG(); }
2045 
2051  double magnitudeR (const int i) const { return m_object[i]->magnitudeR(); }
2052 
2058  double magnitudeI (const int i) const { return m_object[i]->magnitudeI(); }
2059 
2065  double radius (const int i) const { return m_object[i]->radius(); }
2066 
2072  double densityContrast (const int i) const { return m_object[i]->densityContrast(); }
2073 
2079  double centralDensity (const int i) const { return m_object[i]->centralDensity(); }
2080 
2086  int ID (const int i) const { return m_object[i]->ID(); }
2087 
2094  double mass_proxy (const int i) const { return m_object[i]->mass_proxy(); }
2095 
2102  double mass_proxy_error (const int i) const { return m_object[i]->mass_proxy_error(); }
2103 
2109  int IDHost (const int i) const { return m_object[i]->IDHost(); }
2110 
2116  double galaxyTag (const int i) const { return m_object[i]->galaxyTag(); }
2117 
2123  double mstar (const int i) const { return m_object[i]->mstar(); }
2124 
2130  double massinfall (const int i) const { return m_object[i]->massinfall(); }
2131 
2137  double generic (const int i) const { return m_object[i]->generic(); }
2138 
2144  double tot_mass (const int i) const { return m_object[i]->tot_mass(); }
2145 
2150  std::vector<long> region () const;
2151 
2156  std::vector<std::string> field () const;
2157 
2163  std::vector<std::shared_ptr<Object>> satellites (const int index) const { return m_object[index]->satellites(); }
2164 
2170  std::vector<unsigned int> part (const int index) const { return m_object[index]->part(); }
2171 
2177  std::vector<std::vector<unsigned int>> nearCells (const int index) const { return m_object[index]->nearCells(); }
2178 
2185  double var (const int index, const Var var_name) const;
2186 
2193  int var_int (const int index, const Var var_name) const;
2194 
2200  std::vector<double> var (const Var var_name) const;
2201 
2207  std::vector<int> var_int (const Var var_name) const;
2208 
2219  bool isSetVar (const int index, const Var var_name) const;
2220 
2229  bool isSetVar (const Var var_name) const;
2230 
2236  inline std::shared_ptr<Object> catalogue_object (const int i) const { return m_object[i]; }
2237 
2243  inline std::shared_ptr<Object> operator[] (const size_t i) const { return m_object[i]; };
2244 
2249  inline std::vector<std::shared_ptr<Object>> catalogue_object () const { return m_object; }
2250 
2258  std::vector<double> coordinate (const int i) const { return m_object[i]->coords(); }
2259 
2264  size_t nObjects () const { return m_object.size(); }
2265 
2271  std::vector<size_t> nObjects_lightCone (const int nbin) const {
2272  std::vector<double> bin_limits = linear_bin_vector(nbin+1, cbl::Min(var(Var::_Redshift_)), cbl::Max(var(Var::_Redshift_)));
2273  std::vector<size_t> numobjects(nbin);
2274  for (int i=0; i<(int)nbin; i++) {
2275  auto temp_cat = sub_catalogue(Var::_Redshift_, bin_limits[i], bin_limits[i+1]);
2276  numobjects.emplace_back(temp_cat.nObjects());
2277  }
2278  return numobjects;
2279  }
2280 
2287  double Min (const Var var_name) const { return cbl::Min(var(var_name)); }
2288 
2295  double Max (const Var var_name) const { return cbl::Max(var(var_name)); }
2296 
2308  std::vector<double> stats_var (const Var var_name) const;
2309 
2321  std::vector<std::vector<double>> stats_var (const std::vector<Var> var_name) const;
2322 
2346  void var_distr (const Var var_name, std::vector<double> &_var, std::vector<double> &dist, std::vector<double> &err, const int nbin, const bool linear=true, const std::string file_out=par::defaultString, const double Volume=1., const bool norm=false, const double V1=par::defaultDouble, const double V2=par::defaultDouble, const std::string bin_type="Linear", const bool convolution=false, const double sigma=0.) const;
2347 
2352  double weightedN () const;
2353 
2359  double volume (const double boxside=par::defaultDouble) const {
2360  double vol = (boxside > 0.) ? pow(boxside, 3.) :
2364  return vol;
2365  }
2366 
2372  double numdensity (const double boxside=par::defaultDouble) const {
2373  double ndens = m_object.size()/volume(boxside);
2374  return ndens;
2375  }
2376 
2382  double numdensity_error (const double boxside=par::defaultDouble) const {
2383  double error = pow(m_object.size(), 1./2)/volume(boxside);
2384  return error;
2385  }
2386 
2392  double mps (const double boxside=par::defaultDouble) const {
2393  double mps = pow(numdensity(boxside), -1./3.);
2394  return mps;
2395  }
2396 
2402  double mps_error (const double boxside=par::defaultDouble) const {
2403  double error = mps(boxside)*(1./3)*(numdensity_error()/numdensity());
2404  return error;
2405  }
2406 
2412  std::vector<double> z_bins (const int nbin ) const {
2413  std::vector<double> b = linear_bin_vector(nbin+1, cbl::Min(var(Var::_Redshift_)), cbl::Max(var(Var::_Redshift_)));
2414  std::vector<double> bins(nbin);
2415  for (int i=0; i<nbin; i++) bins[i] = (b[i]+b[i+1])/2;
2416  return bins;
2417  }
2418 
2420 
2421 
2426 
2436  void set_region (const std::vector<long> region, const int nRegions=-1);
2437 
2442  void set_region_number (const size_t nRegions);
2443 
2454  void set_ra_dec_tile (const std::vector<double> RA_tile, const std::vector<double> Dec_tile, const CoordinateUnits inputUnits=CoordinateUnits::_degrees_);
2455 
2460  void set_field (const std::vector<std::string> field);
2461 
2473  void set_var (const int index, const Var var_name, const double value, const cosmology::Cosmology cosmology={}, const bool update_coordinates=true);
2474 
2482  void set_var (const int index, const Var var_name, const int value, const cosmology::Cosmology cosmology={});
2483 
2494  void set_var (const Var var_name, const std::vector<double> var, const cosmology::Cosmology cosmology={}, const bool update_coordinates=true);
2495 
2502  void set_var (const Var var_name, const std::vector<int> var, const cosmology::Cosmology cosmology={});
2503 
2509  void set_satellite (const int index, const std::shared_ptr<Object> satellite={})
2510  {
2511  m_object[index]->set_satellite(satellite);
2512  }
2513 
2519  void set_satellites (const int index, const std::vector<std::shared_ptr<Object>> satellites={})
2520  {
2521  m_object[index]->set_satellites(satellites);
2522  }
2523 
2529  void set_part (const int index, const std::vector<unsigned int> part={})
2530  {m_object[index]->set_part(part); }
2531 
2537  void set_nearCells (const int index, const std::vector<std::vector<unsigned int>> nearCells={})
2538  {m_object[index]->set_nearCells(nearCells); }
2539 
2555  void compute_centralDensity (const std::shared_ptr<Catalogue> tracers_catalogue, chainmesh::ChainMesh3D ChM, const double threshold);
2556 
2578  void compute_centralDensity (const std::shared_ptr<Catalogue> tracers_catalogue, chainmesh::ChainMesh3D ChM, const std::vector<double> par_numdensity, const double threshold);
2579 
2607  void compute_centralDensity (const std::shared_ptr<Catalogue> tracers_catalogue, chainmesh::ChainMesh3D ChM, const std::vector<std::vector<double>> data_numdensity, const std::string method_interpolation, const double threshold);
2608 
2627  void compute_densityContrast (const std::shared_ptr< Catalogue > tracers_catalogue, chainmesh::ChainMesh3D ChM, const double ratio=0.1);
2628 
2630 
2631 
2636 
2641  void add_object (std::shared_ptr<Object> object) { m_object.push_back(move(object)); }
2642 
2647  template<typename T>
2648  void add_object (T object) { m_object.push_back(move(std::make_shared<T>(T(object)))); }
2649 
2654  void add_objects (std::vector<std::shared_ptr<Object> > sample) {
2655  for (auto &&i : sample)
2656  m_object.push_back(move(i));
2657  }
2658 
2663  template<typename T>
2664  void add_objects (std::vector<T> sample) {
2665  for (auto &&i : sample)
2666  add_object(i);
2667  }
2668 
2673  template<typename T>
2674  void replace_objects(std::vector<T> sample) {
2675  m_object.erase(m_object.begin(), m_object.end());
2677  }
2678 
2683  void replace_objects (std::vector<std::shared_ptr<Object> > sample) {
2684  m_object.erase(m_object.begin(), m_object.end());
2685  for (auto &&i : sample)
2686  m_object.push_back(move(i));
2687  }
2688 
2693  void remove_objects () { m_object.erase(m_object.begin(), m_object.end()); }
2694 
2699  void remove_object (const int index) { m_object.erase(m_object.begin()+index); }
2700 
2705  void remove_objects (const std::vector<bool> index);
2706 
2712  void swap_objects (const int ind1, const int ind2);
2713 
2723  void sort (const Var var_name, const bool increasing=false);
2724 
2730  void shuffle (const int seed);
2731 
2733 
2734 
2739 
2748 
2756 
2767  void computePolarCoordinates (const cosmology::Cosmology &cosmology, const double z1=0., const double z2=10., const CoordinateUnits outputUnits=CoordinateUnits::_radians_);
2768 
2776 
2783  void restoreComovingCoordinates ();
2784 
2789  void Order (const std::vector<int> vv);
2790 
2795  void Order ();
2796 
2802  void write_comoving_coordinates (const std::string outputFile) const;
2803 
2809  void write_obs_coordinates (const std::string outputFile) const;
2810 
2825  void write_data (const std::string outputFile, const std::vector<Var> var_name={}, const std::string sep=" ", const std::string header="") const;
2826 
2835  double distance (const int i, std::shared_ptr<Object> obj) const;
2836 
2845  double angsep_xyz (const int i, std::shared_ptr<Object> obj) const;
2846 
2852  Catalogue operator += (std::shared_ptr<Catalogue> cc)
2853  {
2854  for (auto &&ss : cc->m_object)
2855  m_object.push_back(std::shared_ptr<Object>(new Object(*ss)));
2856  return *this;
2857  }
2858 
2865  {
2866  for (auto &&ss : cc.m_object)
2867  m_object.push_back(std::shared_ptr<Object>(new Object(*ss)));
2868  return *this;
2869  }
2870 
2880  Catalogue sub_catalogue (const Var var_name, const double down, const double up, const bool excl=false) const;
2881 
2889  Catalogue sub_catalogue (const mask_function mask, const bool excl=false) const;
2890 
2898  Catalogue sub_catalogue (const MaskObject &mask, const bool excl=false) const;
2899 
2960  Catalogue sub_catalogue (catalogue::Catalogue &data, const double tile_width_RA, const double tile_width_Dec, const bool write_tiles=false, const std::string dir_tiles="./", const std::string file_tiles="tiles_coordinates.txt");
2961 
2970  Catalogue mangle_cut (const std::string mangle_mask, const bool excl=false) const;
2971 
2982  Catalogue diluted_catalogue (const double nSub, const int seed=3213) const;
2983 
2999  std::shared_ptr<Catalogue> smooth (const double gridsize, const cosmology::Cosmology cosmology, const std::vector<Var> vars={}, const int SUB=1);
3000 
3011  int nObjects_condition (const Var var_name, const double down, const double up, const bool excl=false);
3012 
3023  double weightedN_condition (const Var var_name, const double down, const double up, const bool excl=false);
3024 
3030  std::vector<double> compute_catalogueProperties_box (const double boxside);
3031 
3042  std::vector<std::vector<double>> compute_catalogueProperties_lightCone (cbl::cosmology::Cosmology cosmology, const std::vector<double> RA_range, const std::vector<double> DEC_range, const unsigned int nbin);
3043 
3059  data::ScalarField3D counts_in_cell (const double cell_size, const int interpolation_type=0, const bool useMass=false, const double minX=par::defaultDouble, const double maxX=par::defaultDouble, const double minY=par::defaultDouble, const double maxY=par::defaultDouble, const double minZ=par::defaultDouble, const double maxZ=par::defaultDouble) const;
3060 
3074  data::ScalarField3D density_field (const double cell_size, const Catalogue mask_catalogue, const int interpolation_type=0, const double kernel_radius=0., const bool useMass=false) const;
3075 
3084  void equalize_random_lightCone (cbl::catalogue::Catalogue tracer_catalogue, cbl::cosmology::Cosmology cosm, const std::vector<double> RA_range, const std::vector<double> DEC_range, const int seed);
3085 
3091  void equalize_random_box (cbl::catalogue::Catalogue tracer_catalogue, const int seed);
3092 
3128  void clean_void_catalogue (const bool initial_radius=false, const std::vector<double> delta_r={-1, 1000}, const double threshold=0.205, const bool rescale=true, const std::shared_ptr<Catalogue> tracers_catalogue={}, chainmesh::ChainMesh3D ChM={}, const double ratio=1.5, const bool checkoverlap=true, const Var ol_criterion=Var::_CentralDensity_);
3129 
3172  void clean_void_catalogue (const std::vector<double> par_numdensity, const bool initial_radius=false, const std::vector<double> delta_r={-1, 1000}, const double threshold=0.205, const bool rescale=true, const std::shared_ptr<Catalogue> tracers_catalogue={}, chainmesh::ChainMesh3D ChM={}, const double ratio=1.5, const bool checkoverlap=true, const Var ol_criterion=Var::_CentralDensity_);
3173 
3221  void clean_void_catalogue (const std::vector<std::vector<double>> data_numdensity, const std::string method_interpolation, const bool initial_radius=false, const std::vector<double> delta_r={-1, 1000}, const double threshold=0.205, const bool rescale=true, const std::shared_ptr<Catalogue> tracers_catalogue={}, chainmesh::ChainMesh3D ChM={}, const double ratio=1.5, const bool checkoverlap=true, const Var ol_criterion=Var::_CentralDensity_);
3222 
3224 
3225  };
3226 
3241  double Average_c_Zehavi_2011 (const double x, const double logMmin, const double logsigma_c);
3242 
3257  double Average_s_Zehavi_2011 (const double x, const double M0, const double M1, const double alpha);
3258 
3270  double Average_c_Zehavi_2005 (const double x, const double Mmin);
3271 
3285  double Average_s_Zehavi_2005 (const double x, const double alpha, const double M1);
3286 
3287  }
3288 }
3289 
3290 #endif
The class ChainMeshCell.
Implementation of the chain-mesh data structure.
The class Cluster.
The class Cosmology.
The class field3D.
The class Galaxy.
The class Halo.
The class HostHalo.
The class Mock.
The class Object.
The class RandomObject.
The class Void.
The class Catalogue.
Definition: Catalogue.h:654
void set_part(const int index, const std::vector< unsigned int > part={})
set the private member ChainMeshCell::m_part
Definition: Catalogue.h:2529
double z_displacement(const int i) const
get the private member Catalogue::m_object[i]->m_z_displacement
Definition: Catalogue.h:1985
Catalogue()=default
default constructor
double weight(const int i) const
get the private member Catalogue::m_object[i]->m_weight
Definition: Catalogue.h:1947
void compute_centralDensity(const std::shared_ptr< Catalogue > tracers_catalogue, chainmesh::ChainMesh3D ChM, const double threshold)
compute the central density of each object in a void catalogue. We define as central density the dens...
void add_object(T object)
add one single object to the catalogue
Definition: Catalogue.h:2648
double lensingWeight(const int i) const
get the private member Catalogue::m_object[i]->m_lensingWeight
Definition: Catalogue.h:1933
size_t nRegions()
get the private member m_nRegions
Definition: Catalogue.cpp:396
double magnitudeR(const int i) const
get the private member Catalogue::m_object[i]->m_magnitudeR
Definition: Catalogue.h:2051
double tot_mass(const int i) const
get the private member Catalogue::m_object[ii]->m_tot_mass
Definition: Catalogue.h:2144
void remove_objects()
remove all objects remove all objects of the catalogue
Definition: Catalogue.h:2693
std::vector< std::vector< unsigned int > > nearCells(const int index) const
get the private member Catalogue::m_object[index]->m_nearCells of ChainMeshCell
Definition: Catalogue.h:2177
double yy(const int i) const
get the private member Catalogue::m_object[i]->m_yy
Definition: Catalogue.h:1814
int IDHost(const int i) const
get the private member Catalogue::m_object[i]->m_IDHost
Definition: Catalogue.h:2109
double mass(const int i) const
get the private member Catalogue::m_object[i]->m_mass
Definition: Catalogue.h:2023
std::vector< int > m_index
vector containing the object indexes
Definition: Catalogue.h:662
Gadget_Header m_swap_header(Gadget_Header header)
swap endianism of the GADGET snapshot header
void add_objects(std::vector< std::shared_ptr< Object > > sample)
add some objects to the catalogue
Definition: Catalogue.h:2654
void restoreComovingCoordinates()
restore comoving coordinates
Definition: Catalogue.cpp:1697
double Min(const Var var_name) const
get the minimum value of a variable of the catalogue objects
Definition: Catalogue.h:2287
void normalizeComovingCoordinates()
normalize comoving coordinates
Definition: Catalogue.cpp:1684
Catalogue sub_catalogue(const Var var_name, const double down, const double up, const bool excl=false) const
create a sub-catalogue
Definition: Catalogue.cpp:1890
double weightedN_condition(const Var var_name, const double down, const double up, const bool excl=false)
return the weighted number of objectes following a condition on the variable VAR
Definition: Catalogue.cpp:2248
std::vector< std::shared_ptr< Object > > m_object
vector containing the objects of the catalogue
Definition: Catalogue.h:659
int ID(const int i) const
get the private member Catalogue::m_object[i]->m_ID
Definition: Catalogue.h:2086
Catalogue mangle_cut(const std::string mangle_mask, const bool excl=false) const
create a sub-catalogue
Definition: Catalogue.cpp:2027
size_t nObjects() const
get the number of objects of the catalogue
Definition: Catalogue.h:2264
void set_region_number(const size_t nRegions)
set the private variable m_nRegion
Definition: Catalogue.cpp:944
double lensingCalib(const int i) const
get the private member Catalogue::m_object[i]->m_lensingCalib
Definition: Catalogue.h:1940
double odds(const int i) const
get the private member Catalogue::m_object[i]->m_odds
Definition: Catalogue.h:1926
void set_ra_dec_tile(const std::vector< double > RA_tile, const std::vector< double > Dec_tile, const CoordinateUnits inputUnits=CoordinateUnits::_degrees_)
set the central R.A. and Dec of the tiles
Definition: Catalogue.cpp:957
double numdensity(const double boxside=par::defaultDouble) const
compute the catalogue's number density
Definition: Catalogue.h:2372
void set_satellite(const int index, const std::shared_ptr< Object > satellite={})
set the private member HostHalo::m_satellites
Definition: Catalogue.h:2509
void write_comoving_coordinates(const std::string outputFile) const
write the comoving coordinates of the catalogue to an output file
Definition: Catalogue.cpp:1765
double dec(const int i) const
get the private member Catalogue::m_object[i]->m_dec
Definition: Catalogue.h:1863
double galaxyTag(const int i) const
get the private member Catalogue::m_object[i]->m_galaxyTag
Definition: Catalogue.h:2116
bool isSetVar(const int index, const Var var_name) const
check if the given variable of the i-th object is set
Definition: Catalogue.cpp:740
SubFindTab_Header m_read_header(std::ifstream &finh, const bool swap=false)
read the GADGET subfind table header
double xx(const int i) const
get the private member Catalogue::m_object[i]->m_xx
Definition: Catalogue.h:1807
Catalogue(Catalogue &&obj)
move constructor for the Catalogue class
Definition: Catalogue.h:765
double sn(const int i) const
get the private member Catalogue::m_object[i]->m_sn
Definition: Catalogue.h:1884
std::shared_ptr< Object > operator[](const size_t i) const
access the i-th Catalogue object
Definition: Catalogue.h:2243
double ra_tile(const int i) const
get the private member Catalogue::m_object[i]->m_ra_tile
Definition: Catalogue.h:1870
double magnitude(const int i) const
get the private member Catalogue::m_object[i]->m_magnitude
Definition: Catalogue.h:2030
size_t nFields() const
get the total number of fields where the objects have been observed
Definition: Catalogue.h:2016
double shear1(const int i) const
get the private member Catalogue::m_object[i]->m_shear1
Definition: Catalogue.h:1912
double volume(const double boxside=par::defaultDouble) const
compute the catalogue's comoving volume
Definition: Catalogue.h:2359
void add_objects(std::vector< T > sample)
add some objects to the catalogue
Definition: Catalogue.h:2664
void add_object(std::shared_ptr< Object > object)
add one single object to the catalogue
Definition: Catalogue.h:2641
std::vector< double > coordinate(const int i) const
get the X, Y, Z coordinates of the i-th object of the catalogue
Definition: Catalogue.h:2258
double mstar(const int i) const
get the private member Catalogue::m_object[i]->m_mstar
Definition: Catalogue.h:2123
std::shared_ptr< Object > catalogue_object(const int i) const
get the i-th object of the catalogue
Definition: Catalogue.h:2236
void var_distr(const Var var_name, std::vector< double > &_var, std::vector< double > &dist, std::vector< double > &err, const int nbin, const bool linear=true, const std::string file_out=par::defaultString, const double Volume=1., const bool norm=false, const double V1=par::defaultDouble, const double V2=par::defaultDouble, const std::string bin_type="Linear", const bool convolution=false, const double sigma=0.) const
get the distribution of a variable
Definition: Catalogue.cpp:1544
std::vector< unsigned int > part(const int index) const
get the private member Catalogue::m_object[index]->m_part of ChainMeshCell
Definition: Catalogue.h:2170
double redshift(const int i) const
get the private member Catalogue::m_object[i]->m_redshift
Definition: Catalogue.h:1891
Catalogue(std::vector< T > object)
constructor, using vectors of generic objects
Definition: Catalogue.h:1091
void set_field(const std::vector< std::string > field)
set a private variable
Definition: Catalogue.cpp:969
double shear2(const int i) const
get the private member Catalogue::m_object[i]->m_shear2
Definition: Catalogue.h:1919
Catalogue(const Catalogue &obj)
Copy constructor for the Catalogue class.
Definition: Catalogue.h:746
double mps_error(const double boxside=par::defaultDouble) const
compute the catalogue's mean particle separation error
Definition: Catalogue.h:2402
void write_obs_coordinates(const std::string outputFile) const
write the polar coordinates of the catalogue to an output file
Definition: Catalogue.cpp:1783
double y_displacement(const int i) const
get the private member Catalogue::m_object[i]->m_y_displacement
Definition: Catalogue.h:1977
double massinfall(const int i) const
get the private member Catalogue::m_object[i]->m_minfall
Definition: Catalogue.h:2130
double ra(const int i) const
get the private member Catalogue::m_object[i]->m_ra
Definition: Catalogue.h:1856
size_t m_nRegions
number of regions
Definition: Catalogue.h:665
double var(const int index, const Var var_name) const
get the value of the i-th object variable
Definition: Catalogue.cpp:449
void compute_densityContrast(const std::shared_ptr< Catalogue > tracers_catalogue, chainmesh::ChainMesh3D ChM, const double ratio=0.1)
compute density contrast of cosmic voids in catalogue as the ratio between an inner and an outer sphe...
std::vector< std::vector< double > > compute_catalogueProperties_lightCone(cbl::cosmology::Cosmology cosmology, const std::vector< double > RA_range, const std::vector< double > DEC_range, const unsigned int nbin)
compute catalogue volume, number density and mean particle separation in light cones
Definition: Catalogue.cpp:2595
void sort(const Var var_name, const bool increasing=false)
bubble sort of a catalogue wrt a variable
Definition: Catalogue.cpp:2521
data::ScalarField3D density_field(const double cell_size, const Catalogue mask_catalogue, const int interpolation_type=0, const double kernel_radius=0., const bool useMass=false) const
return the density field from object position
Definition: Catalogue.cpp:2341
std::vector< std::shared_ptr< Object > > satellites(const int index) const
get the private member Catalogue::m_object[ii]->m_satellites
Definition: Catalogue.h:2163
double angsep_xyz(const int i, std::shared_ptr< Object > obj) const
get the angular distrance between the i-th object of the catalogue and another object
Definition: Catalogue.cpp:2114
void computeComovingCoordinates(const cosmology::Cosmology &cosm, const CoordinateUnits inputUnits=CoordinateUnits::_radians_)
compute the comoving coordinates (x, y, z) from the observed coordinates (R.A., Dec,...
Definition: Catalogue.cpp:1553
void set_nearCells(const int index, const std::vector< std::vector< unsigned int >> nearCells={})
set the private member ChainMeshCell::m_nearCells
Definition: Catalogue.h:2537
~Catalogue()=default
default destructor
int nObjects_condition(const Var var_name, const double down, const double up, const bool excl=false)
return the number of objectes following a condition on the variable VAR
Definition: Catalogue.cpp:2229
double Max(const Var var_name) const
get the maximum value of a variable of the catalogue objects
Definition: Catalogue.h:2295
double mass_proxy(const int i) const
get the private member Catalogue::m_object[i]->m_mass_proxy
Definition: Catalogue.h:2094
Catalogue(const ObjectType objectType, const CoordinateType coordinateType, const std::vector< std::string > file, const cosmology::Cosmology &cosm, const CoordinateUnits inputUnits=CoordinateUnits::_radians_)
constructor, reading a file with coordinates
Definition: Catalogue.h:955
void equalize_random_box(cbl::catalogue::Catalogue tracer_catalogue, const int seed)
equalize the number of objects in two Box catalogues
std::string field(const int i) const
get the private member Catalogue::m_object[i]->m_field
Definition: Catalogue.h:1961
double zz(const int i) const
get the private member Catalogue::m_object[i]->m_zz
Definition: Catalogue.h:1821
double x_displacement(const int i) const
get the private member Catalogue::m_object[i]->m_x_displacement
Definition: Catalogue.h:1969
double mps(const double boxside=par::defaultDouble) const
compute the catalogue's mean particle separation
Definition: Catalogue.h:2392
double numdensity_error(const double boxside=par::defaultDouble) const
compute the catalogue's number density error
Definition: Catalogue.h:2382
double weightedN() const
get the total weight of the objects of the catalogue
Definition: Catalogue.cpp:1753
void replace_objects(std::vector< T > sample)
replace existing objects with new ones
Definition: Catalogue.h:2674
void m_check_it_out(std::ifstream &finr, const bool swap)
Ouput function to check consistency in reading block-headers in binary GADGET snapshots.
double dc(const int i) const
get the private member Catalogue::m_object[i]->m_dc
Definition: Catalogue.h:1849
Catalogue & operator=(Catalogue &&obj) noexcept
move assignment for the Catalogue class
Definition: Catalogue.h:805
long region(const int i) const
get the private member Catalogue::m_object[i]->m_region
Definition: Catalogue.h:1954
void clean_void_catalogue(const bool initial_radius=false, const std::vector< double > delta_r={-1, 1000}, const double threshold=0.205, const bool rescale=true, const std::shared_ptr< Catalogue > tracers_catalogue={}, chainmesh::ChainMesh3D ChM={}, const double ratio=1.5, const bool checkoverlap=true, const Var ol_criterion=Var::_CentralDensity_)
function that modifies a void catalogue according to a set of user selected criteria....
void computePolarCoordinates(const CoordinateUnits outputUnits=CoordinateUnits::_radians_)
compute the polar coordinates (R.A., Dec, dc) from the comoving coordinates (x, y,...
Definition: Catalogue.cpp:1587
std::vector< std::string > field_list() const
get the list of fields where the objects have been observed
Definition: Catalogue.h:2008
double distance(const int i, std::shared_ptr< Object > obj) const
get the distrance between the i-th object of the catalogue and another object
Definition: Catalogue.cpp:2103
void set_region(const std::vector< long > region, const int nRegions=-1)
set a private variable
Definition: Catalogue.cpp:933
double centralDensity(const int i) const
get the private member Catalogue::m_object[i]->m_centralDensity
Definition: Catalogue.h:2079
double magnitudeU(const int i) const
get the private member Catalogue::m_object[i]->m_magnitudeU
Definition: Catalogue.h:2037
double radius(const int i) const
get the private member Catalogue::m_object[i]->m_radius
Definition: Catalogue.h:2065
double redshiftMax(const int i) const
get the private member Catalogue::m_object[i]->m_redshiftMax
Definition: Catalogue.h:1905
int m_blockheader
contains the block-header temporary value
Definition: Catalogue.h:673
double vx(const int i) const
get the private member Catalogue::m_object[i]->m_vx
Definition: Catalogue.h:1828
Catalogue & operator=(const Catalogue &obj)
copy assignment for the Catalogue class
Definition: Catalogue.h:786
void set_var(const int index, const Var var_name, const double value, const cosmology::Cosmology cosmology={}, const bool update_coordinates=true)
set a private variable
Definition: Catalogue.cpp:978
void remove_object(const int index)
remove an existing object
Definition: Catalogue.h:2699
std::vector< double > compute_catalogueProperties_box(const double boxside)
compute catalogue volume, number density and mean particle separation
Definition: Catalogue.cpp:2571
std::vector< double > z_bins(const int nbin) const
get the catalogue's redshift bins
Definition: Catalogue.h:2412
double mass_proxy_error(const int i) const
get the private member Catalogue::m_object[i]->m_mass_proxy_error
Definition: Catalogue.h:2102
std::vector< std::string > field() const
get the values of the object fields
Definition: Catalogue.cpp:436
Catalogue(const ObjectType objectType, const CoordinateType coordinateType, const std::vector< double > coord1, const std::vector< double > coord2, const std::vector< double > coord3, const cosmology::Cosmology &cosm, const CoordinateUnits inputUnits=CoordinateUnits::_radians_)
constructor
Definition: Catalogue.h:881
void equalize_random_lightCone(cbl::catalogue::Catalogue tracer_catalogue, cbl::cosmology::Cosmology cosm, const std::vector< double > RA_range, const std::vector< double > DEC_range, const int seed)
equalize the number of objects in two Light Cones catalogues
std::vector< double > stats_var(const Var var_name) const
get the mean, the median, the standard deviation, and the difference between the third and first quar...
Definition: Catalogue.cpp:1521
void write_data(const std::string outputFile, const std::vector< Var > var_name={}, const std::string sep=" ", const std::string header="") const
write both the comoving and polar coordinates, and the regions (if present) of the catalogue to an ou...
Definition: Catalogue.cpp:1804
std::shared_ptr< Catalogue > smooth(const double gridsize, const cosmology::Cosmology cosmology, const std::vector< Var > vars={}, const int SUB=1)
create a smoothed version of the catalogue averaging quantities on a X, Y, Z grid
Definition: Catalogue.cpp:2125
void swap_objects(const int ind1, const int ind2)
swap two existing objects
Definition: Catalogue.cpp:2510
double dec_tile(const int i) const
get the private member Catalogue::m_object[i]->m_dec_tile
Definition: Catalogue.h:1877
void m_check_it_in(std::ifstream &finr, const bool swap)
Input function to check consistency in reading block-headers in binary GADGET snapshots.
int var_int(const int index, const Var var_name) const
get the value of the i-th object integer variable
Definition: Catalogue.cpp:697
std::vector< long > region_list() const
get the list of regions in which the catalogue is divided
Definition: Catalogue.cpp:411
std::vector< std::shared_ptr< Object > > sample() const
get the private member Catalogue::m_object
Definition: Catalogue.h:1800
double densityContrast(const int i) const
get the private member Catalogue::m_object[i]->m_densityContrast
Definition: Catalogue.h:2072
void Order()
restore the original vector (i.e. the opposite of Order(std::vector<int>))
Definition: Catalogue.cpp:1733
void shuffle(const int seed)
shuffle objects in the catalogue
Definition: Catalogue.cpp:2556
std::vector< long > region() const
get the values of the object regions
Definition: Catalogue.cpp:423
double redshiftMin(const int i) const
get the private member Catalogue::m_object[i]->m_redshiftMin
Definition: Catalogue.h:1898
data::ScalarField3D counts_in_cell(const double cell_size, const int interpolation_type=0, const bool useMass=false, const double minX=par::defaultDouble, const double maxX=par::defaultDouble, const double minY=par::defaultDouble, const double maxY=par::defaultDouble, const double minZ=par::defaultDouble, const double maxZ=par::defaultDouble) const
return the density field from object positions
Definition: Catalogue.cpp:2266
std::vector< size_t > nObjects_lightCone(const int nbin) const
get the number of objects of the catalogue for Light Cones
Definition: Catalogue.h:2271
std::vector< std::shared_ptr< Object > > catalogue_object() const
get the object vector
Definition: Catalogue.h:2249
double magnitudeG(const int i) const
get the private member Catalogue::m_object[i]->m_magnitudeG
Definition: Catalogue.h:2044
void replace_objects(std::vector< std::shared_ptr< Object > > sample)
replace existing objects with new ones
Definition: Catalogue.h:2683
Catalogue(std::vector< std::shared_ptr< Object > > sample)
constructor, using vectors of pointers to generic objects
Definition: Catalogue.h:1103
Catalogue operator+=(std::shared_ptr< Catalogue > cc)
overloading of the += operator, to sum two catalogues
Definition: Catalogue.h:2852
double magnitudeI(const int i) const
get the private member Catalogue::m_object[i]->m_magnitudeI
Definition: Catalogue.h:2058
Catalogue diluted_catalogue(const double nSub, const int seed=3213) const
create a diluted catalogue
Definition: Catalogue.cpp:2076
double vy(const int i) const
get the private member Catalogue::m_object[i]->m_vy
Definition: Catalogue.h:1835
void set_satellites(const int index, const std::vector< std::shared_ptr< Object >> satellites={})
set the private member HostHalo::m_satellites
Definition: Catalogue.h:2519
double vz(const int i) const
get the private member Catalogue::m_object[i]->m_vz
Definition: Catalogue.h:1842
The class Object.
Definition: Object.h:132
The class ChainMesh3D.
Definition: ChainMesh.h:392
The class Cosmology.
Definition: Cosmology.h:277
The class ScalarField3D.
Definition: Field3D.h:648
static const std::string defaultString
default std::string value
Definition: Constants.h:336
static const double defaultDouble
default double value
Definition: Constants.h:348
static const double alpha
: the fine-structure constant
Definition: Constants.h:233
static const double cc
: the speed of light in vacuum (the value is exact) [km/sec]
Definition: Constants.h:221
std::function< bool(const std::shared_ptr< Object > obj)> mask_function
Definition of a new type to manage mask function.
Definition: Catalogue.h:266
Var
the catalogue variables
Definition: Catalogue.h:70
@ _MassInfall_
Infall mass of substructures.
@ _MassProxyError_
mass proxy error
@ _Y_displacement_
yy displacement
@ _MagnitudeI_
i-band magnitude
@ _Vz_
velocity along the z direction
@ _VmaxRad_
maximum radial velocity
@ _MagnitudeR_
r-band magnitude
@ _IDHOST_
unique identification number of the halo that host galaxy
@ _LensingCalib_
lensing calibration factor
@ _MassProxy_
mass proxy
@ _Shear2_
second component of the shear signal
@ _ID_
unique identification number
@ _MagnitudeG_
g-band magnitude
@ _Vy_
velocity along the y direction
@ _XCM_
centre of mass x-coordinate
@ _GalaxyTag_
tag of galaxy "central" or "satellite"
@ _Generic_
generic property
@ _Mstar_
stellar mass
@ _CentralDensity_
centralDensity
@ _Vx_
velocity along the x direction
@ _Nsub_
number of sub-groups
@ _Dc_
comoving distance
@ _YSpin_
spin y-coordinate
@ _SN_
Signal-to-noise ratio.
@ _ZSpin_
spin z-coordinate
@ _MagnitudeU_
u-band magnitude
@ _RedshiftMax_
maximum redshift
@ _XSpin_
spin x-coordinate
@ _RadiusEstimate_
radius estimate
@ _TileDec_
Central value of the tile Declination.
@ _TotMass_
total halo mass
@ _VeldispEstimate_
velocity dispersion estimate
@ _Z_
coordinate z
@ _MassEstimate_
mass estimate
@ _RA_
Right Ascension.
@ _Y_
coordinate y
@ _X_
coordinate x
@ _TileRA_
Central value of the tile Right Ascension.
@ _VelDisp_
velocity dispersion
@ _Z_displacement_
zz displacement
@ _sSFR_
specific star formation rate
@ _RedshiftMin_
minimum redshift
@ _ZCM_
centre of mass z-coordinate
@ _X_displacement_
xx displacement
@ _Shear1_
first component of the shear signal
@ _YCM_
centre of mass y-coordinate
@ _LensingWeight_
lensing weight
@ _Vmax_
maximum velocity
@ _Parent_
parent unique identification number
@ _Dec_
Declination.
@ _DensityContrast_
densityContrast
@ _SFR_
star formation rate
@ _Magnitude_
magnitude
double Average_c_Zehavi_2005(const double x, const double Mmin)
return the average number of central galaies inside an halo of mass x
std::vector< std::string > CharEncodeNames()
return a vector containing the CharEncode names
Definition: Catalogue.h:492
std::vector< std::string > EstimateCriterionNames()
return a vector containing the EstimateCriterion names
Definition: Catalogue.h:518
double Average_c_Zehavi_2011(const double x, const double logMmin, const double logsigma_c)
return the average number of central galaies inside an halo of mass x
std::vector< std::string > VoidAlgorithmNames()
return a vector containing the VoidAlgorithm names
Definition: Catalogue.h:469
RandomType
the type of random catalogue
Definition: Catalogue.h:345
@ _createRandom_VIPERS_
random catalogue for VIPERS
@ _createRandom_SDSS_stripes_
create random for SDSS, using stripes
@ _createRandom_square_
random catalogue with square geometry in observed coordinates (R.A., Dec)
@ _createRandom_shuffleTOT_
random catalogue obtained with shuffling in observed coordinates (R.A., Dec) and redshift
@ _createRandom_cone_
random catalogue with conic geometry
@ _createRandom_homogeneous_LC_
homogeneous random catalogue in ra and dec with redshift dependent density
@ _createRandom_MANGLE_
random catalogue using mangle
@ _createRandom_box_
random catalogue with cubic geometry (or parallelepiped) in comoving coordinates
@ _createRandom_shuffle_
random catalogue obtained with shuffling in observed coordinates (R.A., Dec)
ObjectType
the object types
Definition: Object.h:51
RandomType RandomTypeCast(const int randomTypeIndex)
cast an enum of type RandomType from its index
Definition: Catalogue.h:390
EstimateCriterion EstimateCriterionCast(const int estimateCriterionIndex)
cast an enum of type EstimateCriterion from its index
Definition: Catalogue.h:527
std::vector< std::string > RandomTypeNames()
return a vector containing the RandomType names
Definition: Catalogue.h:381
VoidAlgorithm
the algorithm used to look for Voids
Definition: Catalogue.h:452
@ _LaZeVo_
Lagrangian Zel'dovich approximation Void algorithm used to move particles.
HODType
type of HOD catalogue, which corresponds to the authors of the calibrated HOD model
Definition: Catalogue.h:426
@ _Zehavi11_
Zehavi et al. (2011)
@ _Zehavi05_
Zehavi et al. (2005)
@ _Moster10_
Moster et al. (2010)
std::vector< std::string > HODTypeNames()
return a vector containing the HODTypes names
Definition: Catalogue.h:445
EstimateCriterion
method used to estimate mass, radius and velocity of a halo
Definition: Catalogue.h:499
CharEncode
character encoding of input file
Definition: Catalogue.h:476
@ _ascii_
Format ASCII file.
@ _binary_
Format binary file.
std::vector< std::string > VarNames()
return a vector containing the Var names
Definition: Catalogue.h:302
double Average_s_Zehavi_2005(const double x, const double alpha, const double M1)
return the average number of satellite galaies per halo of mass x
double Average_s_Zehavi_2011(const double x, const double M0, const double M1, const double alpha)
return the average number of satellite galaies per halo of mass x
Var VarCast(const int varIndex)
cast an enum of type Var from its index
Definition: Catalogue.h:311
The global namespace of the CosmoBolognaLib
Definition: CAMB.h:38
T Min(const std::vector< T > vect)
minimum element of a std::vector
Definition: Kernel.h:1324
int N_different_elements(const std::vector< T > vect_input)
get the number of unique elements of a std::vector
Definition: Kernel.h:1364
std::string conv(const T val, const char *fact)
convert a number to a std::string
Definition: Kernel.h:903
CoordinateType
the coordinate type
Definition: Kernel.h:624
std::vector< T > different_elements(const std::vector< T > vect_input)
get the unique elements of a std::vector
Definition: Kernel.h:1349
std::vector< T > linear_bin_vector(const size_t nn, const T min, const T max)
fill a std::vector with linearly spaced values
Definition: Kernel.h:1604
T Max(const std::vector< T > vect)
maximum element of a std::vector
Definition: Kernel.h:1336
CoordinateUnits
the coordinate units
Definition: Kernel.h:562
@ _radians_
angle in radians
@ _degrees_
angle in degrees
void convolution(const std::vector< double > f1, const std::vector< double > f2, std::vector< double > &res, const double deltaX)
convolution of two functions
Definition: Func.cpp:1580
This structure allows to store GADGET header.
Definition: Catalogue.h:561
int nfiles
number of files in each snapshot
Definition: Catalogue.h:588
double time
time of output, or expansion factor for cosmological simulations
Definition: Catalogue.h:570
int flag_entr_ics
flags that the initial conditions contain entropy instead of thermal energy in the u block
Definition: Catalogue.h:612
int flag_cool
flag for cooling (unused)
Definition: Catalogue.h:585
int flag_stAge
creation time of stars (unused)
Definition: Catalogue.h:603
double redshift
z = 1/a-1 (only set for cosmological integrations)
Definition: Catalogue.h:573
int flag_feedback
flag for feedback (unused)
Definition: Catalogue.h:579
double omega0
matter density at z=0 in units of the critical density
Definition: Catalogue.h:594
int npartTotal[6]
total number of particles of each type in the simulation
Definition: Catalogue.h:582
double boxsize
gives the box size if periodic boundary conditions are used
Definition: Catalogue.h:591
short la[40]
currently unused space which fills the header to a total length of 256 bytes leaving room for future ...
Definition: Catalogue.h:615
double omegaLambda
vacuum energy density at z=0 in units of the critical density
Definition: Catalogue.h:597
int flag_Metals
flag for metallicity values (unused)
Definition: Catalogue.h:606
int npart_totHW
internal variable for simulations that use more than 2^32 particles
Definition: Catalogue.h:609
double hubblePar
gives the Hubble constant in units of 100 km/(s Mpc)
Definition: Catalogue.h:600
int npart[6]
the number of particles of each type in the snapshot file
Definition: Catalogue.h:564
int flag_sfr
flag for star formation (unused in the public version of GADGET-2)
Definition: Catalogue.h:576
double massarr[6]
the mass of each particle type
Definition: Catalogue.h:567
object that encapsulate the mask function.
Definition: Catalogue.h:277
virtual ~MaskObject()
Default destructor.
Definition: Catalogue.h:292
virtual bool operator()(const std::shared_ptr< Object > obj) const
call function This function can contain one or more checks on object variables, returning a bool
Definition: Catalogue.h:287
This structure allows to store SUBFIND Tab file header.
Definition: Catalogue.h:622
uint64_t totNids
total number of particle IDs
Definition: Catalogue.h:634
uint32_t Nids
number of particle IDs in corresponding file
Definition: Catalogue.h:631
uint32_t totNsubs
total number of subgroups
Definition: Catalogue.h:643
uint32_t Nsubs
number of subgroups in file
Definition: Catalogue.h:640
uint32_t Ngroups
number of groups in file
Definition: Catalogue.h:625
uint32_t Ntask
number of files in which the groups/subgroups are stored
Definition: Catalogue.h:637
uint32_t totNgroups
total number of groups
Definition: Catalogue.h:628