From 875a43dabf402b27eee1e777d095f1db28234ce4 Mon Sep 17 00:00:00 2001 From: Matt Craig Date: Sun, 24 Nov 2024 10:44:34 -0600 Subject: [PATCH] Better document the first fitting notebook --- .../photometry/06-transit-fit-template.ipynb | 166 ++++++++++++++++-- 1 file changed, 150 insertions(+), 16 deletions(-) diff --git a/stellarphot/notebooks/photometry/06-transit-fit-template.ipynb b/stellarphot/notebooks/photometry/06-transit-fit-template.ipynb index 166951f7..5801b5c2 100644 --- a/stellarphot/notebooks/photometry/06-transit-fit-template.ipynb +++ b/stellarphot/notebooks/photometry/06-transit-fit-template.ipynb @@ -33,7 +33,11 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### 0. Get some data" + "### 0. Get some data\n", + "\n", + "+ Select photometry file with relative flux\n", + "+ Select passband\n", + "+ Select TESS info file" ] }, { @@ -83,7 +87,9 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### 👇👇👇 use this to exclude some data (only if needed!) 👇👇👇" + "### 👇👇👇 use this to exclude some data (only if needed!) 👇👇👇\n", + "\n", + "Option to filter by date..even though you do not know yet what the data looks like" ] }, { @@ -101,6 +107,13 @@ "use_no_data_after = Time(2499999, format=\"jd\", scale=\"tdb\")" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Read the photometry and TESS info" + ] + }, { "cell_type": "code", "execution_count": null, @@ -116,6 +129,13 @@ "# tess_info = pickle.load(f)" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Actually filter out data by date" + ] + }, { "cell_type": "code", "execution_count": null, @@ -165,6 +185,16 @@ "### You may need to alter some of the settings here" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Fit settings\n", + "\n", + "+ Do any detrending by a covariate?\n", + "+ Which parameters are fixed?" + ] + }, { "cell_type": "code", "execution_count": null, @@ -200,6 +230,13 @@ "fit_width = False" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Create separate variables for a bunch of things because it was a PITA to write to code later in the notebook \n" + ] + }, { "cell_type": "code", "execution_count": null, @@ -223,10 +260,19 @@ "# Enter object name\n", "obj = f\"TIC {tess_info.tic_id}\"\n", "\n", + "\n", + "# 👇👇👇 BUG 🐛 BUG 🐛 BUG 🐛 BUG 👇👇👇👇\n", "# Enter filter\n", "phot_filter = \"rp\"" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### Plot settings 🤦‍♂️" + ] + }, { "cell_type": "code", "execution_count": null, @@ -249,6 +295,13 @@ "outputs": [], "source": [] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Get just the target star and some information about it" + ] + }, { "cell_type": "code", "execution_count": null, @@ -273,6 +326,13 @@ "Looks like we need to normalize the data first....." ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Keep only the data in the right filter" + ] + }, { "cell_type": "code", "execution_count": null, @@ -283,18 +343,17 @@ "source": [ "band_filter = photometry[\"passband\"] == phot_filter\n", "\n", - "target_and_filter = target_star & band_filter" + "target_and_filter = target_star & band_filter\n", + "photometry = photometry[target_and_filter]" ] }, { - "cell_type": "code", - "execution_count": null, + "cell_type": "markdown", "metadata": { "tags": [] }, - "outputs": [], "source": [ - "photometry = photometry[target_and_filter]" + "### Find the transit number....this is off by one if we observe only the second half of the transit" ] }, { @@ -310,6 +369,13 @@ "that_transit" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Find the OOT region and use it to get normalization factor" + ] + }, { "cell_type": "code", "execution_count": null, @@ -334,13 +400,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Bin Data\n", - "\n", - "Need\n", - "* data table\n", - "* start\n", - "* end\n", - "* bin_size" + "#### WTF?" ] }, { @@ -352,6 +412,23 @@ "len(normalization_factor * photometry[\"relative_flux_error\"].value)" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Bin Data\n", + "\n", + "Need\n", + "* data table\n", + "* start\n", + "* end\n", + "* bin_size\n", + "\n", + "Data is binned twice because the method for finding error is different in each\n", + "\n", + "**Also make times smaller**" + ] + }, { "cell_type": "code", "execution_count": null, @@ -397,6 +474,14 @@ "# binned_time = BinnedTimeSeries(photometry['bjd'], time_bin_start=first_time, time_bin_end=last_time, time_bin_size=bin_size)" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Model mash-up....weird mix of model and data filtering\n", + "### OMG so many places we subtract by 2400000" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -492,7 +577,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### 3.5 Constrain the fits if you want\n", + "### 3.5 Constrain the fits if you want...this approach is terrible\n", "\n", "#### Exoplanet parameters" ] @@ -534,6 +619,13 @@ "mod.model.width_trend.fixed = not fit_width" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Detrending string, including a spelling error" + ] + }, { "cell_type": "code", "execution_count": null, @@ -579,7 +671,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### 5. Let's try a plot...." + "### 5. Let's try a plot....maybe need some way here to deal with discrepant points???" ] }, { @@ -620,6 +712,13 @@ "# mod._fitter.fit_info" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Remove trends from the data if desired" + ] + }, { "cell_type": "code", "execution_count": null, @@ -632,6 +731,13 @@ "flux_full_detrend_model = mod.model_light_curve(detrend_by=\"all\")" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Calculate RMS before and after detrending, hopefully correctly...." + ] + }, { "cell_type": "code", "execution_count": null, @@ -648,6 +754,13 @@ "rel_flux_rms = np.std(mod.data)" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Random isolated plot command..." + ] + }, { "cell_type": "code", "execution_count": null, @@ -659,6 +772,13 @@ "grid_y_ticks = np.arange(low, high, 0.02)" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Make the big plot" + ] + }, { "cell_type": "code", "execution_count": null, @@ -751,6 +871,13 @@ ")" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Cruft" + ] + }, { "cell_type": "code", "execution_count": null, @@ -773,6 +900,13 @@ "mod._all_detrend_params" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Attempt to calculate BIC, but...this seems to have side effects on the rest of notebook " + ] + }, { "cell_type": "code", "execution_count": null,