From 1e57c24d24690cffd15f4ff2438a1919aecc0efd Mon Sep 17 00:00:00 2001 From: Dave Date: Wed, 12 Oct 2022 15:56:47 +0100 Subject: [PATCH 1/3] CCD rotation effect Implements RotateCCD effect which allows for integer rotations of the field by 90 degrees --- scopesim/effects/__init__.py | 2 ++ scopesim/effects/rotation.py | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 scopesim/effects/rotation.py diff --git a/scopesim/effects/__init__.py b/scopesim/effects/__init__.py index 3b62cf77..e232667f 100644 --- a/scopesim/effects/__init__.py +++ b/scopesim/effects/__init__.py @@ -16,4 +16,6 @@ from .obs_strategies import * from .fits_headers import * +from .rotation import * + # from . import effects_utils diff --git a/scopesim/effects/rotation.py b/scopesim/effects/rotation.py new file mode 100644 index 00000000..b3410f16 --- /dev/null +++ b/scopesim/effects/rotation.py @@ -0,0 +1,36 @@ +"""Effects related to rotation of the field/CCD + +Classes: +- RotateCCD - Rotates CCD by integer multiples of 90 degrees +""" + +import logging +import numpy as np + +from . import Effect +from .. import utils +from ..utils import from_currsys +from ..base_classes import DetectorBase + + +class RotateCCD(Effect): + """ + Rotates CCD by integer multiples of 90 degrees + rotations kwarg is number of counter-clockwise rotations + + """ + def __init__(self, **kwargs): + super(RotateCCD, self).__init__(**kwargs) + params = {"z_order": [809]} + self.meta.update(params) + self.meta.update(kwargs) + + required_keys = ["rotations"] + utils.check_keys(self.meta, required_keys, action="error") + + def apply_to(self, obj, **kwargs): + if isinstance(obj, DetectorBase): + rotations = from_currsys(self.meta["rotations"]) + obj._hdu.data = np.rot90(obj._hdu.data,rotations) + + return obj From f776e5f3734370a49502aad3824c9686a62b5ae8 Mon Sep 17 00:00:00 2001 From: Dave Date: Wed, 12 Oct 2022 16:37:14 +0100 Subject: [PATCH 2/3] Adds unequal binning (i.e. 2x1) --- scopesim/effects/electronic.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/scopesim/effects/electronic.py b/scopesim/effects/electronic.py index f0c901a6..a889302c 100644 --- a/scopesim/effects/electronic.py +++ b/scopesim/effects/electronic.py @@ -12,6 +12,7 @@ - LinearityCurve - apply detector (non-)linearity and saturation - ReferencePixelBorder - BinnedImage +- UnequalBinnedImage - Bias - adds constant bias level to readout Functions: @@ -557,6 +558,24 @@ def apply_to(self, det, **kwargs): return det +class UnequalBinnedImage(Effect): + def __init__(self, **kwargs): + super(UnequalBinnedImage, self).__init__(**kwargs) + self.meta["z_order"] = [870] + + self.required_keys = ["binx","biny"] + utils.check_keys(self.meta, self.required_keys, action="error") + + def apply_to(self, det, **kwargs): + if isinstance(det, DetectorBase): + bx = from_currsys(self.meta["binx"]) + by = from_currsys(self.meta["biny"]) + image = det._hdu.data + h, w = image.shape + new_image = image.reshape((h//bx, bx, w//by, by)) + det._hdu.data = new_image.sum(axis=3).sum(axis=1) + + return det ################################################################################ From 2ea1dee4ee141aaa889fca6e671aa89f3434e8d2 Mon Sep 17 00:00:00 2001 From: Dave Date: Thu, 13 Oct 2022 08:48:02 +0100 Subject: [PATCH 3/3] Update rotation.py --- scopesim/effects/rotation.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scopesim/effects/rotation.py b/scopesim/effects/rotation.py index b3410f16..33025b4f 100644 --- a/scopesim/effects/rotation.py +++ b/scopesim/effects/rotation.py @@ -13,14 +13,14 @@ from ..base_classes import DetectorBase -class RotateCCD(Effect): +class Rotate90CCD(Effect): """ Rotates CCD by integer multiples of 90 degrees rotations kwarg is number of counter-clockwise rotations """ def __init__(self, **kwargs): - super(RotateCCD, self).__init__(**kwargs) + super(Rotate90CCD, self).__init__(**kwargs) params = {"z_order": [809]} self.meta.update(params) self.meta.update(kwargs)