Subversion Repositories public iLand

Rev

Rev 1221 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1033 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
********************************************************************************************/
922 werner 19
#include "abestandout.h"
20
#include "globalsettings.h"
21
 
22
#include "forestmanagementengine.h"
23
#include "fmstand.h"
24
#include "fmunit.h"
25
#include "scheduler.h"
1074 werner 26
#include "species.h"
922 werner 27
 
28
namespace ABE {
29
 
30
ABEStandOut::ABEStandOut()
31
{
929 werner 32
    setName("Annual stand output (state).", "abeStand");
1074 werner 33
    setDescription("This output provides details about the forest state on stand level. " \
34
                   "The timber is provided as standing timber per hectare. \n" \
972 werner 35
                   "The output is rather performance critical. You can use the ''condition'' XML-tag to limit the execution to certain years (e.g., mod(year,10)=1 ).");
922 werner 36
    columns() << OutputColumn::year()
37
              << OutputColumn("unitid", "unique identifier of the planning unit", OutString)
38
              << OutputColumn("standid", "unique identifier of the forest stand", OutInteger)
1157 werner 39
              << OutputColumn("initialstandid", "stand id if not split, stand id of the source stand after splitting a stand.", OutInteger)
922 werner 40
              << OutputColumn("area", "total area of the forest stand (ha)", OutDouble)
929 werner 41
              << OutputColumn("volume", "standing timber volume (after harvests of the year) (m3/ha)", OutDouble)
42
              << OutputColumn("basalarea", "basal area (trees >4m) (m2/ha)", OutDouble)
43
              << OutputColumn("dbh", "mean diameter (basal area weighted, of trees >4m) (cm)", OutDouble)
44
              << OutputColumn("height", "mean stand tree height (basal area weighted, of trees >4m)(cm)", OutDouble)
45
              << OutputColumn("stems", "number of trees (trees >4m) per ha", OutDouble)
951 werner 46
              << OutputColumn("age", "the age of the stand (years since beginning of the rotation)", OutDouble)
929 werner 47
                 ;
922 werner 48
}
49
 
50
void ABEStandOut::exec()
51
{
972 werner 52
    if (!mCondition.isEmpty())
53
        if (!mCondition.calculate(GlobalSettings::instance()->currentYear()))
54
            return;
55
 
929 werner 56
    foreach(FMStand *stand, ForestManagementEngine::instance()->stands()) {
922 werner 57
 
929 werner 58
        // Note: EXPENSIVE reload operation for every stand and every year....
59
        stand->reload();
60
 
61
        *this << currentYear();
1157 werner 62
        *this << stand->unit()->id() << stand->id() << stand->initialStandId() << stand->area();
929 werner 63
        *this << qRound(stand->volume()*100.)/100.;
64
        *this << qRound(stand->basalArea()*100.)/100.;
65
        *this << qRound(stand->dbh()*100.)/100.;
66
        *this << qRound(stand->height()*100.)/100.;
67
        *this << qRound(stand->stems());
951 werner 68
        *this << stand->absoluteAge();
929 werner 69
        writeRow();
70
 
922 werner 71
    }
72
}
73
 
74
void ABEStandOut::setup()
75
{
972 werner 76
    // use a condition for to control execuation for the current year
77
    QString condition = settings().value(".condition", "");
78
    mCondition.setExpression(condition);
922 werner 79
 
80
}
81
 
1074 werner 82
ABEStandDetailsOut::ABEStandDetailsOut()
83
{
84
    setName("Detailed annual stand output (state).", "abeStandDetail");
85
    setDescription("This output provides details about the forest state on species- and stand level. " \
86
                   "This output is more detailed than the abeStand output.\n" \
87
                   "The output is rather performance critical. You can use the ''condition'' XML-tag to limit the execution to certain years (e.g., mod(year,10)=1 ).");
88
    columns() << OutputColumn::year()
89
              << OutputColumn::species()
90
              << OutputColumn("standid", "unique identifier of the forest stand", OutInteger)
91
              << OutputColumn("basalarea", "basal area of the species(trees >4m) (m2/ha)", OutDouble)
92
              << OutputColumn("relBasalarea", "relative basal area share of the species (trees >4m) (0..1)", OutDouble)
93
                 ;
922 werner 94
 
1074 werner 95
}
922 werner 96
 
1074 werner 97
void ABEStandDetailsOut::exec()
98
{
99
    if (!mCondition.isEmpty())
100
        if (!mCondition.calculate(GlobalSettings::instance()->currentYear()))
101
            return;
922 werner 102
 
1074 werner 103
    foreach(FMStand *stand, ForestManagementEngine::instance()->stands()) {
104
 
105
        // Note: EXPENSIVE reload operation for every stand and every year....
106
        stand->reload();
107
 
108
        // loop over all species
109
        for (int i = 0; i<stand->nspecies(); ++i) {
110
            SSpeciesStand &sss = stand->speciesData(i);
111
            *this << currentYear();
112
            *this << sss.species->id();
113
            *this << stand->id();
114
            *this << sss.basalArea;
115
            *this << sss.relBasalArea;
116
            writeRow();
117
        }
118
 
119
    }
120
 
121
 
122
}
123
 
124
void ABEStandDetailsOut::setup()
125
{
126
    // use a condition for to control execuation for the current year
127
    QString condition = settings().value(".condition", "");
128
    mCondition.setExpression(condition);
129
 
130
}
131
 
132
 
133
 
134
 
922 werner 135
} // namespace