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

62 lines
1.8 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-04-24 11:05:01 +02:00
from logging import info, debug
2020-04-28 17:21:26 +02:00
from typing import Tuple
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")
2020-04-28 17:21:26 +02:00
def __init__(self, sfd: SpectralQty, wl_bins: u.Quantity, size: str = "Point"):
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.
size : str
The size of the target. Can be either point or extended.
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-28 17:21:26 +02:00
self.__size = size
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-04-24 11:05:01 +02:00
info("Calculating Noise 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))
debug(background)
return background
2020-04-08 09:56:04 +02:00
2020-04-28 17:21:26 +02:00
def calcSignal(self) -> Tuple[SpectralQty, str]:
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-04-28 17:21:26 +02:00
size : str
The size of the target.
2020-04-08 09:56:04 +02:00
"""
2020-04-24 11:05:01 +02:00
info("Calculating Signal for class '" + self.__class__.__name__ + "'.")
debug(self.__sfd)
2020-04-28 17:21:26 +02:00
return self.__sfd, self.__size