[
https://issues.apache.org/jira/browse/SDAP-155?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16650579#comment-16650579
]
ASF GitHub Bot commented on SDAP-155:
-------------------------------------
fgreg commented on a change in pull request #10: SDAP-155 add processor to
extract timestamp from granule metadata
URL:
https://github.com/apache/incubator-sdap-ningesterpy/pull/10#discussion_r225256456
##########
File path: sdap/processors/extracttimestampprocessor.py
##########
@@ -0,0 +1,63 @@
+# 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.
+
+import nexusproto
+from nexusproto.serialization import from_shaped_array
+
+import datetime
+import time
+import logging
+from netCDF4 import Dataset, num2date
+from pytz import timezone
+
+from sdap.processors import NexusTileProcessor
+
+EPOCH = timezone('UTC').localize(datetime.datetime(1970, 1, 1))
+
+
+def to_seconds_from_epoch(timestamp, pattern='%Y-%m-%dT%H:%M:%S'):
+ try:
+ seconds = int(time.mktime(time.strptime(timestamp[:19], pattern)))
+ except ValueError:
+ logging.logger.error(timestamp + ' timestamp is not of the format
\'%Y-%m-%dT%H:%M:%S\'')
+ return seconds
+
+class ExtractTimestampProcessor(NexusTileProcessor):
+
+ def __init__(self, attribute_name, *args, **kwargs):
+ super().__init__(*args, **kwargs)
+
+ self.stored_var_name = self.environ['STORED_VAR_NAME']
Review comment:
Don't need `self.stored_var_name`
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> Add Processor to Pull Timestamp from Granule Metadata
> -----------------------------------------------------
>
> Key: SDAP-155
> URL: https://issues.apache.org/jira/browse/SDAP-155
> Project: Apache Science Data Analytics Platform
> Issue Type: Task
> Reporter: Elizabeth Yam
> Assignee: Elizabeth Yam
> Priority: Major
>
> Some datasets don't have a time variable and have a timestamp in their
> metadata and file headers instead. Without a convention, we need to be able
> to pull the timestamp, given the variable name and add it to the nexus tile.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)