Skip to content

Commit

Permalink
Add bad bias columns to comcam manual defects.
Browse files Browse the repository at this point in the history
  • Loading branch information
erykoff committed Dec 18, 2024
1 parent 10018ea commit 361a5cb
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions python/lsst/obs/lsst/script/write_comcam_manual_defects.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.
import re
import os
import numpy as np
import dateutil.parser
from lsst.ip.isr import Defects
from lsst.geom import Box2I, Point2I, Extent2I
import lsst.utils
from lsst.obs.lsst import LsstComCam
from lsst.daf.butler import Butler


camera = LsstComCam().getCamera()
Expand All @@ -35,6 +37,8 @@
valid_date = dateutil.parser.parse(valid_start)
datestr = "".join(re.split(r"[:-]", valid_date.isoformat()))

butler = Butler("embargo", instrument="LSSTComCam", collections=["LSSTComCam/calib/DM-47447"])

for det in camera:
print("Building manual defects from detector ", det.getName(), det.getId())
name = det.getName()
Expand Down Expand Up @@ -76,6 +80,23 @@
),
)

# Add bad bias column defects from DM-48174.
bias = butler.get("bias", detector=det.getId())

det_height = det.getBBox().getHeight()
for half in ["bottom", "top"]:
if half == "bottom":
ylow, yhigh = 0, det_height // 2
else:
ylow, yhigh = det_height // 2, det_height

col_median = np.median(bias.image.array[ylow: yhigh, :], axis=0)

bad_cols, = np.where(np.abs(col_median) > 10)

for bad_col in bad_cols:
box_xywh.append((bad_col, ylow, 1, yhigh - ylow))

bboxes = [
Box2I(corner=Point2I(x, y), dimensions=Extent2I(w, h))
for x, y, w, h in box_xywh
Expand Down

0 comments on commit 361a5cb

Please sign in to comment.