globalco2file.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. ///////////////////////////////////////////////////////////////////////////////////////
  2. /// \file globalco2file.h
  3. /// \brief A class for reading in CO2 values from a text file
  4. ///
  5. ///
  6. /// \author Joe Siltberg
  7. ///
  8. /// $Date: 2014-09-09 10:49:13 +0200 (mar, 09 sep 2014) $
  9. ///
  10. ///////////////////////////////////////////////////////////////////////////////////////
  11. #ifndef LPJ_GUESS_GLOBALCO2FILE_H
  12. #define LPJ_GUESS_GLOBALCO2FILE_H
  13. #include <vector>
  14. /// Reads in and stores CO2 values from a text file
  15. class GlobalCO2File {
  16. public:
  17. GlobalCO2File();
  18. /// Loads CO2 values from text file
  19. /** The text file specifies CO2 values for historical period, each line in
  20. * the format <year> <co2-value>. The years can be for any period but all
  21. * years in the period must be specified.
  22. */
  23. void load_file(const char* path);
  24. /// Returns the CO2 value for a given year
  25. /** When accessing co2 values outside of the period specified in the file,
  26. * the class will return the co2 value for the first or the last year
  27. * specified.
  28. *
  29. * \param year The historical year for which to get the CO2 value
  30. */
  31. double operator[](int year) const;
  32. private:
  33. /// The co2 values from file
  34. std::vector<double> co2;
  35. /// The first historical year
  36. int first_year;
  37. };
  38. #endif // LPJ_GUESS_GLOBALCO2FILE_H