ARTS 2.5.11 (git: 725533f0)
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 "matpack_data.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)
22struct Tag {
24 Index spec_ind{-1};
25
27
28 Numeric lower_freq{-1};
29
31
32 Numeric upper_freq{-1};
33
35 TagType type{TagType::FINAL};
36
38
39 Species cia_2nd_species{Species::FINAL};
40
41 constexpr Tag() noexcept = default;
42
43 // Documentation is with implementation.
44 explicit Tag(std::string_view text);
45
46 constexpr Tag(const IsotopeRecord& isot) noexcept :
47 spec_ind(find_species_index(isot)),
48 type(is_predefined_model(isot) ? TagType::Predefined : TagType::Plain) { /* Nothing to be done here. */
49 }
50
51 // Documentation is with implementation.
52 [[nodiscard]] String Name() const;
53
54 [[nodiscard]] constexpr IsotopeRecord Isotopologue() const noexcept {return spec_ind < 0 ? IsotopeRecord{} : Isotopologues[spec_ind];}
55
56 constexpr void Isotopologue(const IsotopeRecord& ir) ARTS_NOEXCEPT {
57 Index ind = find_species_index(ir);
58 ARTS_ASSERT(ind < 0, "Bad species extracted from: ", ir)
59 spec_ind = ind;
60 }
61
62 [[nodiscard]] constexpr Numeric Mass() const noexcept {return Isotopologue().mass;}
63
64 [[nodiscard]] Numeric Q(Numeric T) const;
65
66 [[nodiscard]] Numeric dQdT(Numeric T) const;
67
68 [[nodiscard]] String FullName() const noexcept {return Isotopologue().FullName();}
69
70 [[nodiscard]] constexpr Species Spec() const noexcept {return Isotopologue().spec;}
71
72 [[nodiscard]] constexpr TagType Type() const noexcept {return type;}
73
74 friend std::ostream& operator<<(std::ostream& os, const Tag& ot) {return os << ot.Name();}
75
76 constexpr bool operator==(const Tag& other) const noexcept {
77 return other.spec_ind == spec_ind and
78 other.lower_freq == lower_freq and
79 other.upper_freq == upper_freq and
80 other.type == type and
81 other.cia_2nd_species == cia_2nd_species;
82 }
83
84 constexpr bool operator!=(const Tag& other) const noexcept {
85 return not operator==(other);
86 }
87
88 [[nodiscard]] constexpr bool is_joker() const ARTS_NOEXCEPT {ARTS_ASSERT(spec_ind >= 0) return Joker == Isotopologue().isotname;}
89};
90} // namespace Species
91
92using SpeciesTagType = Species::TagType;
93
94using SpeciesTag = Species::Tag;
95
96class ArrayOfSpeciesTag final : public Array<SpeciesTag> {
97public:
99 explicit ArrayOfSpeciesTag(Index n) : Array<SpeciesTag>(n) {}
100 ArrayOfSpeciesTag(Index n, const SpeciesTag& fillvalue) : Array<SpeciesTag>(n, fillvalue) {}
103 explicit ArrayOfSpeciesTag(std::vector<SpeciesTag> x) : Array<SpeciesTag>(std::move(x)) {}
104
105 // Assignment operators:
107 std::fill(this->begin(), this->end(), x);
108 return *this;
109 }
110
112 this->resize(A.size());
113 std::copy(A.begin(), A.end(), this->begin());
114 return *this;
115 }
116
118 Array<SpeciesTag>::operator=(std::move(A));
119 return *this;
120 }
121
122 ArrayOfSpeciesTag(std::string_view text);
123
124 friend std::ostream& operator<<(std::ostream& os, const ArrayOfSpeciesTag& ot) {
125 bool first = true;
126 for (auto& x: ot) {if (not first) os << ' '; else first = false; os << x;}
127 return os;
128 }
129
131 [[nodiscard]] Species::Species Species() const ARTS_NOEXCEPT {
132 ARTS_ASSERT(size() not_eq 0, "Invalid ArrayOfSpeciesTag without any species")
133 return operator[](0).Spec();
134 }
135
136// /*! Returns the species of the first elements, it is not allowed to have an empty list calling this */
137 [[nodiscard]] Species::TagType Type() const ARTS_NOEXCEPT {
138 ARTS_ASSERT(size() not_eq 0, "Invalid ArrayOfSpeciesTag without any species")
139 return operator[](0).Type();
140 }
141
142 [[nodiscard]] String Name() const;
143
144 [[nodiscard]] bool Plain() const noexcept {
145 return std::any_of(cbegin(), cend(), [](auto& spec){return spec.Type() == Species::TagType::Plain;});
146 }
147
148 [[nodiscard]] bool Zeeman() const noexcept {
149 return std::any_of(cbegin(), cend(), [](auto& spec){return spec.Type() == Species::TagType::Zeeman;});
150 }
151
152 [[nodiscard]] bool RequireLines() const noexcept {
153 return Plain() or Zeeman();
154 }
155
156 [[nodiscard]] bool FreeElectrons() const noexcept {
157 return std::any_of(cbegin(), cend(), [](auto& spec){return spec.Type() == Species::TagType::FreeElectrons;});
158 }
159
160 [[nodiscard]] bool Particles() const noexcept {
161 return std::any_of(cbegin(), cend(), [](auto& spec){return spec.Type() == Species::TagType::Particles;});
162 }
163};
164
166
169 bool Plain{false},
170 Zeeman{false},
171 Predefined{false},
172 Cia{false},
173 FreeElectrons{false},
174 Particles{false},
175 XsecFit{false};
177 friend std::ostream& operator<<(std::ostream&, SpeciesTagTypeStatus);
178};
179
187Index find_next_species(const ArrayOfArrayOfSpeciesTag& abs_species, Species::Species spec, Index i) noexcept;
188
195Index find_first_species(const ArrayOfArrayOfSpeciesTag& abs_species, Species::Species spec) noexcept;
196
203std::pair<Index, Index> find_first_species_tag(const ArrayOfArrayOfSpeciesTag& abs_species, const SpeciesTag& tag) noexcept;
204
211std::pair<Index, Index> find_first_isotologue(const ArrayOfArrayOfSpeciesTag& abs_species, const SpeciesIsotopeRecord& isot) noexcept;
212
221void check_abs_species(const ArrayOfArrayOfSpeciesTag& abs_species);
222
228std::set<Species::Species> lbl_species(const ArrayOfArrayOfSpeciesTag&) noexcept;
229
230namespace Species {
237Numeric first_vmr(const ArrayOfArrayOfSpeciesTag& abs_species,
238 const Vector& rtp_vmr,
239 const Species spec) ARTS_NOEXCEPT;
240
250Array<Tag> parse_tags(std::string_view text);
251} // namespace Species
252
253#endif // species_tags_h
std::ostream & operator<<(std::ostream &os, AbsorptionCutoffTagTypeStatus val)
This file contains the definition of Array.
ArrayOfSpeciesTag() noexcept
ArrayOfSpeciesTag(ArrayOfSpeciesTag &&A) noexcept
ArrayOfSpeciesTag & operator=(SpeciesTag x)
ArrayOfSpeciesTag & operator=(ArrayOfSpeciesTag &&A) noexcept
friend std::ostream & operator<<(std::ostream &os, const ArrayOfSpeciesTag &ot)
ArrayOfSpeciesTag(const ArrayOfSpeciesTag &A)=default
Species::Species Species() const ARTS_NOEXCEPT
ArrayOfSpeciesTag(Index n, const SpeciesTag &fillvalue)
ArrayOfSpeciesTag(std::vector< SpeciesTag > x)
ArrayOfSpeciesTag & operator=(const ArrayOfSpeciesTag &A)
ArrayOfSpeciesTag(Index n)
This can be used to make arrays out of anything.
Definition array.h:31
Array & operator=(base x)
Definition array.h:58
const SpeciesTag & operator[](const Index n) const
Definition array.h:82
#define ARTS_NOEXCEPT
Definition debug.h:83
#define ARTS_ASSERT(condition,...)
Definition debug.h:86
#define ENUMCLASS(ENUMTYPE, TYPE,...)
Definition enums.h:142
This file contains the definition of String, the ARTS string class.
constexpr Species spec(std::string_view part, std::string_view orig)
Array< Tag > parse_tags(std::string_view text)
Parse a list of species tags into an Array<Tag>
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.
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
constexpr std::string_view Joker
Implements Zeeman modeling.
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
void check_abs_species(const ArrayOfArrayOfSpeciesTag &abs_species)
Species::Tag SpeciesTag
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.
Struct containing all information needed about one isotope.