41 if (pathstr.empty()) {
return false;}
44 std::string endchar =
"/";
45 int strcomp = pathstr.compare(
46 pathstr.length() - endchar.length(), endchar.length(), endchar
48 if (strcomp == 0) {
return false;}
52 for (std::string::size_type ichar = 0; ichar < pathstr.length(); ichar++){
53 if (!std::isspace(pathstr[ichar])) {
return true;}
61 if (dirstr.empty() || dirstr ==
"." || dirstr ==
"./" || dirstr ==
"/") {
65 while (!dirstr.empty() && (dirstr.back() ==
'/')) {
69 std::filesystem::path dir(dirstr);
71 if (std::filesystem::create_directories(dir, ec)) {
79 "Failed to create directory: %s", dirstr.c_str()
83 "Failed to create directory: %s", dirstr.c_str()
106 double norm_factor_part,
double norm_factor_mesh,
double norm_factor_meshes
110 "%s Data catalogue source: %s\n",
111 comment_delimiter, catalogue_data.
source.c_str()
115 "%s Data catalogue size: ntotal = %d, wtotal = %.3f, wstotal = %.3f\n",
121 "%s Data-source particle extents: "
122 "[(%.3f, %.3f), (%.3f, %.3f), (%.3f, %.3f)]\n",
130 "%s Random catalogue source: %s\n",
131 comment_delimiter, catalogue_rand.
source.c_str()
135 "%s Random catalogue size: ntotal = %d, wtotal = %.3f, wstotal = %.3f\n",
141 "%s Random-source particle extents: "
142 "[(%.3f, %.3f), (%.3f, %.3f), (%.3f, %.3f)]\n",
151 "%s Box size: [%.3f, %.3f, %.3f]\n",
157 "%s Box alignment: %s\n",
163 "%s Mesh number: [%d, %d, %d]\n",
169 "%s Mesh assignment and interlacing: %s, %s\n",
177 "%s Normalisation factor: %.9e (%s)\n",
184 "%s Normalisation factor: %.9e (%s)\n",
191 "%s Normalisation factor: %.9e (%s)\n",
198 "%s Normalisation factor: %.9e (%s)\n",
205 "%s Normalisation factor alternatives: "
206 "%.9e (particle), %.9e (mesh), %.9e (mesh-mixed)\n",
208 norm_factor_part, norm_factor_mesh, norm_factor_meshes
215 double norm_factor_part,
double norm_factor_mesh,
double norm_factor_meshes
219 "%s Catalogue source: %s\n",
220 comment_delimiter, catalogue.
source.c_str()
224 "%s Catalogue size: ntotal = %d, wtotal = %.3f, wstotal = %.3f\n",
229 "%s Catalogue particle extents: "
230 "[(%.3f, %.3f), (%.3f, %.3f), (%.3f, %.3f)]\n",
239 "%s Box size: [%.3f, %.3f, %.3f]\n",
245 "%s Box alignment: %s\n",
251 "%s Mesh number: [%d, %d, %d]\n",
257 "%s Mesh assignment and interlacing: %s, %s\n",
265 "%s Normalisation factor: %.9e (%s)\n",
272 "%s Normalisation factor: %.9e (%s)\n",
279 "%s Normalisation factor: %.9e (%s)\n",
286 "%s Normalisation factor: %.9e (%s)\n",
293 "%s Normalisation factor alternatives: "
294 "%.9e (particle), %.9e (mesh), %.9e (mesh-mixed)\n",
296 norm_factor_part, norm_factor_mesh, norm_factor_meshes
312 "%s Box size: [%.3f, %.3f, %.3f]\n",
318 "%s Mesh number: [%d, %d, %d]\n",
324 "%s Vector count: %d\n", comment_delimiter, binned_vectors.
count
328 "%s Bin number: %d\n", comment_delimiter, binned_vectors.
num_bins
335 "[0] bin_index, [1] bin_lower, [2] bin_upper, "
336 "[3] vec_x, [4] vec_y, [5] vec_z\n",
341 for (
int ivec = 0; ivec < binned_vectors.
count; ivec++) {
344 "%d\t%.9e\t%.9e\t% .9e\t% .9e\t% .9e\n",
348 binned_vectors.
vecx[ivec],
349 binned_vectors.
vecy[ivec],
350 binned_vectors.
vecz[ivec]
368 "[0] k_cen, [1] k_eff, [2] nmodes, "
369 "[3] Re{pk%d_raw}, [4] Im{pk%d_raw}, "
370 "[5] Re{pk%d_shot}, [6] Im{pk%d_shot}\n",
376 for (
int idx_dv = 0; idx_dv < meas_powspec.
dim; idx_dv++) {
379 "%.9e\t%.9e\t%10d\t% .9e\t% .9e\t% .9e\t% .9e\n",
380 meas_powspec.
kbin[idx_dv],
381 meas_powspec.
keff[idx_dv],
382 meas_powspec.
nmodes[idx_dv],
383 meas_powspec.
pk_raw[idx_dv].real(), meas_powspec.
pk_raw[idx_dv].imag(),
384 meas_powspec.
pk_shot[idx_dv].real(), meas_powspec.
pk_shot[idx_dv].imag()
396 "%s [0] r_cen, [1] r_eff, [2] npairs, [3] Re{xi%d}, [4] Im{xi%d}\n",
402 for (
int idx_dv = 0; idx_dv < meas_2pcf.
dim; idx_dv++) {
405 "%.9e\t%.9e\t%10d\t% .9e\t% .9e\n",
406 meas_2pcf.
rbin[idx_dv],
407 meas_2pcf.
reff[idx_dv],
409 meas_2pcf.
xi[idx_dv].real(), meas_2pcf.
xi[idx_dv].imag()
421 "%s [0] r_cen, [1] r_eff, [2] npairs, [3] Re{xi%d}, [4] Im{xi%d}\n",
427 for (
int idx_dv = 0; idx_dv < meas_2pcf_win.
dim; idx_dv++) {
430 "%.9e\t%.9e\t%10d\t% .9e\t% .9e\n",
431 meas_2pcf_win.
rbin[idx_dv],
432 meas_2pcf_win.
reff[idx_dv],
433 meas_2pcf_win.
npairs[idx_dv],
434 meas_2pcf_win.
xi[idx_dv].real(), meas_2pcf_win.
xi[idx_dv].imag()
448 char multipole_str[8];
450 multipole_str,
sizeof(multipole_str),
"%d%d%d",
458 "[0] k1_cen, [1] k1_eff, [2] nmodes_1, "
459 "[3] k2_cen, [4] k2_eff, [5] nmodes_2, "
460 "[6] Re{bk%s_raw}, [7] Im{bk%s_raw}, "
461 "[8] Re{bk%s_shot}, [9] Im{bk%s_shot}\n",
463 multipole_str, multipole_str, multipole_str, multipole_str
467 for (
int idx_dv = 0; idx_dv < meas_bispec.
dim; idx_dv++) {
470 "%.9e\t%.9e\t%10d\t%.9e\t%.9e\t%10d\t% .9e\t% .9e\t% .9e\t% .9e\n",
475 meas_bispec.
bk_raw[idx_dv].real(), meas_bispec.
bk_raw[idx_dv].imag(),
476 meas_bispec.
bk_shot[idx_dv].real(), meas_bispec.
bk_shot[idx_dv].imag()
485 char multipole_str[8];
487 multipole_str,
sizeof(multipole_str),
"%d%d%d",
495 "[0] r1_cen, [1] r1_eff, [2] npairs_1, "
496 "[3] r2_cen, [4] r2_eff, [5] npairs_2, "
497 "[6] Re{zeta%s_raw}, [7] Im{zeta%s_raw}, "
498 "[8] Re{zeta%s_shot}, [9] Im{zeta%s_shot}\n",
500 multipole_str, multipole_str, multipole_str, multipole_str
504 for (
int idx_dv = 0; idx_dv < meas_3pcf.
dim; idx_dv++) {
507 "%.9e\t%.9e\t%10d\t%.9e\t%.9e\t%10d\t% .9e\t% .9e\t% .9e\t% .9e\n",
522 char multipole_str[8];
524 multipole_str,
sizeof(multipole_str),
"%d%d%d",
532 "[0] r1_cen, [1] r1_eff, [2] npairs_1, "
533 "[3] r2_cen, [4] r2_eff, [5] npairs_2, "
534 "[6] Re{zeta%s_raw}, [7] Im{zeta%s_raw}, "
535 "[8] Re{zeta%s_shot}, [9] Im{zeta%s_shot}\n",
537 multipole_str, multipole_str, multipole_str, multipole_str
541 for (
int idx_dv = 0; idx_dv < meas_3pcf_win.
dim; idx_dv++) {
544 "%.9e\t%.9e\t%10d\t%.9e\t%.9e\t%10d\t% .9e\t% .9e\t% .9e\t% .9e\n",
545 meas_3pcf_win.
r1_bin[idx_dv], meas_3pcf_win.
r1_eff[idx_dv],
547 meas_3pcf_win.
r2_bin[idx_dv], meas_3pcf_win.
r2_eff[idx_dv],
549 meas_3pcf_win.
zeta_raw[idx_dv].real(),
550 meas_3pcf_win.
zeta_raw[idx_dv].imag(),
std::string alignment
box alignment: {"centre" (default), "pad"}
std::string assignment
mesh assignment scheme: {"ngp", "cic", "tsc" (default), "pcs"}
int ELL
spherical degree associated with the line of sight
std::string norm_convention
int ell1
spherical degree associated with the first wavevector
std::string interlace
interlacing switch: {"true"/"on", "false"/"off" (default)}
int ell2
spherical degree associated with the second wavevector
int ngrid[3]
grid cell number in each dimension
double boxsize[3]
box size (in Mpc/h) in each dimension
std::string source
catalogue source
double pos_min[3]
minimum particle coordinates
int ntotal
total number of particles
double wtotal
total overall weight of particles
double wstotal
total sample weight of particles
double pos_max[3]
maximum particle coordinates
Exception raised when an input/output operation fails.
I/O support including custom exceptions and utility functions.
void print_binned_vectors_to_file(std::FILE *fileptr, trv::ParameterSet ¶ms, trv::BinnedVectors &binned_vectors)
Print binned vectors to a file.
void print_measurement_header_to_file(std::FILE *fileptr, trv::ParameterSet ¶ms, trv::ParticleCatalogue &catalogue_data, trv::ParticleCatalogue &catalogue_rand, double norm_factor_part, double norm_factor_mesh, double norm_factor_meshes)
Print the pre-measurement header to a file including information about the catalogue(s) and mesh grid...
void print_measurement_datatab_to_file(std::FILE *fileptr, trv::ParameterSet ¶ms, trv::PowspecMeasurements &meas_powspec)
Print measurements as a data table to a file.
Logger logger
default logger (at NSET logging level)
void make_write_dir(std::string dirstr)
Make write directory.
bool if_filepath_is_set(const std::string &pathstr)
Check if a file path is set.
std::vector< double > vecy
y-components
std::vector< double > vecz
z-components
int count
number of vectors
int num_bins
number of bins
std::vector< double > upper_edges
upper bin edges
std::vector< double > lower_edges
lower bin edges
std::vector< double > vecx
x-components
std::vector< int > indices
bin indices
std::vector< std::complex< double > > bk_raw
bispectrum raw measurements (with normalisation and shot noise)
std::vector< double > k2_eff
second effective wavenumber in bins
std::vector< int > nmodes_2
std::vector< std::complex< double > > bk_shot
bispectrum shot noise
std::vector< double > k1_bin
first central wavenumber in bins
std::vector< double > k1_eff
first effective wavenumber in bins
std::vector< double > k2_bin
second central wavenumber in bins
int dim
dimension of data vector
std::vector< int > nmodes_1
number of first wavevectors in bins
Power spectrum measurements.
int dim
dimension of data vector
std::vector< double > kbin
central wavenumber in bins
std::vector< int > nmodes
std::vector< std::complex< double > > pk_shot
power spectrum shot noise
std::vector< double > keff
effective wavenumber in bins
std::vector< std::complex< double > > pk_raw
power spectrum raw measurements (with normalisation and shot noise)
Three-point correlation function measurements.
std::vector< double > r2_bin
second central separation in bins
std::vector< int > npairs_1
number of first separation vectors in bins
std::vector< double > r1_bin
first central separation in bins
std::vector< std::complex< double > > zeta_shot
three-point correlation function shot noise
std::vector< double > r2_eff
std::vector< std::complex< double > > zeta_raw
std::vector< double > r1_eff
first effective separation in bins
std::vector< int > npairs_2
number of second separation vectors in bins
int dim
dimension of data vector
Three-point correlation function window measurements.
std::vector< std::complex< double > > zeta_shot
three-point correlation function window shot noise
std::vector< int > npairs_2
number of second separation vectors in bins
std::vector< int > npairs_1
number of first separation vectors in bins
std::vector< double > r1_eff
first effective separation in bins
std::vector< double > r2_eff
int dim
dimension of data vector
std::vector< double > r2_bin
second central separation in bins
std::vector< double > r1_bin
first central separation in bins
std::vector< std::complex< double > > zeta_raw
Two-point correlation function measurements.
std::vector< double > rbin
central separation in bins
std::vector< int > npairs
int dim
dimension of data vector
std::vector< std::complex< double > > xi
two-point correlation function measurements (with normalisation)
std::vector< double > reff
effective separation in bins
Two-point correlation function window measurements.
std::vector< std::complex< double > > xi
int dim
dimension of data vector
std::vector< double > reff
effective separation in bins
std::vector< double > rbin
central separation in bins
std::vector< int > npairs