Skip to content

Commit

Permalink
Better document the first fitting notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
mwcraig committed Nov 24, 2024
1 parent 657b27c commit 875a43d
Showing 1 changed file with 150 additions and 16 deletions.
166 changes: 150 additions & 16 deletions stellarphot/notebooks/photometry/06-transit-fit-template.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
},
{
Expand Down Expand Up @@ -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"
]
},
{
Expand All @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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"
]
},
{
Expand All @@ -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,
Expand All @@ -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?"
]
},
{
Expand All @@ -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,
Expand Down Expand Up @@ -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": {},
Expand Down Expand Up @@ -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"
]
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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???"
]
},
{
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -751,6 +871,13 @@
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Cruft"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -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,
Expand Down

0 comments on commit 875a43d

Please sign in to comment.