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.
|
||||
"""
|
||||
@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,
|
||||
obstructor_emissivity: float = 1):
|
||||
"""
|
||||
@ -37,7 +37,12 @@ class BeamSplitter(AHotOpticalComponent):
|
||||
obstructor_emissivity : float
|
||||
Emissivity of the obstructing component.
|
||||
"""
|
||||
self._transmittance = SpectralQty.fromFile(transmittance, u.nm, u.dimensionless_unscaled)
|
||||
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
|
||||
super().__init__(parent, emissivity, temp, obstruction, obstructor_temp, obstructor_emissivity)
|
||||
|
||||
def _propagate(self, rad: SpectralQty) -> SpectralQty:
|
||||
@ -73,7 +78,9 @@ class BeamSplitter(AHotOpticalComponent):
|
||||
"""
|
||||
mes = conf.check_file("transmittance")
|
||||
if mes is not None:
|
||||
return mes
|
||||
mes = conf.check_float("transmittance")
|
||||
if mes is not None:
|
||||
return mes
|
||||
if hasattr(conf, "emissivity"):
|
||||
mes = conf.check_file("emissivity")
|
||||
if mes is not None:
|
||||
|
@ -104,7 +104,7 @@ class Filter(AHotOpticalComponent):
|
||||
obstructor_temp, obstructor_emissivity)
|
||||
|
||||
# @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,
|
||||
obstructor_emissivity: float = 1) -> dict:
|
||||
"""
|
||||
@ -136,7 +136,13 @@ class Filter(AHotOpticalComponent):
|
||||
args : dict
|
||||
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,
|
||||
"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"])
|
||||
elif hasattr(conf, "transmittance"):
|
||||
mes = conf.check_file("transmittance")
|
||||
if mes is not None:
|
||||
mes = conf.check_float("transmittance")
|
||||
elif hasattr(conf, "start") and hasattr(conf, "end"):
|
||||
mes = conf.check_quantity("start", u.m)
|
||||
if mes is not None:
|
||||
|
@ -11,7 +11,7 @@ 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] = 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,
|
||||
obstructor_emissivity: float = 1):
|
||||
"""
|
||||
@ -37,7 +37,12 @@ class Lens(AHotOpticalComponent):
|
||||
obstructor_emissivity : float
|
||||
Emissivity of the obstructing component.
|
||||
"""
|
||||
self._transmittance = SpectralQty.fromFile(transmittance, u.nm, u.dimensionless_unscaled)
|
||||
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
|
||||
super().__init__(parent, emissivity, temp, obstruction, obstructor_temp, obstructor_emissivity)
|
||||
|
||||
def _propagate(self, rad: SpectralQty) -> SpectralQty:
|
||||
@ -73,7 +78,9 @@ class Lens(AHotOpticalComponent):
|
||||
"""
|
||||
mes = conf.check_file("transmittance")
|
||||
if mes is not None:
|
||||
return mes
|
||||
mes = conf.check_float("transmittance")
|
||||
if mes is not None:
|
||||
return mes
|
||||
if hasattr(conf, "emissivity"):
|
||||
mes = conf.check_file("emissivity")
|
||||
if mes is not None:
|
||||
|
@ -11,7 +11,7 @@ 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: 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,
|
||||
obstructor_emissivity: float = 1):
|
||||
"""
|
||||
@ -37,7 +37,12 @@ class Mirror(AHotOpticalComponent):
|
||||
obstructor_emissivity : float
|
||||
Emissivity of the obstructing component.
|
||||
"""
|
||||
self._reflectance = SpectralQty.fromFile(reflectance, u.nm, u.dimensionless_unscaled)
|
||||
try:
|
||||
self._reflectance = float(reflectance) * u.dimensionless_unscaled
|
||||
except ValueError:
|
||||
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)
|
||||
|
||||
def _propagate(self, rad: SpectralQty) -> SpectralQty:
|
||||
@ -73,7 +78,9 @@ class Mirror(AHotOpticalComponent):
|
||||
"""
|
||||
mes = conf.check_file("reflectance")
|
||||
if mes is not None:
|
||||
return mes
|
||||
mes = conf.check_float("reflectance")
|
||||
if mes is not None:
|
||||
return mes
|
||||
if hasattr(conf, "emissivity"):
|
||||
mes = conf.check_file("emissivity")
|
||||
if mes is not None:
|
||||
|
Loading…
Reference in New Issue
Block a user