Allow single value for transmittance / reflectivity and use 1-value as emissivity
This commit is contained in:
parent
047e54bd84
commit
5c31dbf87c
@ -11,7 +11,7 @@ class BeamSplitter(AHotOpticalComponent):
|
|||||||
A class to model the optical characteristics of a beam splitter.
|
A class to model the optical characteristics of a beam splitter.
|
||||||
"""
|
"""
|
||||||
@u.quantity_input(temp=[u.Kelvin, u.Celsius], obstructor_temp=[u.Kelvin, u.Celsius])
|
@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] = 1,
|
def __init__(self, parent: IRadiant, transmittance: str, emissivity: Union[str, float] = None,
|
||||||
temp: u.Quantity = 0 * u.K, obstruction: float = 0, obstructor_temp: u.Quantity = 0 * u.K,
|
temp: u.Quantity = 0 * u.K, obstruction: float = 0, obstructor_temp: u.Quantity = 0 * u.K,
|
||||||
obstructor_emissivity: float = 1):
|
obstructor_emissivity: float = 1):
|
||||||
"""
|
"""
|
||||||
@ -37,7 +37,12 @@ class BeamSplitter(AHotOpticalComponent):
|
|||||||
obstructor_emissivity : float
|
obstructor_emissivity : float
|
||||||
Emissivity of the obstructing component.
|
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)
|
self._transmittance = SpectralQty.fromFile(transmittance, u.nm, u.dimensionless_unscaled)
|
||||||
|
if emissivity is None:
|
||||||
|
emissivity = -1 * self._transmittance + 1.0
|
||||||
super().__init__(parent, emissivity, temp, obstruction, obstructor_temp, obstructor_emissivity)
|
super().__init__(parent, emissivity, temp, obstruction, obstructor_temp, obstructor_emissivity)
|
||||||
|
|
||||||
def _propagate(self, rad: SpectralQty) -> SpectralQty:
|
def _propagate(self, rad: SpectralQty) -> SpectralQty:
|
||||||
@ -72,6 +77,8 @@ class BeamSplitter(AHotOpticalComponent):
|
|||||||
The error message of the check. This will be None if the check was successful.
|
The error message of the check. This will be None if the check was successful.
|
||||||
"""
|
"""
|
||||||
mes = conf.check_file("transmittance")
|
mes = conf.check_file("transmittance")
|
||||||
|
if mes is not None:
|
||||||
|
mes = conf.check_float("transmittance")
|
||||||
if mes is not None:
|
if mes is not None:
|
||||||
return mes
|
return mes
|
||||||
if hasattr(conf, "emissivity"):
|
if hasattr(conf, "emissivity"):
|
||||||
|
@ -104,7 +104,7 @@ class Filter(AHotOpticalComponent):
|
|||||||
obstructor_temp, obstructor_emissivity)
|
obstructor_temp, obstructor_emissivity)
|
||||||
|
|
||||||
# @u.quantity_input(temp=[u.Kelvin, u.Celsius], obstructor_temp=[u.Kelvin, u.Celsius])
|
# @u.quantity_input(temp=[u.Kelvin, u.Celsius], obstructor_temp=[u.Kelvin, u.Celsius])
|
||||||
def _fromFile(self, parent: IRadiant, transmittance: str, emissivity: Union[str, float] = 1,
|
def _fromFile(self, parent: IRadiant, transmittance: str, emissivity: Union[str, float] = None,
|
||||||
temp: u.Quantity = 0 * u.K, obstruction: float = 0, obstructor_temp: u.Quantity = 0 * u.K,
|
temp: u.Quantity = 0 * u.K, obstruction: float = 0, obstructor_temp: u.Quantity = 0 * u.K,
|
||||||
obstructor_emissivity: float = 1) -> dict:
|
obstructor_emissivity: float = 1) -> dict:
|
||||||
"""
|
"""
|
||||||
@ -136,7 +136,13 @@ class Filter(AHotOpticalComponent):
|
|||||||
args : dict
|
args : dict
|
||||||
The arguments for the class instantiation.
|
The arguments for the class instantiation.
|
||||||
"""
|
"""
|
||||||
return {"parent": parent, "transmittance": SpectralQty.fromFile(transmittance, u.nm, u.dimensionless_unscaled),
|
try:
|
||||||
|
_transmittance = float(transmittance) * u.dimensionless_unscaled
|
||||||
|
except ValueError:
|
||||||
|
_transmittance = SpectralQty.fromFile(transmittance, u.nm, u.dimensionless_unscaled)
|
||||||
|
if emissivity is None:
|
||||||
|
emissivity = -1 * _transmittance + 1.0
|
||||||
|
return {"parent": parent, "transmittance": _transmittance,
|
||||||
"emissivity": emissivity, "temp": temp, "obstruction": obstruction, "obstructor_temp": obstructor_temp,
|
"emissivity": emissivity, "temp": temp, "obstruction": obstruction, "obstructor_temp": obstructor_temp,
|
||||||
"obstructor_emissivity": obstructor_emissivity}
|
"obstructor_emissivity": obstructor_emissivity}
|
||||||
|
|
||||||
@ -235,6 +241,8 @@ class Filter(AHotOpticalComponent):
|
|||||||
mes = conf.check_selection("band", ["U", "B", "V", "R", "I", "J", "H", "K", "L", "M", "N"])
|
mes = conf.check_selection("band", ["U", "B", "V", "R", "I", "J", "H", "K", "L", "M", "N"])
|
||||||
elif hasattr(conf, "transmittance"):
|
elif hasattr(conf, "transmittance"):
|
||||||
mes = conf.check_file("transmittance")
|
mes = conf.check_file("transmittance")
|
||||||
|
if mes is not None:
|
||||||
|
mes = conf.check_float("transmittance")
|
||||||
elif hasattr(conf, "start") and hasattr(conf, "end"):
|
elif hasattr(conf, "start") and hasattr(conf, "end"):
|
||||||
mes = conf.check_quantity("start", u.m)
|
mes = conf.check_quantity("start", u.m)
|
||||||
if mes is not None:
|
if mes is not None:
|
||||||
|
@ -11,7 +11,7 @@ class Lens(AHotOpticalComponent):
|
|||||||
A class to model the optical characteristics of a lens.
|
A class to model the optical characteristics of a lens.
|
||||||
"""
|
"""
|
||||||
@u.quantity_input(temp=[u.Kelvin, u.Celsius], obstructor_temp=[u.Kelvin, u.Celsius])
|
@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] = 1,
|
def __init__(self, parent: IRadiant, transmittance: str, emissivity: Union[str, float] = None,
|
||||||
temp: u.Quantity = 0 * u.K, obstruction: float = 0, obstructor_temp: u.Quantity = 0 * u.K,
|
temp: u.Quantity = 0 * u.K, obstruction: float = 0, obstructor_temp: u.Quantity = 0 * u.K,
|
||||||
obstructor_emissivity: float = 1):
|
obstructor_emissivity: float = 1):
|
||||||
"""
|
"""
|
||||||
@ -37,7 +37,12 @@ class Lens(AHotOpticalComponent):
|
|||||||
obstructor_emissivity : float
|
obstructor_emissivity : float
|
||||||
Emissivity of the obstructing component.
|
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)
|
self._transmittance = SpectralQty.fromFile(transmittance, u.nm, u.dimensionless_unscaled)
|
||||||
|
if emissivity is None:
|
||||||
|
emissivity = -1 * self._transmittance + 1.0
|
||||||
super().__init__(parent, emissivity, temp, obstruction, obstructor_temp, obstructor_emissivity)
|
super().__init__(parent, emissivity, temp, obstruction, obstructor_temp, obstructor_emissivity)
|
||||||
|
|
||||||
def _propagate(self, rad: SpectralQty) -> SpectralQty:
|
def _propagate(self, rad: SpectralQty) -> SpectralQty:
|
||||||
@ -72,6 +77,8 @@ class Lens(AHotOpticalComponent):
|
|||||||
The error message of the check. This will be None if the check was successful.
|
The error message of the check. This will be None if the check was successful.
|
||||||
"""
|
"""
|
||||||
mes = conf.check_file("transmittance")
|
mes = conf.check_file("transmittance")
|
||||||
|
if mes is not None:
|
||||||
|
mes = conf.check_float("transmittance")
|
||||||
if mes is not None:
|
if mes is not None:
|
||||||
return mes
|
return mes
|
||||||
if hasattr(conf, "emissivity"):
|
if hasattr(conf, "emissivity"):
|
||||||
|
@ -11,7 +11,7 @@ class Mirror(AHotOpticalComponent):
|
|||||||
A class to model the optical characteristics of a mirror.
|
A class to model the optical characteristics of a mirror.
|
||||||
"""
|
"""
|
||||||
@u.quantity_input(temp=[u.Kelvin, u.Celsius], obstructor_temp=[u.Kelvin, u.Celsius])
|
@u.quantity_input(temp=[u.Kelvin, u.Celsius], obstructor_temp=[u.Kelvin, u.Celsius])
|
||||||
def __init__(self, parent: IRadiant, reflectance: str, emissivity: Union[str, float] = 1,
|
def __init__(self, parent: IRadiant, reflectance: str, emissivity: Union[str, float] = None,
|
||||||
temp: u.Quantity = 0 * u.K, obstruction: float = 0, obstructor_temp: u.Quantity = 0 * u.K,
|
temp: u.Quantity = 0 * u.K, obstruction: float = 0, obstructor_temp: u.Quantity = 0 * u.K,
|
||||||
obstructor_emissivity: float = 1):
|
obstructor_emissivity: float = 1):
|
||||||
"""
|
"""
|
||||||
@ -37,7 +37,12 @@ class Mirror(AHotOpticalComponent):
|
|||||||
obstructor_emissivity : float
|
obstructor_emissivity : float
|
||||||
Emissivity of the obstructing component.
|
Emissivity of the obstructing component.
|
||||||
"""
|
"""
|
||||||
|
try:
|
||||||
|
self._reflectance = float(reflectance) * u.dimensionless_unscaled
|
||||||
|
except ValueError:
|
||||||
self._reflectance = SpectralQty.fromFile(reflectance, u.nm, u.dimensionless_unscaled)
|
self._reflectance = SpectralQty.fromFile(reflectance, u.nm, u.dimensionless_unscaled)
|
||||||
|
if emissivity is None:
|
||||||
|
emissivity = -1 * self._reflectance + 1.0
|
||||||
super().__init__(parent, emissivity, temp, obstruction, obstructor_temp, obstructor_emissivity)
|
super().__init__(parent, emissivity, temp, obstruction, obstructor_temp, obstructor_emissivity)
|
||||||
|
|
||||||
def _propagate(self, rad: SpectralQty) -> SpectralQty:
|
def _propagate(self, rad: SpectralQty) -> SpectralQty:
|
||||||
@ -72,6 +77,8 @@ class Mirror(AHotOpticalComponent):
|
|||||||
The error message of the check. This will be None if the check was successful.
|
The error message of the check. This will be None if the check was successful.
|
||||||
"""
|
"""
|
||||||
mes = conf.check_file("reflectance")
|
mes = conf.check_file("reflectance")
|
||||||
|
if mes is not None:
|
||||||
|
mes = conf.check_float("reflectance")
|
||||||
if mes is not None:
|
if mes is not None:
|
||||||
return mes
|
return mes
|
||||||
if hasattr(conf, "emissivity"):
|
if hasattr(conf, "emissivity"):
|
||||||
|
Loading…
Reference in New Issue
Block a user