From 1f97191581b6f598ee5e829fb10a351eab4dbeed Mon Sep 17 00:00:00 2001 From: Tianqing Zhang Date: Tue, 3 Dec 2024 10:35:37 -0500 Subject: [PATCH 1/3] specify ref_band and redshift_col --- examples/creation_examples/blending_degrader_demo.ipynb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/creation_examples/blending_degrader_demo.ipynb b/examples/creation_examples/blending_degrader_demo.ipynb index cfbb612..d493f35 100644 --- a/examples/creation_examples/blending_degrader_demo.ipynb +++ b/examples/creation_examples/blending_degrader_demo.ipynb @@ -106,7 +106,7 @@ "## model configuration; linking length is in arcsecs\n", "\n", "blModel = UnrecBlModel.make_stage(name='unrec_bl_model', ra_label='ra', dec_label='dec', linking_lengths=1.0, \\\n", - " bands='ugrizy')\n", + " bands='ugrizy', ref_band = 'i', redshift_col = 'z')\n", "blModel.get_config_dict()\n" ] }, @@ -275,7 +275,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.12.3" + "version": "3.11.4" } }, "nbformat": 4, From f22518a672099a6a011ea2155fbf46ef6c1dedc9 Mon Sep 17 00:00:00 2001 From: shuang92 Date: Fri, 6 Dec 2024 16:17:06 -0800 Subject: [PATCH 2/3] add weighted redshift --- .../blending_degrader_demo.ipynb | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/examples/creation_examples/blending_degrader_demo.ipynb b/examples/creation_examples/blending_degrader_demo.ipynb index d493f35..b9496c7 100644 --- a/examples/creation_examples/blending_degrader_demo.ipynb +++ b/examples/creation_examples/blending_degrader_demo.ipynb @@ -54,12 +54,13 @@ "metadata": {}, "outputs": [], "source": [ - "data = np.random.normal(23, 3, size = (1000,12))\n", + "data = np.random.normal(24, 3, size = (1000,13))\n", "data[:, 0] = np.random.uniform(low=0, high=0.03, size=1000)\n", "data[:, 1] = np.random.uniform(low=0, high=0.03, size=1000)\n", + "data[:, 2] = np.random.uniform(low=0, high=2, size=1000)\n", "\n", "data_df = pd.DataFrame(data=data, # values\n", - " columns=['ra', 'dec', 'u', 'g', 'r', 'i', 'z', 'y', 'Y', 'J', 'H', 'F'])\n", + " columns=['ra', 'dec', 'z_true', 'u', 'g', 'r', 'i', 'z', 'y', 'Y', 'J', 'H', 'F'])\n", "\n", "data_truth_handle = DS.add_data('input', data_df, PqHandle)\n", "data_truth = data_truth_handle.data" @@ -106,7 +107,7 @@ "## model configuration; linking length is in arcsecs\n", "\n", "blModel = UnrecBlModel.make_stage(name='unrec_bl_model', ra_label='ra', dec_label='dec', linking_lengths=1.0, \\\n", - " bands='ugrizy', ref_band = 'i', redshift_col = 'z')\n", + " bands='ugrizy', ref_band = 'i', redshift_col = 'z_true')\n", "blModel.get_config_dict()\n" ] }, @@ -151,7 +152,7 @@ "metadata": {}, "outputs": [], "source": [ - "b = 'r'\n", + "b = 'i'\n", "plt.hist(data_truth[b], bins=np.linspace(10, 30, 20), label='Original')\n", "plt.hist(samples_w_bl[b], bins=np.linspace(10, 30, 20), fill=False, label='w. Unrec-BL')\n", "\n", @@ -163,18 +164,15 @@ { "cell_type": "code", "execution_count": null, - "id": "a1d51c15-1e04-4b22-9abb-9b267965dbeb", + "id": "51d759a6-2d27-42d6-896e-098059a25ffe", "metadata": {}, "outputs": [], "source": [ - "flux = 10**(-(data_truth[b]-28.10)/2.5) # r band zp for lsst is 28.10\n", - "flux_bl = 10**(-(samples_w_bl[b]-28.10)/2.5)\n", "\n", - "plt.hist(flux, bins=np.linspace(0, 10000, 40), label='Original')\n", - "plt.hist(flux_bl, bins=np.linspace(0, 10000, 40), fill=False, label='w. Unrec-BL')\n", + "plt.hist(data_truth['z_true'], bins=20, label='True Redshift')\n", + "plt.hist(samples_w_bl['z_weighted'], bins=20, fill=False, label='Weighted Mean')\n", "\n", - "plt.xlabel(fr'Flux ${b}$', fontsize=14)\n", - "plt.yscale('log')\n", + "plt.xlabel(fr'Rdshift', fontsize=14)\n", "plt.legend(fontsize=12)\n", "plt.show()\n" ] @@ -202,8 +200,9 @@ " rand_ind = np.random.randint(len(samples_w_bl))\n", " this_bl = samples_w_bl.iloc[rand_ind]\n", " group_id = this_bl['group_id']\n", - " \n", - " FoF_group = component_ind.query(f\"group_id == {group_id}\")\n", + "\n", + " mask = (component_ind['group_id'] == group_id)\n", + " FoF_group = component_ind[mask]\n", " group_size = len(FoF_group)\n", "\n", "truth_comp = data_truth.iloc[FoF_group.index]\n", @@ -275,7 +274,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.4" + "version": "3.12.3" } }, "nbformat": 4, From b3f65d5a5014108793427ec39751733c7868f6c5 Mon Sep 17 00:00:00 2001 From: shuang92 Date: Fri, 6 Dec 2024 16:37:47 -0800 Subject: [PATCH 3/3] add flex mag zp --- examples/creation_examples/blending_degrader_demo.ipynb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/creation_examples/blending_degrader_demo.ipynb b/examples/creation_examples/blending_degrader_demo.ipynb index b9496c7..2da3d47 100644 --- a/examples/creation_examples/blending_degrader_demo.ipynb +++ b/examples/creation_examples/blending_degrader_demo.ipynb @@ -106,8 +106,10 @@ "source": [ "## model configuration; linking length is in arcsecs\n", "\n", + "lsst_zp_dict = {'u':12.65, 'g':14.69, 'r':14.56, 'i': 14.38, 'z':13.99, 'y': 13.02}\n", "blModel = UnrecBlModel.make_stage(name='unrec_bl_model', ra_label='ra', dec_label='dec', linking_lengths=1.0, \\\n", - " bands='ugrizy', ref_band = 'i', redshift_col = 'z_true')\n", + " bands='ugrizy', zp_dict=lsst_zp_dict, \n", + " ref_band = 'i', redshift_col = 'z_true')\n", "blModel.get_config_dict()\n" ] },