Observation format

This section will help you convert your observationnal data into the ForMoSA format

Imports

[1]:
from astropy.io import fits
from astropy.table import Table

Data .fits

Your observed data (spectroscopy and/or photometry) should be formated in a .fits file with the following extensions :

  • ‘WAV’ : (array) wavelength grid.

  • ‘FLX’ : (array) flux.

  • ‘ERR’ or ‘COV’ : (array or 2D-array) errors or covariance matrix. The covariance matrix should have diag(COV)=ERR².

  • ‘RES’ : (array) resolution. Note : You must put res = 0.0 where you have photometric points.

  • ‘INS’ : (array) instrument name. Note : You must use the right filter name when you have photometric points. Check the phototeque for more information.

exemple :

[34]:
# CHECKUP FORMAT
hdul = fits.open('~/YOUR/PATH/formosa_desk/inversion_targetname/inputs/data.fits')
print(hdul[1].columns)
wav = hdul[1].data['WAV']
flx = hdul[1].data['FLX']
err = hdul[1].data['ERR']
res = hdul[1].data['RES']
ins = hdul[1].data['INS']
ColDefs(
    name = 'WAV'; format = 'D'
    name = 'FLX'; format = 'D'
    name = 'ERR'; format = 'D'
    name = 'RES'; format = 'D'
    name = 'INS'; format = '3A'
)

optional extensions can also be used when dealing with stellar-contaminated high-resolution spectroscopy:

  • ‘TRANSM’ : (array) transmission (atmospheric + instrumental)

  • ‘STAR_FLX’ or ‘STAR_FLXi’ : (array or i arrays) star flux or shifted star flux (to account for LSF changes)

  • ‘SYSTEM’ or ‘SYSTEMj’ : (array or j arrays) systematic model(s) (usually computed from PCA)

Format your data

To format your data, you can use the simple Python routine below :

[35]:
# FITS converter :
table = Table([wav, flx, res, res, ins], names=('WAV', 'FLX', 'ERR', 'RES', 'INS'))
hdul = fits.HDUList()
hdu = fits.BinTableHDU(table)
hdul.append(hdu)
hdul.writeto('~/YOUR/PATH/formosa_desk/inversion_targetname/inputs/data.fits')
print('correction successful')
correction successful

If you have multiple observations, we recommand that you create separated .fits files (e.g data_1.fits, data_2.fits, …)