ARTS  2.4.0(git:4fb77825)
m_linemixing.cc
Go to the documentation of this file.
1 /* Copyright (C) 2020
2  * Richard Larsson <larsson@mps.mpg.de>
3  *
4  * This program is free software; you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License as published by the
6  * Free Software Foundation; either version 2, or (at your option) any
7  * later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
17  * USA. */
18 
31 #include "global_data.h"
32 #include "linemixing_hitran.h"
33 #include "propagationmatrix.h"
34 
35 
39  const String& basedir,
40  const Numeric& linemixinglimit,
41  const Numeric& fmin,
42  const Numeric& fmax,
43  const Numeric& stot,
44  const String& mode,
45  const Verbosity&)
46 {
48 
50  if (mode == "VP") intmode = lm_hitran_2017::ModeOfLineMixing::VP;
51  else if (mode == "VP_Y") intmode = lm_hitran_2017::ModeOfLineMixing::VP_Y;
52  else if (mode == "SDVP") intmode = lm_hitran_2017::ModeOfLineMixing::SDVP;
53  else if (mode == "SDVP_Y") intmode = lm_hitran_2017::ModeOfLineMixing::SDVP_Y;
54  else if (mode == "FullW") intmode = lm_hitran_2017::ModeOfLineMixing::FullW;
55  else if (mode == "VP_W") intmode = lm_hitran_2017::ModeOfLineMixing::VP_W;
56  else throw std::runtime_error("Bad mode, see method instruction for valid arguments");
57 
58  if (abs_species.nelem() not_eq abs_lines_per_species.nelem())
59  throw std::runtime_error("Bad size of input species+lines");
60 
62  lm_hitran_2017::read(abs_hitran_relmat_data, lines, basedir, linemixinglimit, fmin, fmax, stot, intmode);
63  std::for_each(lines.begin(), lines.end(), [](auto& band){band.sort_by_frequency();}); // Sort so largest frequency is last
64  ArrayOfIndex used(lines.nelem(), false);
65 
66  bool emptied=false;
67  for (Index i=0; i<abs_species.nelem(); i++) {
68 
69  for (Index j=0; j<abs_species[i].nelem(); j++) {
70  if (abs_species[i][j].Species() not_eq SpeciesTag("CO2").Species())
71  continue;
72 
73  if (not emptied) {
74  abs_lines_per_species[i].resize(0);
75  emptied = true;
76  }
77 
78  for (Index k=0; k<lines.nelem(); k++) {
79  if (used[k]) continue;
80 
81  const Numeric lf{abs_species[i][j].Lf() > 0 ? abs_species[i][j].Lf() : -std::numeric_limits<Numeric>::max()};
82  const Numeric uf{abs_species[i][j].Uf() > 0 ? abs_species[i][j].Uf() : std::numeric_limits<Numeric>::max()};
83 
84  // Select lines with correct Isotopologue and one line center within the range
85  if ((abs_species[i][j].Isotopologue() == lines[k].Isotopologue() or
87  (lines[k].AllLines().front().F0() <= uf and lines[k].AllLines().back().F0() >= lf)) {
88  used[k] = true; // The lines should not be copied into other places
89  abs_lines_per_species[i].push_back(lines[k]);
90  }
91  }
92  }
93  }
94 }
95 
99  const Vector& f_grid,
103  const Numeric& rtp_pressure,
104  const Numeric& rtp_temperature,
105  const Vector& rtp_vmr,
106  const Verbosity&)
107 {
108  if (jacobian_quantities.nelem())
109  throw std::runtime_error("Cannot support any Jacobian at this time");
110  if (abs_species.nelem() not_eq abs_lines_per_species.nelem())
111  throw std::runtime_error("Bad size of input species+lines");
112  if (abs_species.nelem() not_eq rtp_vmr.nelem())
113  throw std::runtime_error("Bad size of input species+vmrs");
114 
115  // vmrs should be [air, water, co2]
116  Vector vmrs(3, 0);
117  for (Index i=0; i<abs_species.nelem(); i++) {
118  auto& specs = abs_species[i];
119  for (auto& spec: specs) {
120  if (SpeciesTag("H2O").Species() == spec.Species()) {
121  vmrs[1] = rtp_vmr[i];
122  }
123  else if (SpeciesTag("CO2").Species() == spec.Species()) {
124  vmrs[2] = rtp_vmr[i];
125  }
126  }
127  }
128  vmrs[0] = 1 - vmrs[1] - vmrs[2];
129 
130  for (Index i=0; i<abs_species.nelem(); i++) {
131  if (abs_lines_per_species[i].nelem() and
133  abs_lines_per_species[i].front().Population() == Absorption::PopulationType::ByHITRANRosenkranzRelmat))
135  }
136 }
ARTS::Var::jacobian_quantities
ArrayOfRetrievalQuantity jacobian_quantities(Workspace &ws) noexcept
Definition: autoarts.h:3924
ARTS::Var::abs_hitran_relmat_data
HitranRelaxationMatrixData abs_hitran_relmat_data(Workspace &ws) noexcept
Definition: autoarts.h:2006
lm_hitran_2017::ModeOfLineMixing
ModeOfLineMixing
Class that controls ReadFromLineMixingStream output.
Definition: linemixing_hitran.h:106
ARTS::Var::abs_lines_per_species
ArrayOfArrayOfAbsorptionLines abs_lines_per_species(Workspace &ws) noexcept
Definition: autoarts.h:2022
ARTS::Var::rtp_vmr
Vector rtp_vmr(Workspace &ws) noexcept
Definition: autoarts.h:5826
Species
QuantumIdentifier::QType Index LowerQuantumNumbers Species
Definition: arts_api_classes.cc:255
lm_hitran_2017::read
void read(HitranRelaxationMatrixData &hitran, ArrayOfAbsorptionLines &bands, const String &basedir, const Numeric linemixinglimit, const Numeric fmin, const Numeric fmax, const Numeric stot, const ModeOfLineMixing mode)
Read from HITRAN online line mixing file.
Definition: linemixing_hitran.cc:1940
global_data::species_data
const Array< SpeciesRecord > species_data
Species Data.
Definition: partition_function_data.cc:42
SpeciesAuxData
Auxiliary data for isotopologues.
Definition: absorption.h:217
Array
This can be used to make arrays out of anything.
Definition: array.h:108
SpeciesTag
A tag group can consist of the sum of several of these.
Definition: abs_species_tags.h:44
Absorption::nelem
Index nelem(const Lines &l)
Number of lines.
Definition: absorptionlines.h:1820
HitranRelaxationMatrixData
Definition: linemixing_hitran.h:38
my_basic_string< char >
lm_hitran_2017::ModeOfLineMixing::VP
@ VP
ARTS::Var::abs_species
ArrayOfArrayOfSpeciesTag abs_species(Workspace &ws) noexcept
Definition: autoarts.h:2157
Numeric
NUMERIC Numeric
The type to use for all floating point numbers.
Definition: matpack.h:33
Verbosity
Definition: messages.h:49
global_data.h
ARTS::Var::f_grid
Vector f_grid(Workspace &ws) noexcept
Definition: autoarts.h:3449
max
#define max(a, b)
Definition: legacy_continua.cc:20629
propagationmatrix.h
Stuff related to the propagation matrix.
ARTS::Var::rtp_pressure
Numeric rtp_pressure(Workspace &ws) noexcept
Definition: autoarts.h:5790
abs_hitran_relmat_dataReadHitranRelmatDataAndLines
void abs_hitran_relmat_dataReadHitranRelmatDataAndLines(HitranRelaxationMatrixData &abs_hitran_relmat_data, ArrayOfArrayOfAbsorptionLines &abs_lines_per_species, const ArrayOfArrayOfSpeciesTag &abs_species, const String &basedir, const Numeric &linemixinglimit, const Numeric &fmin, const Numeric &fmax, const Numeric &stot, const String &mode, const Verbosity &)
WORKSPACE METHOD: abs_hitran_relmat_dataReadHitranRelmatDataAndLines.
Definition: m_linemixing.cc:36
propmat_clearskyAddHitranLineMixingLines
void propmat_clearskyAddHitranLineMixingLines(ArrayOfPropagationMatrix &propmat_clearsky, const HitranRelaxationMatrixData &abs_hitran_relmat_data, const ArrayOfArrayOfAbsorptionLines &abs_lines_per_species, const Vector &f_grid, const ArrayOfArrayOfSpeciesTag &abs_species, const ArrayOfRetrievalQuantity &jacobian_quantities, const SpeciesAuxData &partition_functions, const Numeric &rtp_pressure, const Numeric &rtp_temperature, const Vector &rtp_vmr, const Verbosity &)
WORKSPACE METHOD: propmat_clearskyAddHitranLineMixingLines.
Definition: m_linemixing.cc:96
Isotopologue
QuantumIdentifier::QType Isotopologue
Definition: arts_api_classes.cc:242
ARTS::Var::rtp_temperature
Numeric rtp_temperature(Workspace &ws) noexcept
Definition: autoarts.h:5807
ARTS::Var::partition_functions
SpeciesAuxData partition_functions(Workspace &ws) noexcept
Definition: autoarts.h:4860
lm_hitran_2017::compute
Vector compute(const Numeric p, const Numeric t, const Numeric xco2, const Numeric xh2o, const ConstVectorView invcm_grid, const Numeric stotmax, const calctype type)
Definition: linemixing_hitran.cc:1882
Index
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:39
F0
G0 G2 FVC Y DV F0
Definition: arts_api_classes.cc:218
Vector
The Vector class.
Definition: matpackI.h:860
ARTS::Var::propmat_clearsky
ArrayOfPropagationMatrix propmat_clearsky(Workspace &ws) noexcept
Definition: autoarts.h:5398
Array::nelem
Index nelem() const
Number of elements.
Definition: array.h:195
Absorption::PopulationType::ByLTE
@ ByLTE
LineShape::vmrs
Vector vmrs(const ConstVectorView &atmospheric_vmrs, const ArrayOfArrayOfSpeciesTag &atmospheric_species, const QuantumIdentifier &self, const ArrayOfSpeciesTag &lineshape_species, bool self_in_list, bool bath_in_list, Type type)
Returns a VMR vector for this model's main calculations.
Definition: lineshapemodel.cc:474
linemixing_hitran.h
Namespace and functions to deal with HITRAN linemixing.