Skip to content

Commit

Permalink
Merge pull request #168 from DanRyanIrish/time_base
Browse files Browse the repository at this point in the history
Add a base time to SpectrogramCube.time if derived from WCS.
  • Loading branch information
DanRyanIrish committed Jul 24, 2020
2 parents 45fd88f + ef56e0a commit d27fd55
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions changelog/168.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Include a base time to output of `sunraster.SpectrogramCube.time` when time is derived from WCS and a recognized base time can be found in meta.
13 changes: 10 additions & 3 deletions sunraster/spectrogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
import numbers

import numpy as np
from astropy.time import TimeDelta
import astropy.units as u
from ndcube.ndcube import NDCube
from ndcube.utils.cube import convert_extra_coords_dict_to_input_format

import astropy.units as u

__all__ = ['SpectrogramCube']


Expand Down Expand Up @@ -282,7 +282,14 @@ def time(self):
if not self._time_name:
raise ValueError("Time" + AXIS_NOT_FOUND_ERROR +
f"{SUPPORTED_TIME_NAMES}")
return self._get_axis_coord(self._time_name, self._time_loc)
times = self._get_axis_coord(self._time_name, self._time_loc)
if isinstance(times, (u.Quantity, TimeDelta)):
try:
if self.meta.date_reference:
times += self.meta.date_reference
except AttributeError:
pass
return times

@property
def exposure_time(self):
Expand Down

0 comments on commit d27fd55

Please sign in to comment.