ESBO-ETC/tests/optical_component/test_AHotOpticalComponent.py

43 lines
1.9 KiB
Python
Raw Normal View History

2020-04-14 15:53:15 +02:00
from unittest import TestCase
2020-05-08 15:06:44 +02:00
from esbo_etc import Entry
2020-04-14 15:53:15 +02:00
from esbo_etc.classes.optical_component.AHotOpticalComponent import AHotOpticalComponent
2020-04-16 09:35:24 +02:00
from esbo_etc.classes.IRadiant import IRadiant
2020-04-14 15:53:15 +02:00
from esbo_etc.classes.SpectralQty import SpectralQty
from esbo_etc.classes.target.FileTarget import FileTarget
import astropy.units as u
import numpy as np
2020-04-16 09:35:24 +02:00
from typing import Union
2020-04-14 15:53:15 +02:00
class HotOpticalComponent(AHotOpticalComponent):
2020-04-16 09:35:24 +02:00
def __init__(self, parent: IRadiant, emissivity: Union[SpectralQty, int, float, str], temp: u.Quantity,
obstruction: float = 0, obstructor_temp: u.Quantity = 0 * u.K, obstructor_emissivity: float = 1):
2020-04-15 15:39:25 +02:00
super().__init__(parent, emissivity, temp, obstruction, obstructor_temp, obstructor_emissivity)
2020-04-14 15:53:15 +02:00
2020-04-16 13:04:21 +02:00
def _propagate(self, sqty: SpectralQty) -> SpectralQty:
2020-04-14 15:53:15 +02:00
return sqty
2020-05-08 15:06:44 +02:00
@staticmethod
def check_config(conf: Entry) -> Union[None, str]:
pass
2020-04-14 15:53:15 +02:00
class TestAHotOpticalComponent(TestCase):
wl = np.arange(201, 205, 1) << u.nm
def setUp(self):
2020-07-21 15:37:49 +02:00
self.target = FileTarget("tests/data/target/target_demo_1.csv", self.wl)
2020-04-14 15:53:15 +02:00
def test___init__(self):
2020-04-16 09:35:24 +02:00
comp = HotOpticalComponent(self.target, SpectralQty(self.wl, np.repeat(0.5, 4) << u.dimensionless_unscaled),
temp=300 * u.K)
self.assertEqual(comp.calcBackground(),
2020-04-17 09:57:52 +02:00
SpectralQty(self.wl, np.array([4.31413931e-96, 1.37122214e-95, 4.30844544e-95,
1.33846280e-94]) << u.W / (u.m ** 2 * u.nm * u.sr)))
2020-04-16 09:35:24 +02:00
2020-07-21 15:37:49 +02:00
comp = HotOpticalComponent(self.target, "tests/data/mirror/mirror_emissivity.csv", temp=300 * u.K)
self.assertEqual(comp.calcBackground(),
2020-04-17 09:57:52 +02:00
SpectralQty(self.wl, np.array([4.31413931e-96, 1.37122214e-95, 4.30844544e-95,
1.33846280e-94]) << u.W / (u.m ** 2 * u.nm * u.sr)))