Skip to content

Improve writing of Time and TimeDelta in "ascii.mrt" tables #20662

Open

Description

@hamogu

What is the problem this feature will solve?

Time and TimeDelta objects can be written to MIT tables, but all their meta information (like units) is lost. The code should set units for time deltas (and time where consistent with MRT standards, e.g. AAS journals user the units of days ("d") for JD, MJD, ...) and sensible default for the column descriptions.

Describe the desired outcome

Here is an example of current astropy behaviour:

import sys

from astropy.table import Table, QTable
from astropy.time import Time, TimeDelta
from astropy import units as u

times = Time(['2024-01-01T00:00:00', '2024-01-02T12:00:01'], format='isot', scale='utc')
times.format = 'mjd'
timediffs = TimeDelta([0, 1.500001] * u.day)
tab = Table({'obs': ['a', 'b'], 'time': times, 'timediff': timediffs})

tab.write(sys.stdout, format='ascii.mrt')

gives

Title:
Authors:
Table:
================================================================================
Byte-by-byte Description of file: table.dat
--------------------------------------------------------------------------------
 Bytes Format Units  Label     Explanations
--------------------------------------------------------------------------------
    1  A1     ---    obs      Description of obs     
 3-19  A17    ---    time     Description of time    
21-28  A8     ---    timediff Description of timediff
--------------------------------------------------------------------------------
Notes:
--------------------------------------------------------------------------------
a 60310.0           0.0     
b 60311.50001157408 1.500001

timediff doesn't have a unit, and time doesn't have any system. From the output, I cannot identify if time is in seconds since launch of the observatory, in MJD, in some other system and the 'time` column has about 6 more digits than it should have. One might say that it's up to the user to specify this in the "explanations" column, but astropy should set the units for the timediff and a sensible detail for the explanation of the time. (While the table writer can't know if this data was observed at the VLT or with HST, it could at list default to "Time in MJD".)

While an "astropy.time.Time" object doesn't have a unit, the AAS MRT example on https://journals.aas.org/mrt-standards/ explicitly lists a date in BJD with a unit of "d". I don't think there is a specified "you need to use BJD" or you need to use "ISOT" format in the MRT definition - it's up to the authors to pick what's best.

Additional context

PR #12027 had a draft implementation for this, but never got finished after the GSOC ended and was eventually closed by the bot.
While I've tried to summarize the discussion in that PR here, there are more details on how this might be implemented, which time format to choose etc.

Activity

  1. hamogu commented on Oct 20, 2026

    @hamogu
    MemberAuthor
  2. neutrinoceros commented on Oct 20, 2026

    @neutrinoceros
    Contributor

    did you actually mean "MIT tables" ?

  3. neutrinoceros commented on Oct 20, 2026

    @neutrinoceros
    Contributor

    also, does this replace #18385 ?

  4. hamogu commented on Oct 20, 2026

    @hamogu
    MemberAuthor

    did you actually mean "MIT tables" ?

    Stupid auto-correct. Editing above to fix.

    also, does this replace #18385 ?

    I'm not sure. This is an actionably sub-aspect of #18385. That issue title is pretty generic about all columns, while this is specifically for times and time deltas. Looking back at #18385, all the examples mentioned there are for times and time-deltas, so maybe the issue is meant narrower than the title sounds.

    We could close this as duplicate, or keep this as a specific request for one aspect of #18385. You call ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions