Rev 1115 | Rev 1158 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1115 | Rev 1118 | ||
---|---|---|---|
Line 35... | Line 35... | ||
35 | 35 | ||
36 | }
|
36 | }
|
37 | 37 | ||
38 | void Saplings::establishment(const ResourceUnit *ru) |
38 | void Saplings::establishment(const ResourceUnit *ru) |
39 | {
|
39 | {
|
40 | Grid<float> &seedmap = const_cast<Grid<float>& > (ru->ruSpecies().first()->species()->seedDispersal()->seedMap() ); |
- | |
41 | HeightGrid *height_grid = GlobalSettings::instance()->model()->heightGrid(); |
40 | HeightGrid *height_grid = GlobalSettings::instance()->model()->heightGrid(); |
42 | FloatGrid *lif_grid = GlobalSettings::instance()->model()->grid(); |
41 | FloatGrid *lif_grid = GlobalSettings::instance()->model()->grid(); |
43 | 42 | ||
44 | QPoint |
43 | QPoint imap = ru->cornerPointOffset(); // offset on LIF/saplings grid |
45 | QPoint |
44 | QPoint iseedmap = QPoint(imap.x()/10, imap.y()/10); // seed-map has 20m resolution, LIF 2m -> factor 10 |
46 | 45 | ||
47 | int species_idx = irandom(0, ru->ruSpecies().size()-1); |
46 | int species_idx = irandom(0, ru->ruSpecies().size()-1); |
48 | for (int s_idx = 0; s_idx<ru->ruSpecies().size(); ++s_idx) { |
47 | for (int s_idx = 0; s_idx<ru->ruSpecies().size(); ++s_idx) { |
49 | 48 | ||
50 | // start from a random species (and cycle through the available species)
|
49 | // start from a random species (and cycle through the available species)
|
51 | species_idx = ++species_idx % ru->ruSpecies().size(); |
50 | species_idx = ++species_idx % ru->ruSpecies().size(); |
52 | 51 | ||
53 | ResourceUnitSpecies *rus = ru->ruSpecies()[species_idx]; |
52 | ResourceUnitSpecies *rus = ru->ruSpecies()[species_idx]; |
54 | // check if there are seeds of the given species on the resource unit
|
53 | // check if there are seeds of the given species on the resource unit
|
55 | float seeds = 0.f; |
54 | float seeds = 0.f; |
- | 55 | Grid<float> &seedmap = const_cast<Grid<float>& >(rus->species()->seedDispersal()->seedMap()); |
|
56 | for (int iy=0;iy<5;++iy) { |
56 | for (int iy=0;iy<5;++iy) { |
57 | float *p = seedmap.ptr(iseedmap.x(), iseedmap.y()); |
57 | float *p = seedmap.ptr(iseedmap.x(), iseedmap.y()); |
58 | for (int ix=0;ix<5;++ix) |
58 | for (int ix=0;ix<5;++ix) |
59 | seeds += *p++; |
59 | seeds += *p++; |
60 | }
|
60 | }
|
Line 91... | Line 91... | ||
91 | }
|
91 | }
|
92 | 92 | ||
93 | if (viable && i_occupied>=0) { |
93 | if (viable && i_occupied>=0) { |
94 | // grass cover?
|
94 | // grass cover?
|
95 | DBG_IF(i_occupied<0, "establishment", "invalid value i_occupied<0"); |
95 | DBG_IF(i_occupied<0, "establishment", "invalid value i_occupied<0"); |
96 | float seed_map_value = seedmap[ |
96 | float seed_map_value = seedmap[mGrid.index10(isc)]; |
97 | if (seed_map_value==0.f) |
97 | if (seed_map_value==0.f) |
98 | continue; |
98 | continue; |
99 | const HeightGridValue &hgv = (*height_grid)[ |
99 | const HeightGridValue &hgv = (*height_grid)[mGrid.index5(isc)]; |
100 | float lif_value = (*lif_grid)[isc]; |
100 | float lif_value = (*lif_grid)[isc]; |
101 | double lif_corrected = rus->species()->speciesSet()->LRIcorrection(lif_value, 4. / hgv.height); |
101 | double lif_corrected = rus->species()->speciesSet()->LRIcorrection(lif_value, 4. / hgv.height); |
102 | // check for the combination of seed availability and light on the forest floor
|
102 | // check for the combination of seed availability and light on the forest floor
|
103 | if (drandom() < seed_map_value*lif_corrected*abiotic_env ) { |
103 | if (drandom() < seed_map_value*lif_corrected*abiotic_env ) { |
104 | // ok, lets add a sapling at the given position
|
104 | // ok, lets add a sapling at the given position
|
Line 177... | Line 177... | ||
177 | 177 | ||
178 | double lif_corrected = species->speciesSet()->LRIcorrection(lif_value, rel_height); // correction based on height |
178 | double lif_corrected = species->speciesSet()->LRIcorrection(lif_value, rel_height); // correction based on height |
179 | 179 | ||
180 | double lr = species->lightResponse(lif_corrected); // species specific light response (LUI, light utilization index) |
180 | double lr = species->lightResponse(lif_corrected); // species specific light response (LUI, light utilization index) |
181 | 181 | ||
- | 182 | rus->calculate(true); // calculate the 3pg module (this is done only if that did not happen up to now); true: call comes from regeneration |
|
- | 183 | double f_env_yr = rus->prod3PG().fEnvYear(); |
|
- | 184 | ||
182 | double delta_h_factor = |
185 | double delta_h_factor = f_env_yr * lr; // relative growth |
183 | 186 | ||
184 | if (h_pot<0. || delta_h_pot<0. || lif_corrected<0. || lif_corrected>1. || delta_h_factor<0. || delta_h_factor>1. ) |
187 | if (h_pot<0. || delta_h_pot<0. || lif_corrected<0. || lif_corrected>1. || delta_h_factor<0. || delta_h_factor>1. ) |
185 | qDebug() << "invalid values in Sapling::growSapling"; |
188 | qDebug() << "invalid values in Sapling::growSapling"; |
186 | 189 | ||
187 | // check browsing
|
190 | // check browsing
|