Return obstruction

This commit is contained in:
Lukas Klass 2020-05-08 17:21:33 +02:00
parent 81c6a854b3
commit a12b767aed
5 changed files with 16 additions and 9 deletions

View File

@ -9,7 +9,7 @@ class IRadiant(ABC):
in the beam.
"""
@abstractmethod
def calcSignal(self) -> Tuple[SpectralQty, str]:
def calcSignal(self) -> Tuple[SpectralQty, str, float]:
"""
Calculate the signal coming from the component
@ -19,6 +19,8 @@ class IRadiant(ABC):
The emitted, reflected or transmitted signal
size : str
The size of the target.
obstruction : float
The obstruction factor.
"""
pass

View File

@ -52,7 +52,7 @@ class AOpticalComponent(IRadiant):
self.__obstructor_temp = obstructor_temp
self.__obstructor_emissivity = obstructor_emissivity
def calcSignal(self) -> Tuple[SpectralQty, str]:
def calcSignal(self) -> Tuple[SpectralQty, str, float]:
"""
Calculate the spectral flux density of the target's signal
@ -62,12 +62,15 @@ class AOpticalComponent(IRadiant):
The spectral flux density of the target's signal
size : str
The size of the target.
obstruction : float
The obstruction factor.
"""
signal, size = self.__parent.calcSignal()
signal, size, obstruction = self.__parent.calcSignal()
info("Calculating signal for class '" + self.__class__.__name__ + "'.")
signal = self._propagate(signal) * (1 - self.__obstruction)
obstruction = obstruction + self.__obstruction
debug(signal)
return signal, size
return signal, size, obstruction
def calcBackground(self) -> SpectralQty:
"""

View File

@ -46,7 +46,7 @@ class ATarget(IRadiant):
debug(background)
return background
def calcSignal(self) -> Tuple[SpectralQty, str]:
def calcSignal(self) -> Tuple[SpectralQty, str, float]:
"""
Calculate the spectral flux density of the target's signal
@ -56,10 +56,12 @@ class ATarget(IRadiant):
The spectral flux density of the target's signal
size : str
The size of the target.
obstruction : float
The obstruction factor.
"""
info("Calculating Signal for class '" + self.__class__.__name__ + "'.")
debug(self.__sfd)
return self.__sfd, self.__size
return self.__sfd, self.__size, 0.0
@staticmethod
@abstractmethod

View File

@ -13,7 +13,7 @@ class TestBlackBodyTarget(TestCase):
def test_calcSignal(self):
signal = SpectralQty(np.arange(400, 800, 100) << u.nm, np.array([4.91164694e-15, 5.61732017e-15, 5.22403225e-15,
4.43017583e-15]) << u.W / (u.m ** 2 * u.nm))
self.assertEqual(self.target.calcSignal(), (signal, "Point"))
self.assertEqual(self.target.calcSignal(), (signal, "Point", 0.0))
def test_calcBackground(self):
noise = SpectralQty(np.arange(400, 800, 100) << u.nm, np.repeat(0, 4) << u.W / (u.m ** 2 * u.nm * u.sr))

View File

@ -11,8 +11,8 @@ class TestFileTarget(TestCase):
def test_calcSignal(self):
signal = SpectralQty(np.arange(200, 210, 1) << u.nm,
np.arange(1.1e-15, 2.0e-15, 1e-16) << u.W / (u.m ** 2 * u.nm))
self.assertEqual(self.target.calcSignal(), (signal, "Point"))
np.arange(1.1e-15, 2.0e-15, 1e-16) << u.W / (u.m ** 2 * u.nm))
self.assertEqual(self.target.calcSignal(), (signal, "Point", 0.0))
def test_calcBackground(self):
noise = SpectralQty(np.arange(200, 210, 1) << u.nm,