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

Added a subclass of astropy.time to support utime #2409

Merged
merged 11 commits into from
Feb 28, 2018
Merged

Added a subclass of astropy.time to support utime #2409

merged 11 commits into from
Feb 28, 2018

Conversation

jmason86
Copy link
Sponsor Contributor

Implemented handling of utime by creating a custom subclass of astropy.time.Time, which uses the third code example from their documentation as a template.

@wafels
Copy link
Member

wafels commented Jan 17, 2018 via email

@wafels
Copy link
Member

wafels commented Jan 17, 2018 via email

@jmason86
Copy link
Sponsor Contributor Author

Will do. It's needed because @Cadair told me so? 😛

@Cadair
Copy link
Member

Cadair commented Jan 18, 2018

Knowing very little about this, can you construct it with the float? A test for that use would be great as well. (Seeing how that's the most likely use of this, not to save out utime as we are not monsters :p )

@jmason86
Copy link
Sponsor Contributor Author

I was afraid of you asking for that.. that's what I spent a couple hours on yesterday (but for a new yyyydoy_sod subclass) and that is much harder to figure out since I haven't found any comprehensive astropy examples. I'll keep at it though.

@jmason86
Copy link
Sponsor Contributor Author

This PR is now dependent on the resolution of issue 7092 in astropy that will enable, in this case, utime as an input.

@nabobalis nabobalis added the time Affects the time submodule label Jan 23, 2018


class TimeUTime(TimeFromEpoch):
"""Seconds from 1979-01-01 00:00:00 UTC. Same as Unix time
Copy link
Contributor

Choose a reason for hiding this comment

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

I forget, should there not be a new line after the docstring quotes?

Copy link
Sponsor Contributor Author

Choose a reason for hiding this comment

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

PEP257 doesn't specify but I can change it if that's a standard recommended in sunpy or in the science stack.

Copy link
Contributor

Choose a reason for hiding this comment

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

It's not an issue then!

Copy link
Member

Choose a reason for hiding this comment

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

It's a Cadair standard, which means most of SunPy is like that ;)

from astropy.time import Time
t = Time('2000-01-01T13:53:23')
print(t.utime)
>>> 662738003.0
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks wrong for example syntax.

I think it should be somrthing like:

Examples
--------
     >>> code line 1
     >>> code line 2

I forget how you add the output.

Copy link
Sponsor Contributor Author

Choose a reason for hiding this comment

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

I think you're right. I couldn't find a PEP standard but I found a random example of how it's done in scipy. For example:

 >>> from scipy.interpolate import BSpline
 >>> k = 2
 >>> t = [0, 1, 2, 3, 4, 5, 6]
 >>> c = [-1, 2, 0, -1]
 >>> spl = BSpline(t, c, k)
 >>> spl(2.5)
 array(1.375)
 >>> bspline(2.5, t, c, k)
 1.375

This time format is included for historical reasons. Some
people in solar physics prefer using this epoch.

Example:
Copy link
Contributor

Choose a reason for hiding this comment

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

I think example should be underlined

Example
-------



def test_utime_random_date():
assert Time('2018-01-13T13:32:56').utime == 1231853576.0
Copy link
Member

Choose a reason for hiding this comment

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

Could you please add a test which is marked with @pytest.mark.xfail of the reverse conversion? i.e. the open astropy issue?

from __future__ import absolute_import, division, print_function

from astropy.time import Time

Copy link
Member

Choose a reason for hiding this comment

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

should this not explicitly import the utime format to register it with astropy?

@Cadair
Copy link
Member

Cadair commented Jan 25, 2018

@jmason86 can you merge master into this to fix the CI please?

@Cadair
Copy link
Member

Cadair commented Jan 27, 2018

Can you add a changelog entry for this please? Other than that this looks great.

@Cadair Cadair merged commit 6cc0c24 into sunpy:master Feb 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
time Affects the time submodule
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants