2020-04-16 09:35:24 +02:00
|
|
|
from .AOpticalComponent import AOpticalComponent
|
|
|
|
from ..IRadiant import IRadiant
|
|
|
|
from ..SpectralQty import SpectralQty
|
2020-05-08 15:06:13 +02:00
|
|
|
from ..Entry import Entry
|
2020-04-14 13:12:33 +02:00
|
|
|
import astropy.units as u
|
2020-05-08 15:06:13 +02:00
|
|
|
from typing import Union
|
2020-04-14 13:12:33 +02:00
|
|
|
|
|
|
|
|
|
|
|
class Atmosphere(AOpticalComponent):
|
|
|
|
"""
|
|
|
|
A class to model the atmosphere including the atmosphere's spectral transmittance and emission.
|
|
|
|
"""
|
2020-04-16 09:35:24 +02:00
|
|
|
|
|
|
|
def __init__(self, parent: IRadiant, transmittance: str, emission: str = None):
|
2020-04-14 13:12:33 +02:00
|
|
|
"""
|
|
|
|
Initialize a new atmosphere model
|
|
|
|
|
|
|
|
Parameters
|
|
|
|
----------
|
2020-04-16 09:35:24 +02:00
|
|
|
parent : IRadiant
|
2020-04-14 13:12:33 +02:00
|
|
|
The parent element of the atmosphere from which the electromagnetic radiation is received.
|
|
|
|
This element is usually of type Target or StrayLight.
|
|
|
|
transmittance : str
|
|
|
|
Path to the file containing the spectral transmittance-coefficients of the atmosphere.
|
|
|
|
The format of the file will be guessed by `astropy.io.ascii.read()`.
|
|
|
|
emission : str
|
|
|
|
Path to the file containing the spectral radiance of the atmosphere.
|
|
|
|
The format of the file will be guessed by `astropy.io.ascii.read()`.
|
|
|
|
"""
|
|
|
|
# Read the transmittance
|
|
|
|
transmittance_sqty = SpectralQty.fromFile(transmittance, wl_unit_default=u.nm,
|
2020-04-16 09:35:24 +02:00
|
|
|
qty_unit_default=u.dimensionless_unscaled)
|
2020-04-14 13:12:33 +02:00
|
|
|
if emission is None:
|
|
|
|
# No emission is given, initialize the super class
|
2020-06-08 11:33:41 +02:00
|
|
|
super().__init__(parent, transmittance_sqty, 0)
|
2020-04-14 13:12:33 +02:00
|
|
|
else:
|
|
|
|
# Read the emission
|
|
|
|
emission_sqty = SpectralQty.fromFile(emission, wl_unit_default=u.nm,
|
2020-04-16 09:35:24 +02:00
|
|
|
qty_unit_default=u.W / (u.m ** 2 * u.nm * u.sr))
|
2020-04-14 13:12:33 +02:00
|
|
|
# Initialize the super class
|
|
|
|
super().__init__(parent, transmittance_sqty, emission_sqty)
|
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:
|
|
|
|
return mes
|
|
|
|
if hasattr(conf, "emission"):
|
|
|
|
mes = conf.check_file("emission")
|
|
|
|
if mes is not None:
|
|
|
|
return mes
|