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

Report date_dt as fractional days, not full days between #38

Merged
merged 1 commit into from
Oct 4, 2021

Conversation

jhkennedy
Copy link
Contributor

Current implementation will round-down the date_dt attribute to the number of full days between acquisitions.

For an extreme example, start with parsing the acquisition times, and getting the datetime.timedelta

import numpy as np
from datetime import datetime

>>> d0 = datetime.strptime('2020-06-26T20:48:33Z', '%Y-%m-%dT%H:%M:%SZ')
... d1 = datetime.strptime('2020-07-01T20:48:30Z', '%Y-%m-%dT%H:%M:%SZ')
...
... dt = d1 - d0
>>> dt
datetime.timedelta(days=4, seconds=86397)

you can see datetime thinks of this as "four days plus some seconds". So that means, when the current date_dt is calculated, you get:

>>> date_dt = np.float64(dt.days)
>>> date_dt
4.0

This switches to the actual fractional days, like:

>>> dt.total_seconds() / timedelta(days=1).total_seconds()
4.999965277777778

@leiyangleon
Copy link
Collaborator

LGTM

@leiyangleon leiyangleon merged commit 8424dee into nasa-jpl:master Oct 4, 2021
@jhkennedy jhkennedy deleted the fractional-date-dt branch November 11, 2021 20:55
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.

None yet

2 participants