ARTS 2.5.0 (git: 9ee3ac6c)
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 "mystring.h"
9#include "partfun.h"
10
11namespace Species {
12ENUMCLASS(TagType, unsigned char,
13 Plain,
14 Zeeman,
15 Predefined,
16 Cia,
17 FreeElectrons,
18 Particles,
19 HitranXsec,
20 NoLines)
21
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
42
43 Index cia_dataset_index{-1};
44
45 constexpr Tag() noexcept = default;
46
47 // Documentation is with implementation.
48 explicit Tag(String def);
49
50 constexpr Tag(const IsotopeRecord& isot) noexcept :
51 spec_ind(find_species_index(isot)),
52 type(is_predefined_model(isot) ? TagType::Predefined : TagType::Plain) { /* Nothing to be done here. */
53 }
54
55 // Documentation is with implementation.
56 [[nodiscard]] String Name() const;
57
58 [[nodiscard]] constexpr const IsotopeRecord& Isotopologue() const noexcept {return Isotopologues[spec_ind];}
59
60 constexpr void Isotopologue(const IsotopeRecord& ir) ARTS_NOEXCEPT {
61 Index ind = find_species_index(ir);
62 ARTS_ASSERT(ind < 0, "Bad species extracted from: ", ir)
63 spec_ind = ind;
64 }
65
66 [[nodiscard]] constexpr Numeric Mass() const noexcept {return Isotopologue().mass;}
67
68 [[nodiscard]] constexpr Numeric Q(Numeric T) const {return PartitionFunctions::Q(T, Isotopologue());}
69
70 [[nodiscard]] constexpr Numeric dQdT(Numeric T) const {return PartitionFunctions::dQdT(T, Isotopologue());}
71
72 [[nodiscard]] String FullName() const noexcept {return Isotopologue().FullName();}
73
74 [[nodiscard]] constexpr Species Spec() const noexcept {return Isotopologue().spec;}
75
76 [[nodiscard]] constexpr TagType Type() const noexcept {return type;}
77
78 friend std::ostream& operator<<(std::ostream& os, const Tag& ot) {return os << ot.Name();}
79
80 constexpr bool operator==(const Tag& other) const noexcept {
81 return other.spec_ind == spec_ind and
82 other.lower_freq == lower_freq and
83 other.upper_freq == upper_freq and
84 other.type == type and
85 other.cia_2nd_species == cia_2nd_species and
86 other.cia_dataset_index == cia_dataset_index;
87 }
88
89 constexpr bool operator!=(const Tag& other) const noexcept {
90 return not operator==(other);
91 }
92
93 [[nodiscard]] constexpr bool is_joker() const ARTS_NOEXCEPT {ARTS_ASSERT(spec_ind >= 0) return Joker == Isotopologue().isotname;}
94};
95} // namespace Species
96
97using SpeciesTagType = Species::TagType;
98
99using SpeciesTag = Species::Tag;
100
101class ArrayOfSpeciesTag final : public Array<SpeciesTag> {
102public:
105 ArrayOfSpeciesTag(Index n, const SpeciesTag& fillvalue) : Array<SpeciesTag>(n, fillvalue) {}
108
109 // Assignment operators:
111 std::fill(this->begin(), this->end(), x);
112 return *this;
113 }
115 this->resize(A.size());
116 std::copy(A.begin(), A.end(), this->begin());
117 return *this;
118 }
120 Array<SpeciesTag>::operator=(std::move(A));
121 return *this;
122 }
123
125
126 friend std::ostream& operator<<(std::ostream& os, const ArrayOfSpeciesTag& ot) {
127 bool first = true;
128 for (auto& x: ot) {if (not first) os << ' '; else first = false; os << x;}
129 return os;
130 }
131
133 [[nodiscard]] Species::Species Species() const ARTS_NOEXCEPT {
134 ARTS_ASSERT(size() not_eq 0, "Invalid ArrayOfSpeciesTag without any species")
135 return operator[](0).Spec();
136 }
137
138// /*! Returns the species of the first elements, it is not allowed to have an empty list calling this */
139 [[nodiscard]] Species::TagType Type() const ARTS_NOEXCEPT {
140 ARTS_ASSERT(size() not_eq 0, "Invalid ArrayOfSpeciesTag without any species")
141 return operator[](0).Type();
142 }
143
144 [[nodiscard]] String Name() const;
145
146 [[nodiscard]] bool Plain() const noexcept {
147 return std::any_of(cbegin(), cend(), [](auto& spec){return spec.Type() == Species::TagType::Plain;});
148 }
149
150 [[nodiscard]] bool Zeeman() const noexcept {
151 return std::any_of(cbegin(), cend(), [](auto& spec){return spec.Type() == Species::TagType::Zeeman;});
152 }
153
154 [[nodiscard]] bool RequireLines() const noexcept {
155 return Plain() or Zeeman();
156 }
157
158 [[nodiscard]] bool FreeElectrons() const noexcept {
159 return std::any_of(cbegin(), cend(), [](auto& spec){return spec.Type() == Species::TagType::FreeElectrons;});
160 }
161
162 [[nodiscard]] bool Particles() const noexcept {
163 return std::any_of(cbegin(), cend(), [](auto& spec){return spec.Type() == Species::TagType::Particles;});
164 }
165};
166
168
176Index find_next_species(const ArrayOfArrayOfSpeciesTag& abs_species, Species::Species spec, Index i) noexcept;
177
184Index find_first_species(const ArrayOfArrayOfSpeciesTag& abs_species, Species::Species spec) noexcept;
185
192std::pair<Index, Index> find_first_species_tag(const ArrayOfArrayOfSpeciesTag& abs_species, const SpeciesTag& tag) noexcept;
193
200std::pair<Index, Index> find_first_isotologue(const ArrayOfArrayOfSpeciesTag& abs_species, const SpeciesIsotopeRecord& isot) noexcept;
201
210void check_abs_species(const ArrayOfArrayOfSpeciesTag& abs_species);
211
217std::set<Species::Species> lbl_species(const ArrayOfArrayOfSpeciesTag&) noexcept;
218
219#endif // species_tags_h
std::ostream & operator<<(std::ostream &os, const ArrayOfAbsorptionLines &aol)
This file contains the definition of Array.
char * isot
ArrayOfSpeciesTag() noexcept
Definition: species_tags.h:103
ArrayOfSpeciesTag(ArrayOfSpeciesTag &&A) noexcept
Definition: species_tags.h:107
ArrayOfSpeciesTag & operator=(SpeciesTag x)
Definition: species_tags.h:110
ArrayOfSpeciesTag & operator=(ArrayOfSpeciesTag &&A) noexcept
Definition: species_tags.h:119
friend std::ostream & operator<<(std::ostream &os, const ArrayOfSpeciesTag &ot)
Definition: species_tags.h:126
ArrayOfSpeciesTag(const ArrayOfSpeciesTag &A)=default
Species::Species Species() const ARTS_NOEXCEPT
Definition: species_tags.h:133
ArrayOfSpeciesTag(Index n, const SpeciesTag &fillvalue)
Definition: species_tags.h:105
ArrayOfSpeciesTag & operator=(const ArrayOfSpeciesTag &A)
Definition: species_tags.h:114
ArrayOfSpeciesTag(Index n)
Definition: species_tags.h:104
This can be used to make arrays out of anything.
Definition: array.h:107
const SpeciesTag & operator[](const Index n) const
Constant index operator.
Definition: array.h:204
Array & operator=(base x)
Assignment from base type (fill entire Array with this value).
Definition: array.h:158
The Joker class.
Definition: matpackI.h:131
#define ARTS_NOEXCEPT
Definition: debug.h:80
#define ARTS_ASSERT(condition,...)
Definition: debug.h:83
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:39
NUMERIC Numeric
The type to use for all floating point numbers.
Definition: matpack.h:33
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.
char Type type
constexpr Numeric dQdT(Numeric T, const Species::IsotopeRecord &ir)
Definition: partfun.h:143
constexpr Numeric Q(Numeric T, const Species::IsotopeRecord &ir)
Definition: partfun.h:139
ENUMCLASS(TagType, unsigned char, Plain, Zeeman, Predefined, Cia, FreeElectrons, Particles, HitranXsec, NoLines) struct Tag
Definition: species_tags.h:12
constexpr bool is_predefined_model(const IsotopeRecord &ir) noexcept
constexpr std::array Isotopologues
Definition: isotopologues.h:50
constexpr Index find_species_index(const Species spec, const std::string_view isot) noexcept
Implements Zeeman modeling.
Definition: zeemandata.cc:281
constexpr Rational end(Rational Ju, Rational Jl, Polarization type) noexcept
Gives the largest M for a polarization type of this transition.
Definition: zeemandata.h:109
constexpr bool operator==(const QuantumNumbers &a, const QuantumNumbers &b)
Check if all quantum numbers are the same between a and b.
Definition: quantum.h:257
constexpr bool operator!=(const QuantumNumbers &a, const QuantumNumbers &b)
Opposite of operator==()
Definition: quantum.h:277
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:97
void check_abs_species(const ArrayOfArrayOfSpeciesTag &abs_species)
Species::Tag SpeciesTag
Definition: species_tags.h:99
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 containing all information needed about one isotope.
Definition: isotopologues.h:14