5 from .base
import Creator, ParamPassThru
6 from .value
import CreatorFlaggedValue
7 from .util
import ExtendedFormatter
10 from refractor
import framework
as rf
12 DEFAULT_REFERENCE_ATM_FILENAME = os.path.join(os.environ.get(
"REFRACTOR_INPUTS",
"$ENV{REFRACTOR_INPUTS}"),
"reference_atmosphere.h5")
18 if self.reference_atm_file()
is not None:
19 if not os.path.exists(self.reference_atm_file()):
20 raise param.ParamError(
"Could not find reference atmosphere file supplied through config: %s" % self.reference_atm_file())
22 ref_atm_data = rf.HdfFile(self.reference_atm_file())
24 if not os.path.exists(DEFAULT_REFERENCE_ATM_FILENAME):
25 raise param.ParamError(
"Could not find default reference atmosphere file: %s" % DEFAULT_REFERENCE_ATM_FILENAME)
27 ref_atm_data = rf.HdfFile(DEFAULT_REFERENCE_ATM_FILENAME)
32 "Creates a VMR apriori for a gas species using the TCCON method" 46 def create(self, gas_name=None, **kwargs):
50 elif gas_name
is None:
51 raise param.ParamError(
"gas_name not supplied to creator %s" % self.__class__.__name__)
54 return apriori_obj.apriori_vmr(self.
pressure())
57 "Creates a VMR apriori for a gas species using the TCCON method" 73 def create(self, gas_name=None, **kwargs):
77 elif gas_name
is None:
78 raise param.ParamError(
"gas_name not supplied to creator %s" % self.__class__.__name__)
80 pressure_levels = self.
pressure().pressure_grid.value.value
83 apriori_obj = rf.GasVmrApriori(pressure_levels, temperature_levels, self.
latitude().value[0], self.
time()[0], \
85 return apriori_obj.apriori_vmr()
88 "Creates a AbsorberVmrLevel that supplies a AbsorberVmr class for use in an creating an Atmosphere" 95 def create(self, gas_name=None, **kwargs):
99 elif gas_name
is None:
100 raise param.ParamError(
"gas_name not supplied to creator %s" % self.__class__.__name__)
109 def create(self, gas_name=None, **kwargs):
112 raise param.ParamError(
"gas_name not supplied to creator %s" % self.__class__.__name__)
114 return rf.AbsorberVmrMet(self.
met(), self.
pressure(), self.
value(gas_name=gas_name)[0], bool(self.
retrieval_flag(gas_name=gas_name)[0]), gas_name)
123 def create(self, gas_name=None, **kwargs):
129 except ValueError
as exc:
132 if not os.path.exists(absco_filename):
133 raise param.ParamError(
"HDF ABSCO filename does not exist: %s" % absco_filename)
137 if np.isscalar(table_scale):
138 return rf.AbscoHdf(absco_filename, table_scale)
140 spectral_bound = self.
spec_win().spectral_bound
143 table_scale_vector = rf.vector_double()
144 for val
in table_scale:
145 table_scale_vector.push_back(val)
147 return rf.AbscoHdf(absco_filename, spectral_bound, table_scale_vector)
150 "Defines the interface expected for VMR config defnition blocks, values are pass through as a dictionary" 156 "Creates an AbsorberAbsco object that statisfies the AtmosphereCreato;rs absorber value" 168 vmrs = rf.vector_absorber_vmr()
169 absorptions = rf.vector_gas_absorption()
171 for gas_name
in self.
gases():
174 gas_def = self.
param(gas_name, gas_name=gas_name)
179 raise param.ParamError(
"No definition for gas %s and no default_gas_defintion block defined" % gas_name)
181 if not "vmr" in gas_def:
182 raise param.ParamError(
"vmr value not in gas definition for gas: %s" % gas_name)
184 if not "absorption" in gas_def:
185 raise param.ParamError(
"absorption value not in gas definition for gas: %s" % gas_name)
187 vmrs.push_back(gas_def[
'vmr'])
188 absorptions.push_back(gas_def[
'absorption'])
def create(self, gas_name=None, kwargs)
def create(self, gas_name=None, kwargs)
def register_parameter(self, param_name, param_def)
def create(self, gas_name=None, kwargs)
def param(self, param_name, kwargs)
def create(self, gas_name=None, kwargs)
def create(self, gas_name=None, kwargs)
def retrieval_flag(self, kwargs)