From 998ae066afdd86313c7716e1831ae8ee636d8361 Mon Sep 17 00:00:00 2001 From: LukasK13 Date: Tue, 14 Apr 2020 16:20:25 +0200 Subject: [PATCH] Allow int and float es transreflectivity and noise --- esbo_etc/classes/optical_component/AHotOpticalComponent.py | 3 +-- esbo_etc/classes/optical_component/AOpticalComponent.py | 7 ++++--- esbo_etc/classes/optical_component/StrayLight.py | 4 +--- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/esbo_etc/classes/optical_component/AHotOpticalComponent.py b/esbo_etc/classes/optical_component/AHotOpticalComponent.py index d5ebd6d..42e1de7 100644 --- a/esbo_etc/classes/optical_component/AHotOpticalComponent.py +++ b/esbo_etc/classes/optical_component/AHotOpticalComponent.py @@ -34,8 +34,7 @@ class AHotOpticalComponent(AOpticalComponent): 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)) + self._noise = 0 def ownNoise(self) -> SpectralQty: """ diff --git a/esbo_etc/classes/optical_component/AOpticalComponent.py b/esbo_etc/classes/optical_component/AOpticalComponent.py index dbb286e..6a35f65 100644 --- a/esbo_etc/classes/optical_component/AOpticalComponent.py +++ b/esbo_etc/classes/optical_component/AOpticalComponent.py @@ -4,6 +4,7 @@ from ..SpectralQty import SpectralQty from esbo_etc.lib.helpers import error import astropy.units as u from astropy.modeling.models import BlackBody +from typing import Union class AOpticalComponent(ITransmissive): @@ -13,9 +14,9 @@ class AOpticalComponent(ITransmissive): @abstractmethod @u.quantity_input(obstructor_temp=[u.K, u.Celsius]) - def __init__(self, parent: ITransmissive, transreflectivity: SpectralQty = None, - noise: SpectralQty = None, obstruction: float = 0, obstructor_temp: u.Quantity = 0 * u.K, - obstructor_emissivity: float = 0): + def __init__(self, parent: ITransmissive, transreflectivity: Union[SpectralQty, int, float, u.Quantity] = None, + noise: Union[SpectralQty, int, float, u.Quantity] = None, obstruction: float = 0, + obstructor_temp: u.Quantity = 0 * u.K, obstructor_emissivity: float = 0): """ Initialize a new optical component diff --git a/esbo_etc/classes/optical_component/StrayLight.py b/esbo_etc/classes/optical_component/StrayLight.py index 9f0442e..d2b476d 100644 --- a/esbo_etc/classes/optical_component/StrayLight.py +++ b/esbo_etc/classes/optical_component/StrayLight.py @@ -24,7 +24,5 @@ class StrayLight(AOpticalComponent): # Read the emission emission_sqty = SpectralQty.fromFile(emission, wl_unit_default=u.nm, qty_unit_default=u.W / (u.m**2 * u.nm * u.sr)) - # Create dummy transmittance - transmittance_sqty = SpectralQty(emission_sqty.wl, [1] * len(emission_sqty.wl) * u.dimensionless_unscaled) # Initialize the super class - super().__init__(parent, transmittance_sqty, emission_sqty) + super().__init__(parent, 1.0, emission_sqty)