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

Convert Datetime to Astropy Time #107

Merged
merged 2 commits into from
Dec 7, 2023

Conversation

Alrobbertz
Copy link
Member

@Alrobbertz Alrobbertz commented Nov 16, 2023

This PR converts use of the datetime library to use exclusively astropy.time.Time objects within the HERMES data container. datetime objects are still required for interactions with the spacepy library because spacepy does not have Astropy time support. However, this improves consistency within the data container itself so the datetime library is only used in the IO functionality needed to load and save CDFs with spacepy.

closes #102

Copy link

codecov bot commented Nov 16, 2023

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (a7315cb) 94.28% compared to head (cef182c) 94.47%.

Files Patch % Lines
hermes_core/util/schema.py 92.85% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #107      +/-   ##
==========================================
+ Coverage   94.28%   94.47%   +0.19%     
==========================================
  Files          10       10              
  Lines        1767     1757      -10     
==========================================
- Hits         1666     1660       -6     
+ Misses        101       97       -4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@ehsteve ehsteve left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of the time object changes look good but this merge request seems to be doing more than just this. Could you further describe what other issues you are solving here? Thanks!

@@ -1321,8 +1299,7 @@ def _get_generation_date(self, data):
"""
Function to get the date that the CDF was generated.
"""
day = datetime.date.today()
return datetime.datetime(day.year, day.month, day.day)
return Time.now().strftime("%Y-%m-%d")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should further specify the date here in case we generate two CDF files in a single day?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ehsteve The previous implementation just included the date (no time) so I followed that paradigm. We would only have naming conflicts if the other portions of the name were also the same: instrument, start time, mode, data level...
I do not think we'll meet these conditions where all aspects are the same, but if you think we will, I can update to include a timestamp in addition to the date.

@Alrobbertz Alrobbertz merged commit 6ef8e07 into HERMES-SOC:main Dec 7, 2023
14 checks passed
@Alrobbertz Alrobbertz deleted the 102-datatime-to-astropy-time branch January 2, 2024 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Convert datatime to Astropy time
2 participants