ARTS  2.3.1285(git:92a29ea9-dirty)
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 
90  void Isotopologue(Index x) { misotopologue = x; }
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 
112  void CIASecond(Index x) { mcia_second = x; }
113 
115  Index CIADataset() const { return mcia_dataset; }
116 
118  void CIADataset(Index x) { mcia_dataset = x; }
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 
285 void check_abs_species(const ArrayOfArrayOfSpeciesTag& abs_species);
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
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:39
Index misotopologue
Isotopologue species index.
bool is_zeeman(const ArrayOfSpeciesTag &tg)
Is this a Zeeman tag group?
Index find_next_species_tg(const ArrayOfArrayOfSpeciesTag &tgs, const Index &spec, const Index &start)
Find next occurrence of species in tag groups.
void Type(Index x)
Return the type of this tag.
SpeciesTag()
Default constructor.
Index CIADataset() const
CIA dataset index inside this CIA file.
Index CIASecond() const
Species index of the 2nd CIA species.
String Name() const
Return the full name of the tag.
Index Species() const
Molecular species index.
Index Type() const
Return the type of this tag.
void CIASecond(Index x)
Species index of the 2nd CIA species.
void Lf(Numeric x)
The lower line center frequency in Hz.
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.
void CIADataset(Index x)
CIA dataset index inside this CIA file.
Numeric Uf() const
The upper line center frequency in Hz: If this is <0 it means no upper limit.
Numeric mlf
The lower limit line center frequency in Hz.
This file contains the definition of Array.
bool IsSpecies(const String &s) const
Check if the species is same as SpeciesTag(s).Species()
void Uf(Numeric x)
The upper line center frequency in Hz: If this is <0 it means no upper limit.
String get_species_name(const ArrayOfSpeciesTag &tg)
Return the species of a tag group as a string.
This file contains the class declaration of bifstream.
static bool validIndexForType(Index x) noexcept
Checks if input is a valid Type.
Numeric Lf() const
The lower line center frequency in Hz.
Array< ArrayOfSpeciesTag > ArrayOfArrayOfSpeciesTag
Contains the available tag groups.
A tag group can consist of the sum of several of these.
NUMERIC Numeric
The type to use for all floating point numbers.
Definition: matpack.h:33
Numeric SpeciesMass() const
Mass of main species.
Index string2Type(const String &str) const
bool IsIsotopologue(const String &i) const
Check if the isotopologue is same as SpeciesTag(s).Isotopologue()
Index mspecies
Molecular species index.
Numeric muf
The upper line center frequency in Hz.
Implementation of Matrix, Vector, and such stuff.
void array_species_tag_from_string(ArrayOfSpeciesTag &tags, const String &names)
Converts a String to ArrayOfSpeciesTag.
void Species(Index x)
Set molecular species index.
bool operator==(const SpeciesTag &other) const
Comparison operator for species tags.
void Isotopologue(Index x)
Isotopologue species index.
Index mcia_dataset
CIA dataset index.
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
void check_abs_species(const ArrayOfArrayOfSpeciesTag &abs_species)
Check the correctness of abs_species.
Index mtype
Type of this tag.
ostream & operator<<(ostream &os, const SpeciesTag &ot)
Output operator for SpeciesTag.
String SpeciesNameMain() const
Name of main species.
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
Array< SpeciesTag > ArrayOfSpeciesTag
A tag group is an array of SpeciesTags.
Index Isotopologue() const
Isotopologue species index.
Index find_first_species_tg(const ArrayOfArrayOfSpeciesTag &tgs, const Index &spec)
Find first occurrence of species in tag groups.
String get_tag_group_name(const ArrayOfSpeciesTag &tg)
Return the name of a tag group as a string.
Index mcia_second
2nd CIA species index.
This file contains the definition of String, the ARTS string class.
Index BathSpecies() const
Molecular species index.