-
-
Notifications
You must be signed in to change notification settings - Fork 14
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
Time
values do not always round trip perfectly
#133
Comments
Tagging @mhvk and @taldcroft as the experts on |
I think that if you write the |
I think option (1) seems better as it is guaranteed to work even if new time formats are introduced, while for option (2) you'll need to special case almost every format. The suggestion of a comment with the normal representation makes sense to me. As @taldcroft notes, we had the same problem for writing times to ascii tables, and ended up giving the user the choice. |
Besides storing Looks like we need |
In particular the |
Indeed, |
Due to how we are generating the representation for
astropy.time.Time
objects, some numerical inaccuracies accumulate. This results in the time value read from asdf for aastropy.time.Time
object slightly differing the value of the original object. The reason for this is that several of the available timeformats
require a conversion into a format which we write to ASDF (for human readability) and then thatformat
will get converted to the original format, which is a process that generates numerical errors.A demonstration of this is the need for a
atol
and the use ofisclose
instead of==
in this test:https://github.com/WilliamJamieson/asdf-astropy/blob/889005badaea78a6feb59f72574d3b9b299292b9/asdf_astropy/converters/time/tests/test_time.py#L139-L153 (fixing an incorrectly written test as part of #132).
Currently, there are two possible solutions that I see:
astropy.time.Time
should be written under a new schema (sayhttp://astropy.org/schemas/astropy/time/time-1.0.0
) rather than the one built into ASDF. This schema should instead write the base-representation (usingval1
andval2
directly) for theastropy.time.Time
object rather than attempting to write the object in a human-readable format. @perrygreenfield suggested that maybe ASDF should support converters including a comment alongside this to make it human readable.decimal
built-in type ofpython
to exactly convertval1
andval2
into their exact representation for the universal time value, and write that value as an exact string. Then forcing the read indecimal
followed by a computation indecimal
to extractval1
andval2
. Maybe include a flag in the existingtime
schema to indicate this mode should be used.Other solutions may exist, which should be discussed as part of this issue.
The text was updated successfully, but these errors were encountered: