Try to convert frequencies to wavelength
esbo_ds/ESBO-ETC/pipeline/head This commit looks good Details

This commit is contained in:
Lukas Klass 2020-07-22 11:07:02 +02:00
parent 04a58d3684
commit 3c55434c71
3 changed files with 9 additions and 5 deletions

View File

@ -12,7 +12,7 @@ Attributes:
* | **val:** float
| The value of the minimal wavelength.
* | **val_unit:** str, *optional* = "m"
| The unit of the minimal wavelength. This has to be one of [``m``, ``cm``, ``mm``, ``um``, ``nm``, ``pm``]. The default is ``m``.
| The unit of the minimal wavelength. This has to be one of [``m``, ``cm``, ``mm``, ``um``, ``nm``, ``pm``, ``Hz``, ``kHZ``, ``MHz``, ``GHz``, ``THz``]. The default is ``m``.
wl_max
------
@ -26,7 +26,7 @@ Attributes:
* | **val:** float
| The value of the maximal wavelength.
* | **val_unit:** str, *optional* = "m"
| The unit of the maximal wavelength. This has to be one of [``m``, ``cm``, ``mm``, ``um``, ``nm``, ``pm``]. The default is ``m``.
| The unit of the maximal wavelength. This has to be one of [``m``, ``cm``, ``mm``, ``um``, ``nm``, ``pm``, ``Hz``, ``kHZ``, ``MHz``, ``GHz``, ``THz``]. The default is ``m``.
.. _wl_delta:
@ -42,7 +42,7 @@ Attributes:
* | **val:** float
| The value of the wavelength grid size.
* | **val_unit:** str, *optional* = "m"
| The unit of the wavelength grid size. This has to be one of [``m``, ``cm``, ``mm``, ``um``, ``nm``, ``pm``]. The default is ``m``.
| The unit of the wavelength grid size. This has to be one of [``m``, ``cm``, ``mm``, ``um``, ``nm``, ``pm``, ``Hz``, ``kHZ``, ``MHz``, ``GHz``, ``THz``]. The default is ``m``.
.. _res:

View File

@ -310,7 +310,7 @@ Attributes:
* | **val:** float
| The wavelength of the observed line.
* | **val_unit:** str, *optional* = "m"
| The unit of the observed line wavelength. This has to be on of [``nm``, ``um``, ``mm``, ``cm``, ``m``].
| The unit of the observed line wavelength. This has to be on of [``nm``, ``um``, ``mm``, ``cm``, ``m``, ``Hz``, ``kHZ``, ``MHz``, ``GHz``, ``THz``].
kappa
^^^^^

View File

@ -83,7 +83,11 @@ class Entry(object):
return "Expected parameter '" + name + "' with unit '" + unit.to_string() + "' but got no unit."
if not attr.unit.is_equivalent(unit):
if unit == u.K and attr.unit == u.Celsius:
setattr(self, name, attr.to(u.K, equivalencies=u.temperature()))
setattr(self, name, attr.to(unit, equivalencies=u.temperature()))
setattr(self, name + '_unit', unit.to_string())
elif unit.is_equivalent(u.m) and attr.unit.is_equivalent(u.Hz):
setattr(self, name, attr.to(unit, equivalencies=u.spectral()))
setattr(self, name + '_unit', unit.to_string())
else:
return "Expected parameter '" + name + "' with unit equivalent to '" + unit.to_string() + \
"' but got unit '" + attr.unit.to_string() + "'."