[Xulu-commits] r108 - trunk/src/edu/bonn/xulu/plugin/model/sleuth

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Mon Dec 20 14:37:06 CET 2010


Author: rgoetzke
Date: 2010-12-20 14:37:06 +0100 (Mon, 20 Dec 2010)
New Revision: 108

Modified:
   trunk/src/edu/bonn/xulu/plugin/model/sleuth/UrbanGrowthModelCalibration.java
Log:


Modified: trunk/src/edu/bonn/xulu/plugin/model/sleuth/UrbanGrowthModelCalibration.java
===================================================================
--- trunk/src/edu/bonn/xulu/plugin/model/sleuth/UrbanGrowthModelCalibration.java	2010-11-08 14:24:56 UTC (rev 107)
+++ trunk/src/edu/bonn/xulu/plugin/model/sleuth/UrbanGrowthModelCalibration.java	2010-12-20 13:37:06 UTC (rev 108)
@@ -101,7 +101,7 @@
 	protected int years = 0;
 	protected int neighborhoodRange = 0;
 	protected int numSteps = 0;
-	protected float[] resultArray;
+	protected float[][] resultArray;
 	protected float[] mrvTempResultArray;
 	protected float[] finalArray;
 	
@@ -500,7 +500,7 @@
 									
 									System.out.print("Slope: "+slope+" Spread: "+spread+" Disp: "+disp+" Breed: "+breed+" Road: "+roadGravity+" : ");
 									
-									for(int i = 0;i < mrvTempResultArray.length-2;i++){
+									for(int i = 1;i <= mrvTempResultArray.length-2;i++){
 										//print every element of the result array comma separated in one line in the status output
 										finalArray[i] = mrvTempResultArray[i]/MonteCarlo;
 										System.out.print(finalArray[i]+",");
@@ -554,7 +554,7 @@
 	//	numSteps = (int) ((int)1+ Math.floor(Math.log(neighborhoodRange)/Math.log(2)));	//calculates how many steps are needed by doubling the pixel size until neighborhoodRange is reached. It is the reverse of an exponential function, which is the logarithm of neighborhoodRange to the basis 2. 2 is added because the calculation starts with 1 and not with 2 (1,2,4,8,16,32,...) and an array starts with 0.
 	//	statusOut.println("Maximum pixel size (as multiple of original resolution): "+neighborhoodRange);
 	//	statusOut.println("Number of steps: "+numSteps);
-		resultArray = new float[numSteps+2];
+		resultArray = new float[2][2+numSteps];
 		
 		for (int x = 0; x < referenceMap.getWidth(); x++)
 			for (int y = 0; y < referenceMap.getHeight(); y++) {
@@ -650,8 +650,8 @@
 			totalAgreement = SumWn / (float)SumCells;	//Main Results
 			//statusOut.println(totalAgreement);	
 			outResults.addValue(totalAgreement);
-			//resultArray[0][ngrids-1] = r;
-			resultArray[ngrids-1] = totalAgreement;	//write the results in an array 
+			resultArray[0][ngrids] = r;
+			resultArray[1][ngrids] = totalAgreement;	//write the results in an array 
 			//the result array looks like this:
 			//1	   |2	 |4	   |8    |...
 			//0.876|0.892|0.913|0.948|...
@@ -668,24 +668,25 @@
 		float SumFw = 0f;	//Sum of all weighted agreements
 		float Ft = 0f;
 		
-		for(int i = 0; i <= ngrids-1; i++){
-//			System.out.print(resultArray[i]+",");
+		for(int i = 0; i < ngrids; i++){
+			System.out.print(resultArray[1][i+1]+",");
 			//calculations for weighted average after Costanza (1989):
-			w = (float) Math.exp(-0.1*(resultArray[i] - 1));
-			Fw = resultArray[i]*w;
+			w = (float) Math.exp(-0.1*(resultArray[0][i+1] - 1));
+			Fw = resultArray[1][i+1]*w;
 			SumW += w;
 			SumFw += Fw;
+			//statusOut.println(i+": w:"+w+" Fw: "+Fw+" SumW: "+SumW+" SumFw: "+SumFw);
 		}
 		
 		Ft = SumFw / SumW;	//Final calculation of the weighted average of all fits after Costanza (1989)
 		WeightedAgreement = Vg / VgWeights;	//Final calculation of the weighted average of all fits after Pontius (2002)
 		
 //		System.out.print("Ft:"+Ft+",TA:"+WeightedAgreement);	//the result is written directly behind the single fits for every resolution
-		resultArray[numSteps] = Ft;
+		resultArray[1][numSteps] = Ft;
 //		System.out.println("");
 //		System.out.println(resultArray[numSteps+1]);
-		resultArray[numSteps+1] = WeightedAgreement;
+		resultArray[1][numSteps+1] = WeightedAgreement;
 //		System.out.println(resultArray[numSteps+2]);
-		return resultArray;	
+		return resultArray[1];	
 	}
 }



More information about the Xulu-commits mailing list