2020-04-09 17:51:55 +02:00
|
|
|
from unittest import TestCase
|
|
|
|
from esbo_etc.classes import *
|
|
|
|
import astropy.units as u
|
|
|
|
import numpy as np
|
|
|
|
|
|
|
|
|
|
|
|
class OpticalComponent(AOpticalComponent):
|
2020-04-16 09:35:24 +02:00
|
|
|
def __init__(self, parent: IRadiant, transreflectivity: SpectralQty = None,
|
2020-04-09 17:51:55 +02:00
|
|
|
noise: SpectralQty = None, obstruction: float = 0, obstructor_temp: u.Quantity = 0 * u.K,
|
|
|
|
obstructor_emissivity: float = 0):
|
|
|
|
super().__init__(parent, transreflectivity, noise, obstruction, obstructor_temp, obstructor_emissivity)
|
|
|
|
|
|
|
|
|
|
|
|
class TestAOpticalComponent(TestCase):
|
|
|
|
wl = np.arange(4, 8, 1) << u.um
|
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
self.target = BlackBodyTarget(self.wl, temp=5778 * u.K, mag=10 * u.mag, band="U")
|
2020-04-17 09:57:52 +02:00
|
|
|
self.comp = OpticalComponent(self.target, SpectralQty(self.wl, np.repeat(0.5, 4) << u.dimensionless_unscaled),
|
|
|
|
SpectralQty(self.wl, np.repeat(1e-5, 4) << u.W / (u.m ** 2 * u.nm * u.sr)),
|
2020-04-09 17:51:55 +02:00
|
|
|
obstruction=0.1, obstructor_temp=300 * u.K, obstructor_emissivity=1)
|
|
|
|
|
|
|
|
def test_calcSignal(self):
|
2020-04-28 17:21:26 +02:00
|
|
|
self.assertEqual(self.comp.calcSignal()[0],
|
2020-04-24 11:41:39 +02:00
|
|
|
SpectralQty(self.wl, np.array([1.29074440e-17, 5.65909989e-18, 2.85372997e-18,
|
|
|
|
1.58973516e-18]) << u.W / (u.m ** 2 * u.nm)))
|
2020-04-09 17:51:55 +02:00
|
|
|
|
2020-04-24 17:10:08 +02:00
|
|
|
def test_calcBackground(self):
|
|
|
|
self.assertEqual(self.comp.calcBackground(),
|
2020-04-17 09:57:52 +02:00
|
|
|
SpectralQty(self.wl, np.array([8.21976423e-05, 2.70268340e-04, 5.27503292e-04,
|
|
|
|
7.60597616e-04]) << u.W / (u.m ** 2 * u.nm * u.sr)))
|
|
|
|
comp = OpticalComponent(self.comp, SpectralQty(self.wl, np.repeat(0.5, 4) << u.dimensionless_unscaled),
|
|
|
|
SpectralQty(self.wl, np.repeat(0, 4) << u.W / (u.m ** 2 * u.nm * u.sr)),
|
2020-04-09 17:51:55 +02:00
|
|
|
obstruction=0.1, obstructor_temp=300 * u.K, obstructor_emissivity=1)
|
2020-04-24 17:10:08 +02:00
|
|
|
self.assertEqual(comp.calcBackground(),
|
2020-04-17 09:57:52 +02:00
|
|
|
SpectralQty(self.wl, np.array([1.09186581e-04, 3.81889092e-04, 7.54879773e-04,
|
|
|
|
10.92866544e-04]) << u.W / (u.m ** 2 * u.nm * u.sr)))
|