Skip to content

Commit

Permalink
Fix start and end times in Landsat L1 reader.
Browse files Browse the repository at this point in the history
  • Loading branch information
simonrp84 committed Sep 16, 2024
1 parent 31aff4d commit 411741c
Showing 1 changed file with 24 additions and 14 deletions.
38 changes: 24 additions & 14 deletions satpy/readers/oli_tirs_l1_tif.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,23 +62,13 @@ def get_btype(file_type):

@property
def start_time(self):
"""Return start time.
This is actually the scene center time, as we don't have the start time.
It is constructed from the observation date (from the filename) and the center time (from the metadata).
"""
return datetime(self._obs_date.year, self._obs_date.month, self._obs_date.day,
self._mda.center_time.hour, self._mda.center_time.minute, self._mda.center_time.second)
"""Return start time."""
return self._mda.start_time

@property
def end_time(self):
"""Return end time.
This is actually the scene center time, as we don't have the end time.
It is constructed from the observation date (from the filename) and the center time (from the metadata).
"""
return datetime(self._obs_date.year, self._obs_date.month, self._obs_date.day,
self._mda.center_time.hour, self._mda.center_time.minute, self._mda.center_time.second)
"""Return end time."""
return self._mda.end_time

def __init__(self, filename, filename_info, filetype_info, mda, **kwargs):
"""Initialize the reader."""
Expand Down Expand Up @@ -211,6 +201,26 @@ def center_time(self):
"""Return center time."""
return datetime.strptime(self.root.find(".//IMAGE_ATTRIBUTES/SCENE_CENTER_TIME").text[:-2], "%H:%M:%S.%f")

@property
def start_time(self):
"""Return start time.
This is actually the scene center time, as we don't have the start time.
It is constructed from the observation date (from the filename) and the center time (from the metadata).
"""
return datetime(self._obs_date.year, self._obs_date.month, self._obs_date.day,
self.center_time.hour, self.center_time.minute, self.center_time.second)

@property
def end_time(self):
"""Return end time.
This is actually the scene center time, as we don't have the end time.
It is constructed from the observation date (from the filename) and the center time (from the metadata).
"""
return datetime(self._obs_date.year, self._obs_date.month, self._obs_date.day,
self.center_time.hour, self.center_time.minute, self.center_time.second)

@property
def cloud_cover(self):
"""Return estimated granule cloud cover percentage."""
Expand Down

0 comments on commit 411741c

Please sign in to comment.