From bedd21a215a4d96632e62dffd96ae8d68d88e4a2 Mon Sep 17 00:00:00 2001 From: Matt Craig Date: Thu, 10 Oct 2024 14:31:08 -0500 Subject: [PATCH] Working notebook --- .../photometry/04-transform-pared-back.ipynb | 121 +++++++++++++++--- 1 file changed, 100 insertions(+), 21 deletions(-) mode change 100755 => 100644 stellarphot/notebooks/photometry/04-transform-pared-back.ipynb diff --git a/stellarphot/notebooks/photometry/04-transform-pared-back.ipynb b/stellarphot/notebooks/photometry/04-transform-pared-back.ipynb old mode 100755 new mode 100644 index fef0dbd7..a847b467 --- a/stellarphot/notebooks/photometry/04-transform-pared-back.ipynb +++ b/stellarphot/notebooks/photometry/04-transform-pared-back.ipynb @@ -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" ] }, { @@ -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\"" ] }, @@ -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\"])" @@ -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": {}, @@ -148,6 +183,7 @@ "cell_type": "code", "execution_count": null, "metadata": { + "scrolled": true, "tags": [] }, "outputs": [], @@ -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", @@ -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()" ] }, @@ -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, @@ -227,7 +306,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.5" + "version": "3.11.9" } }, "nbformat": 4,