Skip to content

Commit

Permalink
Use plot_many_factors
Browse files Browse the repository at this point in the history
  • Loading branch information
mwcraig committed Nov 25, 2023
1 parent 05f11bb commit 18e1a00
Showing 1 changed file with 40 additions and 49 deletions.
89 changes: 40 additions & 49 deletions stellarphot/notebooks/photometry/06-transit-fit-template.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"from stellarphot.transit_fitting import TransitModelFit\n",
"from stellarphot.transit_fitting.gui import *\n",
"from stellarphot.gui_tools.fits_opener import FitsOpener\n",
"from stellarphot.plotting import plot_many_factors\n",
"\n",
"from astropy.timeseries import BinnedTimeSeries, TimeSeries, aggregate_downsample\n",
"from astropy.time import Time\n",
Expand Down Expand Up @@ -452,7 +453,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"mod.fit()"
Expand All @@ -468,7 +471,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"plt.plot(mod.times, mod.data, '.')\n",
Expand All @@ -482,7 +487,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"mod.model"
Expand All @@ -491,7 +498,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"# mod._fitter.fit_info"
Expand All @@ -500,7 +509,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"flux_full_detrend = mod.data_light_curve(detrend_by='all') \n",
Expand All @@ -510,7 +521,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"rel_detrended_flux = flux_full_detrend / np.mean(flux_full_detrend)\n",
Expand All @@ -524,35 +537,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"airmass = photometry['airmass'] / np.mean(photometry['airmass'])\n",
"x = photometry['xcenter'] / np.mean(photometry['xcenter'])\n",
"y = photometry['ycenter'] / np.mean(photometry['ycenter'])\n",
"comp_counts = photometry['comparison counts'] / np.mean(photometry['comparison counts'])\n",
"sky_per_pix = photometry['sky_per_pix_avg'] / np.mean(photometry['sky_per_pix_avg'])\n",
"width = photometry['width'] / np.mean(photometry['width'])"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"scale_airmass = scale_and_shift(airmass, scale, 0.75 * shift, pos=False)\n",
"scale_x = scale_and_shift(x, scale, shift, pos=True)\n",
"scale_y = scale_and_shift(y, scale, shift, pos=True)\n",
"scale_sky_pix = scale_and_shift(sky_per_pix, scale, shift, pos=True)\n",
"scale_counts = scale_and_shift(comp_counts, scale, shift, pos=True)\n",
"scale_width = scale_and_shift(width, scale, shift, pos=True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"grid_y_ticks = np.arange(low, high, 0.02)"
Expand All @@ -561,15 +548,17 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"#(RMS={rel_flux_rms:.5f})\n",
"\n",
"plt.figure(figsize=(8,11))\n",
"fig, ax = plt.subplots(1, 1, figsize=(8, 11))\n",
"\n",
"plt.plot(photometry['BJD'] - 2400000, normalized_flux, 'b.', label=f\"rel_flux_T1 (RMS={rel_flux_rms:.5f})\", ms=4)\n",
"plt.plot((photometry['bjd'] - 2400000 * u.day).jd, normalized_flux, 'b.', label=f\"rel_flux_T1 (RMS={rel_flux_rms:.5f})\", ms=4)\n",
"\n",
"plt.plot(mod.times, flux_full_detrend - 0.04, '.', c='r', ms=4,\n",
" label=f\"rel_flux_T1 ({detrended_by})(RMS={rel_detrended_flux_rms:.5f}), (bin size={bin_size} min)\")\n",
Expand All @@ -582,13 +571,7 @@
" f\"[Tc={mod.model.t0.value + 2400000:.4f}], \"\n",
" f\"[u1={mod.model.limb_u1.value:.1f}, u2={mod.model.limb_u2.value:.1f})\")\n",
"\n",
"plt.plot(photometry['BJD'] - 2400000, scale_counts, '.', c='brown', label='tot_C_cnts (arbitrarily scaled and shifted)', alpha=0.5, ms=4)\n",
"plt.plot(photometry['BJD'] - 2400000, scale_airmass, 'c-', label=\"AIRMASS (arbitrarily scaled and shifted)\", ms=4)\n",
"plt.plot(photometry['BJD'] - 2400000, scale_sky_pix, c='gold', label='Sky/Pixel_T1 (arbitrarily scaled and shifted)', ms=4)\n",
"plt.plot(photometry['BJD'] - 2400000, scale_width, '-', c='gray', label=\"Width_T1 (arbitrarily scaled and shifted)\", ms=4)\n",
"plt.plot(photometry['BJD'] - 2400000, scale_x, '-', c='pink', label=\"X(FITS)_T1 (arbitrarily scaled and shifted)\", ms=4)\n",
"plt.plot(photometry['BJD'] - 2400000, scale_y, '-', c='lightblue', label=\"Y(FITS)_T1 (arbitrarily scaled and shifted)\", ms=4)\n",
"\n",
"plot_many_factors(photometry, low, high, shift, scale)\n",
"\n",
"plt.vlines(start.jd - 2400000, low, 1.025, colors='r', linestyle='--', alpha=0.5)\n",
"plt.vlines(end.jd - 2400000, low, 1.025, colors='r', linestyle='--', alpha=0.5)\n",
Expand Down Expand Up @@ -616,7 +599,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"mod.n_fit_parameters"
Expand All @@ -625,7 +610,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"mod._all_detrend_params"
Expand All @@ -634,7 +621,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"def evaluate_fits(mod):\n",
Expand All @@ -660,7 +649,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"bic_table = evaluate_fits(mod)\n",
Expand Down Expand Up @@ -692,7 +683,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.6"
"version": "3.11.5"
}
},
"nbformat": 4,
Expand Down

0 comments on commit 18e1a00

Please sign in to comment.