Skip to content

Commit

Permalink
Working notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
mwcraig committed Oct 10, 2024
1 parent 531b3c9 commit bedd21a
Showing 1 changed file with 100 additions and 21 deletions.
121 changes: 100 additions & 21 deletions stellarphot/notebooks/photometry/04-transform-pared-back.ipynb
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@
"import matplotlib.pyplot as plt\n",
"\n",
"from stellarphot.utils.magnitude_transforms import (\n",
" f,\n",
" calibrated_from_instrumental,\n",
" opts_to_str,\n",
" calc_residual,\n",
" transform_to_catalog,\n",
")"
")\n",
"\n",
"from stellarphot import PhotometryData, vsx_vizier"
]
},
{
Expand Down Expand Up @@ -74,29 +76,49 @@
"c_min = -0.5\n",
"d_min = -1e-6\n",
"\n",
"our_filters = [\"SI\"]\n",
"our_filters = [\"SR\"]\n",
"\n",
"aavso_band_names = dict(B=\"B\", V=\"V\", gp=\"SG\", rp=\"SR\", ip=\"SI\", SI=\"SI\", SR=\"SR\")\n",
"\n",
"aavso_band_names = dict(B=\"B\", V=\"V\", gp=\"SG\", rp=\"SR\", ip=\"SI\", SI=\"SI\")\n",
"# cat_color_colums = dict(\n",
"# B=(\"Bmag\", \"Vmag\"),\n",
"# V=(\"Bmag\", \"Vmag\"),\n",
"# gp=(\"g_mag\", \"r_mag\"),\n",
"# rp=(\"r_mag\", \"i_mag\"),\n",
"# ip=(\"r_mag\", \"i_mag\"),\n",
"# SI=(\"r_mag\", \"i_mag\"),\n",
"# )\n",
"\n",
"cat_color_colums = dict(\n",
" B=(\"Bmag\", \"Vmag\"),\n",
" V=(\"Bmag\", \"Vmag\"),\n",
" gp=(\"g_mag\", \"r_mag\"),\n",
" rp=(\"r_mag\", \"i_mag\"),\n",
" ip=(\"r_mag\", \"i_mag\"),\n",
" SI=(\"r_mag\", \"i_mag\"),\n",
" B=(\"mag_B\", \"mag_V\"),\n",
" V=(\"mag_B\", \"mag_V\"),\n",
" gp=(\"mag_SG\", \"mag_SR\"),\n",
" rp=(\"mag_SR\", \"mag_SI\"),\n",
" SR=(\"SR\", \"SI\"),\n",
" ip=(\"mag_SR\", \"mag_SI\"),\n",
" SI=(\"mag_SR\", \"mag_SI\"),\n",
")\n",
"\n",
"# cat_filter = dict(\n",
"# B=\"Bmag\",\n",
"# V=\"Vmag\",\n",
"# gp=\"g_mag\",\n",
"# rp=\"r_mag\",\n",
"# ip=\"i_mag\",\n",
"# SI=\"i_mag\",\n",
"# )\n",
"\n",
"cat_filter = dict(\n",
" B=\"Bmag\",\n",
" V=\"Vmag\",\n",
" gp=\"g_mag\",\n",
" rp=\"r_mag\",\n",
" ip=\"i_mag\",\n",
" SI=\"i_mag\",\n",
" B=\"B\",\n",
" V=\"mag_V\",\n",
" gp=\"mag_SG\",\n",
" rp=\"mag_SR\",\n",
" SR=\"SR\",\n",
" ip=\"mag_SI\",\n",
" SI=\"mag_SI\",\n",
")\n",
"\n",
"input_photometry_file = \"TIC-402828941-2021-09-28.ecsv\"\n",
"input_photometry_file = \"sp2-kelt-1b-photometry-2021-09-14.ecsv\"\n",
"output_photometry_file = \"some_name.ecsv\""
]
},
Expand All @@ -108,7 +130,11 @@
},
"outputs": [],
"source": [
"all_mags = Table.read(input_photometry_file)\n",
"all_mags = PhotometryData.read(input_photometry_file)\n",
"\n",
"# BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD\n",
"all_mags[\"passband\"] = \"SR\"\n",
"\n",
"\n",
"# Ensure we have the right table ordering later\n",
"all_mags.sort([\"passband\", \"bjd\"])"
Expand Down Expand Up @@ -137,6 +163,15 @@
"assert all(k[0] in cat_filter.keys() for k in filter_groups.groups.keys)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"filter_groups.groups.keys"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand All @@ -148,6 +183,7 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": true,
"tags": []
},
"outputs": [],
Expand All @@ -156,7 +192,7 @@
"\n",
"for k, group in zip(our_filters, filter_groups.groups):\n",
" print(f\"Transforming band {k}\")\n",
" by_bjd = group.group_by(\"bjd\")\n",
" by_bjd = group.group_by(\"file\")\n",
"\n",
" transform_to_catalog(\n",
" by_bjd,\n",
Expand Down Expand Up @@ -190,7 +226,32 @@
"metadata": {},
"outputs": [],
"source": [
"plt.plot(by_bjd[\"mag_cat\"] - by_bjd[\"mag_inst_cal\"], \"o\")\n",
"plt.plot(by_bjd[\"mag_cat\"], by_bjd[\"mag_cat\"] - by_bjd[\"mag_inst_cal\"], \"o\")\n",
"plt.ylim(-0.05, 0.05)\n",
"plt.grid()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"plt.figure()\n",
"kelt1 = by_bjd.lightcurve_for(\"kelt-1\", flux_column=\"mag_inst_cal\") # by_bjd[\"star_id\"] == 1\n",
"plt.plot(kelt1.time.jd, kelt1.flux, \".\")\n",
"plt.ylim(reversed(plt.ylim()))\n",
"plt.grid()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"plt.figure()\n",
"plt.plot(kelt1.time.value, kelt1[\"z\"], \".\")\n",
"plt.grid()"
]
},
Expand All @@ -203,6 +264,24 @@
"output_table.write(output_photometry_file)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"by_bjd.colnames"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"by_bjd['id']"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -227,7 +306,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.5"
"version": "3.11.9"
}
},
"nbformat": 4,
Expand Down

0 comments on commit bedd21a

Please sign in to comment.