72 if (out3.sufficient_priority()) {
75 os <<
" f_grid: " << f_grid[0] <<
" - " << f_grid[nf - 1] <<
" Hz\n"
76 <<
" data_f_grid: " << data_f_grid[0] <<
" - "
77 << data_f_grid[data_f_grid.
nelem() - 1] <<
" Hz\n"
78 <<
" temperature: " << temperature <<
" K\n"
79 <<
" data_T_grid: " << data_T_grid[0] <<
" - "
80 << data_T_grid[data_T_grid.
nelem() - 1] <<
" K\n";
91 Index i_fstart, i_fstop;
93 for (i_fstart = 0; i_fstart < nf; ++i_fstart)
94 if (f_grid[i_fstart] >= data_f_grid[0])
break;
97 if (i_fstart == nf)
return;
99 for (i_fstop = nf - 1; i_fstop >= 0; --i_fstop)
100 if (f_grid[i_fstop] <= data_f_grid[data_f_grid.
nelem() - 1])
break;
103 if (i_fstop == -1)
return;
106 const Index f_extent = i_fstop - i_fstart + 1;
108 if (out3.sufficient_priority()) {
110 os <<
" " << f_extent <<
" frequency extraction points starting at "
111 <<
"frequency index " << i_fstart <<
".\n";
118 if (f_extent < 1)
return;
127 constexpr Index f_order = 3;
131 if (data_f_grid.
nelem() < f_order + 1) {
133 os <<
"Not enough frequency grid points in CIA data.\n"
134 <<
"You have only " << data_f_grid.
nelem() <<
" grid points.\n"
135 <<
"But need at least " << f_order + 1 <<
".";
136 throw runtime_error(os.str());
142 switch (data_T_grid.
nelem()) {
171 }
catch (
const std::runtime_error& e) {
179 throw runtime_error(e.what());
185 const auto f_lag = Interpolation::FixedLagrangeVector<f_order>(f_grid_active, data_f_grid);
193 const auto Tnew = std::array<double, 1>{temperature};
195 const auto T_lag = Interpolation::FixedLagrangeVector<1>(Tnew, data_T_grid);
197 }
else if (T_order == 2) {
198 const auto T_lag = Interpolation::FixedLagrangeVector<2>(Tnew, data_T_grid);
200 }
else if (T_order == 3) {
201 const auto T_lag = Interpolation::FixedLagrangeVector<3>(Tnew, data_T_grid);
204 throw std::runtime_error(
"Cannot have this T_order, you must update the code...");
212 for (
Index i = 0; i < result_active.
nelem(); ++i)
213 if (result_active[i] < 0) result_active[i] = 0;
227 const Species::Species sp1,
228 const Species::Species sp2) {
230 if ((cia_data[i].
Species(0) == sp1 && cia_data[i].
Species(1) == sp2) ||
241 const Index& dataset,
252 os <<
"There are only " <<
mdata.
nelem() <<
" datasets in this CIA file.\n"
253 <<
"But you are trying to use dataset " << dataset
254 <<
". (Zero-based indexing.)";
255 throw runtime_error(os.str());
262 result, f_grid, temperature, this_cia, T_extrapolfac, robust, verbosity);
273 return Species::toShortName(
mspecies[i]);
283 Species::Species spec_ind = Species::fromShortName(name);
288 "Species does not exist in ARTS: ", name)
308 out2 <<
" Reading file: " << filename <<
"\n";
342 if (is.eof())
continue;
344 if (line.
nelem() < 100) {
346 os <<
"Error in line " << nline <<
" reading CIA catalog file "
348 <<
"Header line unexpectedly short: " << endl
351 throw runtime_error(os.str());
356 os <<
"Error in line " << nline <<
" reading CIA catalog file "
359 throw runtime_error(os.str());
372 istr >> set_wave_min >> set_wave_max >> set_npoints >> set_temp;
377 os <<
"Error in line " << nline <<
" reading CIA catalog file "
380 throw runtime_error(os.str());
385 if (npoints == -1 || wave_min != set_wave_min || wave_max != set_wave_max) {
388 npoints = set_npoints;
390 wave_min = set_wave_min;
391 wave_max = set_wave_max;
397 if (npoints != set_npoints) {
399 os <<
"Error in line " << nline <<
" reading CIA catalog file "
401 <<
"Inconsistent number of data points. Expected " << npoints
402 <<
", got " << set_npoints;
404 throw runtime_error(os.str());
407 temp.push_back(set_temp);
408 cia.push_back(
Vector(npoints));
412 for (
Index i = 0; i < npoints; i++) {
425 os <<
"Error in line " << nline <<
" reading CIA catalog file "
426 << filename <<
":" << endl
429 throw runtime_error(os.str());
437 cia[nset][i] =
c / 1e10;
445 os <<
"Error in line " << nline <<
" reading CIA catalog file " << filename
448 throw runtime_error(os.str());
477 mdata.push_back(dataset);
496 os <<
"CIARecord output operator not yet implemented." << endl;
Declarations required for the calculation of absorption coefficients.
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.
const Numeric SPEED_OF_LIGHT
ostream & operator<<(ostream &os, const CIARecord &)
Output operator for CIARecord.
Header file for work with HITRAN collision induced absorption (CIA).
This can be used to make arrays out of anything.
Index nelem() const ARTS_NOEXCEPT
Number of elements.
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.
Index nelem() const
Number of elements.
#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 String &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.
void reinterp(VectorView out, const ConstVectorView &iy, const Grid< Vector, 1 > &iw, const Array< Lagrange > &dim0)
constexpr bool isnan(double d) noexcept
invlib::Vector< ArtsVector > Vector
invlib wrapper type for ARTS vectors.