AHotOpticalComponent added

This commit is contained in:
Lukas Klass 2020-04-14 15:53:15 +02:00
parent 9263967251
commit 6f984f7730
3 changed files with 77 additions and 0 deletions

View File

@ -0,0 +1,49 @@
from esbo_etc.classes.optical_component.AOpticalComponent import AOpticalComponent
from esbo_etc.classes.ITransmissive import ITransmissive
from esbo_etc.classes.SpectralQty import SpectralQty
from abc import abstractmethod
import astropy.units as u
from astropy.modeling.models import BlackBody
class AHotOpticalComponent(AOpticalComponent):
"""
Abstract super class for an optical component with thermal emission
"""
@abstractmethod
@u.quantity_input(wl_bins='length', temp=[u.Kelvin, u.Celsius])
def __init__(self, parent: ITransmissive, emissivity: SpectralQty, wl_bins: u.Quantity, temp: u.Quantity):
"""
Initialize a new optical component with thermal emission
Parameters
----------
parent : ITransmissive
The parent element of the optical component from which the electromagnetic radiation is received.
emissivity : SpectralQty
The spectral emissivity coefficient for the optical surface.
wl_bins : Quantity
Wavelengths used for binning
temp: Quantity in Kelvin / Celsius
Temperature of the optical component
"""
# Initialize super class
super().__init__(parent)
if temp > 0 * u.K:
# Create noise from black body model
bb = BlackBody(temperature=temp, scale=1. * u.W / (u.m ** 2 * u.nm * u.sr))
self._noise = SpectralQty(wl_bins, bb(wl_bins)) * emissivity
else:
# Create zero dummy noise
self._noise = SpectralQty(wl_bins, [0] * len(wl_bins) << u.W / (u.m ** 2 * u.nm * u.sr))
def ownNoise(self) -> SpectralQty:
"""
Calculate the noise created by the optical component
Returns
-------
noise : SpectralQty
The noise created by the optical component
"""
return self._noise

View File

@ -1,3 +1,4 @@
from esbo_etc.classes.optical_component.AOpticalComponent import *
from esbo_etc.classes.optical_component.Atmosphere import *
from esbo_etc.classes.optical_component.StrayLight import *
from esbo_etc.classes.optical_component.AHotOpticalComponent import *

View File

@ -0,0 +1,27 @@
from unittest import TestCase
from esbo_etc.classes.optical_component.AHotOpticalComponent import AHotOpticalComponent
from esbo_etc.classes.ITransmissive import ITransmissive
from esbo_etc.classes.SpectralQty import SpectralQty
from esbo_etc.classes.target.FileTarget import FileTarget
import astropy.units as u
import numpy as np
class HotOpticalComponent(AHotOpticalComponent):
def __init__(self, parent: ITransmissive, emissivity: SpectralQty, wl_bins: u.Quantity, temp: u.Quantity):
super().__init__(parent, emissivity, wl_bins, temp)
def propagate(self, sqty: SpectralQty) -> SpectralQty:
return sqty
class TestAHotOpticalComponent(TestCase):
wl = np.arange(201, 205, 1) << u.nm
def setUp(self):
self.target = FileTarget("data/target/target_demo_1.csv")
self.comp = HotOpticalComponent(self.target, SpectralQty(self.wl, [0.5] * 4), wl_bins=self.wl, temp=300 * u.K)
def test___init__(self):
self.assertEqual(self.comp.calcNoise(), SpectralQty(self.wl, [4.31413931e-96, 1.37122214e-95, 4.30844544e-95,
1.33846280e-94] << u.W / (u.m**2 * u.nm * u.sr)))