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 | |||
373 | werner | 20 | #ifndef SEEDDISPERSAL_H |
21 | #define SEEDDISPERSAL_H |
||
764 | werner | 22 | #include <QHash> |
373 | werner | 23 | #include "grid.h" |
387 | werner | 24 | class Species; |
373 | werner | 25 | |
26 | class SeedDispersal |
||
27 | { |
||
28 | public: |
||
387 | werner | 29 | SeedDispersal(Species *species=0): mIndexFactor(10), mSetup(false), mSpecies(species) {} |
373 | werner | 30 | ~SeedDispersal(); |
31 | bool isSetup() const { return mSetup; } |
||
32 | void setup(); |
||
764 | werner | 33 | // |
34 | static void setupExternalSeeds(); |
||
35 | static void finalizeExternalSeeds(); |
||
375 | werner | 36 | // access |
704 | werner | 37 | const Grid<float> &seedMap() const { return mSeedMap; } ///< access to the seedMap |
387 | werner | 38 | const Species *species() const {return mSpecies; } |
391 | werner | 39 | /// setMatureTree is called by individual (mature) trees. This actually fills the initial state of the seed map. |
1180 | werner | 40 | void setMatureTree(const QPoint &lip_index, double leaf_area) { |
41 | if (mProbMode) |
||
42 | mSeedMap.valueAtIndex(lip_index.x()/mIndexFactor, lip_index.y()/mIndexFactor)=1.f; |
||
43 | else |
||
44 | mSourceMap.valueAtIndex(lip_index.x()/mIndexFactor, lip_index.y()/mIndexFactor) += leaf_area; |
||
45 | } |
||
1167 | werner | 46 | /// extra seed rain of serotinous species at 'position_index' |
47 | void seedProductionSerotiny(const QPoint &position_index); |
||
48 | |||
375 | werner | 49 | // operations |
50 | void clear(); ///< clears the grid |
||
51 | void execute(); ///< execute the seed dispersal |
||
1167 | werner | 52 | bool edgeDetection(Grid<float> *seed_map = 0); ///< phase 1: detect edges in the image; returns false if *no* pixel is 'lit' |
53 | void distribute(Grid<float> *seed_map = 0); ///< phase 2: distribute seeds |
||
1180 | werner | 54 | // functions for non-probability mode |
55 | void distributeSeeds(Grid<float> *seed_map=0); |
||
391 | werner | 56 | // debug and helpers |
375 | werner | 57 | void loadFromImage(const QString &fileName); ///< debug function... |
1064 | werner | 58 | void dumpMapNextYear(QString file_name) { mDumpNextYearFileName = file_name; } |
375 | werner | 59 | private: |
1180 | werner | 60 | void createKernel(Grid<float> &kernel, const double max_seed, const double scale_area); ///< initializes / creates the kernel |
61 | double setupLDD(); ///< initialize long distance seed dispersal |
||
391 | werner | 62 | double treemig(const double &distance); |
1178 | werner | 63 | // numerical integration of the treemig function up to a radius 'max_distance' |
64 | double treemig_centercell(const double &max_distance); |
||
391 | werner | 65 | double treemig_distanceTo(const double value); |
1180 | werner | 66 | bool mProbMode; ///< if 'true', seed dispersal uses probabilities to distribute (old version) |
391 | werner | 67 | double mTM_as1, mTM_as2, mTM_ks; ///< seed dispersal paramaters (treemig) |
445 | werner | 68 | double mTM_fecundity_cell; ///< maximum seeds per source cell |
69 | double mTM_occupancy; ///< seeds required per destination regeneration pixel |
||
415 | werner | 70 | double mNonSeedYearFraction; ///< fraction of the seed production in non-seed-years |
1176 | werner | 71 | double mKernelThresholdArea, mKernelThresholdLDD; ///< value of the kernel function that is the threhold for full coverage and LDD, respectively |
391 | werner | 72 | int mIndexFactor; ///< multiplier between light-pixel-size and seed-pixel-size |
373 | werner | 73 | Grid<float> mSeedMap; ///< (large) seedmap. Is filled by individual trees and then processed |
1180 | werner | 74 | Grid<float> mSourceMap; ///< (large) seedmap used to denote the sources |
415 | werner | 75 | Grid<float> mKernelSeedYear; ///< species specific "seed kernel" (small) for seed years |
76 | Grid<float> mKernelNonSeedYear; ///< species specific "seed kernel" (small) for non-seed-years |
||
1167 | werner | 77 | Grid<float> mKernelSerotiny; ///< seed kernel for extra seed rain |
1168 | werner | 78 | Grid<float> mSeedMapSerotiny; ///< seed map that keeps track of serotiny events |
1176 | werner | 79 | QVector<double> mLDDDistance; ///< long distance dispersal distances (e.g. the "rings") |
80 | QVector<double> mLDDDensity; ///< long distance dispersal # of cells that should be affected in each "ring" |
||
81 | int mLDDRings; ///< # of rings (with equal probability) for LDD |
||
1180 | werner | 82 | float mLDDSeedlings; ///< each LDD pixel has this probability |
1167 | werner | 83 | bool mHasPendingSerotiny; ///< true if active (unprocessed) pixels are on the extra-serotiny map |
373 | werner | 84 | bool mSetup; |
387 | werner | 85 | Species *mSpecies; |
472 | werner | 86 | bool mDumpSeedMaps; ///< if true, seedmaps are stored as images |
87 | bool mHasExternalSeedInput; ///< if true, external seeds are modelled for the species |
||
1064 | werner | 88 | QString mDumpNextYearFileName; ///< debug output - dump of the content of the grid to a file during the next execution |
491 | werner | 89 | int mExternalSeedDirection; ///< direction of external seeds |
90 | int mExternalSeedBuffer; ///< how many 20m pixels away from the simulation area should the seeding start? |
||
836 | werner | 91 | double mExternalSeedBackgroundInput; ///< background propability for this species; if set, then a certain seed availability is provided for the full area |
764 | werner | 92 | // external seeds |
93 | Grid<float> mExternalSeedMap; ///< for more complex external seed input, this map holds that information |
||
94 | void setupExternalSeedsForSpecies(Species *species); ///< setup of special external seed input |
||
95 | static Grid<float> *mExternalSeedBaseMap; ///< static intermediate data while setting up external seeds |
||
96 | static QHash<QString, QVector<double> > mExtSeedData; ///< holds definition of species and percentages for external seed input |
||
97 | static int mExtSeedSizeX, mExtSeedSizeY; ///< size of the sectors used to specify external seed input |
||
373 | werner | 98 | }; |
99 | |||
100 | #endif // SEEDDISPERSAL_H |