From 68db02c60dca609172c4fc3df5e7bc4a2e7d795e Mon Sep 17 00:00:00 2001 From: LukasK13 Date: Wed, 15 Apr 2020 17:20:24 +0200 Subject: [PATCH] Mirror added --- esbo_etc/classes/optical_component/Mirror.py | 56 +++++++++++++++++++ .../classes/optical_component/__init__.py | 1 + tests/data/mirror/mirror_reflectance.csv | 5 ++ tests/test_Mirror.py | 21 +++++++ 4 files changed, 83 insertions(+) create mode 100644 esbo_etc/classes/optical_component/Mirror.py create mode 100644 tests/data/mirror/mirror_reflectance.csv create mode 100644 tests/test_Mirror.py diff --git a/esbo_etc/classes/optical_component/Mirror.py b/esbo_etc/classes/optical_component/Mirror.py new file mode 100644 index 0000000..adf597f --- /dev/null +++ b/esbo_etc/classes/optical_component/Mirror.py @@ -0,0 +1,56 @@ +from .AHotOpticalComponent import AHotOpticalComponent +from ..SpectralQty import SpectralQty +from ..ITransmissive import ITransmissive +from astropy import units as u +from typing import Union + + +class Mirror(AHotOpticalComponent): + """ + A class to model the optical characteristics of a mirror. + """ + @u.quantity_input(temp=[u.Kelvin, u.Celsius], obstructor_temp=[u.Kelvin, u.Celsius]) + def __init__(self, parent: ITransmissive, reflectance: str, + emissivity: Union[int, float, str] = 1, temp: u.Quantity = 0 * u.K, + obstruction: float = 0, obstructor_temp: u.Quantity = 0 * u.K, obstructor_emissivity: float = 1): + """ + Instantiate a new mirror model + + Parameters + ---------- + parent : ITransmissive + The parent element of the optical component from which the electromagnetic radiation is received. + reflectance : str + The spectral transmittance coefficients of the filter. + emissivity : Union[int, float, str] + The spectral emissivity coefficient for the optical surface. + temp: Quantity in Kelvin / Celsius + Temperature of the optical component + obstruction : float + The additional obstruction factor of the optical component. 0 means the component is not obstructed, 1 + denotes a completely obstructed component with therefore no incoming flux. It is important to note, that + the obstruction factor reflects the obstruction of the optical component additionally to the obstruction + factors of the prior elements in the beam. + obstructor_temp : Quantity in Kelvin / Celsius + Temperature of the obstructing component. + obstructor_emissivity : float + Emissivity of the obstructing component. + """ + self._reflectance = SpectralQty.fromFile(reflectance, u.nm, u.dimensionless_unscaled) + super().__init__(parent, emissivity, temp, obstruction, obstructor_temp, obstructor_emissivity) + + def propagate(self, sqty: SpectralQty) -> SpectralQty: + """ + Propagate incoming radiation through the optical component + + Parameters + ---------- + sqty : SpectralQty + The incoming radiation + + Returns + ------- + sqty : SpectralQty + Manipulated incoming radiation + """ + return sqty * self._reflectance diff --git a/esbo_etc/classes/optical_component/__init__.py b/esbo_etc/classes/optical_component/__init__.py index 6f08e42..d8912f2 100644 --- a/esbo_etc/classes/optical_component/__init__.py +++ b/esbo_etc/classes/optical_component/__init__.py @@ -5,3 +5,4 @@ from esbo_etc.classes.optical_component.AHotOpticalComponent import * from esbo_etc.classes.optical_component.Filter import * from esbo_etc.classes.optical_component.Lens import * from esbo_etc.classes.optical_component.BeamSplitter import * +from esbo_etc.classes.optical_component.Mirror import * diff --git a/tests/data/mirror/mirror_reflectance.csv b/tests/data/mirror/mirror_reflectance.csv new file mode 100644 index 0000000..e12aeac --- /dev/null +++ b/tests/data/mirror/mirror_reflectance.csv @@ -0,0 +1,5 @@ +wavelength,spectral transmittance +201,1 +202,1 +203,1 +204,0.9 diff --git a/tests/test_Mirror.py b/tests/test_Mirror.py new file mode 100644 index 0000000..20060d4 --- /dev/null +++ b/tests/test_Mirror.py @@ -0,0 +1,21 @@ +from unittest import TestCase +from esbo_etc.classes.optical_component.Mirror import Mirror +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 TestMirror(TestCase): + wl = np.arange(201, 205, 1) << u.nm + + def setUp(self): + self.target = FileTarget("data/target/target_demo_1.csv") + self.mirror = Mirror(self.target, "data/mirror/mirror_reflectance.csv", 0.5, temp=300 * u.K) + + def test___init__(self): + self.assertEqual(self.mirror.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))) + self.assertEqual(self.mirror.calcSignal(), + SpectralQty(self.wl, [1.20e-15, 1.30e-15, 1.40e-15, 1.35e-15] << u.W / (u.m ** 2 * u.nm)))