Skip to content

Commit

Permalink
Rename Quantization -> ADConversion
Browse files Browse the repository at this point in the history
  • Loading branch information
oczoske committed Aug 22, 2024
1 parent 93a4757 commit 7129f8d
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions scopesim/effects/electronic/electrons.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"""Effects related to the conversion of photons into electrons.
- LinearityCurve: Detector linearity
- Quantization: Conversion from electrons to ADU
- ADConversion: Conversion from electrons to ADU
Related effects:
- QuantumEfficiencyCurve: can be found in ter_curves.py
Expand Down Expand Up @@ -89,8 +89,12 @@ def plot(self, **kwargs):
return fig


class Quantization(Effect):
"""Converts raw data to whole photons."""
class ADConversion(Effect):
"""Analogue-Digital Conversion effect.
The effect applies the gain to convert from electrons to ADU
and converts the output to the desired data type (e.g. uint16).
"""

def __init__(self, **kwargs):
super().__init__(**kwargs)
Expand All @@ -102,13 +106,15 @@ def __init__(self, **kwargs):
self.meta.update(kwargs)

def _should_apply(self) -> bool:
"""Check cases where the effect should not be applied"""
if self.cmds is None:
logger.warning("Cannot access cmds for Quantization effect.")
logger.warning("Cannot access cmds for ADConversion effect.")
return True

# ..todo: need to deal with this case more realistically
if self.cmds.get("!OBS.autoexpset", False):
logger.debug("DIT, NDIT determined by AutoExposure -> "
"quantization is not applied.")
"ADConversion is not applied.")
return False

if self.cmds["!OBS.ndit"] > 1:
Expand All @@ -129,6 +135,8 @@ def apply_to(self, obj, **kwargs):
logger.warning("Setting quantized data to dtype %s, which is not "
"an integer subtype.", new_dtype)

# TODO: Apply the gain value (copy from DarkCurrent)

# Remove values below 0, because for unsigned types these get wrapped
# around to MAXINT, which is even worse than negative values.
# TODO: Write a test for this.
Expand Down

0 comments on commit 7129f8d

Please sign in to comment.