Rev 1221 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1 | |||
671 | werner | 2 | /******************************************************************************************** |
3 | ** iLand - an individual based forest landscape and disturbance model |
||
4 | ** http://iland.boku.ac.at |
||
5 | ** Copyright (C) 2009- Werner Rammer, Rupert Seidl |
||
6 | ** |
||
7 | ** This program is free software: you can redistribute it and/or modify |
||
8 | ** it under the terms of the GNU General Public License as published by |
||
9 | ** the Free Software Foundation, either version 3 of the License, or |
||
10 | ** (at your option) any later version. |
||
11 | ** |
||
12 | ** This program is distributed in the hope that it will be useful, |
||
13 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
14 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
15 | ** GNU General Public License for more details. |
||
16 | ** |
||
17 | ** You should have received a copy of the GNU General Public License |
||
18 | ** along with this program. If not, see <http://www.gnu.org/licenses/>. |
||
19 | ********************************************************************************************/ |
||
20 | |||
276 | werner | 21 | #include "treeout.h" |
808 | werner | 22 | #include "debugtimer.h" |
276 | werner | 23 | #include "tree.h" |
24 | #include "model.h" |
||
25 | #include "resourceunit.h" |
||
26 | #include "species.h" |
||
27 | #include "expressionwrapper.h" |
||
28 | |||
29 | TreeOut::TreeOut() |
||
30 | { |
||
31 | setName("Tree Output", "tree"); |
||
32 | setDescription("Output of indivdual trees. Use the ''filter'' property to reduce amount of data (filter by resource-unit, year, species, ...).\n" \ |
||
1102 | werner | 33 | "The output is triggered after the growth of the current season. " \ |
276 | werner | 34 | "Initial values (without any growth) are output as 'startyear-1'."); |
570 | werner | 35 | columns() << OutputColumn::year() << OutputColumn::ru() << OutputColumn::id() << OutputColumn::species() |
276 | werner | 36 | << OutputColumn("id", "id of the tree", OutInteger) |
303 | werner | 37 | << OutputColumn("x", "position of the tree, x-direction (m)", OutDouble) |
38 | << OutputColumn("y", "position of the tree, y-direction (m)", OutDouble) |
||
276 | werner | 39 | << OutputColumn("dbh", "dbh (cm) of the tree", OutDouble) |
40 | << OutputColumn("height", "height (m) of the tree", OutDouble) |
||
41 | << OutputColumn("basalArea", "basal area of tree in m2", OutDouble) |
||
42 | << OutputColumn("volume_m3", "volume of tree (m3)", OutDouble) |
||
43 | << OutputColumn("leafArea_m2", "current leaf area of the tree (m2)", OutDouble) |
||
44 | << OutputColumn("foliageMass", "current mass of foliage (kg)", OutDouble) |
||
45 | << OutputColumn("woodyMass", "kg Biomass in woody department", OutDouble) |
||
46 | << OutputColumn("fineRootMass", "kg Biomass in fine-root department", OutDouble) |
||
47 | << OutputColumn("coarseRootMass", "kg Biomass in coarse-root department", OutDouble) |
||
299 | werner | 48 | << OutputColumn("lri", "LightResourceIndex of the tree (raw light index from iLand, without applying resource-unit modifications)", OutDouble) |
276 | werner | 49 | << OutputColumn("lightResponse", "light response value (including species specific response to the light level)", OutDouble) |
279 | werner | 50 | << OutputColumn("stressIndex", "scalar (0..1) indicating the stress level (see [Mortality]).", OutDouble) |
276 | werner | 51 | << OutputColumn("reserve_kg", "NPP currently available in the reserve pool (kg Biomass)", OutDouble); |
52 | |||
53 | |||
54 | } |
||
55 | |||
56 | void TreeOut::setup() |
||
57 | { |
||
58 | qDebug() << "treeout::setup() called"; |
||
59 | if (!settings().isValid()) |
||
60 | throw IException("TreeOut::setup(): no parameter section in init file!"); |
||
61 | QString filter = settings().value(".filter",""); |
||
62 | mFilter.setExpression(filter); |
||
63 | } |
||
64 | |||
65 | void TreeOut::exec() |
||
66 | { |
||
67 | AllTreeIterator at(GlobalSettings::instance()->model()); |
||
68 | DebugTimer t("TreeOut::exec()"); |
||
69 | TreeWrapper tw; |
||
70 | mFilter.setModelObject(&tw); |
||
71 | while (Tree *t=at.next()) { |
||
72 | if (!mFilter.isEmpty()) { // skip fields |
||
73 | tw.setTree(t); |
||
74 | if (!mFilter.execute()) |
||
75 | continue; |
||
76 | } |
||
570 | werner | 77 | *this << currentYear() << t->ru()->index() << t->ru()->id() << t->species()->id(); |
1102 | werner | 78 | *this << t->id() << t->position().x() << t->position().y() << t->dbh() << t->height() << t->basalArea() << t->volume(); |
276 | werner | 79 | *this << t->leafArea() << t->mFoliageMass << t->mWoodyMass << t->mFineRootMass << t->mCoarseRootMass; |
279 | werner | 80 | *this << t->lightResourceIndex() << t->mLightResponse << t->mStressIndex << t->mNPPReserve; |
276 | werner | 81 | writeRow(); |
82 | } |
||
83 | |||
84 | } |
||
85 | |||
1102 | werner | 86 | |
87 | |||
88 | TreeRemovedOut::TreeRemovedOut() |
||
89 | { |
||
90 | setName("Tree Removed Output", "treeremoved"); |
||
91 | setDescription("Output of removed indivdual trees. Use the ''filter'' property to reduce amount of data (filter by resource-unit, year, species, ...).\n" \ |
||
92 | "The output is triggered immediately when a tree is removed due to mortality or management. "); |
||
93 | columns() << OutputColumn::year() << OutputColumn::ru() << OutputColumn::id() << OutputColumn::species() |
||
94 | << OutputColumn("id", "id of the tree", OutInteger) |
||
95 | << OutputColumn("reason", "reason of removal: 0: mortality, 1: management, 2: disturbance ", OutInteger) |
||
96 | << OutputColumn("x", "position of the tree, x-direction (m)", OutDouble) |
||
97 | << OutputColumn("y", "position of the tree, y-direction (m)", OutDouble) |
||
98 | << OutputColumn("dbh", "dbh (cm) of the tree", OutDouble) |
||
99 | << OutputColumn("height", "height (m) of the tree", OutDouble) |
||
100 | << OutputColumn("basalArea", "basal area of tree in m2", OutDouble) |
||
101 | << OutputColumn("volume_m3", "volume of tree (m3)", OutDouble) |
||
102 | << OutputColumn("leafArea_m2", "current leaf area of the tree (m2)", OutDouble) |
||
103 | << OutputColumn("foliageMass", "current mass of foliage (kg)", OutDouble) |
||
104 | << OutputColumn("woodyMass", "kg Biomass in woody department", OutDouble) |
||
105 | << OutputColumn("fineRootMass", "kg Biomass in fine-root department", OutDouble) |
||
106 | << OutputColumn("coarseRootMass", "kg Biomass in coarse-root department", OutDouble) |
||
107 | << OutputColumn("lri", "LightResourceIndex of the tree (raw light index from iLand, without applying resource-unit modifications)", OutDouble) |
||
108 | << OutputColumn("lightResponse", "light response value (including species specific response to the light level)", OutDouble) |
||
109 | << OutputColumn("stressIndex", "scalar (0..1) indicating the stress level (see [Mortality]).", OutDouble) |
||
110 | << OutputColumn("reserve_kg", "NPP currently available in the reserve pool (kg Biomass)", OutDouble); |
||
111 | |||
112 | } |
||
113 | |||
114 | void TreeRemovedOut::execRemovedTree(const Tree *t, int reason) |
||
115 | { |
||
116 | if (!mFilter.isEmpty()) { // skip trees if filter is present |
||
117 | TreeWrapper tw; |
||
118 | mFilter.setModelObject(&tw); |
||
119 | tw.setTree(t); |
||
120 | if (!mFilter.execute()) |
||
121 | return; |
||
122 | } |
||
123 | |||
124 | *this << currentYear() << t->ru()->index() << t->ru()->id() << t->species()->id(); |
||
125 | *this << t->id() << reason; |
||
126 | *this << t->position().x() << t->position().y() << t->dbh() << t->height() << t->basalArea() << t->volume(); |
||
127 | *this << t->leafArea() << t->mFoliageMass << t->mWoodyMass << t->mFineRootMass << t->mCoarseRootMass; |
||
128 | *this << t->lightResourceIndex() << t->mLightResponse << t->mStressIndex << t->mNPPReserve; |
||
129 | writeRow(); |
||
130 | |||
131 | } |
||
132 | |||
133 | void TreeRemovedOut::exec() |
||
134 | { |
||
135 | // do nothing here |
||
136 | return; |
||
137 | } |
||
138 | |||
139 | void TreeRemovedOut::setup() |
||
140 | { |
||
141 | QString filter = settings().value(".filter",""); |
||
142 | mFilter.setExpression(filter); |
||
143 | Tree::setTreeRemovalOutput(this); |
||
144 | |||
145 | } |