{ "cells": [ { "cell_type": "markdown", "id": "7b1ad98d", "metadata": {}, "source": [ "# wcc-phot: differential photometry of a WCC image series\n", "\n", "Tutorial for **wcc_phot**, the photometry sibling of `wcc_sim`: it takes a series of\n", "simulated WCC frames of the same field, picks a **target** plus the **N best reference\n", "stars** (unsaturated, isolated, away from edges, closest in G to the target),\n", "**re-centroids every star in every frame** from its WCS-predicted position, and builds a\n", "differential (relative) light curve — with either **aperture** or **PSF-fit** fluxes.\n", "\n", "**Requirements:** run with the `py313` conda env kernel. The Gaia queries are cached in\n", "`gaia_cache/`, so after the first run this notebook works offline." ] }, { "cell_type": "code", "execution_count": 1, "id": "e2bb13e0", "metadata": { "execution": { "iopub.execute_input": "2026-07-03T00:10:23.692801Z", "iopub.status.busy": "2026-07-03T00:10:23.692465Z", "iopub.status.idle": "2026-07-03T00:10:27.221008Z", "shell.execute_reply": "2026-07-03T00:10:27.220708Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "wcc_sim 0.1.0 | wcc_phot 0.1.0\n" ] } ], "source": [ "import numpy as np\n", "import matplotlib.pyplot as plt\n", "\n", "import wcc_sim\n", "import wcc_phot\n", "from wcc_sim import simulate_field\n", "from wcc_phot import run_photometry\n", "\n", "plt.style.use('gks')\n", "TEAL, RED, AMBER = '#00798c', '#d1495b', '#edae49'\n", "\n", "print(f'wcc_sim {wcc_sim.__version__} | wcc_phot {wcc_phot.__version__}')" ] }, { "cell_type": "markdown", "id": "0f1fa3a6", "metadata": {}, "source": [ "## 1. Simulate a dithered series\n", "\n", "Five 90 s exposures of the same Kepler-field pointing as notebook 01, on a 4096×4096\n", "subarray (≈ 69″ × 69″), with sub-pixel pointing offsets between frames — the kind of\n", "drift the per-frame centroiding is there to follow. `run_photometry` accepts the\n", "`SimulatedField` objects directly (FITS paths work the same way)." ] }, { "cell_type": "code", "execution_count": 2, "id": "c9addc1d", "metadata": { "execution": { "iopub.execute_input": "2026-07-03T00:10:27.222652Z", "iopub.status.busy": "2026-07-03T00:10:27.222453Z", "iopub.status.idle": "2026-07-03T00:10:40.824723Z", "shell.execute_reply": "2026-07-03T00:10:40.824325Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "5 frames, 32 Gaia sources each\n" ] } ], "source": [ "RA0, DEC0 = 291.0, 44.5 # deg, ICRS (Kepler field)\n", "EXPTIME = 90.0 # s\n", "PIX_DEG = 16.87e-3 / 3600.0 # one IMX455 pixel in degrees\n", "\n", "dithers_px = [(0.0, 0.0), (0.4, -0.2), (-0.3, 0.3), (0.1, 0.5), (-0.5, -0.1)]\n", "frames = []\n", "for k, (dx, dy) in enumerate(dithers_px):\n", " frames.append(simulate_field(\n", " ra=RA0 + dx * PIX_DEG, dec=DEC0 + dy * PIX_DEG,\n", " sensorfilter='zwo:r', focus=0, exptime=EXPTIME, seed=42 + k,\n", " shape=(4096, 4096), cache_dir='gaia_cache',\n", " ))\n", "print(f\"{len(frames)} frames, {frames[0].params['n_sources']} Gaia sources each\")" ] }, { "cell_type": "markdown", "id": "ff1315b4", "metadata": {}, "source": [ "## 2. Pick a target and run aperture photometry\n", "\n", "The IMX455 effective full well is only ~16 ke⁻ and the in-focus PSF puts ~8% of the flux\n", "in the peak pixel, so at 90 s any star brighter than G ≈ 18.2 saturates — we take the\n", "unsaturated star closest to G = 18.5. `run_photometry` asks for the 10 best references;\n", "in this sparse subfield only 7 survive the cuts, so it warns and continues. The default\n", "aperture radius is the 95% encircled-energy radius of the wcc-sim PSF model for this\n", "sensorfilter/focus/jitter, with the background annulus at 1.5–2.5 × r_ap." ] }, { "cell_type": "code", "execution_count": 3, "id": "28684c59", "metadata": { "execution": { "iopub.execute_input": "2026-07-03T00:10:40.826854Z", "iopub.status.busy": "2026-07-03T00:10:40.826756Z", "iopub.status.idle": "2026-07-03T00:10:41.901920Z", "shell.execute_reply": "2026-07-03T00:10:41.901669Z" } }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/Users/gudmundurstefansson/Dropbox/mypylib/notebooks/GIT/wcc-sim/src/wcc_phot/select.py:74: UserWarning: only 7 of 10 requested reference stars usable\n", " warnings.warn(\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "target 2126245824998773888: r_ap=9.0 px (model EE=0.950), annulus 13.5-22.5 px, 7 refs\n" ] }, { "data": { "text/html": [ "
| star | role | source_id | ra | dec | gmag |
|---|---|---|---|---|---|
| int64 | str6 | int64 | float64 | float64 | float64 |
| 0 | target | 2126245824998773888 | 290.9890463714144 | 44.49648012727523 | 18.62946128845215 |
| 1 | ref | 2126245790639056384 | 291.0028161167172 | 44.50461676375653 | 18.82853126525879 |
| 2 | ref | 2126245829297362176 | 290.98798994029636 | 44.50020075913573 | 19.419755935668945 |
| 3 | ref | 2126245756279295232 | 290.99211840952046 | 44.49629665426356 | 19.473852157592773 |
| 4 | ref | 2126245790639029504 | 291.0104300591018 | 44.49512296717736 | 19.576889038085938 |
| 5 | ref | 2126245794938018816 | 290.9966134142337 | 44.49911131045152 | 19.74286651611328 |
| 6 | ref | 2126245790639020032 | 291.0062397545951 | 44.49149253211353 | 20.31865119934082 |
| 7 | ref | 2126245898018198144 | 291.00928413138956 | 44.50399266810741 | 20.342300415039062 |