lamarquendep.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. ///////////////////////////////////////////////////////////////////////////////////////
  2. /// \file lamarquendep.h
  3. /// \brief Functionality for reading the Lamarque Nitrogen deposition data set
  4. ///
  5. /// $Date$
  6. ///
  7. ///////////////////////////////////////////////////////////////////////////////////////
  8. #ifndef LPJ_GUESS_LAMARQUENDEP_H
  9. #define LPJ_GUESS_LAMARQUENDEP_H
  10. #include <string>
  11. namespace Lamarque {
  12. /// number of years of historical nitrogen deposition
  13. /** One year from each decade 1850-2009 */
  14. const int NYEAR_HISTNDEP = 16;
  15. /// number of years of scenario nitrogen deposition
  16. /** One year from each decade 2000-2109 */
  17. const int NYEAR_SCENNDEP = 11;
  18. /// total number of years of nitrogen deposition
  19. /** historic and scenario overlap one decade */
  20. const int NYEAR_TOTNDEP = NYEAR_HISTNDEP + NYEAR_SCENNDEP - 1;
  21. /// calendar year corresponding to first year nitrogen deposition
  22. const int FIRSTHISTYEARNDEP=1850;
  23. /// Type of time series to use (historic/scenario/fixed)
  24. enum timeseriestype {
  25. /// Only the historic (1850-2009) data set
  26. HISTORIC,
  27. /// Historic + RCP 2.6
  28. RCP26,
  29. /// Historic + RCP 4.5
  30. RCP45,
  31. /// Historic + RCP 6.0
  32. RCP60,
  33. /// Historic + RCP 8.5
  34. RCP85,
  35. /// Fixed pre-industrial values
  36. FIXED,
  37. };
  38. /// Converts a string ("historic", "rcp26" etc.) to a timeseriestype
  39. /** Case insensitive */
  40. timeseriestype parse_timeseries(const std::string& str);
  41. /// Nitrogen deposition forcing for a single grid cell
  42. class NDepData {
  43. public:
  44. /// Default constructor
  45. /** Before getndep is called the data will all be set to
  46. * pre-industrial level (same as calling getndep with an empty filename).
  47. */
  48. NDepData();
  49. /// Retrieves nitrogen deposition for a particular gridcell
  50. /** The values are either taken from a binary archive file or when it's not
  51. * provided default to pre-industrial level of 2 kgN/ha/year.
  52. *
  53. * The binary archive files have nitrogen deposition in gN/m2 on a monthly timestep
  54. * for 16 years with 10 year interval starting from 1850 (Lamarque et. al., 2011).
  55. *
  56. * \param file_ndep Path to binary archive (empty gives pre-industrial values)
  57. * \param lon Longitude
  58. * \param lat Latitude
  59. * \param timeseries Which time series to use
  60. */
  61. void getndep(const char* file_ndep,
  62. double lon, double lat,
  63. timeseriestype timeseries = HISTORIC);
  64. /// ecev3 - Retrieves the NEAREST nitrogen deposition for a particular gridcell
  65. /** The values are either taken from a binary archive file or when it's not
  66. * provided default to pre-industrial level of 2 kgN/ha/year.
  67. *
  68. * The binary archive files have nitrogen deposition in gN/m2 on a monthly timestep
  69. * for 16 years with 10 year interval starting from 1850 (Lamarque et. al., 2011).
  70. *
  71. * \param file_ndep Path to binary archive (empty gives pre-industrial values)
  72. * \param lon Longitude
  73. * \param lat Latitude
  74. * \param timeseries Which time series to use
  75. */
  76. bool getndep_nearest(const char* file_ndep,
  77. double lon, double lat,
  78. timeseriestype timeseries = HISTORIC);
  79. /// Returns nitrogen deposition for one year
  80. /** Given a calendar year, this function chooses values from the correct
  81. * 10 year interval, and sums the different types of wet and dry
  82. * deposition.
  83. *
  84. * If calendar_year is earlier than the first year in data set (1850),
  85. * the values for the first year will be used. If later than the last
  86. * year, fail() is called and the program terminated.
  87. *
  88. * \param calendar_year The year for which to get ndep data
  89. * \param mndrydep Monthly values for dry nitrogen deposition (kgN/m2/day)
  90. * \param mnwetdep Monthly values for wet nitrogen deposition (kgN/m2/day)
  91. */
  92. void get_one_calendar_year(int calendar_year,
  93. double mndrydep[12],
  94. double mnwetdep[12]);
  95. private:
  96. /// Fills all arrays with pre-industrial level of 2 kgN/ha/year
  97. void set_to_pre_industrial();
  98. /// Currently chosen type of time series
  99. timeseriestype timeseries;
  100. /// Monthly data on daily dry NHx deposition (kgN/m2/day)
  101. double NHxDryDep[NYEAR_TOTNDEP][12];
  102. /// Monthly data on daily wet NHx deposition (kgN/m2/day)
  103. double NHxWetDep[NYEAR_TOTNDEP][12];
  104. /// Monthly data on daily dry NOy deposition (kgN/m2/day)
  105. double NOyDryDep[NYEAR_TOTNDEP][12];
  106. /// Monthly data on daily wet NOy deposition (kgN/m2/day)
  107. double NOyWetDep[NYEAR_TOTNDEP][12];
  108. };
  109. }
  110. #endif // LPJ_GUESS_LAMARQUENDEP_H