@@ -271,7 +271,8 @@ |
public void computeKssValue(double totalcanopycover, double totalgroundcover) { |
// Kss variables |
double Kss_Seg_Bunch, Kss_Seg_Sod, Kss_Seg_Shrub, Kss_Seg_Shrub_0, Kss_Seg_Forbs; |
- double Kss_Average, Kss_Final; |
+ double Kss_Average = 0.0; //If totalcanopycover is 0, then this value will never be changed, but also not used. |
+ double Kss_Final; |
|
// 1) |
// a) CALCULATE KSS FOR EACH VEGETATION COMMUNITY USING TOTAL FOLIAR COVER |
@@ -312,6 +313,7 @@ |
Kss_Seg_Shrub_0 = 3.2773975 + 2.5535 * aoa.slopeSteepness - 0.4811 * totalgroundcover; |
Kss_Seg_Shrub_0 = Math.pow(10, Kss_Seg_Shrub_0); |
} |
+ |
if (totalcanopycover > 0 && totalcanopycover < 0.02) { |
Kss_Average = totalcanopycover / 0.02 * ((aoa.shrubsCanopyCover / totalcanopycover) * Kss_Seg_Shrub |
+ (aoa.sodGrassCanopyCover / totalcanopycover) * Kss_Seg_Sod |
@@ -319,18 +321,12 @@ |
+ (aoa.forbsCanopyCover / totalcanopycover) * Kss_Seg_Forbs) |
+ (0.02 - totalcanopycover) / 0.02 * Kss_Seg_Shrub_0; |
} else { |
- //?? add this or....why is there a test for 0 below, which won't happen |
- // if this section gets called, even without the new exception.... |
- // Something is really amiss with the logic of this calculation!! |
- //?? |
- |
- if (totalcanopycover == 0.0) { //Just added this because if totalcanopycover is 0, this section of code will be called before step 3) below and we will NEVER get there. |
- throw new ArithmeticException("Divide by zero for totalcanopycover value. Cannot continue with Kss_average calculation."); |
- } |
- Kss_Average = (aoa.shrubsCanopyCover / totalcanopycover) * Kss_Seg_Shrub |
- + (aoa.sodGrassCanopyCover / totalcanopycover) * Kss_Seg_Sod |
- + (aoa.bunchGgrassCanopyCover / totalcanopycover) * Kss_Seg_Bunch |
- + (aoa.forbsCanopyCover / totalcanopycover) * Kss_Seg_Forbs; |
+ if (totalcanopycover >= 0.02) { |
+ Kss_Average = (aoa.shrubsCanopyCover / totalcanopycover) * Kss_Seg_Shrub |
+ + (aoa.sodGrassCanopyCover / totalcanopycover) * Kss_Seg_Sod |
+ + (aoa.bunchGgrassCanopyCover / totalcanopycover) * Kss_Seg_Bunch |
+ + (aoa.forbsCanopyCover / totalcanopycover) * Kss_Seg_Forbs; |
+ } // Otherwise, see below, if statement in step 3, don't ever use Kss_Average in this case and won't divide anywhere else by totalcanopycover. |
} |
|
// 3) CALCULATE KSS USED FOR RHEM |