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
 
665 werner 20
#include "fireout.h"
21
#include "model.h"
22
#include "resourceunit.h"
23
#include "snag.h"
24
#include "soil.h"
25
 
26
FireOut::FireOut()
27
{
28
    mFire = 0;
29
    setName("Fire RU/yr", "fire");
30
    setDescription("Fire event aggregates per fire event. "\
31
                   "The output contains a row for each (ignited) fire event. " \
32
                   " ");
33
    columns() << OutputColumn::year()
666 werner 34
              << OutputColumn("fireId", "unique ID of the fire event (1..N) on the whole project area.", OutInteger)
665 werner 35
              << OutputColumn("area_plan_m2", "Area of the planned fire m2", OutInteger)
36
              << OutputColumn("area_m2", "Realized area of burnt cells m2", OutInteger)
37
              << OutputColumn("iterations", "Number of iterations of the cellular automaton", OutInteger)
666 werner 38
              << OutputColumn("coord_x", "Coordinates (x) of the starting point (m)", OutDouble)
39
              << OutputColumn("coord_y", "Coordinates (y) of the starting point (m)", OutDouble)
665 werner 40
              << OutputColumn("n_trees", "total number of trees on all burning cells", OutInteger)
41
              << OutputColumn("n_trees_died", "total number of trees that were killed by the fire", OutDouble)
693 werner 42
              << OutputColumn("basalArea_total", "sum of basal area on burning pixels of the fire (m2)", OutDouble)
665 werner 43
              << OutputColumn("basalArea_died", "sum of basal area of died trees (m2)", OutDouble)
690 werner 44
              << OutputColumn("psme_died", "fraction of doug fir that died (based on basal area of psme trees on burning pixels)", OutDouble)
693 werner 45
              << OutputColumn("avgFuel_kg_ha", "average total fuel (dry) (forest floor + dwd) of burning cells (kg biomass/ha)", OutDouble)
665 werner 46
              << OutputColumn("windSpeed", "current wind speed during the event (m/s)", OutDouble)
47
              << OutputColumn("windDirection", "current wind direction during the event (°)", OutDouble) ;
48
 
49
 
50
 
51
}
52
 
53
void FireOut::setup()
54
{
55
}
56
 
57
// Output function
58
// fire data is aggregated in this function for each fire event.
59
void FireOut::exec()
60
{
61
    *this << currentYear();
666 werner 62
    *this << mFire->mFireId;
665 werner 63
    *this << mFire->fireStats.fire_size_plan_m2 << mFire->fireStats.fire_size_realized_m2;
64
    *this << mFire->fireStats.iterations;
65
    *this << mFire->fireStats.startpoint.x() << mFire->fireStats.startpoint.y();
66
    int fire_id = mFire->mFireId;
67
    double avg_fuel = 0.;
68
    int n_ru = 0;
69
    double n_trees = 0.;
70
    double n_trees_died = 0.;
71
    double basal_area = 0.;
693 werner 72
    double basal_area_died = 0.;
665 werner 73
    for (FireRUData *fds = mFire->mRUGrid.begin(); fds!=mFire->mRUGrid.end(); ++fds) {
74
        if (fds->fireRUStats.fire_id == fire_id) {
75
            // the current fire burnt on this area
76
            n_ru++;
680 werner 77
            avg_fuel += fds->fireRUStats.fuel_dwd+fds->fireRUStats.fuel_ff;
665 werner 78
            n_trees += fds->fireRUStats.n_trees;
79
            n_trees_died += fds->fireRUStats.n_trees_died;
693 werner 80
            basal_area += fds->fireRUStats.basal_area;
81
            basal_area_died += fds->fireRUStats.died_basal_area;
665 werner 82
        }
83
    }
84
    if (n_ru>0) {
85
        avg_fuel /= double(n_ru);
86
    }
693 werner 87
    *this << n_trees << n_trees_died << basal_area << basal_area_died;
690 werner 88
    *this << (mFire->fireStats.fire_psme_total>0.?mFire->fireStats.fire_psme_died / mFire->fireStats.fire_psme_total:0.);
89
    *this << avg_fuel;
665 werner 90
    *this << mFire->mCurrentWindSpeed << mFire->mCurrentWindDirection;
91
 
92
    writeRow();
93
 
94
}
95