38 for (
auto& line: abs_lines)
39 line.setF(line.F() + freqeuncy_shift);
47 for (
auto& abs_lines: abs_lines_per_species)
54 const Numeric& relative_line_strength_shift,
56 const auto r = 1.0 + relative_line_strength_shift;
57 for (
auto& line: abs_lines)
58 line.setI0(line.I0() *
r);
64 const Numeric& relative_line_strength_shift,
66 for(
auto& abs_lines: abs_lines_per_species)
74 for (
const auto& rline : replacement_lines) {
77 for (
auto& line : abs_lines) {
78 if (line.QuantumIdentity() == rline.QuantumIdentity()) {
86 os <<
"\"" << rline.QuantumIdentity()
87 <<
"\" is not a unique identifier wrt input catalog\n";
88 throw std::runtime_error(os.str());
97 const String& parameter_name,
99 Index parameter_switch = -1;
101 if (parameter_name.
nelem() == 0)
102 throw std::runtime_error(
"parameter_name is empty.\n");
104 if (replacement_lines.
nelem() == 0)
105 throw std::runtime_error(
"replacement_lines is empty.\n");
107 if (parameter_name ==
"Central Frequency")
108 parameter_switch = 0;
109 else if (parameter_name ==
"Line Strength")
110 parameter_switch = 1;
111 else if (parameter_name ==
"Line Shape Model")
112 parameter_switch = 2;
113 else if (parameter_name ==
"Lower State Energy")
114 parameter_switch = 4;
116 for (
const auto& rline : replacement_lines) {
119 for (
auto& line : abs_lines) {
120 if (line.QuantumIdentity() == rline.QuantumIdentity()) {
123 switch (parameter_switch) {
125 line.setF(rline.F());
128 line.setI0(rline.I0());
131 line.SetLineShapeModel(rline.GetLineShapeModel());
134 line.SetElow(rline.Elow());
138 os <<
"Unsupported paramter_name\n" 140 <<
"\nSee method description for supported parameter names.\n";
141 throw std::runtime_error(os.
str());
153 const String& parameter_name,
155 const Index& relative,
156 const Index& loose_matching,
158 Index parameter_switch = -1;
160 if (parameter_name.
nelem() == 0)
161 throw std::runtime_error(
"parameter_name is empty.\n");
162 else if (parameter_name ==
"Central Frequency" or
163 parameter_name ==
"Line Center")
164 parameter_switch = 0;
165 else if (parameter_name ==
"Line Strength")
166 parameter_switch = 1;
167 else if (parameter_name ==
"Lower State Energy")
168 parameter_switch = 4;
170 for (
auto& line : abs_lines) {
171 if (loose_matching ? QI.
In(line.QuantumIdentity())
172 : line.QuantumIdentity() == QI) {
173 switch (parameter_switch) {
176 line.setF(line.F() + change);
178 line.setF(line.F() * (1.0e0 + change));
182 line.setI0(line.I0() + change);
184 line.setI0(line.I0() * (1.0e0 + change));
188 line.SetElow(line.Elow() + change);
190 line.SetElow(line.Elow() * (1.0e0 + change));
194 os <<
"Usupported paramter_name\n" 196 <<
"\nSee method description for supported parameter names.\n";
197 throw std::runtime_error(os.
str());
208 const String& parameter_name,
210 const Index& loose_matching,
212 Index parameter_switch = -1;
214 if (parameter_name.
nelem() == 0)
215 throw std::runtime_error(
"parameter_name is empty.\n");
216 else if (parameter_name ==
"Central Frequency" or
217 parameter_name ==
"Line Center")
218 parameter_switch = 0;
219 else if (parameter_name ==
"Line Strength")
220 parameter_switch = 1;
221 else if (parameter_name ==
"Lower State Energy")
222 parameter_switch = 4;
224 for (
auto& line : abs_lines) {
225 if (loose_matching ? QI.
In(line.QuantumIdentity())
226 : line.QuantumIdentity() == QI) {
227 switch (parameter_switch) {
229 line.setF(new_value);
232 line.setI0(new_value);
235 line.SetElow(new_value);
239 os <<
"Usupported paramter_name\n" 241 <<
"\nSee method description for supported parameter names.\n";
242 throw std::runtime_error(os.
str());
255 const String& coefficient,
260 for (
auto& lr : abs_lines) {
261 if (QI.
In(lr.QuantumIdentity())) {
262 lr.SetLineShapeModelParameter(new_value, species, parameter, coefficient);
263 if (not any) any =
true;
268 throw std::runtime_error(
269 "You have no matches. This is not accepted as a valid use case. (Is your matching information correct?)\n");
277 const String& coefficient,
280 const Index& relative,
283 for (
auto& lr : abs_lines) {
284 if (QI.
In(lr.QuantumIdentity())) {
285 auto x = lr.GetLineShapeModelParameters(species, parameter);
288 lr.SetLineShapeModelParameter(
289 old * (1 + change), species, parameter, coefficient);
291 lr.SetLineShapeModelParameter(
292 old + change, species, parameter, coefficient);
293 if (not any) any =
true;
299 os <<
"You have no matches. This is not accepted as a valid use case. (Is your matching information correct?)\n";
300 os <<
"MATCHING INFORMATION:\t" << QI <<
'\n';
301 throw std::runtime_error(os.str());
311 const Vector& vibrational_energies,
312 const String& population_type,
316 const bool do_ev = vibrational_energies.
nelem();
319 if (vibrational_energies.
nelem() != nlte_quantum_identifiers.
nelem()) {
321 os <<
"Your vibrational energy levels vector is not the same size as\n" 322 <<
"your *nlte_quantum_identifiers* array. These must be the same\n" 323 <<
"size and the content should match.\n";
324 throw std::runtime_error(os.
str());
332 for (
Index ii = 0; ii < vibrational_energies.
nelem(); ii++) {
333 if (vibrational_energies[ii] < 0) {
335 os <<
"Some of your vibrational energy levels are negative. They should be positive.\n" 336 <<
"Your vibrational levels are:\n" 337 << vibrational_energies;
338 throw std::runtime_error(os.
str());
342 for (
Index qi = 0; qi < nlte_quantum_identifiers.
nelem(); qi++) {
343 auto&
id = nlte_quantum_identifiers[qi];
344 for (
Index s = 0; s < abs_lines_per_species.
nelem(); s++) {
345 if (abs_species[s][0].
Species() !=
346 nlte_quantum_identifiers[qi].Species()) {
356 os <<
"The linerecord:\n" 357 << lr <<
"\nhad the energy state level of " 358 <<
"this quantum identifier:\n" 359 << nlte_quantum_identifiers[qi]
360 <<
"\nset twice by the input quantum identifiers. All levels must " 361 <<
"point at a unique state. " << qi;
362 throw std::runtime_error(os.
str());
366 if (do_ev) lr.
SetEvupp(vibrational_energies[qi]);
373 os <<
"The linerecord:\n" 374 << lr <<
"\nhad the energy state level of " 375 <<
"this quantum identifier:\n" 376 << nlte_quantum_identifiers[qi]
377 <<
"\nset twice by the input quantum identifiers. All levels must " 378 <<
"point at a unique state. " << qi;
379 throw std::runtime_error(os.
str());
383 if (do_ev) lr.
SetEvlow(vibrational_energies[qi]);
395 const Index& nr_f_per_line,
396 const Index& line_nr,
403 f_grid.
resize(lines * nr_f_per_line);
405 f_grid.
resize(nr_f_per_line);
407 out2 <<
" Creating f_grid vector of length " << f_grid.
nelem();
410 throw std::runtime_error(
"You need at least one line to run this code.\n");
411 if (line_nr >= lines)
412 throw std::runtime_error(
413 "You specified a line number that is outside the range of abs_lines.\n");
414 if (nr_f_per_line < 1)
415 throw std::runtime_error(
416 "You need more than 0 frequencies per line to execute this function.\n");
423 if ((abs_lines[line_nr].
F() - half_width) < f_max)
424 throw std::runtime_error(
425 "Frequencies below 0 Hz are not supported by this function.\n");
428 abs_lines[line_nr].
F() - half_width,
429 abs_lines[line_nr].
F() + half_width,
434 for (
Index ii = 0; ii < lines; ii++) {
435 if ((abs_lines[ii].
F() - half_width) < f_max)
436 throw std::runtime_error(
437 "Frequency overlaps are not supported by this function.\n");
439 f_max = abs_lines[ii].F() + half_width;
442 abs_lines[ii].
F() - half_width,
443 abs_lines[ii].
F() + half_width,
445 f_grid[
Range(ii * nr_f_per_line, nr_f_per_line)] = tmp;
456 const Index& nr_f_per_line,
457 const String& species_tag,
461 if (species_tag ==
"")
462 throw std::runtime_error(
"You need at least one tag in this code.\n");
467 for (
Index ii = 0; ii < abs_species.
nelem(); ii++) {
471 if (st[jj] == abs_species[ii][jj])
480 abs_lines_per_species[ii],
490 throw std::runtime_error(
"No frequency set for the given species_tag.\n");
495 const String& quantum_number_name,
496 const Rational& quantum_number_value,
499 const bool for_lower = where < 1;
500 const bool for_upper = where > -1;
501 for (
auto& line : abs_lines) {
503 line.SetQuantumNumberLower(quantum_number_name, quantum_number_value);
505 line.SetQuantumNumberUpper(quantum_number_name, quantum_number_value);
508 out3 <<
"Set " << quantum_number_name <<
" to " << quantum_number_value
510 << ((for_lower and for_upper)
512 : for_lower ?
"the lower level" :
"the upper level")
513 <<
" of all " << abs_lines.nelem() <<
" line(s)\n";
522 else if (option ==
"VVW")
524 else if (option ==
"RosenkranzQuadratic")
526 else if (option ==
"None")
529 throw std::runtime_error(
530 "Cannot understand normalization type option, see builtin documentation for details");
532 for (
LineRecord& line : abs_lines) line.SetLineNormalizationType(a);
539 if (option ==
"Lorentz")
541 else if (option ==
"SameAsLineShape")
543 else if (option ==
"None")
546 throw std::runtime_error(
547 "Cannot understand mirroring type option, see builtin documentation for details");
549 for (
LineRecord& line : abs_lines) line.SetMirroringType(a);
555 if (option < 0 and option not_eq -1)
556 throw std::runtime_error(
"Cannot cutoff frequency");
558 for (
LineRecord& line : abs_lines) line.SetCutOff(option);
569 for (
auto& abs_lines : abs_lines_per_species)
577 for (
auto& abs_lines : abs_lines_per_species)
585 for (
auto& abs_lines : abs_lines_per_species)
593 for (
auto& abs_lines : abs_lines_per_species)
602 for (
const auto& lines : abs_lines_per_species)
603 for (
const auto& line : lines) abs_lines.push_back(line);
INDEX Index
The type to use for all integer numbers and indices.
void abs_lines_per_speciesSetNlteOffForAll(ArrayOfArrayOfLineRecord &abs_lines_per_species, const Verbosity &verbosity)
const QuantumIdentifier & QuantumIdentity() const
Quantum identifier.
void f_gridFromabs_linesSet(Vector &f_grid, const ArrayOfLineRecord &abs_lines, const Numeric &half_width, const Index &nr_f_per_line, const Index &line_nr, const Verbosity &verbosity)
MirroringType
Spectral line catalog data.
void abs_linesRelativeLineStrengthShift(ArrayOfLineRecord &abs_lines, const Numeric &relative_line_strength_shift, const Verbosity &)
void abs_linesSetLineShapeModelParameterForMatchingLines(ArrayOfLineRecord &abs_lines, const QuantumIdentifier &QI, const String ¶meter, const String &coefficient, const String &species, const Numeric &new_value, const Verbosity &)
void abs_linesChangeLineShapeModelParameterForMatchingLines(ArrayOfLineRecord &abs_lines, const QuantumIdentifier &QI, const String ¶meter, const String &coefficient, const String &species, const Numeric &change, const Index &relative, const Verbosity &)
Index nelem() const
Number of elements.
QuantumIdentifier::QType Index LowerQuantumNumbers Species
void f_gridFromabs_lines_per_speciesSetFromSpeciesTag(Vector &f_grid, const ArrayOfArrayOfLineRecord &abs_lines_per_species, const ArrayOfArrayOfSpeciesTag &abs_species, const Numeric &half_width, const Index &nr_f_per_line, const String &species_tag, const Verbosity &verbosity)
void abs_linesCutOffForAll(ArrayOfLineRecord &abs_lines, const Numeric &option, const Verbosity &)
constexpr QuantumIdentifier UpperQuantumId() const noexcept
Return a quantum identifer as if it wants to match to upper energy level.
void VectorNLinSpace(Vector &x, const Index &n, const Numeric &start, const Numeric &stop, const Verbosity &verbosity)
WORKSPACE METHOD: VectorNLinSpace.
void SetNLTEUpperIndex(Index nlte_upper_index)
void abs_linesSetMirroringForAll(ArrayOfLineRecord &abs_lines, const String &option, const Verbosity &)
LinePopulationType LinePopulationTypeFromString(const String &in)
Numeric & SingleModelParameter(ModelParameters &mp, const String &type)
Get a coefficient from ModelParameters by name.
void SetEvupp(Numeric evupp)
void abs_lines_per_speciesSetNormalizationForAll(ArrayOfArrayOfLineRecord &abs_lines_per_species, const String &option, const Verbosity &verbosity)
void abs_lines_per_speciesShiftFrequency(ArrayOfArrayOfLineRecord &abs_lines_per_species, const Numeric &freqeuncy_shift, const Verbosity &verbosity)
Index nelem() const
Returns the number of elements.
void abs_linesSetQuantumNumberForAll(ArrayOfLineRecord &abs_lines, const Index &where, const String &quantum_number_name, const Rational &quantum_number_value, const Verbosity &verbosity)
Contains sorting routines.
void nlteSetByQuantumIdentifiers(Index &nlte_do, ArrayOfArrayOfLineRecord &abs_lines_per_species, const ArrayOfQuantumIdentifier &nlte_quantum_identifiers, const ArrayOfArrayOfSpeciesTag &abs_species, const Vector &vibrational_energies, const String &population_type, const Verbosity &)
void abs_linesReplaceParameterWithLinesParameter(ArrayOfLineRecord &abs_lines, const ArrayOfLineRecord &replacement_lines, const String ¶meter_name, const Verbosity &)
void abs_linesShiftFrequency(ArrayOfLineRecord &abs_lines, const Numeric &freqeuncy_shift, const Verbosity &)
void abs_linesReplaceWithLines(ArrayOfLineRecord &abs_lines, const ArrayOfLineRecord &replacement_lines, const Verbosity &)
_CS_string_type str() const
void SetNLTELowerIndex(Index nlte_lower_index)
void abs_lines_per_speciesRelativeLineStrengthShift(ArrayOfArrayOfLineRecord &abs_lines_per_species, const Numeric &relative_line_strength_shift, const Verbosity &verbosity)
Implements rational numbers to work with other ARTS types.
void SetEvlow(Numeric evlow)
void abs_linesSetNlteOffForAll(ArrayOfLineRecord &abs_lines, const Verbosity &)
void abs_linesFromSplitLines(ArrayOfLineRecord &abs_lines, const ArrayOfArrayOfLineRecord &abs_lines_per_species, const Verbosity &)
Class to identify and match lines by their quantum numbers.
NUMERIC Numeric
The type to use for all floating point numbers.
constexpr QuantumIdentifier LowerQuantumId() const noexcept
Return a quantum identifer as if it wants to match to lower energy level.
Index nelem() const
Number of elements.
Declarations required for the calculation of absorption coefficients.
void abs_linesSetBaseParameterForMatchingLines(ArrayOfLineRecord &abs_lines, const QuantumIdentifier &QI, const String ¶meter_name, const Numeric &new_value, const Index &loose_matching, const Verbosity &)
void abs_linesChangeBaseParameterForMatchingLines(ArrayOfLineRecord &abs_lines, const QuantumIdentifier &QI, const String ¶meter_name, const Numeric &change, const Index &relative, const Index &loose_matching, const Verbosity &)
basic_ostringstream< char, string_char_traits< char >, alloc > ostringstream
This can be used to make arrays out of anything.
void SetLinePopulationType(const LinePopulationType in)
void abs_linesSetNormalizationForAll(ArrayOfLineRecord &abs_lines, const String &option, const Verbosity &)
void resize(Index n)
Resize function.
Index nelem(const Lines &l)
Number of lines.
Index NLTEUpperIndex() const
Index NLTELowerIndex() const
void abs_lines_per_speciesSetMirroringForAll(ArrayOfArrayOfLineRecord &abs_lines_per_species, const String &option, const Verbosity &verbosity)
void abs_lines_per_speciesCutOffForAll(ArrayOfArrayOfLineRecord &abs_lines_per_species, const Numeric &option, const Verbosity &verbosity)
bool In(const QuantumIdentifier &other) const
Return if this is in other.