parameter atran introduced

This commit is contained in:
Lukas Klass 2020-10-02 15:10:34 +02:00
parent 8664d10b17
commit e20e602d94
2 changed files with 57 additions and 19 deletions

View File

@ -24,11 +24,13 @@ This component models the behaviour of an atmosphere which has a spectral transm
Attributes: Attributes:
* | **transmittance:** str * | **transmittance:** str
| The path to the file containing the spectral transmittance coefficients. For details on the required file structure see also :ref:`reading_csv`. If the output of ATRAN is given, the emission parameter is not available. Instead the parameter temp is used for the atmospheric emission. | The path to the file containing the spectral transmittance coefficients. For details on the required file structure see also :ref:`reading_csv`.
* | **atran:** str
| Path to a file containing the output of ATRAN. In this case, the parameter emission is not available. Instead the parameter temp is used for the atmospheric emission.
* | **emission:** str, *optional* * | **emission:** str, *optional*
| The path to the file containing the spectral radiance of the emission. For details on the required file structure see also :ref:`reading_csv`. | The path to the file containing the spectral radiance of the emission. For details on the required file structure see also :ref:`reading_csv`. This option is only available, if the parameter transmittance is given.
* | **temp:** str, *optional* * | **temp:** float, *optional*
| The atmospheric temperature used for black body emission using the complement of the ATRAN tranmittance. | The atmospheric temperature used for black body emission (only available for an ATRAN input).
* | **temp_unit:** str, *optional* = "K" * | **temp_unit:** str, *optional* = "K"
| Unit of the atmospheric temperature used for black body emission using the complement of the ATRAN tranmittance. | Unit of the atmospheric temperature used for black body emission using the complement of the ATRAN tranmittance.

View File

@ -22,17 +22,20 @@ class Atmosphere(AOpticalComponent):
---------- ----------
parent : IRadiant parent : IRadiant
The parent element of the atmosphere from which the electromagnetic radiation is received. The parent element of the atmosphere from which the electromagnetic radiation is received.
This element is usually of type Target or StrayLight.
transmittance : str transmittance : str
Path to the file containing the spectral transmittance-coefficients of the atmosphere. 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()`. The format of the file will be guessed by `astropy.io.ascii.read()`.
atran : str
Path to the ATRAN output file containing the spectral transmittance-coefficients of the atmosphere.
emission : str emission : str
Path to the file containing the spectral radiance of the atmosphere. Path to the file containing the spectral radiance of the atmosphere.
The format of the file will be guessed by `astropy.io.ascii.read()`. The format of the file will be guessed by `astropy.io.ascii.read()`.
temp : u.Quantity
The atmospheric temperature for the atmosphere's black body radiation.
""" """
args = dict() args = dict()
if "temp" in kwargs: if "atran" in kwargs:
args = self._fromATRAN(**kwargs) args = self._fromATRAN(**kwargs)
elif "transmittance" in kwargs: elif "transmittance" in kwargs:
args = self._fromFiles(**kwargs) args = self._fromFiles(**kwargs)
@ -48,13 +51,17 @@ class Atmosphere(AOpticalComponent):
---------- ----------
parent : IRadiant parent : IRadiant
The parent element of the atmosphere from which the electromagnetic radiation is received. The parent element of the atmosphere from which the electromagnetic radiation is received.
This element is usually of type Target or StrayLight.
transmittance : str transmittance : str
Path to the file containing the spectral transmittance-coefficients of the atmosphere. 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()`. The format of the file will be guessed by `astropy.io.ascii.read()`.
emission : str emission : str
Path to the file containing the spectral radiance of the atmosphere. Path to the file containing the spectral radiance of the atmosphere.
The format of the file will be guessed by `astropy.io.ascii.read()`. The format of the file will be guessed by `astropy.io.ascii.read()`.
Returns
-------
args : dict
The arguments for the class instantiation.
""" """
# Read the transmittance # Read the transmittance
transmittance = SpectralQty.fromFile(transmittance, wl_unit_default=u.nm, transmittance = SpectralQty.fromFile(transmittance, wl_unit_default=u.nm,
@ -66,20 +73,39 @@ class Atmosphere(AOpticalComponent):
qty_unit_default=u.W / (u.m ** 2 * u.nm * u.sr)) qty_unit_default=u.W / (u.m ** 2 * u.nm * u.sr))
return {"parent": parent, "transmittance": transmittance, "emission": emission} return {"parent": parent, "transmittance": transmittance, "emission": emission}
def _fromATRAN(self, parent: IRadiant, transmittance: str, temp: u.Quantity): def _fromATRAN(self, parent: IRadiant, atran: str, temp: u.Quantity = None):
transmittance = "data_sofia/atmospheric_transmittance.dat" """
Initialize a new atmosphere model from an ATRAN output file
Parameters
----------
parent : IRadiant
The parent element of the atmosphere from which the electromagnetic radiation is received.
atran : str
Path to the ATRAN output file containing the spectral transmittance-coefficients of the atmosphere.
temp : u.Quantity
The atmospheric temperature for the atmosphere's black body radiation.
Returns
-------
args : dict
The arguments for the class instantiation.
"""
# Read the file # Read the file
data = ascii.read(transmittance, format=None) data = ascii.read(atran, format=None)
# Set units # Set units
data["col2"].unit = u.um data["col2"].unit = u.um
data["col3"].unit = u.dimensionless_unscaled data["col3"].unit = u.dimensionless_unscaled
# Create spectral quantity # Create spectral quantity
transmittance = SpectralQty(data["col2"].quantity, data["col3"].quantity) transmittance = SpectralQty(data["col2"].quantity, data["col3"].quantity)
if temp is not None:
# Create black body # Create black body
bb = self.__gb_factory(temp) bb = self.__gb_factory(temp)
# Calculate emission # Calculate emission
emission = SpectralQty(transmittance.wl, bb(transmittance.wl)) * transmittance emission = SpectralQty(transmittance.wl, bb(transmittance.wl)) * transmittance
else:
emission = 0
return {"parent": parent, "transmittance": transmittance, "emission": emission} return {"parent": parent, "transmittance": transmittance, "emission": emission}
@staticmethod @staticmethod
@ -97,6 +123,7 @@ class Atmosphere(AOpticalComponent):
mes : Union[None, str] mes : Union[None, str]
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.
""" """
if hasattr(conf, "transmittance"):
mes = conf.check_file("transmittance") mes = conf.check_file("transmittance")
if mes is not None: if mes is not None:
return mes return mes
@ -104,6 +131,15 @@ class Atmosphere(AOpticalComponent):
mes = conf.check_file("emission") mes = conf.check_file("emission")
if mes is not None: if mes is not None:
return mes return mes
else:
mes = conf.check_file("atran")
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
@staticmethod @staticmethod
@u.quantity_input(temp=[u.Kelvin, u.Celsius]) @u.quantity_input(temp=[u.Kelvin, u.Celsius])