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

Getting Time objects from FITS headers #11297

Open
dstansby opened this issue Feb 4, 2021 · 2 comments
Open

Getting Time objects from FITS headers #11297

dstansby opened this issue Feb 4, 2021 · 2 comments

Comments

@dstansby
Copy link
Contributor

dstansby commented Feb 4, 2021

Description

Several entries in FITS headers indicate a time, e.g. DATE-OBS, DATE-BEG, DATE-END etc. For more information, see section 9, table 35 of the FITS standard: https://fits.gsfc.nasa.gov/standard40/fits_standard40aa-le.pdf

As far as I can tell, there is no simple way to get these out of an astropy.io.fits.Header object, and into a astropy.time.Time object. The best I have is

tsring = header['DATE-OBS']
scale = header['TIMESYS']
dtime = Time(tstring, scale=scale, format='fits')

It would be nice if there was a way for astropy to automatically apply the scale and any other necessary keywords, e.g. MJDREF. Perhaps a Header.get_time(key) method where key could be e.g. DATE-OBS would be helpful?

I would be happy to implement such a helper, but thought it would be best to first seek advice on whether this would be welcomed/what the API should be.

Additional context

There is #6676 already open, but I think that refers to times stored as data in columns as opposed to the header.

@saimn
Copy link
Contributor

saimn commented Feb 4, 2021

There is also #10073 about setting FITS headers with datetime or Time instances.

@mhvk
Copy link
Contributor

mhvk commented Feb 5, 2021

Indeed, this would be great! I think it may be best to move discussion to #10073, and expand that to setting and getting. (I'll comment more there.)

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

No branches or pull requests

4 participants