You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sdap.apache.org by tl...@apache.org on 2021/04/09 01:17:40 UTC
[incubator-sdap-ingester] 21/33: SDAP-286: Add processor module to
Granule Ingester to properly handle longitudes between 180-360deg (#23)
This is an automated email from the ASF dual-hosted git repository.
tloubrieu pushed a commit to branch ascending_latitudes
in repository https://gitbox.apache.org/repos/asf/incubator-sdap-ingester.git
commit dba7a01ffc6da88e45590960ff04a20ff1d7cae2
Author: Eamon Ford <ea...@gmail.com>
AuthorDate: Tue Nov 3 17:10:28 2020 -0800
SDAP-286: Add processor module to Granule Ingester to properly handle longitudes between 180-360deg (#23)
---
.../services/CollectionProcessor.py | 1 +
.../granule_ingester/pipeline/Modules.py | 9 +++--
.../processors/Subtract180FromLongitude.py | 38 ++++++++++++++++++++++
.../granule_ingester/processors/__init__.py | 1 +
4 files changed, 47 insertions(+), 2 deletions(-)
diff --git a/collection_manager/collection_manager/services/CollectionProcessor.py b/collection_manager/collection_manager/services/CollectionProcessor.py
index f08ade9..975f50c 100644
--- a/collection_manager/collection_manager/services/CollectionProcessor.py
+++ b/collection_manager/collection_manager/services/CollectionProcessor.py
@@ -88,6 +88,7 @@ class CollectionProcessor:
**dict(collection.dimension_names),
},
{'name': 'emptyTileFilter'},
+ {'name': 'subtract180FromLongitude'},
{
'name': 'tileSummary',
'dataset_name': collection.dataset_id
diff --git a/granule_ingester/granule_ingester/pipeline/Modules.py b/granule_ingester/granule_ingester/pipeline/Modules.py
index d1950dc..5db706b 100644
--- a/granule_ingester/granule_ingester/pipeline/Modules.py
+++ b/granule_ingester/granule_ingester/pipeline/Modules.py
@@ -1,4 +1,8 @@
-from granule_ingester.processors import GenerateTileId, TileSummarizingProcessor, EmptyTileFilter, KelvinToCelsius
+from granule_ingester.processors import (GenerateTileId,
+ TileSummarizingProcessor,
+ EmptyTileFilter,
+ KelvinToCelsius,
+ Subtract180FromLongitude)
from granule_ingester.processors.reading_processors import (EccoReadingProcessor,
GridReadingProcessor,
SwathReadingProcessor,
@@ -16,5 +20,6 @@ modules = {
"Swath": SwathReadingProcessor,
"tileSummary": TileSummarizingProcessor,
"emptyTileFilter": EmptyTileFilter,
- "kelvinToCelsius": KelvinToCelsius
+ "kelvinToCelsius": KelvinToCelsius,
+ "subtract180FromLongitude": Subtract180FromLongitude
}
diff --git a/granule_ingester/granule_ingester/processors/Subtract180FromLongitude.py b/granule_ingester/granule_ingester/processors/Subtract180FromLongitude.py
new file mode 100644
index 0000000..8dada92
--- /dev/null
+++ b/granule_ingester/granule_ingester/processors/Subtract180FromLongitude.py
@@ -0,0 +1,38 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from granule_ingester.processors.TileProcessor import TileProcessor
+from nexusproto.serialization import from_shaped_array, to_shaped_array
+
+
+class Subtract180FromLongitude(TileProcessor):
+ def process(self, tile, *args, **kwargs):
+ """
+ This method will transform longitude values in degrees_east from 0 TO 360 to -180 to 180
+ :param self:
+ :param nexus_tile: The nexus_tile
+ :return: Tile data with altered longitude values
+ """
+
+ the_tile_type = tile.tile.WhichOneof("tile_type")
+ the_tile_data = getattr(tile.tile, the_tile_type)
+ longitudes = from_shaped_array(the_tile_data.longitude)
+
+ # Only subtract 360 if the longitude is greater than 180
+ longitudes[longitudes > 180] -= 360
+
+ the_tile_data.longitude.CopyFrom(to_shaped_array(longitudes))
+
+ return tile
diff --git a/granule_ingester/granule_ingester/processors/__init__.py b/granule_ingester/granule_ingester/processors/__init__.py
index 592d8ea..ffd73b3 100644
--- a/granule_ingester/granule_ingester/processors/__init__.py
+++ b/granule_ingester/granule_ingester/processors/__init__.py
@@ -3,3 +3,4 @@ from granule_ingester.processors.GenerateTileId import GenerateTileId
from granule_ingester.processors.TileProcessor import TileProcessor
from granule_ingester.processors.TileSummarizingProcessor import TileSummarizingProcessor
from granule_ingester.processors.kelvintocelsius import KelvinToCelsius
+from granule_ingester.processors.Subtract180FromLongitude import Subtract180FromLongitude