Should FITS be careful about the TLMIN/MAX values when writing out?
- Dominant language
- Python
- Stars
- 5.3k
- Forks
- 2.2k
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 81
Description
### What is the problem this feature will solve?
This is a follow-on to https://github.com/astropy/astropy/issues/17254 as I found I can create a FITS file with a string value for a TLMIN or TLMAX value. Is this something that should be disallowed, or automatically converted to a numeric value, or just left as is?
### Describe the desired outcome
I honestly don't have much skin in this game, and understand that it may well be best just to leave as is, but I thought I'd mention it given the comment by @saimn https://github.com/astropy/astropy/issues/17254#issuecomment-2438890184
There is also the possibility that I'm using the API incorrectly, in setting the TLMINx/TLMAXx values directly in the header, but I couldn't find another way to do this.
### Additional context
Here is the example I used:
```
>>> from astropy.table import Table
>>> from astropy.io import fits
>>> t = Table([[1, 2, 3]])
>>> hdu = fits.table_to_hdu(t)
>>> hdu.header
XTENSION= 'BINTABLE' / binary table extension
BITPIX = 8 / array data type
NAXIS = 2 / number of array dimensions
NAXIS1 = 8 / length of dimension 1
NAXIS2 = 3 / length of dimension 2
PCOUNT = 0 / number of group parameters
GCOUNT = 1 / number of groups
TFIELDS = 1 / number of table fields
TTYPE1 = 'col0 '
TFORM1 = 'K '
>>> hdu.header["TLMIN1"] = "1 "
>>> hdu.header["TLMAX1"] = 400
>>> hdu.writeto("xx.fits", overwrite=True)
>>> ihdus = fits.open("xx.fits")
>>> ihdus[1].header
XTENSION= 'BINTABLE' / binary table extension
BITPIX = 8 / array data type
NAXIS = 2 / number of array dimensions
NAXIS1 = 8 / length of dimension 1
NAXIS2 = 3 / length of dimension 2
PCOUNT = 0 / number of group parameters
GCOUNT = 1 / number of groups
TFIELDS = 1 / number of table fields
TTYPE1 = 'col0 '
TFORM1 = 'K '
TLMIN1 = '1 '
TLMAX1 = 400
>>>
```
For reference:
```
>>> import platform; print(platform.platform())
Linux-4.18.0-553.8.1.el8_10.x86_64-x86_64-with-glibc2.28
>>> import sys; print("Python", sys.version)
Python 3.11.7 | packaged by conda-forge | (main, Dec 15 2023, 08:38:37) [GCC 12.3.0]
>>> import astropy; print("astropy", astropy.__version__)
astropy 6.0.0
>>> import numpy; print("numpy", numpy.__version__)
numpy 1.26.3
```
Contributor guide
Research direction
Start with the astropy.table.Table, astropy.io.fits.table_to_hdu, Header assignment, hdu.writeto, and fits.open entry points shown in the example. Check the FITS rules for TLMINx/TLMAX values and decide whether string values should be rejected, converted, or preserved. Done means the chosen behavior is documented and covered by regression tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100