{ "cells": [ { "cell_type": "markdown", "id": "986421ef-f460-416f-a30e-99bfe5377c68", "metadata": {}, "source": [ "## Compare metadetect catalog types\n", "\n", "This is a simple script to measure the match efficiency between different metadectect shear catalogs" ] }, { "cell_type": "markdown", "id": "0a0d82a6-62a3-411d-bea8-3dc7ca19f763", "metadata": {}, "source": [ "#### Standard imports" ] }, { "cell_type": "code", "execution_count": null, "id": "8e5633bc-cfde-4a82-9501-5da113eeb2f5", "metadata": {}, "outputs": [], "source": [ "import hpmcm\n", "import glob\n", "import os\n", "import numpy as np" ] }, { "cell_type": "markdown", "id": "d91c8fdb-de5d-4e58-a261-94e9978cba58", "metadata": {}, "source": [ "#### Set up the configuration" ] }, { "cell_type": "code", "execution_count": null, "id": "02ae089e-f779-4070-af62-97f9e2c7b876", "metadata": {}, "outputs": [], "source": [ "DATADIR = \"test_data\" # Input data directory\n", "shear_st = \"0p01\" # Applied shear as a string\n", "shear = 0.01 # Decimal version of applied shear\n", "shear_type = \"wmom\" # which object characterization to use \n", "tract = 10463 # which tract to study\n", "\n", "SOURCE_TABLEFILES = sorted(glob.glob(os.path.join(DATADIR, f\"shear_{shear_type}_{shear_st}_uncleaned_{tract}_*.pq\")))\n", "SOURCE_TABLEFILES.reverse()\n", "VISIT_IDS = np.arange(len(SOURCE_TABLEFILES))\n", "\n", "PIXEL_R2CUT = 4. # Cut at distance**2 = 4 pixels\n", "PIXEL_MATCH_SCALE = 1 # Use pixel scale to do matching" ] }, { "cell_type": "markdown", "id": "1c3004f6-2c3c-4b82-b021-baa2271a30c0", "metadata": {}, "source": [ "#### Make the matcher, reduce the data" ] }, { "cell_type": "code", "execution_count": null, "id": "0c5e34c0-17cd-493d-a76e-3a17a41046f2", "metadata": {}, "outputs": [], "source": [ "matcher = hpmcm.ShearMatch.createShearMatch(pixel_r2_cut=PIXEL_R2CUT, pixel_match_scale=PIXEL_MATCH_SCALE)\n", "matcher.reduceData(SOURCE_TABLEFILES, VISIT_IDS)" ] }, { "cell_type": "markdown", "id": "df1f0291-6f6d-45c2-bd9c-16fcc9daf84b", "metadata": {}, "source": [ "#### Run the data\n", "\n", "Note the option to run all the cells. By default we only run a small subset for testing" ] }, { "cell_type": "code", "execution_count": null, "id": "18c03bad-473f-40af-86a1-4732ec7e5755", "metadata": {}, "outputs": [], "source": [ "do_partial = True\n", "if do_partial:\n", " x_range = range(50, 70)\n", " y_range = range(170, 190)\n", " matcher.analysisLoop(x_range, y_range)\n", "else:\n", " matcher.analysisLoop()" ] }, { "cell_type": "markdown", "id": "50776edd-185b-42b3-bf9d-f548ad42fbb1", "metadata": {}, "source": [ "#### Classify the objects by match type\n", "\n", "This looks at the characteristics of the matched objects and categorizes them." ] }, { "cell_type": "code", "execution_count": null, "id": "3d8f6046-ab29-4bd4-9fa1-5c7680dee150", "metadata": {}, "outputs": [], "source": [ "obj_lists = hpmcm.classify.classifyObjects(matcher)\n", "hpmcm.classify.printObjectTypes(obj_lists)" ] }, { "cell_type": "code", "execution_count": null, "id": "2d401578-ae4f-4ed8-9c37-bb34cb28cf21", "metadata": {}, "outputs": [], "source": [ "n_good = len(obj_lists['ideal'])\n", "bad_list = ['edge_mixed', 'edge_missing', 'edge_extra', 'orphan', 'missing', 'two_missing', 'many_missing', 'extra', 'caught']\n", "n_bad = np.sum([len(obj_lists[x]) for x in bad_list])" ] }, { "cell_type": "code", "execution_count": null, "id": "37417087-9be8-4652-9da0-47f4d6187d9d", "metadata": {}, "outputs": [], "source": [ "n_good/(n_good+n_bad)" ] }, { "cell_type": "code", "execution_count": null, "id": "e2d0eeec-4ea9-42eb-a96c-e3bebccd762b", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "id": "6e8857e9-ba17-4c2a-8c9f-a177a7457f81", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.12.12" } }, "nbformat": 4, "nbformat_minor": 5 }