Subversion Repositories public iLand

Rev

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
 
278 werner 21
#include "managementout.h"
22
 
23
#include "helper.h"
24
#include "model.h"
25
#include "resourceunit.h"
26
#include "species.h"
27
 
28
ManagementOut::ManagementOut()
29
{
30
    setName("Removed trees by species/RU", "management");
1157 werner 31
    setDescription("Aggregates for trees that are removed in current year on the level of RU x species. All values are scaled to one hectare."\
278 werner 32
                   "The output is created after the growth of the year, " \
662 werner 33
                   "i.e. the growth of the year in which trees are dying, is included!  " \
278 werner 34
                   " ");
570 werner 35
    columns() << OutputColumn::year() << OutputColumn::ru() << OutputColumn::id() << OutputColumn::species()
278 werner 36
              << OutputColumn("count_ha", "tree count (living)", OutInteger)
37
              << OutputColumn("dbh_avg_cm", "average dbh (cm)", OutDouble)
38
              << OutputColumn("height_avg_m", "average tree height (m)", OutDouble)
39
              << OutputColumn("volume_m3", "volume (geomery, taper factor) in m3", OutDouble)
40
              << OutputColumn("basal_area_m2", "total basal area at breast height (m2)", OutDouble);
41
 
42
 
43
 }
44
 
45
void ManagementOut::setup()
46
{
47
}
48
 
49
void ManagementOut::exec()
50
{
51
    Model *m = GlobalSettings::instance()->model();
52
 
53
    foreach(ResourceUnit *ru, m->ruList()) {
574 werner 54
        if (ru->id()==-1)
55
            continue; // do not include if out of project area
56
 
455 werner 57
        foreach(const ResourceUnitSpecies *rus, ru->ruSpecies()) {
58
            const StandStatistics &stat = rus->constStatisticsMgmt();
278 werner 59
            if (stat.count()==0)
60
                continue;
570 werner 61
            *this << currentYear() << ru->index() << ru->id() << rus->species()->id(); // keys
278 werner 62
            *this << stat.count() << stat.dbh_avg() << stat.height_avg() << stat.volume() << stat.basalArea();
63
 
64
            writeRow();
65
        }
66
    }
67
}