You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sdap.apache.org by "RKuttruff (via GitHub)" <gi...@apache.org> on 2023/04/13 17:51:19 UTC

[GitHub] [incubator-sdap-ingester] RKuttruff commented on a diff in pull request #73: SDAP-435 + SDAP-437 - Granule preprocessing and timedelta array support

RKuttruff commented on code in PR #73:
URL: https://github.com/apache/incubator-sdap-ingester/pull/73#discussion_r1165855221


##########
granule_ingester/granule_ingester/processors/reading_processors/TileReadingProcessor.py:
##########
@@ -86,5 +86,12 @@ def _convert_spec_to_slices(spec):
     def _convert_to_timestamp(times: xr.DataArray) -> xr.DataArray:
         if times.dtype == np.float32:
             return times
+        elif times.dtype.type == np.timedelta64:    # If time is an array of offsets from a fixed reference
+            reference = times.time.item() / 1e9     # Get the base time in seconds
+
+            times = (times / 1e9).astype(int)       # Convert offset array to seconds
+            times = times.where(times != -9223372036854775808)  # Replace NaT values with NaN

Review Comment:
   For reference to the big number here:
   
   ```python
   >>> import numpy as np
   >>>
   >>> np.datetime64('NaT').astype(int)
   -9223372036854775808
   >>>
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@sdap.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org