read-spectra.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #ifndef SRC_READ_SPECTRA_READ_SPECTRA_H_
  2. #define SRC_READ_SPECTRA_READ_SPECTRA_H_
  3. /**
  4. * @file read-spectra.h
  5. * @author Konstantin Ladutenko <kostyfisik at gmail (.) com>
  6. * @date Wed Mar 11 11:19:34 2015
  7. * @copyright 2015 Konstantin Ladutenko
  8. *
  9. * @brief Read complex spectra from file in format 'WL real imag'
  10. *
  11. * read-spectra is free software: you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation, either version 3 of the License, or
  14. * (at your option) any later version.
  15. *
  16. * read-spectra is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with read-spectra. If not, see <http://www.gnu.org/licenses/>.
  23. *
  24. */
  25. #include <vector>
  26. #include <string>
  27. #include <complex>
  28. #include <utility>
  29. namespace read_spectra {
  30. class ReadSpectra { // will throw for any error
  31. public:
  32. ReadSpectra &ReadFromFile(std::string filename);
  33. ReadSpectra &ResizeToComplex(double from_wl, double to_wl, int samples);
  34. ReadSpectra &ToIndex();
  35. std::complex<double> at(double wavelength);
  36. void PrintData();
  37. std::vector< std::pair< double, std::complex<double> > >&
  38. GetIndex(){return data_complex_index_;};
  39. private:
  40. std::vector< std::vector<double> > data_;
  41. std::vector< std::pair< double, std::complex<double> > > data_complex_;
  42. std::vector< std::pair< double, std::complex<double> > > data_complex_index_;
  43. void PermittivityToIndex();
  44. }; // end of class ReadSpectra
  45. } // end of namespase read_spectra
  46. #endif // SRC_READ_SPECTRA_READ_SPECTRA_H_