Skip to content

Commit

Permalink
Use plain FileChooser
Browse files Browse the repository at this point in the history
No idea why I was using a FitsOpener to get this since these are not
FITS files...
  • Loading branch information
mwcraig committed Nov 24, 2024
1 parent b5d95c2 commit 960c025
Showing 1 changed file with 11 additions and 34 deletions.
45 changes: 11 additions & 34 deletions stellarphot/notebooks/photometry/06-transit-fit-template.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@
"outputs": [],
"source": [
"from itertools import product\n",
"from pathlib import Path\n",
"\n",
"import ipywidgets as ipw\n",
"import numpy as np\n",
"\n",
"from matplotlib import pyplot as plt\n",
"from astropy.table import Table\n",
"from ipyautoui.custom import FileChooser\n",
"\n",
"from stellarphot.transit_fitting import TransitModelFit\n",
"from stellarphot.transit_fitting.gui import *\n",
Expand Down Expand Up @@ -47,23 +49,23 @@
},
"outputs": [],
"source": [
"fits_openr = FitsOpener(\n",
"fits_openr = FileChooser(\n",
" title=\"Select your photometry/flux file\",\n",
" filter_pattern=[\"*.csv\", \"*.fits\", \"*.ecsv\"],\n",
")\n",
"fits_openr2 = FitsOpener(title=\"Select your TESS info file\", filter_pattern=[\"*.json\"])\n",
"fits_openr2 = FileChooser(title=\"Select your TESS info file\", filter_pattern=[\"*.json\"])\n",
"passband = ipw.Dropdown(description=\"Filter\", options=[\"gp\", \"ip\"], disabled=True)\n",
"box = ipw.VBox()\n",
"\n",
"def update_filter_list(change):\n",
" tab = Table.read(fits_openr.path)[\"passband\"]\n",
" tab = Table.read(fits_openr.value)[\"passband\"]\n",
" passband.options = sorted(set(tab))\n",
" passband.disabled = False\n",
" passband.value = passband.options[0]\n",
"\n",
"\n",
"fits_openr.file_chooser.observe(update_filter_list, names=\"_value\")\n",
"box.children = [fits_openr.file_chooser, fits_openr2.file_chooser, passband]\n",
"fits_openr.observe(update_filter_list, names=\"_value\")\n",
"box.children = [fits_openr, fits_openr2, passband]\n",
"box"
]
},
Expand All @@ -76,10 +78,10 @@
"outputs": [],
"source": [
"# 👉 File with photometry, including flux\n",
"photometry_file = fits_openr.path\n",
"photometry_file = fits_openr.value\n",
"\n",
"# 👉 File with exoplanet info in\n",
"tess_info_output_file = fits_openr2.path"
"tess_info_output_file = fits_openr2.value"
]
},
{
Expand Down Expand Up @@ -123,7 +125,7 @@
"source": [
"inp_photometry = PhotometryData.read(photometry_file)\n",
"\n",
"tess_info = TOI.model_validate_json(tess_info_output_file.read_text())"
"tess_info = TOI.model_validate_json(Path(tess_info_output_file).read_text())"
]
},
{
Expand Down Expand Up @@ -203,7 +205,7 @@
"# These affect the fitting that is done\n",
"\n",
"# bin size in minutes\n",
"bin_size = 10 * u.min\n",
"bin_size = 5 * u.min\n",
"\n",
"# Keep the time of transit fixed?\n",
"keep_fixed_transit_time = True\n",
Expand Down Expand Up @@ -560,31 +562,6 @@
"### Calculate RMS before and after detrending, hopefully correctly...."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"binned"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"binned.colnames\n",
"outside_transit_b = (binned[\"time_bin_start\"] < start) | (binned[\"time_bin_start\"] > end)\n",
"rel_detrended_flux_b = flux_full_detrend / np.mean(flux_full_detrend[outside_transit_b])\n",
"rel_model_rms = np.std(flux_full_detrend_model - rel_detrended_flux)\n",
"\n",
"rel_model_rms_b = np.std(flux_full_detrend_model - rel_detrended_flux_b)\n",
"\n",
"rel_model_rms, rel_model_rms_b"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down

0 comments on commit 960c025

Please sign in to comment.