cphot 0.1
A C++ tool for computing photometry from spectra.
hdf5test.cpp
Go to the documentation of this file.
1 /**
2  * @file hdf5lib_test.cpp
3  * @brief Testing the hdf5 library interface and the file content
4  *
5  * In this module, we create a HDF5Library from the pyphot library file and
6  * extract the characteristics of all the filters to create a csv table.
7  * The pyphot library is downloaded from the pyphot website using
8  * `cphot::download_pyphot_hdf5library`.
9  */
10 #include <cphot/filter.hpp>
11 #include <cphot/library.hpp>
12 #include <cphot/rquantities.hpp>
13 #include <iostream>
14 #include <fstream>
15 #include <cphot/io.hpp>
16 
17 
18 int main(){
19  std::string filename = "pyphot_library.hdf5";
21 
22  auto lib = cphot::HDF5Library(filename);
23  std::cout << lib << "\n";
24 
25  std::ofstream out("filters_properties.csv");
26 
27  out << "name" << ", "
28  << "detector type" << ", "
29  << "wavelength units" << ", "
30  << "number of def points" << ", "
31  << "central wavelength (nm)" << ", "
32  << "pivot wavelength (nm)" << ", "
33  << "effective wavelength (nm)" << ", "
34  << "Vega mag (mag)" << ", "
35  << "Vega flux (flam)" << ", "
36  << "Vega flux (Jy)" << ", "
37  << "AB mag (mag)" << ", "
38  << "AB flux (flam)" << ", "
39  << "AB flux (Jy)" << ", "
40  << "ST mag (mag)" << ", "
41  << "ST flux (flam)" << ", "
42  << "ST flux (Jy)"
43  << "\n";
44 
45  for (auto & c : lib.get_content()) {
46  auto current = lib.load_filter(c);
47  out << current.get_name() << ", "
48  << (current.is_photon_type() ? "photon" : "energy") << ", "
49  << "nm" << ", " // coherence with pyphot table
50  << current.get_wavelength().size() << ", "
51  << current.get_cl().to(nm) << ", "
52  << current.get_lpivot().to(nm) << ", "
53  << current.get_leff().to(nm) << ", "
54  << current.get_Vega_zero_mag() << ", "
55  << current.get_Vega_zero_flux().to(flam) << ", "
56  << current.get_Vega_zero_Jy().to(Jy) << ", "
57  << current.get_AB_zero_mag() << ", "
58  << current.get_AB_zero_flux().to(flam) << ", "
59  << current.get_AB_zero_Jy().to(Jy) << ", "
60  << current.get_ST_zero_mag() << ", "
61  << current.get_ST_zero_flux().to(flam) << ", "
62  << current.get_ST_zero_Jy().to(Jy)
63  << "\n";
64 
65  }
66  std::cout << lib.find("gaia", false) << "\n";
67  out.close();
68 
69  return 0;
70 }
filter.hpp
rquantities.hpp
io.hpp
library.hpp
c
constexpr QSpeed c
Definition: rquantities.hpp:351
cphot::download_pyphot_hdf5library
std::string download_pyphot_hdf5library(const std::string &where="./pyphot_library.hdf5")
Download the filter library from pyphot repository.
Definition: io.hpp:97
Jy
constexpr QSpectralFluxDensity Jy
Definition: rquantities.hpp:364
nm
constexpr QLength nm
Definition: rquantities.hpp:273
flam
constexpr QSpectralFluxDensity flam
Definition: rquantities.hpp:361
main
int main()
Definition: hdf5test.cpp:18
cphot::HDF5Library
Storage of filters in HDF5 format.
Definition: library.hpp:135