ARTS 2.5.4 (git: 31ce4f0e)
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 PredefinedLegacy,
18 PredefinedModern,
19 Cia,
21 Particles,
22 XsecFit,
23 NoLines)
24struct Tag {
26 Index spec_ind{-1};
27
29
30 Numeric lower_freq{-1};
31
33
34 Numeric upper_freq{-1};
35
37 TagType type{TagType::FINAL};
38
40
41 Species cia_2nd_species{Species::FINAL};
42
44
45 Index cia_dataset_index{-1};
46
47 constexpr Tag() noexcept = default;
48
49 // Documentation is with implementation.
50 explicit Tag(String def);
51
52 constexpr Tag(const IsotopeRecord& isot) noexcept :
53 spec_ind(find_species_index(isot)),
54 type(is_predefined_model(isot) ? TagType::PredefinedLegacy : TagType::Plain) { /* Nothing to be done here. */
55 }
56
57 // Documentation is with implementation.
58 [[nodiscard]] String Name() const;
59
60 [[nodiscard]] constexpr IsotopeRecord Isotopologue() const noexcept {return spec_ind < 0 ? IsotopeRecord{} : Isotopologues[spec_ind];}
61
62 constexpr void Isotopologue(const IsotopeRecord& ir) ARTS_NOEXCEPT {
63 Index ind = find_species_index(ir);
64 ARTS_ASSERT(ind < 0, "Bad species extracted from: ", ir)
65 spec_ind = ind;
66 }
67
68 [[nodiscard]] constexpr Numeric Mass() const noexcept {return Isotopologue().mass;}
69
70 [[nodiscard]] Numeric Q(Numeric T) const;
71
72 [[nodiscard]] Numeric dQdT(Numeric T) const;
73
74 [[nodiscard]] String FullName() const noexcept {return Isotopologue().FullName();}
75
76 [[nodiscard]] constexpr Species Spec() const noexcept {return Isotopologue().spec;}
77
78 [[nodiscard]] constexpr TagType Type() const noexcept {return type;}
79
80 friend std::ostream& operator<<(std::ostream& os, const Tag& ot) {return os << ot.Name();}
81
82 constexpr bool operator==(const Tag& other) const noexcept {
83 return other.spec_ind == spec_ind and
84 other.lower_freq == lower_freq and
85 other.upper_freq == upper_freq and
86 other.type == type and
87 other.cia_2nd_species == cia_2nd_species and
88 other.cia_dataset_index == cia_dataset_index;
89 }
90
91 constexpr bool operator!=(const Tag& other) const noexcept {
92 return not operator==(other);
93 }
94
95 [[nodiscard]] constexpr bool is_joker() const ARTS_NOEXCEPT {ARTS_ASSERT(spec_ind >= 0) return Joker == Isotopologue().isotname;}
96};
97} // namespace Species
98
99using SpeciesTagType = Species::TagType;
100
101using SpeciesTag = Species::Tag;
102
103class ArrayOfSpeciesTag final : public Array<SpeciesTag> {
104public:
107 ArrayOfSpeciesTag(Index n, const SpeciesTag& fillvalue) : Array<SpeciesTag>(n, fillvalue) {}
110 explicit ArrayOfSpeciesTag(std::vector<SpeciesTag> x) : Array<SpeciesTag>(std::move(x)) {}
111
112 // Assignment operators:
114 std::fill(this->begin(), this->end(), x);
115 return *this;
116 }
118 this->resize(A.size());
119 std::copy(A.begin(), A.end(), this->begin());
120 return *this;
121 }
123 Array<SpeciesTag>::operator=(std::move(A));
124 return *this;
125 }
126
128
129 friend std::ostream& operator<<(std::ostream& os, const ArrayOfSpeciesTag& ot) {
130 bool first = true;
131 for (auto& x: ot) {if (not first) os << ' '; else first = false; os << x;}
132 return os;
133 }
134
136 [[nodiscard]] Species::Species Species() const ARTS_NOEXCEPT {
137 ARTS_ASSERT(size() not_eq 0, "Invalid ArrayOfSpeciesTag without any species")
138 return operator[](0).Spec();
139 }
140
141// /*! Returns the species of the first elements, it is not allowed to have an empty list calling this */
142 [[nodiscard]] Species::TagType Type() const ARTS_NOEXCEPT {
143 ARTS_ASSERT(size() not_eq 0, "Invalid ArrayOfSpeciesTag without any species")
144 return operator[](0).Type();
145 }
146
147 [[nodiscard]] String Name() const;
148
149 [[nodiscard]] bool Plain() const noexcept {
150 return std::any_of(cbegin(), cend(), [](auto& spec){return spec.Type() == Species::TagType::Plain;});
151 }
152
153 [[nodiscard]] bool Zeeman() const noexcept {
154 return std::any_of(cbegin(), cend(), [](auto& spec){return spec.Type() == Species::TagType::Zeeman;});
155 }
156
157 [[nodiscard]] bool RequireLines() const noexcept {
158 return Plain() or Zeeman();
159 }
160
161 [[nodiscard]] bool FreeElectrons() const noexcept {
162 return std::any_of(cbegin(), cend(), [](auto& spec){return spec.Type() == Species::TagType::FreeElectrons;});
163 }
164
165 [[nodiscard]] bool Particles() const noexcept {
166 return std::any_of(cbegin(), cend(), [](auto& spec){return spec.Type() == Species::TagType::Particles;});
167 }
168};
169
171
174 bool Plain{false},
175 Zeeman{false},
176 PredefinedLegacy{false},
177 PredefinedModern{false},
178 Cia{false},
180 Particles{false},
181 XsecFit{false},
182 NoLines{false};
184 friend std::ostream& operator<<(std::ostream&, SpeciesTagTypeStatus);
185};
186
194Index find_next_species(const ArrayOfArrayOfSpeciesTag& abs_species, Species::Species spec, Index i) noexcept;
195
202Index find_first_species(const ArrayOfArrayOfSpeciesTag& abs_species, Species::Species spec) noexcept;
203
210std::pair<Index, Index> find_first_species_tag(const ArrayOfArrayOfSpeciesTag& abs_species, const SpeciesTag& tag) noexcept;
211
218std::pair<Index, Index> find_first_isotologue(const ArrayOfArrayOfSpeciesTag& abs_species, const SpeciesIsotopeRecord& isot) noexcept;
219
228void check_abs_species(const ArrayOfArrayOfSpeciesTag& abs_species);
229
235std::set<Species::Species> lbl_species(const ArrayOfArrayOfSpeciesTag&) noexcept;
236
237namespace Species {
245 const Vector& rtp_vmr,
246 const Species spec) ARTS_NOEXCEPT;
247} // namespace Species
248
249#endif // species_tags_h
This file contains the definition of Array.
ArrayOfSpeciesTag() noexcept
Definition: species_tags.h:105
ArrayOfSpeciesTag(ArrayOfSpeciesTag &&A) noexcept
Definition: species_tags.h:109
ArrayOfSpeciesTag & operator=(SpeciesTag x)
Definition: species_tags.h:113
ArrayOfSpeciesTag & operator=(ArrayOfSpeciesTag &&A) noexcept
Definition: species_tags.h:122
friend std::ostream & operator<<(std::ostream &os, const ArrayOfSpeciesTag &ot)
Definition: species_tags.h:129
ArrayOfSpeciesTag(const ArrayOfSpeciesTag &A)=default
Species::Species Species() const ARTS_NOEXCEPT
Definition: species_tags.h:136
ArrayOfSpeciesTag(Index n, const SpeciesTag &fillvalue)
Definition: species_tags.h:107
ArrayOfSpeciesTag(std::vector< SpeciesTag > x)
Definition: species_tags.h:110
ArrayOfSpeciesTag & operator=(const ArrayOfSpeciesTag &A)
Definition: species_tags.h:117
ArrayOfSpeciesTag(Index n)
Definition: species_tags.h:106
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:125
The Vector class.
Definition: matpackI.h:899
#define ARTS_NOEXCEPT
Definition: debug.h:80
#define ARTS_ASSERT(condition,...)
Definition: debug.h:83
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
void copy(ConstComplexIterator1D origin, const ConstComplexIterator1D &end, ComplexIterator1D target)
Copy data between begin and end to target.
This file contains the definition of String, the ARTS string class.
std::ostream & operator<<(std::ostream &os, const Absorption::Lines &lines)
Online Transmission UseSurfaceRtprop TransmitterReceiverPath FreeElectrons
Definition: arts_options.h:114
Numeric dQdT(Numeric T, const Species::IsotopeRecord &ir)
Definition: partfun.cc:18
Numeric Q(Numeric T, const Species::IsotopeRecord &ir)
Definition: partfun.cc:14
VectorView std(VectorView std, const Vector &y, const ArrayOfVector &ys, const Index start, const Index end_tmp)
Compute the standard deviation of the ranged ys.
Definition: raw.cc:205
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
ENUMCLASS(TagType, unsigned char, Plain, Zeeman, PredefinedLegacy, PredefinedModern, Cia, FreeElectrons, Particles, XsecFit, NoLines) struct Tag
Definition: species_tags.h:14
Implements Zeeman modeling.
Definition: zeemandata.cc:333
constexpr Rational end(Rational Ju, Rational Jl, Polarization type) noexcept
Gives the largest M for a polarization type of this transition.
Definition: zeemandata.h:113
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:99
void check_abs_species(const ArrayOfArrayOfSpeciesTag &abs_species)
Species::Tag SpeciesTag
Definition: species_tags.h:101
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:173
Struct containing all information needed about one isotope.
Definition: isotopologues.h:16