modifications to add Cohens kappa

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/EcologicalEngineGeoSpatialExtension@76856 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Gianpaolo Coro 2013-06-07 11:07:05 +00:00
parent 900e8ba880
commit 2f172d69d4
1 changed files with 120 additions and 106 deletions

View File

@ -69,11 +69,17 @@ public class MapsComparator extends StandardLocalExternalAlgorithm{
double valuesthreshold = 0.1;
if ((valuesthr$ != null) && (valuesthr$.trim().length() > 0))
try{valuesthreshold =Double.parseDouble(valuesthr$);}catch(Exception ee){}
try {
valuesthreshold = Double.parseDouble(valuesthr$);
} catch (Exception ee) {
}
double z = 0;
if ((z$ != null) && (z$.trim().length() > 0))
try{z =Double.parseDouble(z$);}catch(Exception ee){}
try {
z = Double.parseDouble(z$);
} catch (Exception ee) {
}
try {
String scope = config.getGcubeScope();
@ -88,13 +94,27 @@ public class MapsComparator extends StandardLocalExternalAlgorithm{
status = 10;
FeaturesManager fm = intersector.getFeaturer();
AnalysisLogger.getLogger().debug("MapsComparator: Taking info for the layer: " + layerT1);
Metadata meta1 = fm.checkForMetadatabyTitle(FeaturesManager.treatTitleForGN(layerT1), layerT1);
double resolution1 = FeaturesManager.getResolution(meta1);
Metadata meta1 = fm.getGNInfobyUUIDorName(layerT1);
if (meta1==null) throw new Exception("No Correspondence with Layer 1");
double resolution1 = 0;
try {
resolution1 = FeaturesManager.getResolution(meta1);
} catch (Exception e) {
AnalysisLogger.getLogger().debug("MapsComparator: Undefined resolution");
}
AnalysisLogger.getLogger().debug("MapsComparator: Resolution: " + resolution1);
status = 15;
AnalysisLogger.getLogger().debug("MapsComparator: Taking info for the layer: " + layerT2);
Metadata meta2 = fm.checkForMetadatabyTitle(FeaturesManager.treatTitleForGN(layerT2), layerT2);
double resolution2 = FeaturesManager.getResolution(meta2);
AnalysisLogger.getLogger().debug("MapsComparator: Trying with UUID..." + layerT2);
Metadata meta2 = fm.getGNInfobyUUIDorName(layerT2);
if (meta2==null) throw new Exception("No Correspondence with Layer 2");
double resolution2 = 0;
try {
resolution2 = FeaturesManager.getResolution(meta2);
} catch (Exception e) {
AnalysisLogger.getLogger().debug("MapsComparator: Undefined resolution");
}
AnalysisLogger.getLogger().debug("MapsComparator: Resolution: " + resolution2);
status = 20;
// take the lowest resolution to perform the comparison
@ -122,9 +142,7 @@ public class MapsComparator extends StandardLocalExternalAlgorithm{
AnalysisLogger.getLogger().debug("MapsComparator: Map 2 was dumped in table: " + rastertable2);
status = 60;
/*
String rastertable1 = "rstr909f60c1d3f1472e9de998e844990724";
String rastertable2 = "rstre52e744c99224de3a1c5354263c6c8d8";
String resolution = "0.5";
* String rastertable1 = "rstr909f60c1d3f1472e9de998e844990724"; String rastertable2 = "rstre52e744c99224de3a1c5354263c6c8d8"; String resolution = "0.5";
*/
config.setNumberOfResources(1);
config.setParam("FirstTable", rastertable1);
@ -156,24 +174,23 @@ public class MapsComparator extends StandardLocalExternalAlgorithm{
} catch (Exception e) {
e.printStackTrace();
AnalysisLogger.getLogger().debug("MapsComparator: ERROR!: " + e.getLocalizedMessage());
}
finally{
} finally {
DatabaseUtils.closeDBConnection(dbConnection);
status = 100;
}
}
@Override
protected void setInputParameters() {
addStringInput(layer1,"First Layer Title: The title of a layer indexed in the e-Infrastructure on GeoNetwork","Sarda australis");
addStringInput(layer2,"Second Layer Title: The title of a second layer indexed in the e-Infrastructure on GeoNetwork","Sarda orientalis");
addStringInput(layer1, "First Layer Title or UUID: The title or the UUID (preferred) of a layer indexed in the e-Infrastructure on GeoNetwork - You can retrieve it from GeoExplorer", "Sarda australis");
addStringInput(layer2, "Second Layer Title or UUID: The title or the UUID (preferred) of a second layer indexed in the e-Infrastructure on GeoNetwork - You can retrieve it from GeoExplorer", "Sarda orientalis");
addNumberInput(zString, "value of Z. Default is 0, that means comparison will be at surface level", "0");
addNumberInput(valuesThr, "A comparison threshold for the values in the map. Null equals to 0.1", "0.1");
addNumberInput(t1, "First Layer Time Index. The default is the first", "0");
addNumberInput(t2, "Second Layer Time Index. The default is the first", "0");
addNumberInput("KThreshold", "Threshold for K-Statistic: over this threshold values will be considered 1 for agreement calculation. Default is 0.5","0.5");
DatabaseType.addDefaultDBPars(inputs);
@ -211,9 +228,7 @@ public class MapsComparator extends StandardLocalExternalAlgorithm{
PrimitiveType images = new PrimitiveType(HashMap.class.getName(), producedImages, PrimitiveTypes.IMAGES, "ErrorRepresentation", "Graphical representation of the error spread");
/*
GaussianDistributionGraph graph = new GaussianDistributionGraph("Error Distribution");
graph.mean=mean;graph.variance=variance;
graph.render(xyseriescollection);
* GaussianDistributionGraph graph = new GaussianDistributionGraph("Error Distribution"); graph.mean=mean;graph.variance=variance; graph.render(xyseriescollection);
*/
// end build image
AnalysisLogger.getLogger().debug("MapsComparator: Gaussian Distribution Produced");
@ -225,7 +240,6 @@ public class MapsComparator extends StandardLocalExternalAlgorithm{
// generate a primitive type for the collection
PrimitiveType output = new PrimitiveType(HashMap.class.getName(), map, PrimitiveTypes.MAP, "ResultsMap", "Results Map");
return output;
}