From 960c0254978b2b2efed240429965ba888ce7ac6d Mon Sep 17 00:00:00 2001 From: Matt Craig Date: Sun, 24 Nov 2024 16:58:49 -0600 Subject: [PATCH] Use plain FileChooser No idea why I was using a FitsOpener to get this since these are not FITS files... --- .../photometry/06-transit-fit-template.ipynb | 45 +++++-------------- 1 file changed, 11 insertions(+), 34 deletions(-) diff --git a/stellarphot/notebooks/photometry/06-transit-fit-template.ipynb b/stellarphot/notebooks/photometry/06-transit-fit-template.ipynb index c73f70ae..ef02d84e 100644 --- a/stellarphot/notebooks/photometry/06-transit-fit-template.ipynb +++ b/stellarphot/notebooks/photometry/06-transit-fit-template.ipynb @@ -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", @@ -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" ] }, @@ -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" ] }, { @@ -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())" ] }, { @@ -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", @@ -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": {},