2020-04-21 10:39:55 +02:00
|
|
|
from ..IRadiant import IRadiant
|
|
|
|
import astropy.units as u
|
|
|
|
from abc import abstractmethod
|
2020-05-08 15:06:13 +02:00
|
|
|
from ..Entry import Entry
|
|
|
|
from typing import Union
|
2020-07-07 09:11:21 +02:00
|
|
|
from ..SpectralQty import SpectralQty
|
|
|
|
from ...lib.logger import logger
|
2020-04-21 10:39:55 +02:00
|
|
|
|
|
|
|
|
2020-04-21 14:46:40 +02:00
|
|
|
class ASensor:
|
2020-04-21 10:39:55 +02:00
|
|
|
"""
|
|
|
|
Abstract super class for sensor models
|
|
|
|
"""
|
2020-07-14 12:01:08 +02:00
|
|
|
|
2020-05-20 09:12:29 +02:00
|
|
|
@abstractmethod
|
2020-04-21 10:39:55 +02:00
|
|
|
def __init__(self, parent: IRadiant):
|
|
|
|
"""
|
|
|
|
Initialize a new sensor
|
|
|
|
|
|
|
|
Parameters
|
|
|
|
----------
|
|
|
|
parent : IRadiant
|
|
|
|
The parent element of the optical component from which the electromagnetic radiation is received
|
|
|
|
"""
|
|
|
|
self._parent = parent
|
|
|
|
|
2020-07-07 09:11:21 +02:00
|
|
|
def __calcIncomingRadiation(self):
|
|
|
|
"""
|
|
|
|
Trigger the radiation transportation pipeline in order to calculate the received radiation.
|
|
|
|
|
|
|
|
Returns
|
|
|
|
-------
|
|
|
|
background : SpectralQty
|
|
|
|
The received background radiation
|
|
|
|
signal : SpectralQty
|
|
|
|
The received signal radiation
|
|
|
|
obstruction : float
|
|
|
|
The obstruction factor of the aperture as ratio A_ob / A_ap
|
|
|
|
"""
|
|
|
|
logger.info("Calculating incoming background radiation", extra={"spinning": True})
|
|
|
|
background = self._parent.calcBackground()
|
|
|
|
logger.info("Calculating incoming signal radiation", extra={"spinning": True})
|
|
|
|
signal, obstruction = self._parent.calcSignal()
|
|
|
|
return background, signal, obstruction
|
|
|
|
|
2020-04-21 10:39:55 +02:00
|
|
|
@u.quantity_input(exp_time="time")
|
2020-05-16 15:55:50 +02:00
|
|
|
def getSNR(self, exp_time: u.Quantity) -> u.dimensionless_unscaled:
|
2020-04-21 10:39:55 +02:00
|
|
|
"""
|
|
|
|
Calculate the signal to noise ratio (SNR) for the given exposure time.
|
|
|
|
|
|
|
|
Parameters
|
|
|
|
----------
|
|
|
|
exp_time : time-Quantity
|
|
|
|
The exposure time to calculate the SNR for.
|
|
|
|
|
|
|
|
Returns
|
|
|
|
-------
|
2020-05-16 15:55:50 +02:00
|
|
|
snr : Quantity
|
2020-04-21 10:39:55 +02:00
|
|
|
The calculated SNR
|
|
|
|
"""
|
2020-07-07 09:11:21 +02:00
|
|
|
background, signal, obstruction = self.__calcIncomingRadiation()
|
|
|
|
return self.calcSNR(background, signal, obstruction, exp_time)
|
2020-04-21 10:39:55 +02:00
|
|
|
|
|
|
|
@abstractmethod
|
2020-07-07 09:11:21 +02:00
|
|
|
@u.quantity_input(exp_time="time")
|
|
|
|
def calcSNR(self, background: SpectralQty, signal: SpectralQty, obstruction: float,
|
|
|
|
exp_time: u.Quantity) -> u.dimensionless_unscaled:
|
|
|
|
"""
|
|
|
|
Calculate the signal to noise ratio (SNR) for the given exposure time.
|
|
|
|
|
|
|
|
Parameters
|
|
|
|
----------
|
|
|
|
background : SpectralQty
|
|
|
|
The received background radiation
|
|
|
|
signal : SpectralQty
|
|
|
|
The received signal radiation
|
|
|
|
obstruction : float
|
|
|
|
The obstruction factor of the aperture as ratio A_ob / A_ap
|
|
|
|
exp_time : time-Quantity
|
|
|
|
The exposure time to calculate the SNR for.
|
|
|
|
|
|
|
|
Returns
|
|
|
|
-------
|
|
|
|
snr : Quantity
|
|
|
|
The calculated SNR
|
|
|
|
"""
|
|
|
|
pass
|
|
|
|
|
2020-05-16 15:52:27 +02:00
|
|
|
@u.quantity_input(snr=u.dimensionless_unscaled)
|
2020-05-16 15:55:50 +02:00
|
|
|
def getExpTime(self, snr: u.Quantity) -> u.s:
|
2020-04-21 10:39:55 +02:00
|
|
|
"""
|
|
|
|
Calculate the necessary exposure time in order to achieve the given SNR.
|
|
|
|
|
|
|
|
Parameters
|
|
|
|
----------
|
2020-05-16 15:52:27 +02:00
|
|
|
snr : Quantity
|
2020-04-21 10:39:55 +02:00
|
|
|
The SNR for which the necessary exposure time shall be calculated.
|
|
|
|
|
|
|
|
Returns
|
|
|
|
-------
|
|
|
|
exp_time : Quantity
|
|
|
|
The necessary exposure time in seconds.
|
|
|
|
"""
|
2020-07-07 09:11:21 +02:00
|
|
|
background, signal, obstruction = self.__calcIncomingRadiation()
|
|
|
|
return self.calcExpTime(background, signal, obstruction, snr)
|
2020-05-08 15:06:13 +02:00
|
|
|
|
2020-05-16 15:52:27 +02:00
|
|
|
@abstractmethod
|
2020-07-07 09:11:21 +02:00
|
|
|
@u.quantity_input(snr=u.dimensionless_unscaled)
|
|
|
|
def calcExpTime(self, background: SpectralQty, signal: SpectralQty, obstruction: float, snr: u.Quantity) -> u.s:
|
|
|
|
"""
|
|
|
|
Calculate the necessary exposure time in order to achieve the given SNR.
|
|
|
|
|
|
|
|
Parameters
|
|
|
|
----------
|
|
|
|
background : SpectralQty
|
|
|
|
The received background radiation
|
|
|
|
signal : SpectralQty
|
|
|
|
The received signal radiation
|
|
|
|
obstruction : float
|
|
|
|
The obstruction factor of the aperture as ratio A_ob / A_ap
|
|
|
|
snr : Quantity
|
|
|
|
The SNR for which the necessary exposure time shall be calculated.
|
|
|
|
|
|
|
|
Returns
|
|
|
|
-------
|
|
|
|
exp_time : Quantity
|
|
|
|
The necessary exposure time in seconds.
|
|
|
|
"""
|
|
|
|
pass
|
|
|
|
|
2020-07-14 12:01:08 +02:00
|
|
|
# @u.quantity_input(exp_time="time", snr=u.dimensionless_unscaled, target_brightness=[u.mag, u.mag / u.sr])
|
|
|
|
def getSensitivity(self, exp_time: u.Quantity, snr: u.Quantity, target_brightness: u.Quantity) -> [u.mag, u.mag / u.sr]:
|
2020-05-16 15:52:27 +02:00
|
|
|
"""
|
|
|
|
Calculate the sensitivity of the telescope detector combination.
|
|
|
|
|
|
|
|
Parameters
|
|
|
|
----------
|
|
|
|
exp_time : Quantity
|
|
|
|
The exposure time in seconds.
|
|
|
|
snr : Quantity
|
|
|
|
The SNR for which the sensitivity time shall be calculated.
|
|
|
|
target_brightness : Quantity
|
|
|
|
The target brightness in magnitudes.
|
|
|
|
|
2020-07-07 09:11:21 +02:00
|
|
|
Returns
|
|
|
|
-------
|
|
|
|
sensitivity: Quantity
|
2020-07-14 12:01:08 +02:00
|
|
|
The sensitivity as limiting apparent star magnitude in mag or mag / sr.
|
2020-07-07 09:11:21 +02:00
|
|
|
"""
|
|
|
|
background, signal, obstruction = self.__calcIncomingRadiation()
|
|
|
|
return self.calcSensitivity(background, signal, obstruction, exp_time, snr, target_brightness)
|
|
|
|
|
|
|
|
@abstractmethod
|
2020-07-14 12:01:08 +02:00
|
|
|
# @u.quantity_input(exp_time="time", snr=u.dimensionless_unscaled, target_brightness=[u.mag, u.mag / u.sr])
|
2020-07-07 09:11:21 +02:00
|
|
|
def calcSensitivity(self, background: SpectralQty, signal: SpectralQty, obstruction: float, exp_time: u.Quantity,
|
2020-07-14 12:01:08 +02:00
|
|
|
snr: u.Quantity, target_brightness: u.Quantity) -> [u.mag, u.mag / u.sr]:
|
2020-07-07 09:11:21 +02:00
|
|
|
"""
|
|
|
|
Calculate the sensitivity of the telescope detector combination.
|
|
|
|
|
|
|
|
Parameters
|
|
|
|
----------
|
|
|
|
background : SpectralQty
|
|
|
|
The received background radiation
|
|
|
|
signal : SpectralQty
|
|
|
|
The received signal radiation
|
|
|
|
obstruction : float
|
|
|
|
The obstruction factor of the aperture as ratio A_ob / A_ap
|
|
|
|
exp_time : Quantity
|
|
|
|
The exposure time in seconds.
|
|
|
|
snr : Quantity
|
|
|
|
The SNR for which the sensitivity time shall be calculated.
|
|
|
|
target_brightness : Quantity
|
|
|
|
The target brightness in magnitudes.
|
|
|
|
|
2020-05-16 15:52:27 +02:00
|
|
|
Returns
|
|
|
|
-------
|
|
|
|
sensitivity: Quantity
|
2020-07-14 12:01:08 +02:00
|
|
|
The sensitivity as limiting apparent star magnitude in mag or mag / sr.
|
2020-05-16 15:52:27 +02:00
|
|
|
"""
|
|
|
|
pass
|
|
|
|
|
2020-05-08 15:06:13 +02:00
|
|
|
@staticmethod
|
2020-05-20 09:12:29 +02:00
|
|
|
@abstractmethod
|
2020-05-15 11:15:18 +02:00
|
|
|
def check_config(sensor: Entry, conf: Entry) -> Union[None, str]:
|
2020-05-08 15:06:13 +02:00
|
|
|
"""
|
|
|
|
Check the configuration for this class
|
|
|
|
|
|
|
|
Parameters
|
|
|
|
----------
|
2020-05-15 11:15:18 +02:00
|
|
|
sensor : Entry
|
2020-05-08 15:06:13 +02:00
|
|
|
The configuration entry to be checked.
|
2020-05-15 11:15:18 +02:00
|
|
|
conf: Entry
|
|
|
|
The complete configuration.
|
2020-05-08 15:06:13 +02:00
|
|
|
|
|
|
|
Returns
|
|
|
|
-------
|
|
|
|
mes : Union[None, str]
|
2020-05-08 16:45:39 +02:00
|
|
|
The error message of the check. This will be None if the check was successful.
|
2020-05-08 15:06:13 +02:00
|
|
|
"""
|
|
|
|
pass
|