Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: create_datetime_index mislabels data file index when dates are out of order. #906

Closed
jklenzing opened this issue Sep 29, 2021 · 1 comment · Fixed by #907
Closed
Assignees
Labels
Milestone

Comments

@jklenzing
Copy link
Member

jklenzing commented Sep 29, 2021

Describe the bug
pysat.utils.time.create_datetime_index assumes that input files are in order. This is not always the case and can result in files being mislabeled as later years.

To Reproduce

import numpy as np
import pysat
year = np.array([2014, 2014, 2008])
day = np.array([1, 2, 365])
uts = np.array([0, 3600, 2700])
pysat.utils.time.create_datetime_index(year=year, day=day, uts=uts)

Expected behavior
This should produce an index corresponding to the three years. Instead, the final date is labeled as '2014-12-31 00:45:00' instead of '2008-12-31 00:45:00'

Screenshots
This area seems to be the culprit:

pysat/pysat/utils/time.py

Lines 316 to 318 in 6374f84

# Add in seconds since unix epoch to first day
uts_del += (dt.datetime(year[0], month[0], 1)
- dt.datetime(1970, 1, 1)).total_seconds()

Desktop (please complete the following information):

  • OS: Mac OS X 10.15.7
  • Version python 3.8.11
  • Other details about your setup that could be relevant

Additional context
See pysat/pysatCDAAC#24 for context

@jklenzing
Copy link
Member Author

Closing with merge of #907

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant