Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Some day/night adjustments, NRT handling for AIRS

Mike McGann3b8d2ec5963e
diff --git a/etc/config/config/layers/AIRS_CO_Total_Column_Day.json b/etc/config/config/layers/AIRS_CO_Total_Column_Day.json
index a100d33aa..8a7c83436 100644
--- a/etc/config/config/layers/AIRS_CO_Total_Column_Day.json
+++ b/etc/config/config/layers/AIRS_CO_Total_Column_Day.json
@@ -41,5 +41,11 @@
"rendered": "AIRS_CO_Total_Column",
"startDate": "2012-04-07",
"type": "wmts",
- "units": "ppb"
+ "units": "ppb",
+ "echo": {
+ "product": "AIRX2RET",
+ "query": {
+ "dayNightFlag": "DAY"
+ }
+ }
}
diff --git a/etc/config/config/layers/AIRS_CO_Total_Column_Night.json b/etc/config/config/layers/AIRS_CO_Total_Column_Night.json
index b4684fcc4..0007e0af3 100644
--- a/etc/config/config/layers/AIRS_CO_Total_Column_Night.json
+++ b/etc/config/config/layers/AIRS_CO_Total_Column_Night.json
@@ -41,5 +41,11 @@
"rendered": "AIRS_CO_Total_Column",
"startDate": "2012-04-07",
"type": "wmts",
- "units": "ppb"
+ "units": "ppb",
+ "echo": {
+ "product": "AIRX2RET",
+ "query": {
+ "dayNightFlag": "NIGHT"
+ }
+ }
}
diff --git a/src/data/config b/src/data/config
index 5d66f1598..0b81108c1 100644
--- a/src/data/config
+++ b/src/data/config
@@ -64,6 +64,12 @@
"AIRS_CO_Total_Column_Day": {
"bins": 7,
"description": "Aqua / AIRS",
+ "echo": {
+ "product": "AIRX2RET",
+ "query": {
+ "dayNightFlag": "DAY"
+ }
+ },
"max": "120",
"min": "98.8",
"name": "Carbon Monoxide (Total Column, Day)",
@@ -121,6 +127,12 @@
"AIRS_CO_Total_Column_Night": {
"bins": 7,
"description": "Aqua / AIRS",
+ "echo": {
+ "product": "AIRX2RET",
+ "query": {
+ "dayNightFlag": "NIGHT"
+ }
+ },
"max": "120",
"min": "98.8",
"name": "Carbon Monoxide (Total Column, Night)",
@@ -59690,6 +59702,22 @@
}
},
"products": {
+ "AIRX2RET": {
+ "handler": "AquaSwath5",
+ "name": "AIRS/Aqua Level 2 Standard physical retrieval (AIRS+AMSU)",
+ "nrt": {
+ "by": "regex",
+ "field": "dataset_id",
+ "value": "\\(NRT\\)"
+ },
+ "query": {
+ "dataCenterId": "GSFCS4PA",
+ "shortName": [
+ "AIRX2RET",
+ "AIRX2RET_NRT"
+ ]
+ }
+ },
"MOD04_L2": {
"handler": "TerraSwath5",
"name": "MODIS/Terra Aerosol 5-Min L2 Swath 10km",
diff --git a/src/data/echo.cgi b/src/data/echo.cgi
index e83c1552d..6d9f80506 100755
--- a/src/data/echo.cgi
+++ b/src/data/echo.cgi
@@ -175,7 +175,12 @@ def create_xml(fields):
xml += ["<startDate>", aql_date(start_time), "</startDate>"]
xml += ["<stopDate>", aql_date(end_time), "</stopDate>"]
xml += ["</temporal>", "</granuleCondition>"]
-
+
+ if "dayNightFlag" in fields:
+ xml += ["<granuleCondition>"]
+ xml += ["<dayNightFlag value='%s'/>" % fields["dayNightFlag"].value]
+ xml += ["</granuleCondition>"]
+
xml += ["</where>"]
xml += ["</query>"]
diff --git a/src/js/Worldview/DataDownload/ECHO/Geometry.js b/src/js/Worldview/DataDownload/ECHO/Geometry.js
index 33f00ef49..249d648f4 100644
--- a/src/js/Worldview/DataDownload/ECHO/Geometry.js
+++ b/src/js/Worldview/DataDownload/ECHO/Geometry.js
@@ -22,6 +22,8 @@ Worldview.DataDownload.ECHO.Geometry = function(result) {
var init = function() {
if ( result.polygons ) {
initFromPolygons(result.polygons);
+ } else if ( result.boxes ) {
+ initFromBoxes(result.boxes);
} else {
throw new Error("Unable to find spatial field");
}
@@ -72,6 +74,24 @@ Worldview.DataDownload.ECHO.Geometry = function(result) {
});
};
+ var initFromBoxes = function(echoBoxes) {
+ $.each(echoBoxes, function(index, echoBox) {
+ var ring = [];
+ var fields = echoBox.split(" ");
+ var ymin = parseFloat(fields[0]);
+ var xmin = parseFloat(fields[1]);
+ var ymax = parseFloat(fields[2]);
+ var xmax = parseFloat(fields[3]);
+ ring.push({x: xmin, y: ymin});
+ ring.push({x: xmax, y: ymin});
+ ring.push({x: xmax, y: ymax});
+ ring.push({x: xmin, y: ymax});
+ ring.push({x: xmin, y: ymin});
+
+ self.polygons.push([ring]);
+ });
+ };
+
init();
return self;
}
diff --git a/src/js/Worldview/DataDownload/Handler/AquaSwath5.js b/src/js/Worldview/DataDownload/Handler/AquaSwath5.js
index 6426ff00a..8be16bf7f 100644
--- a/src/js/Worldview/DataDownload/Handler/AquaSwath5.js
+++ b/src/js/Worldview/DataDownload/Handler/AquaSwath5.js
@@ -16,13 +16,31 @@ Worldview.namespace("DataDownload.Handler");
Worldview.DataDownload.Handler.AquaSwath5 = function(config, model) {
- var spec = {
- startTimeDelta: -180,
- endTimeDelta: 180,
- maxDistance: 270,
- eastZone: 300,
- westZone: 1380
- };
+ var parameters = {
+ "DAY": {
+ startTimeDelta: -180,
+ endTimeDelta: 180,
+ maxDistance: 270,
+ eastZone: 300,
+ westZone: 1380
+ },
+ "NIGHT": {
+ startTimeDelta: 0,
+ endTimeDelta: 0,
+ maxDistance: 270,
+ eastZone: 300,
+ westZone: 1380,
+ timeOffset: 720
+ }
+ }
+
+ var echoConfig = config.layers[model.selectedLayer].echo;
+ var spec;
+ if ( echoConfig.query && echoConfig.query.dayNightFlag === "NIGHT" ) {
+ spec = parameters.NIGHT;
+ } else {
+ spec = parameters.DAY;
+ }
var self = Worldview.DataDownload.Handler.MODISSwath5(config, model, spec);
return $.extend(true, self, spec);
diff --git a/src/js/Worldview/DataDownload/Handler/MODISSwath5.js b/src/js/Worldview/DataDownload/Handler/MODISSwath5.js
index c20b7c593..9ad357f2b 100644
--- a/src/js/Worldview/DataDownload/Handler/MODISSwath5.js
+++ b/src/js/Worldview/DataDownload/Handler/MODISSwath5.js
@@ -21,12 +21,18 @@ Worldview.DataDownload.Handler.MODISSwath5 = function(config, model, spec) {
var self = Worldview.DataDownload.Handler.Base(config);
- self._submit = function() {
+ self._submit = function() {
+ productParameters = config.products[model.selectedProduct].query;
+ layerParameters = {};
+ if ( config.layers[model.selectedLayer].echo.query ) {
+ layerParameters = config.layers[model.selectedLayer].echo.query
+ }
+ data = $.extend(true, {}, productParameters, layerParameters)
var queryOptions = {
time: model.time,
startTimeDelta: startTimeDelta,
endTimeDelta: endTimeDelta,
- data: config.products[model.selectedProduct].query
+ data: data
};
return self.echo.submit(queryOptions);
diff --git a/src/js/Worldview/DataDownload/Results/ConnectSwaths.js b/src/js/Worldview/DataDownload/Results/ConnectSwaths.js
index dbd1db41d..0f48467b1 100644
--- a/src/js/Worldview/DataDownload/Results/ConnectSwaths.js
+++ b/src/js/Worldview/DataDownload/Results/ConnectSwaths.js
@@ -17,6 +17,7 @@ Worldview.namespace("DataDownload.Results");
Worldview.DataDownload.Results.ConnectSwaths = function(projection) {
var log = Logging.getLogger("Worldview.DataDownload");
+ var MAX_DISTANCE = 270;
var startTimes = {};
var endTimes = {};
@@ -60,25 +61,29 @@ Worldview.DataDownload.Results.ConnectSwaths = function(projection) {
// Can this swath be added to the end of other swath?
var otherSwath = endTimes[swath[0].time_start];
if ( otherSwath ) {
- // Remove entries for this swath
- delete startTimes[swath[0].time_start];
- delete endTimes[swath[swath.length - 1].time_end];
-
- // Remove entries for other swath
- delete startTimes[otherSwath[0].time_start];
- delete endTimes[otherSwath[otherSwath.length - 1].time_end];
-
- // Combine swaths
- var newSwath = otherSwath.concat(swath);
-
- startTimes[newSwath[0].time_start] = newSwath;
- endTimes[newSwath[newSwath.length - 1].time_end] = newSwath;
- combined = true;
- swath = newSwath;
+ var otherGranule = otherSwath[otherSwath.length - 1];
+ if ( distance(swath[0], otherGranule) < MAX_DISTANCE ) {
+ // Remove entries for this swath
+ delete startTimes[swath[0].time_start];
+ delete endTimes[swath[swath.length - 1].time_end];
+
+ // Remove entries for other swath
+ delete startTimes[otherSwath[0].time_start];
+ delete endTimes[otherSwath[otherSwath.length - 1].time_end];
+
+ // Combine swaths
+ var newSwath = otherSwath.concat(swath);
+
+ startTimes[newSwath[0].time_start] = newSwath;
+ endTimes[newSwath[newSwath.length - 1].time_end] = newSwath;
+ combined = true;
+ swath = newSwath;
+ }
}
+ /*
var otherSwath = startTimes[swath[0].time_end];
- if ( otherSwath ) {
+ if ( otherSwath && distance(swath[0], otherSwath) < MAX_DISTANCE ) {
// Remove entries for this swath
delete startTimes[swath[0].time_start];
delete endTimes[swath[swath.length - 1].time_end];
@@ -95,12 +100,19 @@ Worldview.DataDownload.Results.ConnectSwaths = function(projection) {
combined = true;
swath = newSwath;
}
-
+ */
+
if ( combined ) {
combineSwath(swath);
}
};
+ var distance = function(g1, g2) {
+ var x1 = g1.centroid[projection].x;
+ var x2 = g2.centroid[projection].x;
+ return Math.abs(x2 - x1);
+ };
+
return self;
};
diff --git a/src/js/Worldview/DataDownload/Results/TagNRT.js b/src/js/Worldview/DataDownload/Results/TagNRT.js
index 72e693354..db888cce2 100644
--- a/src/js/Worldview/DataDownload/Results/TagNRT.js
+++ b/src/js/Worldview/DataDownload/Results/TagNRT.js
@@ -20,18 +20,21 @@ Worldview.DataDownload.Results.TagNRT = function(spec) {
self.name = "TagNRT";
- self.process = function(meta, result) {
+ self.process = function(meta, granule) {
var isNRT;
if ( spec.by === "value" ) {
- isNRT = result[spec.field] === spec.value;
+ isNRT = granule[spec.field] === spec.value;
+ } else if ( spec.by === "regex" ) {
+ var re = new RegExp(spec.value);
+ isNRT = re.test(granule[spec.field]);
} else {
throw new Error("Unknown TagNRT method: " + spec.by);
}
if ( isNRT ) {
- result.nrt = true;
+ granule.nrt = true;
meta.nrt = true;
}
- return result;
+ return granule;
};
return self;
diff --git a/src/js/Worldview/DataDownload/Results/TimeFilter.js b/src/js/Worldview/DataDownload/Results/TimeFilter.js
index 2f56b0c47..64f1fe3ab 100644
--- a/src/js/Worldview/DataDownload/Results/TimeFilter.js
+++ b/src/js/Worldview/DataDownload/Results/TimeFilter.js
@@ -28,11 +28,13 @@ Worldview.DataDownload.Results.TimeFilter = function(spec) {
westZone = spec.time.clone().setUTCMinutes(spec.westZone);
eastZone = spec.time.clone().setUTCMinutes(spec.eastZone);
maxDistance = spec.maxDistance;
+ timeOffset = spec.timeOffset || 0;
};
self.process = function(meta, granule) {
var geom = granule.geometry[Worldview.Map.CRS_WGS_84];
var time = Date.parseISOString(granule.time_start);
+ time.setUTCMinutes(time.getUTCMinutes() + timeOffset);
if ( !Worldview.Map.isPolygonValid(geom, maxDistance) ) {
var adjustSign = ( time < eastZone ) ? 1 : -1;
geom =