From 8e99d096c24d8473a5a93d9a7db3ad59e650884a Mon Sep 17 00:00:00 2001 From: Gianpaolo Coro Date: Fri, 3 May 2013 09:27:23 +0000 Subject: [PATCH] git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/EcologicalEngineGeoSpatialExtension@74465 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../geo/test/TestChunkization.java | 9 +- .../geo/test/TestIntersectionNetCDF.java | 68 -------------- .../geo/test/TestLayersRetrieval.java | 92 +++++++++++++++++++ 3 files changed, 99 insertions(+), 70 deletions(-) delete mode 100644 src/main/java/org/gcube/dataanalysis/geo/test/TestIntersectionNetCDF.java create mode 100644 src/main/java/org/gcube/dataanalysis/geo/test/TestLayersRetrieval.java diff --git a/src/main/java/org/gcube/dataanalysis/geo/test/TestChunkization.java b/src/main/java/org/gcube/dataanalysis/geo/test/TestChunkization.java index c6efc17..8ef2f14 100644 --- a/src/main/java/org/gcube/dataanalysis/geo/test/TestChunkization.java +++ b/src/main/java/org/gcube/dataanalysis/geo/test/TestChunkization.java @@ -9,9 +9,14 @@ public class TestChunkization { static String cfg = "./cfg/"; public static void main(String[] args) throws Exception{ String layertitle = "Statistical Mean in [07-01-01 01:00] (3D) {World Ocean Atlas 09: Sea Water Temperature - annual: dods://thredds.research-infrastructures.eu/thredds/dodsC/public/netcdf/temperature_annual_1deg_ENVIRONMENT_OCEANS_.nc}"; +// String layertitle = "Mass Concentration of Chlorophyll in Sea Water in [03-30-13 01:00] (3D) {Mercator Ocean BIOMER1V1R1: Data extracted from dataset http://atoll-mercator.vlandata.cls.fr:44080/thredds/dodsC/global-analysis-bio-001-008-a}"; +// String layertitle = "Objectively Analyzed Climatology in [07-01-01 01:00] (3D) {World Ocean Atlas 09: Sea Water Temperature - annual: dods://thredds.research-infrastructures.eu/thredds/dodsC/public/netcdf/temperature_annual_1deg_ENVIRONMENT_OCEANS_.nc}"; + long t0 = System.currentTimeMillis(); AnalysisLogger.setLogger(cfg+AlgorithmConfiguration.defaultLoggerFile); GeoIntersector intersector = new GeoIntersector(null, cfg); - intersector.takeLastTimeChunk(layertitle, -180, 180, -10, 10, 0, 0.1, 0.1); - +// intersector.takeLastTimeChunk(layertitle, -180, 180, -10, 10, 0, 1, 1); + intersector.takeLastTimeChunk(layertitle, -10, 10, -10, 10, 0,1, 1); +// intersector.takeLastTimeChunk(layertitle, -180, 180, -90, 90, 0, 1, 1); + System.out.println("ELAPSED TIME: "+(System.currentTimeMillis()-t0)); } } diff --git a/src/main/java/org/gcube/dataanalysis/geo/test/TestIntersectionNetCDF.java b/src/main/java/org/gcube/dataanalysis/geo/test/TestIntersectionNetCDF.java deleted file mode 100644 index e95069e..0000000 --- a/src/main/java/org/gcube/dataanalysis/geo/test/TestIntersectionNetCDF.java +++ /dev/null @@ -1,68 +0,0 @@ -package org.gcube.dataanalysis.geo.test; - -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; - -import org.gcube.contentmanagement.graphtools.utils.MathFunctions; -import org.gcube.contentmanagement.lexicalmatcher.utils.AnalysisLogger; -import org.gcube.dataanalysis.ecoengine.configuration.AlgorithmConfiguration; -import org.gcube.dataanalysis.ecoengine.utils.Tuple; -import org.gcube.dataanalysis.geo.retrieval.GeoIntersector; - -public class TestIntersectionNetCDF { - - static String cfg = "./cfg/"; - - public static void main1(String args[] ) throws Exception{ - AnalysisLogger.setLogger(cfg+AlgorithmConfiguration.defaultLoggerFile); - GeoIntersector inters = new GeoIntersector("/gcube/devsec",cfg); - - System.out.println(inters.getFeaturesInTime("temperature (04091217ruc.nc)", 0.1, 0.1)); - } - - public static void main2(String args[]) throws Exception { - AnalysisLogger.setLogger(cfg+AlgorithmConfiguration.defaultLoggerFile); - GeoIntersector inters = new GeoIntersector(null,cfg); - System.out.println(inters.getFeaturesInTime("Statistical Mean in [07-01-01 01:00] (3D) {World Ocean Atlas 09: Sea Water Temperature - annual: dods://thredds.research-infrastructures.eu/thredds/dodsC/public/netcdf/temperature_annual_1deg_ENVIRONMENT_OCEANS_.nc}", -70, 0.1, 3000)); - } - - public static void main(String args[]) throws Exception { - AnalysisLogger.setLogger(cfg+AlgorithmConfiguration.defaultLoggerFile); - GeoIntersector inters = new GeoIntersector(null,cfg); - -// List> tuples = (List>)Arrays.asList( -// new Tuple(0.1,0.1), -// new Tuple(10d,0.1), -// new Tuple(100d,0.1), -// new Tuple(180d,0.1), -// new Tuple(270d,0.1) -// ); - List> tuples = new ArrayList>(); - double start = -180d; - double end = 360d; - int steps = 30; - double step = (end-start)/steps; - double y = 0; - for (int i=0;i(x,y)); - - } - - List> time = inters.getFeaturesInTime("Statistical Mean in [07-01-01 01:00] (3D) {World Ocean Atlas 09: Sea Water Temperature - annual: dods://thredds.research-infrastructures.eu/thredds/dodsC/public/netcdf/temperature_annual_1deg_ENVIRONMENT_OCEANS_.nc}",tuples ); - int i=0; - for (LinkedHashMap timemap : time){ - for (Double val:timemap.values()) - { - System.out.println(tuples.get(i).getElements().get(0)+"="+MathFunctions.roundDecimal(val,2)); - break; - } - i++; - } - - } - -} diff --git a/src/main/java/org/gcube/dataanalysis/geo/test/TestLayersRetrieval.java b/src/main/java/org/gcube/dataanalysis/geo/test/TestLayersRetrieval.java new file mode 100644 index 0000000..374083e --- /dev/null +++ b/src/main/java/org/gcube/dataanalysis/geo/test/TestLayersRetrieval.java @@ -0,0 +1,92 @@ +package org.gcube.dataanalysis.geo.test; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; + +import org.gcube.contentmanagement.graphtools.utils.MathFunctions; +import org.gcube.contentmanagement.lexicalmatcher.utils.AnalysisLogger; +import org.gcube.dataanalysis.ecoengine.configuration.AlgorithmConfiguration; +import org.gcube.dataanalysis.geo.meta.features.FeaturesManager; +import org.gcube.dataanalysis.geo.retrieval.GeoIntersector; +import org.geotoolkit.metadata.iso.identification.DefaultDataIdentification; +import org.opengis.metadata.Metadata; +import org.opengis.metadata.identification.Identification; +import org.opengis.metadata.identification.Keywords; +import org.opengis.util.InternationalString; + +public class TestLayersRetrieval { + + static String cfg = "./cfg/"; + //TODO: filter WoA names and attach them to the title + public static void main(String[] args) throws Exception{ + long t0 = System.currentTimeMillis(); + AnalysisLogger.setLogger(cfg+AlgorithmConfiguration.defaultLoggerFile); + FeaturesManager featurer = new FeaturesManager(); + featurer.setScope(null); + List metae = featurer.getAllGNInfobyText("thredds", "1"); + System.out.println("ELAPSED TIME: "+(System.currentTimeMillis()-t0)); + String d = "#"; + System.out.println("Parameter Name"+d+"Time Range"+d+"Dimensions"+d+"Unit of Measure"+d+"Resolution (decimal degrees)"+d+"Details"); + List table = new ArrayList(); + for (Metadata meta:metae){ + Identification id = meta.getIdentificationInfo().iterator().next(); + String title = id.getCitation().getTitle().toString(); + + DefaultDataIdentification did = (DefaultDataIdentification) id; + double resolution = MathFunctions.roundDecimal(did.getSpatialResolutions().iterator().next().getDistance(),3); + Collection keys = id.getDescriptiveKeywords(); + String unit = ""; + for (Keywords key:keys){ + for(InternationalString string:key.getKeywords()) { + String ss = string.toString(); + if (ss.startsWith("unit:")) + unit = ss.substring(ss.indexOf(":")+1); + } + } + String[] elements = parseTitle(title); + String entry = elements[0]+d+elements[1]+d+elements[2]+d+unit+d+resolution+d+elements[3]; + if (!table.contains(entry)){ + table.add(entry); +// System.out.println(elements[0]+d+elements[1]+d+elements[2]+d+resolution+d+elements[3]); + } + } + Collections.sort(table); + for (String element:table){ + System.out.println(element); + } +// System.out.println("ELAPSED TIME: "+(System.currentTimeMillis()-t0)); + } + + + public static void main1(String[] args) throws Exception{ +// String example = "Standard Deviation from Statistical Mean in [07-01-01 01:00] (3D) {World Ocean Atlas 09: Sea Water Temperature - annual: dods://thredds.research-infrastructures.eu/thredds/dodsC/public/netcdf/temperature_annual_1deg_ENVIRONMENT_OCEANS_.nc}"; +// String example = "Salinity from [12-15-99 01:00] to [12-15-09 01:00] (2D) {Native grid ORCA025.L75 monthly average: Data extracted from dataset http://atoll-mercator.vlandata.cls.fr:44080/thredds/dodsC/global-reanalysis-phys-001-004-b-ref-fr-mjm95-grids}"; + String example = "Salinity from [12-15-99 01:00] to [12-15-09 01:00] (2D) {Native grid ORCA025.L75 monthly average: Data extracted from dataset http://atoll-mercator.vlandata.cls.fr:44080/thredds/dodsC/global-reanalysis-phys-001-004-b-ref-fr-mjm95-grids}"; + parseTitle(example); + } + + public static String[] parseTitle(String title){ + String timerange = title.substring(title.indexOf("["),title.lastIndexOf("]")+1); +// timerange = timerange.replace("] to [", " ; "); +// System.out.println(timerange); + String realtitle = title.substring(0,title.indexOf("[")).trim(); + realtitle = realtitle.substring(0,realtitle.lastIndexOf(" ")).trim(); +// System.out.println(realtitle); + String dimensions = title.substring(title.indexOf("] (")+3); + dimensions = dimensions.substring(0,dimensions.indexOf(")")).trim(); +// System.out.println(dimensions); + String notes = title.substring(title.indexOf("{")+1,title.lastIndexOf("}")); + String woa = "World Ocean Atlas 09:"; + String prefixnote = ""; + if (notes.startsWith(woa)){ + prefixnote = notes.substring(woa.length()+1); + prefixnote = prefixnote.substring(0,prefixnote.indexOf(":")).trim()+": "; + } +// System.out.println(notes); + String[] elements = new String[]{prefixnote+realtitle, timerange, dimensions,notes}; + return elements; + } + +}