ARTS  2.4.0(git:4fb77825)
abs_species_tags.h
Go to the documentation of this file.
1 /* Copyright (C) 2002-2012 Stefan Buehler <sbuehler@ltu.se>
2 
3  This program is free software; you can redistribute it and/or modify it
4  under the terms of the GNU General Public License as published by the
5  Free Software Foundation; either version 2, or (at your option) any
6  later version.
7 
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  GNU General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License
14  along with this program; if not, write to the Free Software
15  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
16  USA. */
17 
32 #ifndef abs_species_h
33 #define abs_species_h
34 
35 #include <stdexcept>
36 #include "array.h"
37 #include "bifstream.h"
38 #include "matpackI.h"
39 #include "mystring.h"
40 
44 class SpeciesTag {
45  public:
48  : mspecies(-1),
49  misotopologue(-1),
50  mlf(0.),
51  muf(0.),
52  mtype(-1),
53  mcia_second(-1),
54  mcia_dataset(-1) { /* Nothing to be done here. */
55  }
56 
57  // Documentation is with implementation.
58  explicit SpeciesTag(String def);
59 
60  // Documentation is with implementation.
61  String Name() const;
62 
64  Index Species() const { return mspecies; }
65 
67  void Species(Index x) { mspecies = x; }
68 
70  Index BathSpecies() const { return mcia_second; }
71 
73  String SpeciesNameMain() const;
74 
76  Numeric SpeciesMass() const;
77 
79  bool IsSpecies(const String& s) const;
80 
82  bool IsIsotopologue(const String& i) const;
83 
87  Index Isotopologue() const { return misotopologue; }
88 
91 
94  Numeric Lf() const { return mlf; }
95 
98  void Lf(Numeric x) { mlf = x; }
99 
102  Numeric Uf() const { return muf; }
103 
106  void Uf(Numeric x) { muf = x; }
107 
109  Index CIASecond() const { return mcia_second; }
110 
113 
115  Index CIADataset() const { return mcia_dataset; }
116 
119 
121 
132  bool operator==(const SpeciesTag& other) const {
133  if (other.mspecies != mspecies) return false;
134  if (other.misotopologue != misotopologue) return false;
135  if (other.mlf != mlf) return false;
136  if (other.muf != muf) return false;
137  if (other.mtype != mtype) return false;
138  if (mtype == TYPE_CIA && (other.mcia_second != mcia_second ||
139  other.mcia_dataset != mcia_dataset))
140  return false;
141  return true;
142  }
143 
147  enum : Index {
155  };
156 
160  Index Type() const { return mtype; }
161 
165  void Type(Index x) { mtype = x; }
166 
168  static bool validIndexForType(Index x) noexcept {
170  return std::any_of(keys.cbegin(), keys.cend(), [x](auto y){return x == y;});
171  }
172 
174  Index string2Type(const String& str) const {
175  if (std::string("TYPE_PLAIN") == str) {
176  return TYPE_PLAIN;
177  } else if (std::string("TYPE_ZEEMAN") == str) {
178  return TYPE_ZEEMAN;
179  } else if (std::string("TYPE_PREDEF") == str) {
180  return TYPE_PREDEF;
181  } else if (std::string("TYPE_CIA") == str) {
182  return TYPE_CIA;
183  } else if (std::string("TYPE_FREE_ELECTRONS") == str) {
184  return TYPE_FREE_ELECTRONS;
185  } else if (std::string("TYPE_PARTICLES") == str) {
186  return TYPE_PARTICLES;
187  } else if (std::string("TYPE_HITRAN_XSEC") == str) {
188  return TYPE_HITRAN_XSEC;
189  } else {
190  return -1;
191  }
192  }
193 
194  private:
197 
199 
204 
206 
208 
210 
212 
228 
230 
232 
234 
236 };
237 
241 ostream& operator<<(ostream& os, const SpeciesTag& ot);
242 
248 
256 
257 //======================================================================
258 // Functions related to species and tags
259 //======================================================================
260 
262 
264 
266  const Index& spec);
267 
269  const Index& spec,
270  const Index& start);
271 
280 Index find_first_species_tg(const ArrayOfArrayOfSpeciesTag& list_of_tags, const SpeciesTag& tag);
281 
283  const String& names);
284 
286 
287 bool is_zeeman(const ArrayOfSpeciesTag& tg);
288 
289 //--------------------------------------------------------------------------------
290 // Functions from ARTS-1-0. Are they still needed?
291 //--------------------------------------------------------------------------------
292 
293 void get_tag_group_index_for_tag_group(Index& tags1_index,
294  const ArrayOfArrayOfSpeciesTag& tags1,
295  const Array<SpeciesTag>& tags2);
296 
297 #endif // abs_species_h
SpeciesTag::SpeciesTag
SpeciesTag()
Default constructor.
Definition: abs_species_tags.h:47
SpeciesTag::Uf
void Uf(Numeric x)
The upper line center frequency in Hz: If this is <0 it means no upper limit.
Definition: abs_species_tags.h:106
SpeciesTag::CIADataset
Index CIADataset() const
CIA dataset index inside this CIA file.
Definition: abs_species_tags.h:115
ArrayOfArrayOfSpeciesTag
Array< ArrayOfSpeciesTag > ArrayOfArrayOfSpeciesTag
Contains the available tag groups.
Definition: abs_species_tags.h:255
SpeciesTag::CIADataset
void CIADataset(Index x)
CIA dataset index inside this CIA file.
Definition: abs_species_tags.h:118
SpeciesTag::Name
String Name() const
Return the full name of the tag.
Definition: abs_species_tags.cc:336
SpeciesTag::BathSpecies
Index BathSpecies() const
Molecular species index.
Definition: abs_species_tags.h:70
ARTS::Var::y
Vector y(Workspace &ws) noexcept
Definition: autoarts.h:7401
ArrayOfSpeciesTag
Array< SpeciesTag > ArrayOfSpeciesTag
A tag group is an array of SpeciesTags.
Definition: abs_species_tags.h:247
SpeciesTag::misotopologue
Index misotopologue
Isotopologue species index.
Definition: abs_species_tags.h:203
array_species_tag_from_string
void array_species_tag_from_string(ArrayOfSpeciesTag &tags, const String &names)
Converts a String to ArrayOfSpeciesTag.
Definition: abs_species_tags.cc:586
SpeciesTag::muf
Numeric muf
The upper line center frequency in Hz.
Definition: abs_species_tags.h:211
SpeciesTag::Type
void Type(Index x)
Return the type of this tag.
Definition: abs_species_tags.h:165
array.h
This file contains the definition of Array.
stdarrayify
constexpr std::array< T, 1+sizeof...(Ts)> stdarrayify(const T &first, const Ts &... the_rest)
Make a std::array of a list of variables (must be 1-long at least)
Definition: array.h:374
SpeciesTag::SpeciesMass
Numeric SpeciesMass() const
Mass of main species.
Definition: abs_species_tags.cc:412
SpeciesTag::string2Type
Index string2Type(const String &str) const
Definition: abs_species_tags.h:174
SpeciesTag::validIndexForType
static bool validIndexForType(Index x) noexcept
Checks if input is a valid Type.
Definition: abs_species_tags.h:168
check_abs_species
void check_abs_species(const ArrayOfArrayOfSpeciesTag &abs_species)
Check the correctness of abs_species.
Definition: abs_species_tags.cc:649
SpeciesTag::operator==
bool operator==(const SpeciesTag &other) const
Comparison operator for species tags.
Definition: abs_species_tags.h:132
matpackI.h
Implementation of Matrix, Vector, and such stuff.
find_next_species_tg
Index find_next_species_tg(const ArrayOfArrayOfSpeciesTag &tgs, const Index &spec, const Index &start)
Find next occurrence of species in tag groups.
Definition: abs_species_tags.cc:555
is_zeeman
bool is_zeeman(const ArrayOfSpeciesTag &tg)
Is this a Zeeman tag group?
Definition: abs_species_tags.cc:702
Array< SpeciesTag >
SpeciesTag
A tag group can consist of the sum of several of these.
Definition: abs_species_tags.h:44
operator<<
ostream & operator<<(ostream &os, const SpeciesTag &ot)
Output operator for SpeciesTag.
Definition: abs_species_tags.cc:447
get_tag_group_name
String get_tag_group_name(const ArrayOfSpeciesTag &tg)
Return the name of a tag group as a string.
Definition: abs_species_tags.cc:464
my_basic_string< char >
SpeciesTag::Uf
Numeric Uf() const
The upper line center frequency in Hz: If this is <0 it means no upper limit.
Definition: abs_species_tags.h:102
SpeciesTag::IsIsotopologue
bool IsIsotopologue(const String &i) const
Check if the isotopologue is same as SpeciesTag(s).Isotopologue()
Definition: abs_species_tags.cc:430
ARTS::Var::abs_species
ArrayOfArrayOfSpeciesTag abs_species(Workspace &ws) noexcept
Definition: autoarts.h:2157
SpeciesTag::mcia_dataset
Index mcia_dataset
CIA dataset index.
Definition: abs_species_tags.h:235
SpeciesTag::TYPE_FREE_ELECTRONS
@ TYPE_FREE_ELECTRONS
Definition: abs_species_tags.h:152
SpeciesTag::CIASecond
Index CIASecond() const
Species index of the 2nd CIA species.
Definition: abs_species_tags.h:109
Numeric
NUMERIC Numeric
The type to use for all floating point numbers.
Definition: matpack.h:33
SpeciesTag::TYPE_ZEEMAN
@ TYPE_ZEEMAN
Definition: abs_species_tags.h:149
find_first_species_tg
Index find_first_species_tg(const ArrayOfArrayOfSpeciesTag &tgs, const Index &spec)
Find first occurrence of species in tag groups.
Definition: abs_species_tags.cc:532
SpeciesTag::mlf
Numeric mlf
The lower limit line center frequency in Hz.
Definition: abs_species_tags.h:207
SpeciesTag::mtype
Index mtype
Type of this tag.
Definition: abs_species_tags.h:227
bifstream.h
This file contains the class declaration of bifstream.
SpeciesTag::Isotopologue
void Isotopologue(Index x)
Isotopologue species index.
Definition: abs_species_tags.h:90
SpeciesTag::Lf
Numeric Lf() const
The lower line center frequency in Hz.
Definition: abs_species_tags.h:94
SpeciesTag::Species
void Species(Index x)
Set molecular species index.
Definition: abs_species_tags.h:67
SpeciesTag::SpeciesNameMain
String SpeciesNameMain() const
Name of main species.
Definition: abs_species_tags.cc:408
SpeciesTag::CIASecond
void CIASecond(Index x)
Species index of the 2nd CIA species.
Definition: abs_species_tags.h:112
Zeeman::start
constexpr Rational start(Rational Ju, Rational Jl, Polarization type) noexcept
Gives the lowest M for a polarization type of this transition.
Definition: zeemandata.h:77
SpeciesTag::TYPE_PLAIN
@ TYPE_PLAIN
Definition: abs_species_tags.h:148
SpeciesTag::mcia_second
Index mcia_second
2nd CIA species index.
Definition: abs_species_tags.h:231
SpeciesTag::IsSpecies
bool IsSpecies(const String &s) const
Check if the species is same as SpeciesTag(s).Species()
Definition: abs_species_tags.cc:426
get_species_name
String get_species_name(const ArrayOfSpeciesTag &tg)
Return the species of a tag group as a string.
Definition: abs_species_tags.cc:497
SpeciesTag::Isotopologue
Index Isotopologue() const
Isotopologue species index.
Definition: abs_species_tags.h:87
SpeciesTag::TYPE_PREDEF
@ TYPE_PREDEF
Definition: abs_species_tags.h:150
SpeciesTag::mspecies
Index mspecies
Molecular species index.
Definition: abs_species_tags.h:196
ARTS::Var::x
Vector x(Workspace &ws) noexcept
Definition: autoarts.h:7346
Index
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:39
get_tag_group_index_for_tag_group
void get_tag_group_index_for_tag_group(Index &tags1_index, const ArrayOfArrayOfSpeciesTag &tags1, const Array< SpeciesTag > &tags2)
Returns the index of the tag group tg2 within the array of tag groups tgs1.
Definition: abs_species_tags.cc:720
SpeciesTag::TYPE_CIA
@ TYPE_CIA
Definition: abs_species_tags.h:151
SpeciesTag::Type
Index Type() const
Return the type of this tag.
Definition: abs_species_tags.h:160
SpeciesTag::TYPE_PARTICLES
@ TYPE_PARTICLES
Definition: abs_species_tags.h:153
SpeciesTag::Species
Index Species() const
Molecular species index.
Definition: abs_species_tags.h:64
SpeciesTag::TYPE_HITRAN_XSEC
@ TYPE_HITRAN_XSEC
Definition: abs_species_tags.h:154
mystring.h
This file contains the definition of String, the ARTS string class.
SpeciesTag::Lf
void Lf(Numeric x)
The lower line center frequency in Hz.
Definition: abs_species_tags.h:98