Skip to content

Commit

Permalink
BUG: fixed large hours
Browse files Browse the repository at this point in the history
Fixed a bug with roll-over hours.
  • Loading branch information
aburrell committed Jul 3, 2024
1 parent 0d4ca86 commit b8fc91f
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions pysatNASA/instruments/methods/jhuapl.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,27 @@ def build_dtimes(data, var, epoch=None, epoch_var='time'):
skey = 'TIME{:s}'.format(var)

if epoch is None:
hours = [int(np.floor(sec / 3600.0)) for sec in data[skey].values]
hours = np.array([int(np.floor(sec / 3600.0))
for sec in data[skey].values])
mins = [int(np.floor((sec - hours[i] * 3600) / 60.0))
for i, sec in enumerate(data[skey].values)]
secs = [int(np.floor((sec - hours[i] * 3600 - mins[i] * 60)))
for i, sec in enumerate(data[skey].values)]
microsecs = [int(np.floor((sec - hours[i] * 3600 - mins[i] * 60
- secs[i]) * 1.0e6))
for i, sec in enumerate(data[skey].values)]
days = np.array([int(dval) for dval in data[dkey].values])

# Ensure hours are within a realistic range. Datetime can handle day of
# roll-over for non-leap years.
days[hours >= 24] += 1
hours[hours >= 24] -= 24

dtimes = [
dt.datetime.strptime(
"{:4d}-{:03d}-{:02d}-{:02d}-{:02d}-{:06d}".format(
int(data[ykey].values[i]), int(data[dkey].values[i]),
hours[i], mins[i], secs[i], microsec), '%Y-%j-%H-%M-%S-%f')
int(data[ykey].values[i]), days[i], hours[i], mins[i],
secs[i], microsec), '%Y-%j-%H-%M-%S-%f')
for i, microsec in enumerate(microsecs)]
else:
dtimes = [
Expand Down

0 comments on commit b8fc91f

Please sign in to comment.