ESBO-ETC/esbo_etc/classes/target/ATarget.py

78 lines
2.2 KiB
Python
Raw Normal View History

2020-04-08 09:56:04 +02:00
from abc import abstractmethod
2020-04-16 09:35:24 +02:00
from ..IRadiant import IRadiant
2020-04-08 09:56:04 +02:00
from ..SpectralQty import SpectralQty
2020-04-08 13:36:08 +02:00
import astropy.units as u
2020-04-16 09:35:24 +02:00
import numpy as np
2020-05-29 09:36:02 +02:00
from ...lib.logger import logger
2020-04-28 17:21:26 +02:00
from typing import Tuple
2020-05-08 15:06:13 +02:00
from ..Entry import Entry
2020-04-08 09:56:04 +02:00
2020-04-16 09:35:24 +02:00
class ATarget(IRadiant):
2020-04-08 09:56:04 +02:00
"""
Abstract super class for target models
"""
2020-04-08 18:16:12 +02:00
2020-04-08 09:56:04 +02:00
@abstractmethod
@u.quantity_input(wl_bins="length")
def __init__(self, sfd: SpectralQty, wl_bins: u.Quantity):
2020-04-08 09:56:04 +02:00
"""
Initialize a new target
Parameters
----------
2020-04-28 17:21:26 +02:00
sfd : SpectralQty
2020-04-08 09:56:04 +02:00
The spectral flux density of the target
2020-04-28 17:21:26 +02:00
wl_bins : length-Quantity
The bins to be used for evaluating spectral quantities.
2020-04-08 09:56:04 +02:00
"""
2020-04-16 13:04:21 +02:00
self.__sfd = sfd
self.__wl_bins = wl_bins
2020-04-08 09:56:04 +02:00
def calcBackground(self) -> SpectralQty:
2020-04-08 09:56:04 +02:00
"""
Calculate the spectral radiance of the target's background
2020-04-08 09:56:04 +02:00
Returns
-------
background : SpectralQty
The spectral radiance of the target's background
2020-04-08 09:56:04 +02:00
"""
2020-07-23 15:21:32 +02:00
logger.info("Calculating background for class '" + self.__class__.__name__ + "'.")
background = SpectralQty(self.__wl_bins, np.repeat(0, len(self.__wl_bins)) << u.W / (u.m**2 * u.nm * u.sr))
2020-05-29 09:36:02 +02:00
logger.debug(background)
return background
2020-04-08 09:56:04 +02:00
def calcSignal(self) -> Tuple[SpectralQty, float]:
2020-04-08 09:56:04 +02:00
"""
Calculate the spectral flux density of the target's signal
Returns
-------
signal : SpectralQty
The spectral flux density of the target's signal
2020-05-08 17:21:33 +02:00
obstruction : float
2020-05-15 14:34:16 +02:00
The obstruction factor as A_ob / A_ap.
2020-04-08 09:56:04 +02:00
"""
2020-05-29 09:36:02 +02:00
logger.info("Calculating signal for class '" + self.__class__.__name__ + "'.")
logger.debug(self.__sfd)
return self.__sfd, 0.0
2020-05-08 15:06:13 +02:00
@staticmethod
@abstractmethod
def check_config(conf: Entry) -> bool:
"""
Check the configuration for this class
Parameters
----------
conf : Entry
The configuration entry to be checked.
Returns
-------
mes : Union[None, str]
The error message of the check. This will be None if the check was successful.
"""
pass