astropy/astropy — pull request #237 by iguananaut (2012-05-15 21:35:19+00:00)
Title: Time alternative implementation

I'm posting this pull request mostly for the sake of discussion on #212. This is based off of @wkerzendorf's `Time` implementation in #212 and is originally copied from his code.

This version of the implementation is far from complete or robust, and is just to give an idea of what I'm thinking. As with the latest version of #212, the time is represented internally as an int64 for seconds and a float64 for fractions of seconds or "subseconds". A `Time` instance has `.seconds`, `.subseconds`, and `.system` attributes which should be considered immutable (I might make them into properties to enforce this somewhat. Currently "system" can be either TAI or TT (and I'm working on adding UTC; could also add UT1, UT2, etc.)

In these `Time` objects the seconds+subseconds are linked to a specific time system. The default is TAI. For each supported time system there is an attribute with the same name that returns the same time as a new `Time` object converted to that time system. For example:

```python
>>> from astropy.time import Time
>>> t = Time(1, .0)
>>> t.seconds, t.subseconds
(1, 0.0)
>>> t.mjd
43144.00038407417
>>> t.tt.seconds, t.tt.subseconds
(33, 0.1839999999999975)
>>> t.tt.mjd
43144.000756574329
>>> t.tt.tai.seconds, t.tt.tai.subseconds # Round trip
(0, 0.0)
```

There's a lot more to do on this, but this should at least illustrate the concept.