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
 
179 werner 21
#include "standout.h"
22
#include "helper.h"
23
#include "model.h"
189 iland 24
#include "resourceunit.h"
179 werner 25
#include "species.h"
26
 
27
 
28
StandOut::StandOut()
29
{
30
    setName("Stand by species/RU", "stand");
1157 werner 31
    setDescription("Output of aggregates on the level of RU x species. Values are always aggregated per hectare (of stockable area). "\
32
                   "Use the 'area' column to scale to the actual values on the resource unit.\n"\
277 werner 33
                   "The output is created after the growth of the year, " \
257 werner 34
                   "i.e. output with year=2000 means effectively the state of at the end of the " \
837 werner 35
                   "year 2000. The initial state (without any growth) is indicated by the year 'startyear-1'. " \
36
                   "You can use the 'condition' to control if the output should be created for the current year(see dynamic stand output)");
570 werner 37
    columns() << OutputColumn::year() << OutputColumn::ru() << OutputColumn::id() << OutputColumn::species()
1157 werner 38
              << OutputColumn("area_ha", "stockable forest area on the resource unit (in ha).", OutDouble)
1051 werner 39
               //<< OutputColumn("x_m", "x-coord", OutInteger) <<  OutputColumn("y_m", "y-coord", OutInteger) // temp
798 werner 40
              << OutputColumn("count_ha", "tree count (living, >4m height) per ha", OutInteger)
182 werner 41
              << OutputColumn("dbh_avg_cm", "average dbh (cm)", OutDouble)
42
              << OutputColumn("height_avg_m", "average tree height (m)", OutDouble)
43
              << OutputColumn("volume_m3", "volume (geomery, taper factor) in m3", OutDouble)
837 werner 44
              << OutputColumn("total_carbon_kg", "total carbon in living biomass (aboveground compartments and roots) of all living trees (including regeneration layer) (kg/ha)", OutDouble)
277 werner 45
              << OutputColumn("gwl_m3", "'gesamtwuchsleistung' (total growth including removed/dead trees) volume (geomery, taper factor) in m3", OutDouble)
257 werner 46
              << OutputColumn("basal_area_m2", "total basal area at breast height (m2)", OutDouble)
261 werner 47
              << OutputColumn("NPP_kg", "sum of NPP (aboveground + belowground) kg Biomass/ha", OutDouble)
351 werner 48
              << OutputColumn("NPPabove_kg", "sum of NPP (abovegroundground) kg Biomass/ha", OutDouble)
456 werner 49
              << OutputColumn("LAI", "Leafareaindex (m2/m2)", OutDouble)
837 werner 50
              << OutputColumn("cohort_count_ha", "number of cohorts in the regeneration layer (<4m) /ha", OutInteger);
257 werner 51
 
179 werner 52
 }
53
 
54
void StandOut::setup()
55
{
837 werner 56
    // use a condition for to control execuation for the current year
57
    QString condition = settings().value(".condition", "");
58
    mCondition.setExpression(condition);
179 werner 59
}
60
 
61
void StandOut::exec()
62
{
63
    Model *m = GlobalSettings::instance()->model();
837 werner 64
    if (!mCondition.isEmpty())
65
        if (!mCondition.calculate(GlobalSettings::instance()->currentYear()))
66
            return;
179 werner 67
 
837 werner 68
 
189 iland 69
    foreach(ResourceUnit *ru, m->ruList()) {
574 werner 70
        if (ru->id()==-1)
71
            continue; // do not include if out of project area
455 werner 72
        foreach(const ResourceUnitSpecies *rus, ru->ruSpecies()) {
73
            const StandStatistics &stat = rus->constStatistics();
574 werner 74
            if (stat.count()==0 && stat.cohortCount()==0)
182 werner 75
                continue;
1157 werner 76
            *this << currentYear() << ru->index() << ru->id() << rus->species()->id() << ru->stockableArea()/cRUArea; // keys
1051 werner 77
            // *this << ru->boundingBox().center().x() << ru->boundingBox().center().y();  // temp
277 werner 78
            *this << stat.count() << stat.dbh_avg() << stat.height_avg()
837 werner 79
                    << stat.volume() << stat.totalCarbon() << stat.gwl() << stat.basalArea()
456 werner 80
                    << stat.npp() << stat.nppAbove() << stat.leafAreaIndex() << stat.cohortCount();
179 werner 81
            writeRow();
82
        }
83
    }
84
}