enhanced the output
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/EcologicalEngineGeoSpatialExtension@76907 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
508045e2f9
commit
595a668600
|
@ -1,6 +1,7 @@
|
||||||
package org.gcube.dataanalysis.geo.algorithms;
|
package org.gcube.dataanalysis.geo.algorithms;
|
||||||
|
|
||||||
import java.awt.Image;
|
import java.awt.Image;
|
||||||
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
|
@ -9,13 +10,16 @@ import java.util.Map;
|
||||||
|
|
||||||
import org.gcube.contentmanagement.graphtools.data.conversions.ImageTools;
|
import org.gcube.contentmanagement.graphtools.data.conversions.ImageTools;
|
||||||
import org.gcube.contentmanagement.graphtools.plotting.graphs.GaussianDistributionGraph;
|
import org.gcube.contentmanagement.graphtools.plotting.graphs.GaussianDistributionGraph;
|
||||||
|
import org.gcube.contentmanagement.graphtools.utils.MathFunctions;
|
||||||
import org.gcube.contentmanagement.lexicalmatcher.utils.AnalysisLogger;
|
import org.gcube.contentmanagement.lexicalmatcher.utils.AnalysisLogger;
|
||||||
import org.gcube.contentmanagement.lexicalmatcher.utils.DatabaseFactory;
|
import org.gcube.contentmanagement.lexicalmatcher.utils.DatabaseFactory;
|
||||||
import org.gcube.dataanalysis.ecoengine.configuration.AlgorithmConfiguration;
|
import org.gcube.dataanalysis.ecoengine.configuration.AlgorithmConfiguration;
|
||||||
import org.gcube.dataanalysis.ecoengine.datatypes.DatabaseType;
|
import org.gcube.dataanalysis.ecoengine.datatypes.DatabaseType;
|
||||||
|
import org.gcube.dataanalysis.ecoengine.datatypes.OutputTable;
|
||||||
import org.gcube.dataanalysis.ecoengine.datatypes.PrimitiveType;
|
import org.gcube.dataanalysis.ecoengine.datatypes.PrimitiveType;
|
||||||
import org.gcube.dataanalysis.ecoengine.datatypes.StatisticalType;
|
import org.gcube.dataanalysis.ecoengine.datatypes.StatisticalType;
|
||||||
import org.gcube.dataanalysis.ecoengine.datatypes.enumtypes.PrimitiveTypes;
|
import org.gcube.dataanalysis.ecoengine.datatypes.enumtypes.PrimitiveTypes;
|
||||||
|
import org.gcube.dataanalysis.ecoengine.datatypes.enumtypes.TableTemplates;
|
||||||
import org.gcube.dataanalysis.ecoengine.evaluation.DiscrepancyAnalysis;
|
import org.gcube.dataanalysis.ecoengine.evaluation.DiscrepancyAnalysis;
|
||||||
import org.gcube.dataanalysis.ecoengine.interfaces.DataAnalysis;
|
import org.gcube.dataanalysis.ecoengine.interfaces.DataAnalysis;
|
||||||
import org.gcube.dataanalysis.ecoengine.utils.DatabaseUtils;
|
import org.gcube.dataanalysis.ecoengine.utils.DatabaseUtils;
|
||||||
|
@ -164,7 +168,7 @@ public class MapsComparator extends DataAnalysis {
|
||||||
da.setConfiguration(config);
|
da.setConfiguration(config);
|
||||||
da.init(false);
|
da.init(false);
|
||||||
outputParameters = da.analyze();
|
outputParameters = da.analyze();
|
||||||
outputParameters.put("RESOLUTION", "" + resolution);
|
outputParameters.put("RESOLUTION", "" + MathFunctions.roundDecimal(resolution,4));
|
||||||
status = 80;
|
status = 80;
|
||||||
AnalysisLogger.getLogger().debug("MapsComparator: Output: " + outputParameters);
|
AnalysisLogger.getLogger().debug("MapsComparator: Output: " + outputParameters);
|
||||||
|
|
||||||
|
@ -193,8 +197,8 @@ public class MapsComparator extends DataAnalysis {
|
||||||
@Override
|
@Override
|
||||||
public List<StatisticalType> getInputParameters(){
|
public List<StatisticalType> getInputParameters(){
|
||||||
|
|
||||||
IOHelper.addStringInput(inputs,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");
|
IOHelper.addStringInput(inputs,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", "86a7ac79-866a-49c6-b5d5-602fc2d87ddd");//"Sarda australis");
|
||||||
IOHelper.addStringInput(inputs, 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");
|
IOHelper.addStringInput(inputs, 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", "0e03d0fa-9c44-4a0c-a7e3-9f6d48710d00");//"Sarda orientalis");
|
||||||
IOHelper.addIntegerInput(inputs, zString, "value of Z. Default is 0, that means comparison will be at surface level", "0");
|
IOHelper.addIntegerInput(inputs, zString, "value of Z. Default is 0, that means comparison will be at surface level", "0");
|
||||||
IOHelper.addDoubleInput(inputs, valuesThr, "A comparison threshold for the values in the map. Null equals to 0.1", "0.1");
|
IOHelper.addDoubleInput(inputs, valuesThr, "A comparison threshold for the values in the map. Null equals to 0.1", "0.1");
|
||||||
IOHelper.addIntegerInput(inputs, t1, "First Layer Time Index. The default is the first", "0");
|
IOHelper.addIntegerInput(inputs, t1, "First Layer Time Index. The default is the first", "0");
|
||||||
|
@ -212,39 +216,54 @@ public class MapsComparator extends DataAnalysis {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
protected Image generateGaussian(double mean, double variance){
|
||||||
|
// gaussian
|
||||||
|
XYSeriesCollection xyseriescollection = new XYSeriesCollection();
|
||||||
|
if (variance == 0)
|
||||||
|
variance = 0.01;
|
||||||
|
AnalysisLogger.getLogger().debug("MapsComparator: Adopting mean:" + mean + " and variance:" + variance);
|
||||||
|
NormalDistributionFunction2D normaldistributionfunction2d = new NormalDistributionFunction2D(mean, variance);
|
||||||
|
org.jfree.data.xy.XYSeries xyseries = DatasetUtilities.sampleFunction2DToSeries(normaldistributionfunction2d, (mean - (2 * variance)), (mean + (2 * variance)), 121, "Distribution of the Error");
|
||||||
|
xyseriescollection.addSeries(xyseries);
|
||||||
|
// end gaussian
|
||||||
|
|
||||||
|
JFreeChart chart = GaussianDistributionGraph.createStaticChart(xyseriescollection, mean, variance);
|
||||||
|
Image image = ImageTools.toImage(chart.createBufferedImage(680, 420));
|
||||||
|
/*
|
||||||
|
* 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");
|
||||||
|
return image;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StatisticalType getOutput() {
|
public StatisticalType getOutput() {
|
||||||
|
|
||||||
// set the output map containing values
|
// set the output map containing values
|
||||||
PrimitiveType p = new PrimitiveType(Map.class.getName(), PrimitiveType.stringMap2StatisticalMap(outputParameters), PrimitiveTypes.MAP, "Discrepancy Analysis", "");
|
|
||||||
AnalysisLogger.getLogger().debug("MapsComparator: Producing Gaussian Distribution for the errors");
|
AnalysisLogger.getLogger().debug("MapsComparator: Producing Gaussian Distribution for the errors");
|
||||||
|
|
||||||
// build image:
|
// build image:
|
||||||
HashMap<String, Image> producedImages = new HashMap<String, Image>();
|
HashMap<String, Image> producedImages = new HashMap<String, Image>();
|
||||||
|
|
||||||
// gaussian
|
|
||||||
XYSeriesCollection xyseriescollection = new XYSeriesCollection();
|
|
||||||
double mean = Double.parseDouble(outputParameters.get("MEAN"));
|
double mean = Double.parseDouble(outputParameters.get("MEAN"));
|
||||||
double variance = Double.parseDouble(outputParameters.get("VARIANCE"));
|
double variance = Double.parseDouble(outputParameters.get("VARIANCE"));
|
||||||
if (variance == 0)
|
producedImages.put("Error Distribution", generateGaussian(mean, variance));
|
||||||
variance = 0.01;
|
PrimitiveType images = new PrimitiveType("Images", producedImages, PrimitiveTypes.IMAGES, "Distribution of the Error", "The distribution of the error along with variance");
|
||||||
|
|
||||||
AnalysisLogger.getLogger().debug("MapsComparator: Adopting mean:" + mean + " and variance:" + variance);
|
|
||||||
NormalDistributionFunction2D normaldistributionfunction2d = new NormalDistributionFunction2D(mean, variance);
|
|
||||||
org.jfree.data.xy.XYSeries xyseries = DatasetUtilities.sampleFunction2DToSeries(normaldistributionfunction2d, (mean - (2 * variance)), (mean + (2 * variance)), 121, "Distribution of the Error");
|
|
||||||
xyseriescollection.addSeries(xyseries);
|
|
||||||
// end gaussian
|
|
||||||
JFreeChart chart = GaussianDistributionGraph.createStaticChart(xyseriescollection, mean, variance);
|
|
||||||
Image image = ImageTools.toImage(chart.createBufferedImage(680, 420));
|
|
||||||
producedImages.put("Gaussian Distribution of the Error", image);
|
|
||||||
|
|
||||||
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);
|
|
||||||
*/
|
|
||||||
// end build image
|
|
||||||
AnalysisLogger.getLogger().debug("MapsComparator: Gaussian Distribution Produced");
|
|
||||||
// collect all the outputs
|
|
||||||
LinkedHashMap<String, StatisticalType> map = new LinkedHashMap<String, StatisticalType>();
|
LinkedHashMap<String, StatisticalType> map = new LinkedHashMap<String, StatisticalType>();
|
||||||
map.put("Result", p);
|
|
||||||
|
for (String key:outputParameters.keySet()){
|
||||||
|
String value = outputParameters.get(key);
|
||||||
|
PrimitiveType val = new PrimitiveType(String.class.getName(), "" + value, PrimitiveTypes.STRING, key, key);
|
||||||
|
map.put(key, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
// collect all the outputs
|
||||||
map.put("Images", images);
|
map.put("Images", images);
|
||||||
|
|
||||||
// generate a primitive type for the collection
|
// generate a primitive type for the collection
|
||||||
|
@ -253,6 +272,10 @@ public class MapsComparator extends DataAnalysis {
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue