73 if (out3.sufficient_priority()) {
76 os <<
" f_grid: " << f_grid[0] <<
" - " << f_grid[nf - 1] <<
" Hz\n"
77 <<
" data_f_grid: " << data_f_grid[0] <<
" - "
78 << data_f_grid[data_f_grid.
nelem() - 1] <<
" Hz\n"
79 <<
" temperature: " << temperature <<
" K\n"
80 <<
" data_T_grid: " << data_T_grid[0] <<
" - "
81 << data_T_grid[data_T_grid.
nelem() - 1] <<
" K\n";
92 Index i_fstart, i_fstop;
94 for (i_fstart = 0; i_fstart < nf; ++i_fstart)
95 if (f_grid[i_fstart] >= data_f_grid[0])
break;
98 if (i_fstart == nf)
return;
100 for (i_fstop = nf - 1; i_fstop >= 0; --i_fstop)
101 if (f_grid[i_fstop] <= data_f_grid[data_f_grid.
nelem() - 1])
break;
104 if (i_fstop == -1)
return;
107 const Index f_extent = i_fstop - i_fstart + 1;
109 if (out3.sufficient_priority()) {
111 os <<
" " << f_extent <<
" frequency extraction points starting at "
112 <<
"frequency index " << i_fstart <<
".\n";
119 if (f_extent < 1)
return;
128 constexpr Index f_order = 3;
132 if (data_f_grid.
nelem() < f_order + 1) {
134 os <<
"Not enough frequency grid points in CIA data.\n"
135 <<
"You have only " << data_f_grid.
nelem() <<
" grid points.\n"
136 <<
"But need at least " << f_order + 1 <<
".";
137 throw runtime_error(os.str());
143 switch (data_T_grid.
nelem()) {
172 }
catch (
const std::runtime_error& e) {
180 throw runtime_error(e.what());
186 const auto f_lag = Interpolation::FixedLagrangeVector<f_order>(f_grid_active, data_f_grid);
194 const auto Tnew = std::array<double, 1>{temperature};
196 const auto T_lag = Interpolation::FixedLagrangeVector<1>(Tnew, data_T_grid);
197 result_active = reinterp(cia_data.
data,
interpweights(f_lag, T_lag), f_lag, T_lag).reduce_rank<0>();
198 }
else if (T_order == 2) {
199 const auto T_lag = Interpolation::FixedLagrangeVector<2>(Tnew, data_T_grid);
200 result_active = reinterp(cia_data.
data,
interpweights(f_lag, T_lag), f_lag, T_lag).reduce_rank<0>();
201 }
else if (T_order == 3) {
202 const auto T_lag = Interpolation::FixedLagrangeVector<3>(Tnew, data_T_grid);
203 result_active = reinterp(cia_data.
data,
interpweights(f_lag, T_lag), f_lag, T_lag).reduce_rank<0>();
205 throw std::runtime_error(
"Cannot have this T_order, you must update the code...");
213 for (
Index i = 0; i < result_active.
nelem(); ++i)
214 if (result_active[i] < 0) result_active[i] = 0;
228 const Species::Species sp1,
229 const Species::Species sp2) {
231 if ((cia_data[i].
Species(0) == sp1 && cia_data[i].
Species(1) == sp2) ||
242 const Index& dataset,
253 os <<
"There are only " <<
mdata.
nelem() <<
" datasets in this CIA file.\n"
254 <<
"But you are trying to use dataset " << dataset
255 <<
". (Zero-based indexing.)";
256 throw runtime_error(os.str());
263 result, f_grid, temperature, this_cia, T_extrapolfac, robust, verbosity);
274 return Species::toShortName(
mspecies[i]);
284 Species::Species spec_ind = Species::fromShortName(name);
289 "Species does not exist in ARTS: ", name)
309 out2 <<
" Reading file: " << filename <<
"\n";
343 if (is.eof())
continue;
345 if (line.
nelem() < 100) {
347 os <<
"Error in line " << nline <<
" reading CIA catalog file "
349 <<
"Header line unexpectedly short: " << endl
352 throw runtime_error(os.str());
357 os <<
"Error in line " << nline <<
" reading CIA catalog file "
360 throw runtime_error(os.str());
377 if (!istr || std::isnan(set_temp) || std::isnan(set_wave_min) ||
378 std::isnan(set_wave_max)) {
380 os <<
"Error in line " << nline <<
" reading CIA catalog file "
383 throw runtime_error(os.str());
388 if (npoints == -1 || wave_min != set_wave_min || wave_max != set_wave_max) {
391 npoints = set_npoints;
393 wave_min = set_wave_min;
394 wave_max = set_wave_max;
400 if (npoints != set_npoints) {
402 os <<
"Error in line " << nline <<
" reading CIA catalog file "
404 <<
"Inconsistent number of data points. Expected " << npoints
405 <<
", got " << set_npoints;
407 throw runtime_error(os.str());
410 temp.push_back(set_temp);
411 cia.push_back(
Vector(npoints));
415 for (
Index i = 0; i < npoints; i++) {
426 if (std::isnan(
w) || std::isnan(
c) || is.bad() || istr.bad()) {
428 os <<
"Error in line " << nline <<
" reading CIA catalog file "
429 << filename <<
":" << endl
432 throw runtime_error(os.str());
440 cia[nset][i] =
c / 1e10;
448 os <<
"Error in line " << nline <<
" reading CIA catalog file " << filename
451 throw runtime_error(os.str());
480 mdata.push_back(dataset);
499 os <<
"CIARecord output operator not yet implemented." << endl;
Declarations required for the calculation of absorption coefficients.
Constants of physical expressions as constexpr.
void cia_interpolation(VectorView result, ConstVectorView f_grid, const Numeric &temperature, const GriddedField2 &cia_data, const Numeric &T_extrapolfac, const Index &robust, const Verbosity &verbosity)
Interpolate CIA data.
Index cia_get_index(const ArrayOfCIARecord &cia_data, const Species::Species sp1, const Species::Species sp2)
Get the index in cia_data for the two given species.
constexpr Numeric SPEED_OF_LIGHT
ostream & operator<<(ostream &os, const CIARecord &)
Output operator for CIARecord.
Header file for work with HITRAN collision induced absorption (CIA).
void cia_interpolation(VectorView result, ConstVectorView frequency, const Numeric &temperature, const GriddedField2 &cia_data, const Numeric &T_extrapolfac, const Index &robust, const Verbosity &verbosity)
Interpolate CIA data.
This can be used to make arrays out of anything.
Index nelem() const ARTS_NOEXCEPT
CIA data for a single pair of molecules.
std::array< Species::Species, 2 > mspecies
The pair of molecules associated with these CIA data.
ArrayOfGriddedField2 mdata
The data itself, directly from the HITRAN file.
void AppendDataset(const CIARecord &c2)
Append other CIARecord to this.
void ReadFromCIA(const String &filename, const Verbosity &verbosity)
Read CIA catalog file.
void SetMoleculeName(const Index i, const String &name)
Set each molecule name (from a string) that is associated with this CIARecord.
Index DatasetCount() const
Return number of datasets in this record.
void Extract(VectorView result, ConstVectorView f_grid, const Numeric &temperature, const Index &dataset, const Numeric &T_extrapolfac, const Index &robust, const Verbosity &verbosity) const
Vector version of extract.
String MoleculeName(const Index i) const
Return each molecule name (as a string) that is associated with this CIARecord.
const GriddedField2 & Dataset(Index dataset) const
Return CIA dataset.
A constant view of a Vector.
Index nelem() const noexcept
Returns the number of elements.
void resize(const GriddedField2 &gf)
Make this GriddedField2 the same size as the given one.
void set_grid_name(Index i, const String &s)
Set grid name.
void set_grid(Index i, const Vector &g)
Set a numeric grid.
const Vector & get_numeric_grid(Index i) const
Get a numeric grid.
void resize(Index n)
Resize function.
Input manipulator class for doubles to enable nan and inf parsing.
#define ARTS_ASSERT(condition,...)
#define ARTS_USER_ERROR_IF(condition,...)
constexpr bool good_enum(EnumType x) noexcept
Checks if the enum number is good.
void open_input_file(ifstream &file, const std::string_view name)
Open a file for reading.
This file contains basic functions to handle ASCII files.
void interpweights(VectorView itw, const GridPos &tc)
Red 1D interpolation weights.
NUMERIC Numeric
The type to use for all floating point numbers.
INDEX Index
The type to use for all integer numbers and indices.
constexpr Numeric speed_of_light
Speed of light [m/s] From: https://en.wikipedia.org/wiki/2019_redefinition_of_SI_base_units Date: 201...