from taurex.log import Logger
from taurex.core import Citable
import numpy as np
[docs]class Opacity(Logger, Citable):
"""
This is the base class for computing opactities
"""
[docs] @classmethod
def discover(cls):
"""
Class method, used to discover molecular opacities
of this type.
"""
raise NotImplementedError
[docs] @classmethod
def priority(cls):
return 100
def __init__(self, name):
super().__init__(name)
@property
def resolution(self):
raise NotImplementedError
@property
def moleculeName(self):
raise NotImplementedError
@property
def wavenumberGrid(self):
raise NotImplementedError
@property
def temperatureGrid(self):
raise NotImplementedError
@property
def pressureGrid(self):
raise NotImplementedError
[docs] def compute_opacity(self, temperature, pressure, wngrid=None):
"""
Must return in units of cm2
"""
raise NotImplementedError
[docs] def opacity(self, temperature, pressure, wngrid=None):
if wngrid is None:
wngrid_filter = slice(None)
else:
wngrid_filter = np.where((self.wavenumberGrid >= wngrid.min()) & (
self.wavenumberGrid <= wngrid.max()))[0]
orig = self.compute_opacity(temperature, pressure, wngrid_filter)
if wngrid is None or np.array_equal(self.wavenumberGrid.take(wngrid_filter), wngrid):
return orig
else:
# min_max = (self.wavenumberGrid <= wngrid.max() ) & (self.wavenumberGrid >= wngrid.min())
# total_bins = self.wavenumberGrid[min_max].shape[0]
# if total_bins > wngrid.shape[0]:
# return np.append(np.histogram(self.wavenumberGrid,wngrid, weights=orig)[0]/np.histogram(self.wavenumberGrid,wngrid)[0],0)
# else:
return np.interp(wngrid, self.wavenumberGrid[wngrid_filter], orig)
[docs] def opacityCitation(self):
"""
Citation for the specific molecular opacity (linelist origin etc)
Returns
-------
list of str:
List of string with reference information
"""
return []