65 assert(result.
nelem() == nf);
71 if (out3.sufficient_priority()) {
74 os <<
" f_grid: " << f_grid[0] <<
" - " << f_grid[nf - 1] <<
" Hz\n" 75 <<
" data_f_grid: " << data_f_grid[0] <<
" - " 76 << data_f_grid[data_f_grid.nelem() - 1] <<
" Hz\n" 77 <<
" temperature: " << temperature <<
" K\n" 78 <<
" data_T_grid: " << data_T_grid[0] <<
" - " 79 << data_T_grid[data_T_grid.
nelem() - 1] <<
" K\n";
90 Index i_fstart, i_fstop;
92 for (i_fstart = 0; i_fstart < nf; ++i_fstart)
93 if (f_grid[i_fstart] >= data_f_grid[0])
break;
96 if (i_fstart == nf)
return;
98 for (i_fstop = nf - 1; i_fstop >= 0; --i_fstop)
99 if (f_grid[i_fstop] <= data_f_grid[data_f_grid.nelem() - 1])
break;
102 if (i_fstop == -1)
return;
105 const Index f_extent = i_fstop - i_fstart + 1;
107 if (out3.sufficient_priority()) {
109 os <<
" " << f_extent <<
" frequency extraction points starting at " 110 <<
"frequency index " << i_fstart <<
".\n";
117 if (f_extent < 1)
return;
126 const Index f_order = 3;
130 if (data_f_grid.nelem() < f_order + 1) {
132 os <<
"Not enough frequency grid points in CIA data.\n" 133 <<
"You have only " << data_f_grid.nelem() <<
" grid points.\n" 134 <<
"But need at least " << f_order + 1 <<
".";
135 throw runtime_error(os.
str());
141 switch (data_T_grid.
nelem()) {
170 }
catch (
const std::runtime_error& e) {
178 throw runtime_error(e.what());
185 gridpos_poly(f_gp, data_f_grid, f_grid_active, f_order);
191 Matrix itw(f_gp.nelem(), f_order + 1);
198 gridpos_poly(T_gp, data_T_grid, temperature, T_order, T_extrapolfac);
201 Tensor3 itw(f_gp.nelem(), T_gp.nelem(), (f_order + 1) * (T_order + 1));
214 interp(result_matrix, itw, cia_data.
data, f_gp, T_gp);
224 if (result_active[
i] < 0) result_active[
i] = 0;
242 (cia_data[
i].Species(0) == sp2 && cia_data[
i].Species(1) == sp1))
252 const Index& dataset,
263 os <<
"There are only " <<
mdata.
nelem() <<
" datasets in this CIA file.\n" 264 <<
"But you are trying to use dataset " << dataset
265 <<
". (Zero-based indexing.)";
266 throw runtime_error(os.
str());
273 result, f_grid, temperature, this_cia, T_extrapolfac, robust, verbosity);
300 os <<
"Species does not exist in ARTS: " << name;
301 throw runtime_error(os.
str());
322 out2 <<
" Reading file: " << filename <<
"\n";
356 if (is.eof())
continue;
358 if (line.
nelem() < 100) {
360 os <<
"Error in line " << nline <<
" reading CIA catalog file " 362 <<
"Header line unexpectedly short: " << endl
365 throw runtime_error(os.
str());
370 os <<
"Error in line " << nline <<
" reading CIA catalog file " 373 throw runtime_error(os.
str());
386 istr >> set_wave_min >> set_wave_max >> set_npoints >> set_temp;
388 if (!istr || std::isnan(set_temp) || std::isnan(set_wave_min) ||
389 std::isnan(set_wave_max)) {
391 os <<
"Error in line " << nline <<
" reading CIA catalog file " 394 throw runtime_error(os.
str());
399 if (npoints == -1 || wave_min != set_wave_min || wave_max != set_wave_max) {
402 npoints = set_npoints;
404 wave_min = set_wave_min;
405 wave_max = set_wave_max;
411 if (npoints != set_npoints) {
413 os <<
"Error in line " << nline <<
" reading CIA catalog file " 415 <<
"Inconsistent number of data points. Expected " << npoints
416 <<
", got " << set_npoints;
418 throw runtime_error(os.
str());
421 temp.push_back(set_temp);
422 cia.push_back(
Vector(npoints));
426 for (
Index i = 0;
i < npoints;
i++) {
437 if (std::isnan(w) || std::isnan(c) || is.bad() || istr.bad()) {
439 os <<
"Error in line " << nline <<
" reading CIA catalog file " 440 << filename <<
":" << endl
443 throw runtime_error(os.
str());
451 cia[nset][
i] = c / 1e10;
459 os <<
"Error in line " << nline <<
" reading CIA catalog file " << filename
462 throw runtime_error(os.
str());
491 mdata.push_back(dataset);
510 os <<
"CIARecord output operator not yet implemented." << endl;
INDEX Index
The type to use for all integer numbers and indices.
Header file for work with HITRAN collision induced absorption (CIA).
Index nelem() const
Number of elements.
QuantumIdentifier::QType Index LowerQuantumNumbers Species
Numeric interp(ConstVectorView itw, ConstVectorView a, const GridPos &tc)
Red 1D Interpolate.
void ReadFromCIA(const String &filename, const Verbosity &verbosity)
Read CIA catalog file.
ArrayOfGriddedField2 mdata
The data itself, directly from the HITRAN file.
Index DatasetCount() const
Return number of datasets in this record.
const GriddedField2 & Dataset(Index dataset) const
Return CIA dataset.
invlib::Vector< ArtsVector > Vector
invlib wrapper type for ARTS vectors.
cmplx FADDEEVA() w(cmplx z, double relerr)
This file contains basic functions to handle ASCII files.
Index nelem() const
Returns the number of elements.
String species_name_from_species_index(const Index spec_ind)
Return species name for given species index.
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.
Index mspecies[2]
The pair of molecules associated with these CIA data.
void AppendDataset(const CIARecord &c2)
Append other CIARecord to this.
_CS_string_type str() const
void set_grid(Index i, const Vector &g)
Set a numeric grid.
void resize(const GriddedField2 &gf)
Make this GriddedField2 the same size as the given one.
const Vector & get_numeric_grid(Index i) const
Get a numeric grid.
NUMERIC Numeric
The type to use for all floating point numbers.
Index nelem() const
Number of elements.
Declarations required for the calculation of absorption coefficients.
void gridpos_poly(ArrayOfGridPosPoly &gp, ConstVectorView old_grid, ConstVectorView new_grid, const Index order, const Numeric &extpolfac)
The maximum difference from 1 that we allow for a sum check.
void SetMoleculeName(const Index i, const String &name)
Set each molecule name (from a string) that is associated with this CIARecord.
Index species_index_from_species_name(String name)
Return species index for given species name.
void open_input_file(ifstream &file, const String &name)
Open a file for reading.
Header file for interpolation_poly.cc.
void resize(Index n)
Resize function.
A constant view of a Vector.
String MoleculeName(const Index i) const
Return each molecule name (as a string) that is associated with this CIARecord.
void set_grid_name(Index i, const String &s)
Set grid name.
CIA data for a single pair of molecules.
Index cia_get_index(const ArrayOfCIARecord &cia_data, const Index sp1, const Index sp2)
Get the index in cia_data for the two given species.
ostream & operator<<(ostream &os, const CIARecord &)
Output operator for CIARecord.
void interpweights(VectorView itw, const GridPos &tc)
Red 1D interpolation weights.
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.
const Numeric SPEED_OF_LIGHT