{ "cells": [ { "cell_type": "markdown", "id": "49c044a8-e659-4f0e-b8e7-fb907832d58f", "metadata": { "execution": { "iopub.execute_input": "2024-03-30T20:37:41.641952Z", "iopub.status.busy": "2024-03-30T20:37:41.641750Z", "iopub.status.idle": "2024-03-30T20:37:41.644172Z", "shell.execute_reply": "2024-03-30T20:37:41.643810Z", "shell.execute_reply.started": "2024-03-30T20:37:41.641939Z" } }, "source": [ "# Same fields as RubinTV has now for visitSummary table with multiple detectors\n", "\n", "\n", "Uses np.mean to average all the detectors. I could envision a median, scatter, max, min etc... too" ] }, { "cell_type": "code", "execution_count": 1, "id": "d25fa525-156b-42b7-9aa3-2d58bb2f31ca", "metadata": { "execution": { "iopub.execute_input": "2024-03-30T20:39:41.621046Z", "iopub.status.busy": "2024-03-30T20:39:41.620925Z", "iopub.status.idle": "2024-03-30T20:39:42.316145Z", "shell.execute_reply": "2024-03-30T20:39:42.315717Z", "shell.execute_reply.started": "2024-03-30T20:39:41.621033Z" } }, "outputs": [], "source": [ "from lsst.daf.butler import Butler\n", "import numpy as np" ] }, { "cell_type": "code", "execution_count": 2, "id": "2fa70307-4847-4e0c-95eb-166319713e5d", "metadata": { "execution": { "iopub.execute_input": "2024-03-30T20:39:42.316802Z", "iopub.status.busy": "2024-03-30T20:39:42.316664Z", "iopub.status.idle": "2024-03-30T20:39:42.627985Z", "shell.execute_reply": "2024-03-30T20:39:42.627555Z", "shell.execute_reply.started": "2024-03-30T20:39:42.316785Z" } }, "outputs": [], "source": [ "butler = Butler(\"/repo/ops-rehearsal-3-prep\", collections=\"u/homer/w_2024_12/DM-43439\")" ] }, { "cell_type": "code", "execution_count": 3, "id": "2c8e2672-7069-451a-811b-8a75b3d06519", "metadata": { "execution": { "iopub.execute_input": "2024-03-30T20:39:42.629258Z", "iopub.status.busy": "2024-03-30T20:39:42.629114Z", "iopub.status.idle": "2024-03-30T20:39:43.296057Z", "shell.execute_reply": "2024-03-30T20:39:43.295594Z", "shell.execute_reply.started": "2024-03-30T20:39:42.629244Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "{'PSF FWHM': 0.7175983664776634, 'PSF e1': 0.017793722, 'PSF e2': -0.019374542, 'Sky mean': 1772.0314, 'Sky RMS': 35.578793, 'Variance plane mean': 1177.3418, 'PSF star count': 1751.0, 'Astrometric bias': 0.009375281, 'Astrometric scatter': 0.004797545, 'Zeropoint': 31.10168, 'effTime': 18.510962, 'effTimePsfSigmaScale': 0.43105182, 'effTimeSkyBgScale': 0.016930519, 'effTimeZeroPointScale': 84.55661, '_PSF FWHM': 'measured', '_PSF e1': 'measured', '_PSF e2': 'measured', '_Sky mean': 'measured', '_Sky RMS': 'measured', '_Variance plane mean': 'measured', '_PSF star count': 'measured', '_Astrometric bias': 'measured', '_Astrometric scatter': 'measured', '_Zeropoint': 'measured', '_effTime': 'measured', '_effTimePsfSigmaScale': 'measured', '_effTimeSkyBgScale': 'measured', '_effTimeZeroPointScale': 'measured'}\n" ] } ], "source": [ "vs = butler.get(\"visitSummary\", visit=7024040200866, instrument=\"LSSTComCamSim\")\n", "\n", "pixToArcseconds = np.mean([row.wcs.getPixelScale().asArcseconds() for row in vs]) \n", "SIGMA2FWHM = np.sqrt(8 * np.log(2))\n", "\n", "e1 = (vs[\"psfIxx\"] - vs[\"psfIyy\"]) / (vs[\"psfIxx\"] + vs[\"psfIyy\"])\n", "e2 = 2*vs[\"psfIxy\"] / (vs[\"psfIxx\"] + vs[\"psfIyy\"])\n", "\n", "outputDict = {\n", " # '5-sigma source count': len(calibrateRes.outputCat),\n", " 'PSF FWHM': np.mean(vs[\"psfSigma\"]) * SIGMA2FWHM * pixToArcseconds,\n", " 'PSF e1': np.mean(e1),\n", " 'PSF e2': np.mean(e2),\n", " 'Sky mean': np.mean(vs[\"skyBg\"]),\n", " 'Sky RMS': np.mean(vs[\"skyNoise\"]),\n", " 'Variance plane mean': np.mean(vs[\"meanVar\"]),\n", " 'PSF star count': np.mean(vs[\"nPsfStar\"]),\n", " 'Astrometric bias': np.mean(vs[\"astromOffsetMean\"]),\n", " 'Astrometric scatter': np.mean(vs[\"astromOffsetStd\"]),\n", " 'Zeropoint': np.mean(vs[\"zeroPoint\"]),\n", " \"effTime\": np.mean(vs[\"effTime\"]), # these are new, I don't know if they're useful \n", " \"effTimePsfSigmaScale\": np.mean(vs[\"effTimePsfSigmaScale\"]), # these are new, I don't know if they're useful.\n", " \"effTimeSkyBgScale\": np.mean(vs[\"effTimeSkyBgScale\"]), # these are new, I don't know if they're useful.\n", " \"effTimeZeroPointScale\": np.mean(vs[\"effTimeZeroPointScale\"]), # these are new, I don't know if they're useful.\n", "}\n", "\n", "# flag all these as measured items to color the cell\n", "labels = {\"_\" + k: \"measured\" for k in outputDict.keys()}\n", "outputDict.update(labels)\n", "print(outputDict)" ] }, { "cell_type": "code", "execution_count": 4, "id": "e6ab8e47-5c8e-4ae5-833f-46fada2c248e", "metadata": { "execution": { "iopub.execute_input": "2024-03-30T20:39:43.296736Z", "iopub.status.busy": "2024-03-30T20:39:43.296601Z", "iopub.status.idle": "2024-03-30T20:39:43.299661Z", "shell.execute_reply": "2024-03-30T20:39:43.299336Z", "shell.execute_reply.started": "2024-03-30T20:39:43.296722Z" } }, "outputs": [ { "data": { "text/plain": [ "Schema(\n", " (Field['L'](name=\"id\", doc=\"unique ID\"), Key(offset=0, nElements=1)),\n", " (Field['I'](name=\"bbox_min_x\", doc=\"bounding box (minimum)\", units=\"pixel\"), Key(offset=8, nElements=1)),\n", " (Field['I'](name=\"bbox_min_y\", doc=\"bounding box (minimum)\", units=\"pixel\"), Key(offset=12, nElements=1)),\n", " (Field['I'](name=\"bbox_max_x\", doc=\"bounding box (maximum)\", units=\"pixel\"), Key(offset=16, nElements=1)),\n", " (Field['I'](name=\"bbox_max_y\", doc=\"bounding box (maximum)\", units=\"pixel\"), Key(offset=20, nElements=1)),\n", " (Field['L'](name=\"visit\", doc=\"Visit number\"), Key(offset=24, nElements=1)),\n", " (Field['String'](name=\"physical_filter\", doc=\"Physical filter\", size=32), Key(offset=32, nElements=32)),\n", " (Field['String'](name=\"band\", doc=\"Name of band\", size=32), Key(offset=64, nElements=32)),\n", " (Field['F'](name=\"psfSigma\", doc=\"PSF model second-moments determinant radius (center of chip) (pixel)\", units=\"pixel\"), Key(offset=96, nElements=1)),\n", " (Field['F'](name=\"psfArea\", doc=\"PSF model effective area (center of chip) (pixel**2)\", units=\"pixel**2\"), Key(offset=100, nElements=1)),\n", " (Field['F'](name=\"psfIxx\", doc=\"PSF model Ixx (center of chip) (pixel**2)\", units=\"pixel**2\"), Key(offset=104, nElements=1)),\n", " (Field['F'](name=\"psfIyy\", doc=\"PSF model Iyy (center of chip) (pixel**2)\", units=\"pixel**2\"), Key(offset=108, nElements=1)),\n", " (Field['F'](name=\"psfIxy\", doc=\"PSF model Ixy (center of chip) (pixel**2)\", units=\"pixel**2\"), Key(offset=112, nElements=1)),\n", " (Field['ArrayD'](name=\"raCorners\", doc=\"Right Ascension of bounding box corners (degrees)\", units=\"degree\", size=4), Key(offset=120, nElements=4)),\n", " (Field['ArrayD'](name=\"decCorners\", doc=\"Declination of bounding box corners (degrees)\", units=\"degree\", size=4), Key(offset=152, nElements=4)),\n", " (Field['D'](name=\"ra\", doc=\"Right Ascension of bounding box center (degrees)\", units=\"degree\"), Key(offset=184, nElements=1)),\n", " (Field['D'](name=\"dec\", doc=\"Declination of bounding box center (degrees)\", units=\"degree\"), Key(offset=192, nElements=1)),\n", " (Field['F'](name=\"zenithDistance\", doc=\"Zenith distance of bounding box center (degrees)\", units=\"degree\"), Key(offset=200, nElements=1)),\n", " (Field['F'](name=\"zeroPoint\", doc=\"Mean zeropoint in detector (mag)\", units=\"mag\"), Key(offset=204, nElements=1)),\n", " (Field['F'](name=\"skyBg\", doc=\"Average sky background (ADU)\", units=\"adu\"), Key(offset=208, nElements=1)),\n", " (Field['F'](name=\"skyNoise\", doc=\"Average sky noise (ADU)\", units=\"adu\"), Key(offset=212, nElements=1)),\n", " (Field['F'](name=\"meanVar\", doc=\"Mean variance of the weight plane (ADU**2)\", units=\"adu**2\"), Key(offset=216, nElements=1)),\n", " (Field['F'](name=\"astromOffsetMean\", doc=\"Mean offset of astrometric calibration matches (arcsec)\", units=\"arcsec\"), Key(offset=220, nElements=1)),\n", " (Field['F'](name=\"astromOffsetStd\", doc=\"Standard deviation of offsets of astrometric calibration matches (arcsec)\", units=\"arcsec\"), Key(offset=224, nElements=1)),\n", " (Field['I'](name=\"nPsfStar\", doc=\"Number of stars used for PSF model\"), Key(offset=228, nElements=1)),\n", " (Field['F'](name=\"psfStarDeltaE1Median\", doc=\"Median E1 residual (starE1 - psfE1) for psf stars\"), Key(offset=232, nElements=1)),\n", " (Field['F'](name=\"psfStarDeltaE2Median\", doc=\"Median E2 residual (starE2 - psfE2) for psf stars\"), Key(offset=236, nElements=1)),\n", " (Field['F'](name=\"psfStarDeltaE1Scatter\", doc=\"Scatter (via MAD) of E1 residual (starE1 - psfE1) for psf stars\"), Key(offset=240, nElements=1)),\n", " (Field['F'](name=\"psfStarDeltaE2Scatter\", doc=\"Scatter (via MAD) of E2 residual (starE2 - psfE2) for psf stars\"), Key(offset=244, nElements=1)),\n", " (Field['F'](name=\"psfStarDeltaSizeMedian\", doc=\"Median size residual (starSize - psfSize) for psf stars (pixel)\", units=\"pixel\"), Key(offset=248, nElements=1)),\n", " (Field['F'](name=\"psfStarDeltaSizeScatter\", doc=\"Scatter (via MAD) of size residual (starSize - psfSize) for psf stars (pixel)\", units=\"pixel\"), Key(offset=252, nElements=1)),\n", " (Field['F'](name=\"psfStarScaledDeltaSizeScatter\", doc=\"Scatter (via MAD) of size residual scaled by median size squared\"), Key(offset=256, nElements=1)),\n", " (Field['F'](name=\"psfTraceRadiusDelta\", doc=\"Delta (max - min) of the model psf trace radius values evaluated on a grid of unmasked pixels (pixel).\", units=\"pixel\"), Key(offset=260, nElements=1)),\n", " (Field['F'](name=\"maxDistToNearestPsf\", doc=\"Maximum distance of an unmasked pixel to its nearest model psf star (pixel).\", units=\"pixel\"), Key(offset=264, nElements=1)),\n", " (Field['F'](name=\"effTime\", doc=\"Effective exposure time calculated from psfSigma, skyBg, and zeroPoint (seconds).\", units=\"second\"), Key(offset=268, nElements=1)),\n", " (Field['F'](name=\"effTimePsfSigmaScale\", doc=\"PSF scaling of the effective exposure time.\"), Key(offset=272, nElements=1)),\n", " (Field['F'](name=\"effTimeSkyBgScale\", doc=\"Sky background scaling of the effective exposure time.\"), Key(offset=276, nElements=1)),\n", " (Field['F'](name=\"effTimeZeroPointScale\", doc=\"Zeropoint scaling of the effective exposure time.\"), Key(offset=280, nElements=1)),\n", ")" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# for the doc strings\n", "vs.schema" ] }, { "cell_type": "code", "execution_count": 7, "id": "2bb610db-71fe-4e6f-8f5e-359b947851b9", "metadata": { "execution": { "iopub.execute_input": "2024-03-30T20:40:05.749231Z", "iopub.status.busy": "2024-03-30T20:40:05.748857Z", "iopub.status.idle": "2024-03-30T20:40:05.752381Z", "shell.execute_reply": "2024-03-30T20:40:05.752006Z", "shell.execute_reply.started": "2024-03-30T20:40:05.749214Z" } }, "outputs": [ { "data": { "text/plain": [ "VisitInfo(exposureTime=30, darkTime=30, date=2024-04-02T09:31:25.985098591, UT1=nan, ERA=5.8227 rad, boresightRaDec=(279.8870548486, -47.8262337699), boresightAzAlt=(nan, +nan), boresightAirmass=1.0764, boresightRotAngle=4.11588 rad, rotType=1, observatory=-30.2446N, -70.7494E 2663, weather=Weather(nan, nan, nan), instrumentLabel='LSSTComCamSim', id=7024040200866, focusZ=0, observationType='science', scienceProgram='12217', observationReason='survey', object='UNKNOWN', hasSimulatedContent=false)" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# we also have:\n", "vs.find(0).getVisitInfo()" ] }, { "cell_type": "code", "execution_count": null, "id": "4794a0c6-2a62-4aba-9847-600af4d0d157", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "LSST", "language": "python", "name": "lsst" }, "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.11.7" } }, "nbformat": 4, "nbformat_minor": 5 }