{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Observation format\n", "\n", "This section will help you convert your observationnal data into the ForMoSA format\n", "\n", "## Imports" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from astropy.io import fits\n", "from astropy.table import Table" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Data ``.fits``\n", "\n", "Your observed data (spectroscopy and/or photometry) should be formated in a ``.fits`` file with the following extensions :\n", "\n", "- **'WAV'** : (array) wavelength grid.\n", "- **'FLX'** : (array) flux.\n", "- **'ERR'** or **'COV'** : (array or 2D-array) errors or covariance matrix. The covariance matrix should have ``diag(COV)=ERR²``.\n", "- **'RES'** : (array) resolution. Note : You must put res = 0.0 where you have photometric points.\n", "- **'INS'** : (array) instrument name. Note : You must use the right filter name when you have photometric points. Check the phototeque for more information.\n", "\n", "exemple :" ] }, { "cell_type": "code", "execution_count": 34, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "ColDefs(\n", " name = 'WAV'; format = 'D'\n", " name = 'FLX'; format = 'D'\n", " name = 'ERR'; format = 'D'\n", " name = 'RES'; format = 'D'\n", " name = 'INS'; format = '3A'\n", ")\n" ] } ], "source": [ "# CHECKUP FORMAT\n", "hdul = fits.open('~/YOUR/PATH/formosa_desk/inversion_targetname/inputs/data.fits')\n", "print(hdul[1].columns)\n", "wav = hdul[1].data['WAV']\n", "flx = hdul[1].data['FLX']\n", "err = hdul[1].data['ERR']\n", "res = hdul[1].data['RES']\n", "ins = hdul[1].data['INS']" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "optional extensions can also be used when dealing with stellar-contaminated high-resolution spectroscopy:\n", "- **'TRANSM'** : (array) transmission (atmospheric + instrumental)\n", "- **'STAR_FLX'** or **'STAR_FLXi'** : (array or i arrays) star flux or shifted star flux (to account for LSF changes)\n", "- **'SYSTEM'** or **'SYSTEMj'** : (array or j arrays) systematic model(s) (usually computed from PCA)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Format your data\n", "\n", "To format your data, you can use the simple Python routine below :" ] }, { "cell_type": "code", "execution_count": 35, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "correction successful\n" ] } ], "source": [ "# FITS converter :\n", "table = Table([wav, flx, res, res, ins], names=('WAV', 'FLX', 'ERR', 'RES', 'INS'))\n", "hdul = fits.HDUList()\n", "hdu = fits.BinTableHDU(table)\n", "hdul.append(hdu)\n", "hdul.writeto('~/YOUR/PATH/formosa_desk/inversion_targetname/inputs/data.fits')\n", "print('correction successful')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "If you have multiple observations, we recommand that you create separated ``.fits`` files (e.g ``data_1.fits``, ``data_2.fits``, ...)" ] } ], "metadata": { "kernelspec": { "display_name": "pRT3_env", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.5" } }, "nbformat": 4, "nbformat_minor": 2 }