You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sdap.apache.org by ea...@apache.org on 2020/11/04 00:49:05 UTC

[incubator-sdap-ingester] branch subtract180fromlongitude created (now b63541f)

This is an automated email from the ASF dual-hosted git repository.

eamonford pushed a change to branch subtract180fromlongitude
in repository https://gitbox.apache.org/repos/asf/incubator-sdap-ingester.git.


      at b63541f  SDAP-286: Add processor module to Granule Ingester to properly handle longitudes between 180-360deg

This branch includes the following new commits:

     new b63541f  SDAP-286: Add processor module to Granule Ingester to properly handle longitudes between 180-360deg

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[incubator-sdap-ingester] 01/01: SDAP-286: Add processor module to Granule Ingester to properly handle longitudes between 180-360deg

Posted by ea...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

eamonford pushed a commit to branch subtract180fromlongitude
in repository https://gitbox.apache.org/repos/asf/incubator-sdap-ingester.git

commit b63541f88d9a4585d6da01c995b396d0aac42973
Author: Eamon Ford <ea...@gmail.com>
AuthorDate: Tue Nov 3 16:48:46 2020 -0800

    SDAP-286: Add processor module to Granule Ingester to properly handle longitudes between 180-360deg
---
 .../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