ESBO-ETC/esbo_etc/classes/optical_component/Lens.py

106 lines
4.0 KiB
Python
Raw Permalink Normal View History

2020-04-15 17:11:36 +02:00
from .AHotOpticalComponent import AHotOpticalComponent
from ..SpectralQty import SpectralQty
2020-04-16 09:35:24 +02:00
from ..IRadiant import IRadiant
2020-05-08 15:06:13 +02:00
from ..Entry import Entry
2020-04-15 17:11:36 +02:00
from astropy import units as u
from typing import Union
class Lens(AHotOpticalComponent):
"""
A class to model the optical characteristics of a lens.
"""
@u.quantity_input(temp=[u.Kelvin, u.Celsius], obstructor_temp=[u.Kelvin, u.Celsius])
def __init__(self, parent: IRadiant, transmittance: str, emissivity: Union[str, float] = None,
2020-05-08 15:06:13 +02:00
temp: u.Quantity = 0 * u.K, obstruction: float = 0, obstructor_temp: u.Quantity = 0 * u.K,
obstructor_emissivity: float = 1):
2020-04-15 17:11:36 +02:00
"""
Instantiate a new lens model
Parameters
----------
2020-04-16 09:35:24 +02:00
parent : IRadiant
2020-04-15 17:11:36 +02:00
The parent element of the optical component from which the electromagnetic radiation is received.
transmittance : str
The spectral transmittance coefficients of the filter.
2020-05-08 15:06:13 +02:00
emissivity : Union[str, float]
2020-04-15 17:11:36 +02:00
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.
"""
try:
self._transmittance = float(transmittance) * u.dimensionless_unscaled
except ValueError:
self._transmittance = SpectralQty.fromFile(transmittance, u.nm, u.dimensionless_unscaled)
if emissivity is None:
emissivity = -1 * self._transmittance + 1.0
2020-04-15 17:11:36 +02:00
super().__init__(parent, emissivity, temp, obstruction, obstructor_temp, obstructor_emissivity)
2020-04-16 13:04:21 +02:00
def _propagate(self, rad: SpectralQty) -> SpectralQty:
2020-04-15 17:11:36 +02:00
"""
Propagate incoming radiation through the optical component
Parameters
----------
2020-04-16 13:04:21 +02:00
rad : SpectralQty
2020-04-15 17:11:36 +02:00
The incoming radiation
Returns
-------
2020-04-16 13:04:21 +02:00
rad : SpectralQty
2020-04-15 17:11:36 +02:00
Manipulated incoming radiation
"""
2020-04-16 13:04:21 +02:00
return rad * self._transmittance
2020-05-08 15:06:13 +02:00
@staticmethod
def check_config(conf: Entry) -> Union[None, str]:
"""
Check the configuration for this class
Parameters
----------
conf : Entry
The configuration entry to be checked.
Returns
-------
mes : Union[None, str]
The error message of the check. This will be None if the check was successful.
"""
mes = conf.check_file("transmittance")
if mes is not None:
mes = conf.check_float("transmittance")
if mes is not None:
return mes
2020-05-08 15:06:13 +02:00
if hasattr(conf, "emissivity"):
mes = conf.check_file("emissivity")
if mes is not None:
mes = conf.check_float("emissivity")
if mes is not None:
return mes
if hasattr(conf, "temp"):
mes = conf.check_quantity("temp", u.K)
if mes is not None:
return mes
if hasattr(conf, "obstruction"):
mes = conf.check_float("obstruction")
if mes is not None:
return mes
if hasattr(conf, "obstructor_temp"):
mes = conf.check_quantity("obstructor_temp", u.K)
if mes is not None:
return mes
if hasattr(conf, "obstructor_emissivity"):
mes = conf.check_float("obstructor_emissivity")
if mes is not None:
return mes