ARTS 2.5.10 (git: 2f1c442c)
species_tags.h
Go to the documentation of this file.
1#ifndef species_tags_h
2#define species_tags_h
3
4#include <algorithm>
5#include <set>
6
7#include "array.h"
8#include "enums.h"
9#include "isotopologues.h"
10#include "matpackI.h"
11#include "mystring.h"
12
13namespace Species {
14ENUMCLASS(TagType, unsigned char,
15 Plain,
16 Zeeman,
17 Predefined,
18 Cia,
19 FreeElectrons,
20 Particles,
21 XsecFit,
22 NoLines)
23struct Tag {
25 Index spec_ind{-1};
26
28
29 Numeric lower_freq{-1};
30
32
33 Numeric upper_freq{-1};
34
36 TagType type{TagType::FINAL};
37
39
40 Species cia_2nd_species{Species::FINAL};
41
43
44 Index cia_dataset_index{-1};
45
46 constexpr Tag() noexcept = default;
47
48 // Documentation is with implementation.
49 explicit Tag(String def);
50
51 constexpr Tag(const IsotopeRecord& isot) noexcept :
52 spec_ind(find_species_index(isot)),
53 type(is_predefined_model(isot) ? TagType::Predefined : TagType::Plain) { /* Nothing to be done here. */
54 }
55
56 // Documentation is with implementation.
57 [[nodiscard]] String Name() const;
58
59 [[nodiscard]] constexpr IsotopeRecord Isotopologue() const noexcept {return spec_ind < 0 ? IsotopeRecord{} : Isotopologues[spec_ind];}
60
61 constexpr void Isotopologue(const IsotopeRecord& ir) ARTS_NOEXCEPT {
62 Index ind = find_species_index(ir);
63 ARTS_ASSERT(ind < 0, "Bad species extracted from: ", ir)
64 spec_ind = ind;
65 }
66
67 [[nodiscard]] constexpr Numeric Mass() const noexcept {return Isotopologue().mass;}
68
69 [[nodiscard]] Numeric Q(Numeric T) const;
70
71 [[nodiscard]] Numeric dQdT(Numeric T) const;
72
73 [[nodiscard]] String FullName() const noexcept {return Isotopologue().FullName();}
74
75 [[nodiscard]] constexpr Species Spec() const noexcept {return Isotopologue().spec;}
76
77 [[nodiscard]] constexpr TagType Type() const noexcept {return type;}
78
79 friend std::ostream& operator<<(std::ostream& os, const Tag& ot) {return os << ot.Name();}
80
81 constexpr bool operator==(const Tag& other) const noexcept {
82 return other.spec_ind == spec_ind and
83 other.lower_freq == lower_freq and
84 other.upper_freq == upper_freq and
85 other.type == type and
86 other.cia_2nd_species == cia_2nd_species and
87 other.cia_dataset_index == cia_dataset_index;
88 }
89
90 constexpr bool operator!=(const Tag& other) const noexcept {
91 return not operator==(other);
92 }
93
94 [[nodiscard]] constexpr bool is_joker() const ARTS_NOEXCEPT {ARTS_ASSERT(spec_ind >= 0) return Joker == Isotopologue().isotname;}
95};
96} // namespace Species
97
98using SpeciesTagType = Species::TagType;
99
100using SpeciesTag = Species::Tag;
101
102class ArrayOfSpeciesTag final : public Array<SpeciesTag> {
103public:
106 ArrayOfSpeciesTag(Index n, const SpeciesTag& fillvalue) : Array<SpeciesTag>(n, fillvalue) {}
109 explicit ArrayOfSpeciesTag(std::vector<SpeciesTag> x) : Array<SpeciesTag>(std::move(x)) {}
110
111 // Assignment operators:
113 std::fill(this->begin(), this->end(), x);
114 return *this;
115 }
117 this->resize(A.size());
118 std::copy(A.begin(), A.end(), this->begin());
119 return *this;
120 }
122 Array<SpeciesTag>::operator=(std::move(A));
123 return *this;
124 }
125
127
128 friend std::ostream& operator<<(std::ostream& os, const ArrayOfSpeciesTag& ot) {
129 bool first = true;
130 for (auto& x: ot) {if (not first) os << ' '; else first = false; os << x;}
131 return os;
132 }
133
135 [[nodiscard]] Species::Species Species() const ARTS_NOEXCEPT {
136 ARTS_ASSERT(size() not_eq 0, "Invalid ArrayOfSpeciesTag without any species")
137 return operator[](0).Spec();
138 }
139
140// /*! Returns the species of the first elements, it is not allowed to have an empty list calling this */
141 [[nodiscard]] Species::TagType Type() const ARTS_NOEXCEPT {
142 ARTS_ASSERT(size() not_eq 0, "Invalid ArrayOfSpeciesTag without any species")
143 return operator[](0).Type();
144 }
145
146 [[nodiscard]] String Name() const;
147
148 [[nodiscard]] bool Plain() const noexcept {
149 return std::any_of(cbegin(), cend(), [](auto& spec){return spec.Type() == Species::TagType::Plain;});
150 }
151
152 [[nodiscard]] bool Zeeman() const noexcept {
153 return std::any_of(cbegin(), cend(), [](auto& spec){return spec.Type() == Species::TagType::Zeeman;});
154 }
155
156 [[nodiscard]] bool RequireLines() const noexcept {
157 return Plain() or Zeeman();
158 }
159
160 [[nodiscard]] bool FreeElectrons() const noexcept {
161 return std::any_of(cbegin(), cend(), [](auto& spec){return spec.Type() == Species::TagType::FreeElectrons;});
162 }
163
164 [[nodiscard]] bool Particles() const noexcept {
165 return std::any_of(cbegin(), cend(), [](auto& spec){return spec.Type() == Species::TagType::Particles;});
166 }
167};
168
170
173 bool Plain{false},
174 Zeeman{false},
175 Predefined{false},
176 Cia{false},
177 FreeElectrons{false},
178 Particles{false},
179 XsecFit{false},
180 NoLines{false};
182 friend std::ostream& operator<<(std::ostream&, SpeciesTagTypeStatus);
183};
184
192Index find_next_species(const ArrayOfArrayOfSpeciesTag& abs_species, Species::Species spec, Index i) noexcept;
193
200Index find_first_species(const ArrayOfArrayOfSpeciesTag& abs_species, Species::Species spec) noexcept;
201
208std::pair<Index, Index> find_first_species_tag(const ArrayOfArrayOfSpeciesTag& abs_species, const SpeciesTag& tag) noexcept;
209
216std::pair<Index, Index> find_first_isotologue(const ArrayOfArrayOfSpeciesTag& abs_species, const SpeciesIsotopeRecord& isot) noexcept;
217
226void check_abs_species(const ArrayOfArrayOfSpeciesTag& abs_species);
227
233std::set<Species::Species> lbl_species(const ArrayOfArrayOfSpeciesTag&) noexcept;
234
235namespace Species {
243 const Vector& rtp_vmr,
244 const Species spec) ARTS_NOEXCEPT;
245} // namespace Species
246
247#endif // species_tags_h
std::ostream & operator<<(std::ostream &os, AbsorptionCutoffTagTypeStatus val)
This file contains the definition of Array.
ArrayOfSpeciesTag() noexcept
Definition: species_tags.h:104
ArrayOfSpeciesTag(ArrayOfSpeciesTag &&A) noexcept
Definition: species_tags.h:108
ArrayOfSpeciesTag & operator=(SpeciesTag x)
Definition: species_tags.h:112
ArrayOfSpeciesTag & operator=(ArrayOfSpeciesTag &&A) noexcept
Definition: species_tags.h:121
friend std::ostream & operator<<(std::ostream &os, const ArrayOfSpeciesTag &ot)
Definition: species_tags.h:128
ArrayOfSpeciesTag(const ArrayOfSpeciesTag &A)=default
Species::Species Species() const ARTS_NOEXCEPT
Definition: species_tags.h:135
ArrayOfSpeciesTag(Index n, const SpeciesTag &fillvalue)
Definition: species_tags.h:106
ArrayOfSpeciesTag(std::vector< SpeciesTag > x)
Definition: species_tags.h:109
ArrayOfSpeciesTag & operator=(const ArrayOfSpeciesTag &A)
Definition: species_tags.h:116
ArrayOfSpeciesTag(Index n)
Definition: species_tags.h:105
This can be used to make arrays out of anything.
Definition: array.h:48
Array & operator=(base x)
Definition: array.h:75
const SpeciesTag & operator[](const Index n) const
Definition: array.h:99
The Joker class.
Definition: matpackI.h:126
The Vector class.
Definition: matpackI.h:910
#define ARTS_NOEXCEPT
Definition: debug.h:99
#define ARTS_ASSERT(condition,...)
Definition: debug.h:102
#define ENUMCLASS(ENUMTYPE, TYPE,...)
Definition: enums.h:142
Implementation of Matrix, Vector, and such stuff.
NUMERIC Numeric
The type to use for all floating point numbers.
Definition: matpack.h:33
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:39
This file contains the definition of String, the ARTS string class.
constexpr bool is_predefined_model(const IsotopeRecord &ir) noexcept
constexpr std::array Isotopologues
A list of all ARTS isotopologues, note how the species enum class input HAS to be sorted.
Definition: isotopologues.h:57
Numeric first_vmr(const ArrayOfArrayOfSpeciesTag &abs_species, const Vector &rtp_vmr, const Species spec) ARTS_NOEXCEPT
constexpr Index find_species_index(const Species spec, const std::string_view isot) noexcept
Implements Zeeman modeling.
Definition: zeemandata.cc:333
constexpr bool operator!=(const Rational a, const Rational b) noexcept
Inequality.
Definition: rational.h:645
constexpr bool operator==(const Rational a, const Rational b) noexcept
Equality.
Definition: rational.h:633
std::pair< Index, Index > find_first_isotologue(const ArrayOfArrayOfSpeciesTag &abs_species, const SpeciesIsotopeRecord &isot) noexcept
std::set< Species::Species > lbl_species(const ArrayOfArrayOfSpeciesTag &) noexcept
Species::TagType SpeciesTagType
Definition: species_tags.h:98
void check_abs_species(const ArrayOfArrayOfSpeciesTag &abs_species)
Species::Tag SpeciesTag
Definition: species_tags.h:100
Index find_next_species(const ArrayOfArrayOfSpeciesTag &abs_species, Species::Species spec, Index i) noexcept
Index find_first_species(const ArrayOfArrayOfSpeciesTag &abs_species, Species::Species spec) noexcept
std::pair< Index, Index > find_first_species_tag(const ArrayOfArrayOfSpeciesTag &abs_species, const SpeciesTag &tag) noexcept
Struct to test of an ArrayOfArrayOfSpeciesTag contains a tagtype.
Definition: species_tags.h:172
Struct containing all information needed about one isotope.
Definition: isotopologues.h:16