Subversion Repositories public iLand

Rev

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