Subversion Repositories public iLand

Rev

Rev 1221 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1221 Rev 1222
1
Redirecting to URL 'https://iland.boku.ac.at/svn/iland/tags/release_1.0/src/core/seeddispersal.h':
1
Redirecting to URL 'https://iland.boku.ac.at/svn/iland/tags/release_1.0/src/core/seeddispersal.h':
2
/********************************************************************************************
2
/********************************************************************************************
3
**    iLand - an individual based forest landscape and disturbance model
3
**    iLand - an individual based forest landscape and disturbance model
4
**    http://iland.boku.ac.at
4
**    http://iland.boku.ac.at
5
**    Copyright (C) 2009-  Werner Rammer, Rupert Seidl
5
**    Copyright (C) 2009-  Werner Rammer, Rupert Seidl
6
**
6
**
7
**    This program is free software: you can redistribute it and/or modify
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
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
9
**    the Free Software Foundation, either version 3 of the License, or
10
**    (at your option) any later version.
10
**    (at your option) any later version.
11
**
11
**
12
**    This program is distributed in the hope that it will be useful,
12
**    This program is distributed in the hope that it will be useful,
13
**    but WITHOUT ANY WARRANTY; without even the implied warranty of
13
**    but WITHOUT ANY WARRANTY; without even the implied warranty of
14
**    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
**    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
**    GNU General Public License for more details.
15
**    GNU General Public License for more details.
16
**
16
**
17
**    You should have received a copy of the GNU General Public License
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/>.
18
**    along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
********************************************************************************************/
19
********************************************************************************************/
20
20
21
#ifndef SEEDDISPERSAL_H
21
#ifndef SEEDDISPERSAL_H
22
#define SEEDDISPERSAL_H
22
#define SEEDDISPERSAL_H
23
#include <QHash>
23
#include <QHash>
24
#include "grid.h"
24
#include "grid.h"
25
class Species;
25
class Species;
26
26
27
class SeedDispersal
27
class SeedDispersal
28
{
28
{
29
public:
29
public:
30
    SeedDispersal(Species *species=0): mIndexFactor(10), mSetup(false), mSpecies(species) {}
30
    SeedDispersal(Species *species=0): mIndexFactor(10), mSetup(false), mSpecies(species) {}
31
    ~SeedDispersal();
31
    ~SeedDispersal();
32
    bool isSetup() const { return mSetup; }
32
    bool isSetup() const { return mSetup; }
33
    void setup();
33
    void setup();
34
    //
34
    //
35
    static void setupExternalSeeds();
35
    static void setupExternalSeeds();
36
    static void finalizeExternalSeeds();
36
    static void finalizeExternalSeeds();
37
    // access
37
    // access
38
    const Grid<float> &seedMap() const { return mSeedMap; } ///< access to the seedMap
38
    const Grid<float> &seedMap() const { return mSeedMap; } ///< access to the seedMap
39
    const Species *species() const {return mSpecies; }
39
    const Species *species() const {return mSpecies; }
40
    /// setMatureTree is called by individual (mature) trees. This actually fills the initial state of the seed map.
40
    /// setMatureTree is called by individual (mature) trees. This actually fills the initial state of the seed map.
41
    void setMatureTree(const QPoint &lip_index, double leaf_area) {
41
    void setMatureTree(const QPoint &lip_index, double leaf_area) {
42
        if (mProbMode)
42
        if (mProbMode)
43
            mSeedMap.valueAtIndex(lip_index.x()/mIndexFactor, lip_index.y()/mIndexFactor)=1.f;
43
            mSeedMap.valueAtIndex(lip_index.x()/mIndexFactor, lip_index.y()/mIndexFactor)=1.f;
44
        else
44
        else
45
            mSourceMap.valueAtIndex(lip_index.x()/mIndexFactor, lip_index.y()/mIndexFactor) += leaf_area;
45
            mSourceMap.valueAtIndex(lip_index.x()/mIndexFactor, lip_index.y()/mIndexFactor) += leaf_area;
46
    }
46
    }
47
    /// extra seed rain of serotinous species at 'position_index'
47
    /// extra seed rain of serotinous species at 'position_index'
48
    void seedProductionSerotiny(const QPoint &position_index);
48
    void seedProductionSerotiny(const QPoint &position_index);
49
49
50
    // operations
50
    // operations
51
    void clear(); ///< clears the grid
51
    void clear(); ///< clears the grid
52
    void execute(); ///< execute the seed dispersal
52
    void execute(); ///< execute the seed dispersal
53
    bool edgeDetection(Grid<float> *seed_map = 0); ///< phase 1: detect edges in the image; returns false if *no* pixel is 'lit'
53
    bool edgeDetection(Grid<float> *seed_map = 0); ///< phase 1: detect edges in the image; returns false if *no* pixel is 'lit'
54
    void distribute(Grid<float> *seed_map = 0); ///< phase 2: distribute seeds
54
    void distribute(Grid<float> *seed_map = 0); ///< phase 2: distribute seeds
55
    // functions for non-probability mode
55
    // functions for non-probability mode
56
    void distributeSeeds(Grid<float> *seed_map=0);
56
    void distributeSeeds(Grid<float> *seed_map=0);
57
    // debug and helpers
57
    // debug and helpers
58
    void loadFromImage(const QString &fileName); ///< debug function...
58
    void loadFromImage(const QString &fileName); ///< debug function...
59
    void dumpMapNextYear(QString file_name) { mDumpNextYearFileName = file_name; }
59
    void dumpMapNextYear(QString file_name) { mDumpNextYearFileName = file_name; }
60
private:
60
private:
61
    void createKernel(Grid<float> &kernel, const double max_seed, const double scale_area); ///< initializes / creates the kernel
61
    void createKernel(Grid<float> &kernel, const double max_seed, const double scale_area); ///< initializes / creates the kernel
62
    double setupLDD(); ///< initialize long distance seed dispersal
62
    double setupLDD(); ///< initialize long distance seed dispersal
63
    double treemig(const double &distance);
63
    double treemig(const double &distance);
64
    // numerical integration of the treemig function up to a radius 'max_distance'
64
    // numerical integration of the treemig function up to a radius 'max_distance'
65
    double treemig_centercell(const double &max_distance);
65
    double treemig_centercell(const double &max_distance);
66
    double treemig_distanceTo(const double value);
66
    double treemig_distanceTo(const double value);
67
    bool mProbMode; ///< if 'true', seed dispersal uses probabilities to distribute (old version)
67
    bool mProbMode; ///< if 'true', seed dispersal uses probabilities to distribute (old version)
68
    double mTM_as1, mTM_as2, mTM_ks; ///< seed dispersal paramaters (treemig)
68
    double mTM_as1, mTM_as2, mTM_ks; ///< seed dispersal paramaters (treemig)
69
    double mTM_fecundity_cell; ///< maximum seeds per source cell
69
    double mTM_fecundity_cell; ///< maximum seeds per source cell
70
    double mTM_occupancy; ///< seeds required per destination regeneration pixel
70
    double mTM_occupancy; ///< seeds required per destination regeneration pixel
71
    double mNonSeedYearFraction; ///< fraction of the seed production in non-seed-years
71
    double mNonSeedYearFraction; ///< fraction of the seed production in non-seed-years
72
    double mKernelThresholdArea, mKernelThresholdLDD; ///< value of the kernel function that is the threhold for full coverage and LDD, respectively
72
    double mKernelThresholdArea, mKernelThresholdLDD; ///< value of the kernel function that is the threhold for full coverage and LDD, respectively
73
    int mIndexFactor; ///< multiplier between light-pixel-size and seed-pixel-size
73
    int mIndexFactor; ///< multiplier between light-pixel-size and seed-pixel-size
74
    Grid<float> mSeedMap; ///< (large) seedmap. Is filled by individual trees and then processed
74
    Grid<float> mSeedMap; ///< (large) seedmap. Is filled by individual trees and then processed
75
    Grid<float> mSourceMap; ///< (large) seedmap used to denote the sources
75
    Grid<float> mSourceMap; ///< (large) seedmap used to denote the sources
76
    Grid<float> mKernelSeedYear; ///< species specific "seed kernel" (small) for seed years
76
    Grid<float> mKernelSeedYear; ///< species specific "seed kernel" (small) for seed years
77
    Grid<float> mKernelNonSeedYear; ///< species specific "seed kernel" (small) for non-seed-years
77
    Grid<float> mKernelNonSeedYear; ///< species specific "seed kernel" (small) for non-seed-years
78
    Grid<float> mKernelSerotiny; ///< seed kernel for extra seed rain
78
    Grid<float> mKernelSerotiny; ///< seed kernel for extra seed rain
79
    Grid<float> mSeedMapSerotiny; ///< seed map that keeps track of serotiny events
79
    Grid<float> mSeedMapSerotiny; ///< seed map that keeps track of serotiny events
80
    QVector<double> mLDDDistance; ///< long distance dispersal distances (e.g. the "rings")
80
    QVector<double> mLDDDistance; ///< long distance dispersal distances (e.g. the "rings")
81
    QVector<double> mLDDDensity;  ///< long distance dispersal # of cells that should be affected in each "ring"
81
    QVector<double> mLDDDensity;  ///< long distance dispersal # of cells that should be affected in each "ring"
82
    int mLDDRings; ///< # of rings (with equal probability) for LDD
82
    int mLDDRings; ///< # of rings (with equal probability) for LDD
83
    float mLDDSeedlings; ///< each LDD pixel has this probability
83
    float mLDDSeedlings; ///< each LDD pixel has this probability
84
    bool mHasPendingSerotiny; ///< true if active (unprocessed) pixels are on the extra-serotiny map
84
    bool mHasPendingSerotiny; ///< true if active (unprocessed) pixels are on the extra-serotiny map
85
    bool mSetup;
85
    bool mSetup;
86
    Species *mSpecies;
86
    Species *mSpecies;
87
    bool mDumpSeedMaps; ///< if true, seedmaps are stored as images
87
    bool mDumpSeedMaps; ///< if true, seedmaps are stored as images
88
    bool mHasExternalSeedInput; ///< if true, external seeds are modelled for the species
88
    bool mHasExternalSeedInput; ///< if true, external seeds are modelled for the species
89
    QString mDumpNextYearFileName; ///< debug output - dump of the content of the grid to a file during the next execution
89
    QString mDumpNextYearFileName; ///< debug output - dump of the content of the grid to a file during the next execution
90
    int mExternalSeedDirection; ///< direction of external seeds
90
    int mExternalSeedDirection; ///< direction of external seeds
91
    int mExternalSeedBuffer; ///< how many 20m pixels away from the simulation area should the seeding start?
91
    int mExternalSeedBuffer; ///< how many 20m pixels away from the simulation area should the seeding start?
92
    double mExternalSeedBackgroundInput; ///< background propability for this species; if set, then a certain seed availability is provided for the full area
92
    double mExternalSeedBackgroundInput; ///< background propability for this species; if set, then a certain seed availability is provided for the full area
93
    // external seeds
93
    // external seeds
94
    Grid<float> mExternalSeedMap; ///< for more complex external seed input, this map holds that information
94
    Grid<float> mExternalSeedMap; ///< for more complex external seed input, this map holds that information
95
    void setupExternalSeedsForSpecies(Species *species); ///< setup of special external seed input
95
    void setupExternalSeedsForSpecies(Species *species); ///< setup of special external seed input
96
    static Grid<float> *mExternalSeedBaseMap; ///< static intermediate data while setting up external seeds
96
    static Grid<float> *mExternalSeedBaseMap; ///< static intermediate data while setting up external seeds
97
    static QHash<QString, QVector<double> > mExtSeedData; ///< holds definition of species and percentages for external seed input
97
    static QHash<QString, QVector<double> > mExtSeedData; ///< holds definition of species and percentages for external seed input
98
    static int mExtSeedSizeX, mExtSeedSizeY; ///< size of the sectors used to specify external seed input
98
    static int mExtSeedSizeX, mExtSeedSizeY; ///< size of the sectors used to specify external seed input
99
};
99
};
100
100
101
#endif // SEEDDISPERSAL_H
101
#endif // SEEDDISPERSAL_H
102
 
102