Rev 1221 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
671 | werner | 1 | /******************************************************************************************** |
2 | ** iLand - an individual based forest landscape and disturbance model |
||
3 | ** http://iland.boku.ac.at |
||
4 | ** Copyright (C) 2009- Werner Rammer, Rupert Seidl |
||
5 | ** |
||
6 | ** This program is free software: you can redistribute it and/or modify |
||
7 | ** it under the terms of the GNU General Public License as published by |
||
8 | ** the Free Software Foundation, either version 3 of the License, or |
||
9 | ** (at your option) any later version. |
||
10 | ** |
||
11 | ** This program is distributed in the hope that it will be useful, |
||
12 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
13 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
14 | ** GNU General Public License for more details. |
||
15 | ** |
||
16 | ** You should have received a copy of the GNU General Public License |
||
17 | ** along with this program. If not, see <http://www.gnu.org/licenses/>. |
||
18 | ********************************************************************************************/ |
||
19 | |||
180 | werner | 20 | #ifndef STANDSTATISTICS_H |
21 | #define STANDSTATISTICS_H |
||
22 | class Tree; |
||
257 | werner | 23 | struct TreeGrowthData; |
234 | werner | 24 | class ResourceUnitSpecies; |
1158 | werner | 25 | class SaplingStat; |
180 | werner | 26 | |
27 | class StandStatistics |
||
28 | { |
||
29 | public: |
||
234 | werner | 30 | StandStatistics() { mRUS=0; clear();} |
31 | void setResourceUnitSpecies(const ResourceUnitSpecies *rus) { mRUS=rus; } |
||
32 | |||
180 | werner | 33 | void add(const StandStatistics &stat); ///< add aggregates of @p stat to own aggregates |
1157 | werner | 34 | void addAreaWeighted(const StandStatistics &stat, const double weight); ///< add aggregates of @p stat to this aggregate and scale using the weight (e.g. stockable area) |
257 | werner | 35 | void add(const Tree *tree, const TreeGrowthData *tgd); ///< call for each tree within the domain |
1158 | werner | 36 | void add(const SaplingStat *sapling); ///< call for regeneration layer of a species in resource unit |
180 | werner | 37 | void clear(); ///< call before trees are aggregated |
1202 | werner | 38 | void clearOnlyTrees(); ///< clear the statistics only for tree biomass (keep NPP, regen, ...) |
234 | werner | 39 | void calculate(); ///< call after all trees are processed (postprocessing) |
182 | werner | 40 | // getters |
855 | werner | 41 | double count() const { return mCount; } |
257 | werner | 42 | double dbh_avg() const { return mAverageDbh; } ///< average dbh (cm) |
43 | double height_avg() const { return mAverageHeight; } ///< average tree height (m) |
||
277 | werner | 44 | double volume() const { return mSumVolume; } ///< sum of tree volume (m3/ha) |
45 | double gwl() const { return mGWL;} ///< total increment (m3/ha) |
||
46 | double basalArea() const { return mSumBasalArea; } ///< sum of basal area of all trees (m2/ha) |
||
377 | werner | 47 | double leafAreaIndex() const { return mLeafAreaIndex; } ///< [m2/m2]/ha stocked area. |
1157 | werner | 48 | double npp() const { return mNPP; } ///< sum. of NPP (kg Biomass increment, above+belowground, trees >4m)/ha |
277 | werner | 49 | double nppAbove() const { return mNPPabove; } ///< above ground NPP (kg Biomass increment)/ha |
1157 | werner | 50 | double nppSaplings() const { return mNPPsaplings; } ///< carbon gain of saplings (kg Biomass increment)/ha |
453 | werner | 51 | int cohortCount() const { return mCohortCount; } ///< number of cohorts of saplings / ha |
52 | int saplingCount() const { return mSaplingCount; } ///< number individuals in regeneration layer (represented by "cohortCount" cohorts) N/ha |
||
454 | werner | 53 | double saplingAge() const { return mAverageSaplingAge; } ///< average age of sapling (currenty not weighted with represented sapling numbers...) |
587 | werner | 54 | // carbon/nitrogen cycle |
55 | double cStem() const { return mCStem; } |
||
56 | double nStem() const { return mNStem; } |
||
57 | double cBranch() const { return mCBranch; } |
||
58 | double nBranch() const { return mNBranch; } |
||
59 | double cFoliage() const { return mCFoliage; } |
||
60 | double nFoliage() const { return mNFoliage; } |
||
61 | double cCoarseRoot() const { return mCCoarseRoot; } |
||
62 | double nCoarseRoot() const { return mNCoarseRoot; } |
||
63 | double cFineRoot() const { return mCFineRoot; } |
||
64 | double nFineRoot() const { return mNFineRoot; } |
||
65 | double cRegeneration() const { return mCRegeneration; } |
||
66 | double nRegeneration() const { return mNRegeneration; } |
||
1157 | werner | 67 | /// total carbon stock: sum of carbon of all living trees + regeneration layer |
837 | werner | 68 | double totalCarbon() const { return mCStem + mCBranch + mCFoliage + mCFineRoot + mCCoarseRoot + mCRegeneration; } |
182 | werner | 69 | |
180 | werner | 70 | private: |
587 | werner | 71 | inline void addBiomass(const double biomass, const double CNRatio, double *C, double *N); |
234 | werner | 72 | const ResourceUnitSpecies *mRUS; ///< link to the resource unit species |
855 | werner | 73 | double mCount; |
180 | werner | 74 | double mSumDbh; |
75 | double mSumHeight; |
||
76 | double mSumBasalArea; |
||
77 | double mSumVolume; |
||
277 | werner | 78 | double mGWL; |
180 | werner | 79 | double mAverageDbh; |
80 | double mAverageHeight; |
||
234 | werner | 81 | double mLeafAreaIndex; |
257 | werner | 82 | double mNPP; |
261 | werner | 83 | double mNPPabove; |
1157 | werner | 84 | double mNPPsaplings; // carbon gain of saplings |
453 | werner | 85 | // regeneration layer |
466 | werner | 86 | int mCohortCount; ///< number of cohrots |
483 | werner | 87 | int mSaplingCount; ///< number of sapling (Reinekes Law) |
454 | werner | 88 | double mSumSaplingAge; |
89 | double mAverageSaplingAge; |
||
587 | werner | 90 | // carbon and nitrogen pools |
91 | double mCStem, mCFoliage, mCBranch, mCCoarseRoot, mCFineRoot; |
||
92 | double mNStem, mNFoliage, mNBranch, mNCoarseRoot, mNFineRoot; |
||
93 | double mCRegeneration, mNRegeneration; |
||
180 | werner | 94 | }; |
95 | |||
615 | werner | 96 | |
97 | /** holds a couple of system statistics primarily aimed for performance and memory analyis. |
||
98 | */ |
||
99 | class SystemStatistics |
||
100 | { |
||
101 | public: |
||
102 | SystemStatistics() { reset(); } |
||
103 | void reset() { treeCount=0; saplingCount=0; newSaplings=0; |
||
104 | tManagement = 0.; tApplyPattern=tReadPattern=tTreeGrowth=0.; |
||
1158 | werner | 105 | tSeedDistribution=tSapling=tEstablishment=tCarbonCycle=tWriteOutput=tTotalYear=0.; } |
615 | werner | 106 | void writeOutput(); |
107 | // the system counters |
||
108 | int treeCount; |
||
109 | int saplingCount; |
||
110 | int newSaplings; |
||
111 | // timings |
||
112 | double tManagement; |
||
113 | double tApplyPattern; |
||
114 | double tReadPattern; |
||
115 | double tTreeGrowth; |
||
116 | double tSeedDistribution; |
||
1158 | werner | 117 | double tSapling; |
118 | double tEstablishment; |
||
615 | werner | 119 | double tCarbonCycle; |
120 | double tWriteOutput; |
||
121 | double tTotalYear; |
||
122 | |||
123 | }; |
||
124 | |||
180 | werner | 125 | #endif // STANDSTATISTICS_H |