70 const Index n_xsec = abs_xsec_per_species.
nelem();
75 "The following variables must all have the same dimension:\n"
76 "abs_species: ", n_tgs,
"\n"
77 "abs_xsec_per_species: ", n_xsec,
"\n"
78 "abs_vmrs.nrows: ", nr_vmrs,
"\n")
114 "The following variables must all have the same dimension:\n"
117 "abs_vmrs.ncols: ", nc_vmrs)
128 if (do_freq_jac) dxsec_temp_dF.
resize(f_grid.
nelem());
129 if (do_temp_jac) dxsec_temp_dT.
resize(f_grid.
nelem());
135 for (
Index ii = 0; ii < abs_species_active.
nelem(); ii++) {
136 const Index i = abs_species_active[ii];
138 for (
Index s = 0; s < abs_species[i].
nelem(); s++) {
139 const SpeciesTag& this_species = abs_species[i][s];
142 if (this_species.Type() != Species::TagType::Cia)
continue;
147 abs_cia_data, this_species.Spec(), this_species.cia_2nd_species);
151 const CIARecord& this_cia = abs_cia_data[this_cia_index];
152 Matrix& this_xsec = abs_xsec_per_species[i];
154 if (out2.sufficient_priority()) {
156 out2 <<
" CIA Species found: " + this_species.Name() +
"\n";
162 "Wrong dimension of abs_xsec_per_species.nrows for species ", i,
164 "should match f_grid (", f_grid.
nelem(),
") but is ",
165 this_xsec.
nrows(),
".")
167 "Wrong dimension of abs_xsec_per_species.ncols for species ", i,
169 "should match abs_p (", abs_p.
nelem(),
") but is ",
170 this_xsec.
ncols(),
".")
178 "VMR profile for second species in CIA species pair does not exist.\n"
179 "Tag ", this_species.Name(),
" needs a VMR profile of ",
183 for (
Index ip = 0; ip < abs_p.
nelem(); ip++) {
189 this_species.cia_dataset_index,
194 this_cia.
Extract(dxsec_temp_dF,
197 this_species.cia_dataset_index,
202 this_cia.
Extract(dxsec_temp_dT,
205 this_species.cia_dataset_index,
209 }
catch (
const std::runtime_error& e) {
211 this_species.Name(),
":\n", e.what())
226 this_xsec(
joker, ip) += xsec_temp;
231 for (
Index iv = 0; iv < xsec_temp.
nelem(); iv++) {
232 this_xsec(iv, ip) += n * xsec_temp[iv];
233 for (
Index iq = 0; iq < jacobian_quantities.
nelem();
235 const auto& deriv = jacobian_quantities[iq];
237 if (not deriv.propmattype())
continue;
240 dabs_xsec_per_species_dx[i][iq](iv, ip) +=
241 n * (dxsec_temp_dF[iv] - xsec_temp[iv]) / df;
242 else if (deriv == Jacobian::Atm::Temperature)
243 dabs_xsec_per_species_dx[i][iq](iv, ip) +=
244 n * (dxsec_temp_dT[iv] - xsec_temp[iv]) / dt +
245 xsec_temp[iv] * dn_dT;
247 dabs_xsec_per_species_dx[i][iq](iv, ip) +=
267 const Numeric& rtp_temperature,
272 const Index& ignore_errors,
285 "*rtp_vmr* must match *abs_species*")
287 "*f_grid* must match *propmat_clearsky*")
289 not nq and (nq not_eq dpropmat_clearsky_dx.
nelem()),
290 "*dpropmat_clearsky_dx* must match derived form of *jacobian_quantities*")
292 not nq and
bad_propmat(dpropmat_clearsky_dx, f_grid),
293 "*dpropmat_clearsky_dx* must have frequency dim same as *f_grid*")
295 "Negative frequency (at least one value).")
297 "Must be sorted and increasing.")
299 "Negative VMR (at least one value).")
308 jacobian_quantities);
313 Vector dabs_t{rtp_temperature + dt};
317 for (
Index iv = 0; iv < f_grid.
nelem(); iv++) dfreq[iv] = f_grid[iv] + df;
320 Vector dxsec_temp_dF, dxsec_temp_dT;
325 !std::isnormal(df),
"df must be >0 and not NaN or Inf: ", df)
330 !std::isnormal(dt),
"dt must be >0 and not NaN or Inf: ", dt)
347 for (
Index ispecies = 0; ispecies < ns; ispecies++) {
348 if (select_abs_species.
nelem() and
349 select_abs_species not_eq abs_species[ispecies])
353 if (not abs_species[ispecies].nelem() or abs_species[ispecies].
Zeeman())
358 for (
Index s = 0; s < abs_species[ispecies].
nelem(); ++s) {
359 const SpeciesTag& this_species = abs_species[ispecies][s];
362 if (this_species.Type() != Species::TagType::Cia)
continue;
367 abs_cia_data, this_species.Spec(), this_species.cia_2nd_species);
371 const CIARecord& this_cia = abs_cia_data[this_cia_index];
373 if (out2.sufficient_priority()) {
375 out2 <<
" CIA Species found: " + this_species.Name() +
"\n";
385 "VMR profile for second species in CIA species pair does not exist.\n"
388 " needs a VMR profile of ",
404 this_species.cia_dataset_index,
409 this_cia.
Extract(dxsec_temp_dF,
412 this_species.cia_dataset_index,
418 this_cia.
Extract(dxsec_temp_dT,
420 rtp_temperature + dt,
421 this_species.cia_dataset_index,
426 }
catch (
const std::runtime_error& e) {
428 "Problem with CIA species ", this_species.Name(),
":\n", e.what())
432 xsec_temp *= nd_sec *
number_density(rtp_pressure, rtp_temperature) *
434 propmat_clearsky.
Kjj() += xsec_temp;
441 for (
Index iv = 0; iv < f_grid.
nelem(); iv++) {
442 propmat_clearsky.
Kjj()[iv] +=
443 nd_sec * xsec_temp[iv] * nd * rtp_vmr[ispecies];
444 for (
Index iq = 0; iq < jacobian_quantities.
nelem(); iq++) {
445 const auto& deriv = jacobian_quantities[iq];
447 if (not deriv.propmattype())
continue;
450 dpropmat_clearsky_dx[iq].Kjj()[iv] +=
451 nd_sec * (dxsec_temp_dF[iv] - xsec_temp[iv]) / df * nd *
453 }
else if (deriv == Jacobian::Atm::Temperature) {
454 dpropmat_clearsky_dx[iq].Kjj()[iv] +=
455 ((nd_sec * (dxsec_temp_dT[iv] - xsec_temp[iv]) / dt +
456 xsec_temp[iv] * dnd_dt_sec) *
458 xsec_temp[iv] * nd_sec * dnd_dt) *
460 }
else if (deriv == abs_species[ispecies]) {
461 dpropmat_clearsky_dx[iq].Kjj()[iv] +=
462 nd_sec * xsec_temp[iv] * nd;
464 dpropmat_clearsky_dx[iq].Kjj()[iv] +=
465 nd * nd_sec * xsec_temp[iv] *
466 (this_species.cia_2nd_species == this_species.Spec() ? 2.0
468 }
else if (
species_match(deriv, this_species.cia_2nd_species)) {
469 dpropmat_clearsky_dx[iq].Kjj()[iv] +=
470 nd * nd * xsec_temp[iv] * rtp_vmr[ispecies] *
471 (this_species.cia_2nd_species == this_species.Spec() ? 2.0
485 const String& species_tag,
492 "Invalid species tag ", species_tag,
".\n"
493 "This is not recognized as a CIA type.\n")
495 cia_record.
SetSpecies(species.Spec(), species.cia_2nd_species);
504 const Index& clobber,
510 abs_cia_data.push_back(cia_record);
512 abs_cia_data[cia_index] = cia_record;
514 abs_cia_data[cia_index].AppendDataset(cia_record);
522 const String& catalogpath,
525 subfolders.push_back(
"Main-Folder/");
526 subfolders.push_back(
"Alternate-Folder/");
528 abs_cia_data.resize(0);
533 for (
Index sp = 0; sp < abs_species.
nelem(); sp++) {
534 for (
Index iso = 0; iso < abs_species[sp].
nelem(); iso++) {
535 if (abs_species[sp][iso].Type() != Species::TagType::Cia)
continue;
540 abs_species[sp][iso].Spec(),
541 abs_species[sp][iso].cia_2nd_species);
544 if (cia_index != -1)
continue;
546 cia_names.push_back(
String(Species::toShortName(abs_species[sp][iso].Spec())) +
548 String(Species::toShortName(abs_species[sp][iso].cia_2nd_species)));
551 String(Species::toShortName(abs_species[sp][iso].cia_2nd_species)) +
553 String(Species::toShortName(abs_species[sp][iso].Spec())));
558 for (
Index fname = 0; !found && fname < cia_names.
nelem(); fname++) {
559 String cia_name = cia_names[fname];
561 for (
Index dir = 0; !found && dir < subfolders.
nelem(); dir++) {
563 checked_dirs.push_back(catalogpath +
"/" + subfolders[dir] +
567 }
catch (
const std::runtime_error& e) {
571 for (
Index i = files.
nelem() - 1; i >= 0; i--) {
572 if (files[i].find(cia_name) != 0 ||
573 files[i].rfind(
".cia") != files[i].length() - 4) {
574 files.erase(files.begin() + i);
581 String catfile = *(checked_dirs.end() - 1) + files[0];
584 abs_species[sp][iso].cia_2nd_species);
587 abs_cia_data.push_back(ciar);
593 "Error: No data file found for CIA species ", cia_names[0],
595 "Looked in directories: ", checked_dirs)
612 vector<String> missing_tags;
617 for (
Index sp = 0; sp < abs_species.
nelem(); sp++) {
618 for (
Index iso = 0; iso < abs_species[sp].
nelem(); iso++) {
619 if (abs_species[sp][iso].Type() != Species::TagType::Cia)
continue;
622 abs_species[sp][iso].Spec(),
623 abs_species[sp][iso].cia_2nd_species);
626 if (cia_index == -1) {
627 missing_tags.push_back(
628 String(Species::toShortName(abs_species[sp][iso].Spec())) +
630 String(Species::toShortName(abs_species[sp][iso].cia_2nd_species)));
635 if (missing_tags.size()) {
639 os <<
"Error: The following CIA tag(s) are missing in input file: ";
640 for (
size_t i = 0; i < missing_tags.size(); i++) {
645 os << missing_tags[i];
653 const String& catalogpath,
660 for (
Index i = 0; i < cia_tags.
nelem(); i++) {
665 cia_tags[i].split(species_names,
"-");
668 "ERROR: Cannot parse CIA tag: ", cia_tags[i])
670 this_species_tag.push_back(
671 SpeciesTag(species_names[0] +
"-CIA-" + species_names[1] +
"-0"));
673 species_tags.push_back(this_species_tag);
680 Print(cia_data, 1, verbosity);
690 for (
auto& spec : abs_species) {
691 for (
auto& tag : spec) {
692 if (tag.type == Species::TagType::Cia) {
696 Species::toShortName(tag.cia_2nd_species)));
701 names.erase(std::unique(names.begin(), names.end()), names.end());
703 const std::filesystem::path inpath{basename.c_str()};
704 const bool is_dir = std::filesystem::is_directory(inpath);
706 for (
auto& name : names) {
709 fil /= name +
".xml";
711 fil +=
"." + name +
".xml";
714 if (std::filesystem::is_regular_file(fil)) {
720 "\nIt is required to be there for ",
722 " is found in a tag")
Declarations required for the calculation of absorption coefficients.
The global header file for ARTS.
Constants of physical expressions as constexpr.
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.
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
CIA data for a single pair of molecules.
void SetSpecies(const Species::Species first, const Species::Species second)
Set CIA species.
Species::Species Species(const Index i) const
Return CIA species index.
void ReadFromCIA(const String &filename, const Verbosity &verbosity)
Read CIA catalog file.
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.
Index nrows() const noexcept
Index ncols() const noexcept
Index nelem() const noexcept
Returns the number of elements.
Index NumberOfFrequencies() const
The number of frequencies of the propagation matrix.
VectorView Kjj(const Index iz=0, const Index ia=0)
Vector view to diagonal elements.
void resize(Index n)
Resize function.
Helper macros for debugging.
#define ARTS_ASSERT(condition,...)
#define ARTS_USER_ERROR(...)
std::string var_string(Args &&... args)
#define ARTS_USER_ERROR_IF(condition,...)
ArrayOfString list_directory(const std::string_view dirname)
Return list of files in directory.
This file contains basic functions to handle ASCII files.
bool supports_CIA(const ArrayOfRetrievalQuantity &js)
Returns if the array supports CIA derivatives.
bool is_wind_parameter(const RetrievalQuantity &t) noexcept
Returns if the Retrieval quantity is a wind parameter in propagation matrix calculations.
bool do_frequency_jacobian(const ArrayOfRetrievalQuantity &js) noexcept
Returns if the array wants a frequency derivative.
bool species_match(const RetrievalQuantity &rq, const ArrayOfSpeciesTag &ast)
Returns if the Retrieval quantity is VMR derivative for all the species in the species tags.
bool do_temperature_jacobian(const ArrayOfRetrievalQuantity &js) noexcept
Returns if the array wants the temperature derivative.
bool do_wind_jacobian(const ArrayOfRetrievalQuantity &js) noexcept
Returns if the array wants a wind-based frequency derivative derivative.
bool is_frequency_parameter(const RetrievalQuantity &t) noexcept
Returns if the Retrieval quantity is a frequency parameter in propagation matrix calculations.
Numeric temperature_perturbation(const ArrayOfRetrievalQuantity &js) noexcept
Returns the temperature perturbation if it exists.
Numeric frequency_perturbation(const ArrayOfRetrievalQuantity &js) noexcept
Returns the frequency perturbation if it exists.
bool is_increasing(ConstVectorView x)
Checks if a vector is sorted and strictly increasing.
void abs_cia_dataAddCIARecord(ArrayOfCIARecord &abs_cia_data, const CIARecord &cia_record, const Index &clobber, const Verbosity &)
WORKSPACE METHOD: abs_cia_dataAddCIARecord.
constexpr Numeric SPEED_OF_LIGHT
void abs_cia_dataReadFromXML(ArrayOfCIARecord &abs_cia_data, const ArrayOfArrayOfSpeciesTag &abs_species, const String &filename, const Verbosity &verbosity)
WORKSPACE METHOD: abs_cia_dataReadFromXML.
void propmat_clearskyAddCIA(PropagationMatrix &propmat_clearsky, ArrayOfPropagationMatrix &dpropmat_clearsky_dx, const ArrayOfArrayOfSpeciesTag &abs_species, const ArrayOfSpeciesTag &select_abs_species, const ArrayOfRetrievalQuantity &jacobian_quantities, const Vector &f_grid, const Numeric &rtp_pressure, const Numeric &rtp_temperature, const Vector &rtp_vmr, const ArrayOfCIARecord &abs_cia_data, const Numeric &T_extrapolfac, const Index &ignore_errors, const Verbosity &verbosity)
WORKSPACE METHOD: propmat_clearskyAddCIA.
void abs_xsec_per_speciesAddCIA(ArrayOfMatrix &abs_xsec_per_species, ArrayOfArrayOfMatrix &dabs_xsec_per_species_dx, const ArrayOfArrayOfSpeciesTag &abs_species, const ArrayOfRetrievalQuantity &jacobian_quantities, const ArrayOfIndex &abs_species_active, const Vector &f_grid, const Vector &abs_p, const Vector &abs_t, const Matrix &abs_vmrs, const ArrayOfCIARecord &abs_cia_data, const Numeric &T_extrapolfac, const Index &robust, const Verbosity &verbosity)
void abs_cia_dataReadFromCIA(ArrayOfCIARecord &abs_cia_data, const ArrayOfArrayOfSpeciesTag &abs_species, const String &catalogpath, const Verbosity &verbosity)
WORKSPACE METHOD: abs_cia_dataReadFromCIA.
void CIAInfo(const String &catalogpath, const ArrayOfString &cia_tags, const Verbosity &verbosity)
WORKSPACE METHOD: CIAInfo.
void CIARecordReadFromFile(CIARecord &cia_record, const String &species_tag, const String &filename, const Verbosity &verbosity)
WORKSPACE METHOD: CIARecordReadFromFile.
void abs_cia_dataReadSpeciesSplitCatalog(ArrayOfCIARecord &abs_cia_data, const ArrayOfArrayOfSpeciesTag &abs_species, const String &basename, const Index &robust, const Verbosity &verbosity)
WORKSPACE METHOD: abs_cia_dataReadSpeciesSplitCatalog.
void Print(Workspace &ws, const Agenda &x, const Index &level, const Verbosity &verbosity)
constexpr bool any_negative(const MatpackType &var) noexcept
Checks for negative values.
NUMERIC Numeric
The type to use for all floating point numbers.
INDEX Index
The type to use for all integer numbers and indices.
Declarations having to do with the four output streams.
my_basic_string< char > String
The String type for ARTS.
constexpr Numeric speed_of_light
Speed of light [m/s] From: https://en.wikipedia.org/wiki/2019_redefinition_of_SI_base_units Date: 201...
Implements Zeeman modeling.
This file contains declerations of functions of physical character.
constexpr Numeric dnumber_density_dt(Numeric p, Numeric t) noexcept
dnumber_density_dT
constexpr Numeric number_density(Numeric p, Numeric t) noexcept
number_density
bool bad_propmat(const Array< T > &main, const Vector &f_grid, const Index sd=1) noexcept
Checks if a Propagation Matrix or something similar has good grids.
This file contains basic functions to handle XML data files.
void xml_read_from_file(const String &filename, T &type, const Verbosity &verbosity)
Reads data from XML file.