ARTS  2.2.66
test_quantum.cc
Go to the documentation of this file.
1 /* Copyright (C) 2003-2012 Oliver Lemke <olemke@core-dump.info>
2 
3  This program is free software; you can redistribute it and/or
4  modify it under the terms of the GNU General Public License as
5  published by the Free Software Foundation; either version 2 of the
6  License, or (at your option) any 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 
18 #include <iostream>
19 #include "arts.h"
20 #include "auto_md.h"
21 #include "matpackII.h"
22 #include "m_xml.h"
23 #include "xml_io.h"
24 #include "exceptions.h"
25 #include "absorption.h"
26 
27 int
28 main (int /*argc*/, char * /*argv*/ [])
29 {
30  try {
32  QuantumNumbers q2;
33 
34  q1.Set(QN_J, Rational(1,2));
35  q1.Set(QN_S, Rational(1,2));
36 
37  q2.Set(QN_J, Rational(1,2));
38  q2.Set(QN_N, Rational(1,3));
39  q2.Set(QN_S, Rational(1,2));
40 
41  cout << "Compare q1==q2: " << q1.Compare(q2) << endl;
42  cout << "Compare q2==q1: " << q2.Compare(q1) << endl;
43 
44  ostringstream os;
45  os << q2;
46  cout << "q1: " << q1 << endl;
47  cout << "q2: " << q2 << endl;
48 
49  WriteXML("ascii", q1, "quantum.xml", 0,
50  "q1", "", "", Verbosity(0, 2, 0));
51 
52  QuantumNumbers q3;
53  ReadXML(q3, "q3", "quantum.xml", "", Verbosity(0,2,0));
54  cout << "q3: " << q3 << endl;
55 
56  cout << endl << "========================================" << endl << endl;
57 
60 
61  Verbosity v(2,2,2);
62 
63  ArrayOfLineRecord abs_lines;
64  Timer timer;
65 
66  timerStart(timer, v);
67  abs_linesReadFromHitran(abs_lines,
68  "/Users/olemke/Dropbox/Hacking/sat/catalogue/HITRAN2008/HITRAN08.par",
69  1, 1.1876e+11, v);
70  // 1, 3e12, v);
71  // 118e9, 119e9, v);
72  timerStop(timer, v);
73 
74  Print(timer, 1, v);
75 
76 
77  SpeciesTag stag("O2-66");
79  qnr.SetUpper(QN_J, Rational(1, 1));
80  qnr.SetLower(QN_J, Rational(1, 1));
81 
82  cout << "qnr: " << qnr << endl;
83 
84  WriteXML("ascii", qnr, "quantumrecord.xml", 0,
85  "qnr", "", "", Verbosity(0, 2, 0));
86 
88  ReadXML(qnr2, "qnr2", "quantumrecord.xml", "", Verbosity(0,2,0));
89  cout << "qnr2: " << qnr2 << endl;
90 
91 
92  ArrayOfIndex matches;
93 
94  timerStart(timer, v);
95  find_matching_lines(matches, abs_lines, stag.Species(), stag.Isotopologue(), qnr);
96  timerStop(timer, v);
97  Print(timer, 1, v);
98 
99  cout << "========================================" << endl << endl;
100 
101  cout << "Matches: " << matches.nelem() << endl;
102 
103  for (Index i = 0; i < matches.nelem(); i++)
104  {
105  cout << abs_lines[matches[i]] << endl;
106  cout << abs_lines[matches[i]].QuantumNumbers() << endl;
107  }
108 
109  cout << "========================================" << endl << endl;
110 
111  cout << "Search key: " << endl;
112  cout << "Species: " << stag.Name() << " species: " << stag.Species() << " iso: " << stag.Isotopologue() << endl;
113  cout << qnr << endl;
114 
115  }
116  catch (runtime_error e)
117  {
118  cout << e.what() << endl;
119  }
120 
121 
122  return (0);
123 }
QN_J
@ QN_J
Definition: quantum.h:42
timerStart
void timerStart(Timer &, const Verbosity &)
WORKSPACE METHOD: timerStart.
Definition: m_general.cc:369
abs_linesReadFromHitran
void abs_linesReadFromHitran(ArrayOfLineRecord &abs_lines, const String &filename, const Numeric &fmin, const Numeric &fmax, const Verbosity &verbosity)
WORKSPACE METHOD: abs_linesReadFromHitran.
Definition: m_abs.cc:189
QuantumNumbers
Container class for Quantum Numbers.
Definition: quantum.h:58
exceptions.h
The declarations of all the exception classes.
Print
void Print(Workspace &ws, const Agenda &x, const Index &level, const Verbosity &verbosity)
Definition: m_general.cc:81
auto_md.h
find_matching_lines
bool find_matching_lines(ArrayOfIndex &matches, const ArrayOfLineRecord &abs_lines, const Index species, const Index isotopologue, const QuantumNumberRecord qr, const LineMatchingCriteria match_criteria)
Find lines matching the given criteria.
Definition: linerecord.cc:2631
absorption.h
Declarations required for the calculation of absorption coefficients.
q1
#define q1
Definition: continua.cc:21197
SpeciesTag::Name
String Name() const
Return the full name of the tag.
Definition: abs_species_tags.cc:397
Timer
Definition: m_general.h:59
Array
This can be used to make arrays out of anything.
Definition: array.h:107
SpeciesTag
A tag group can consist of the sum of several of these.
Definition: abs_species_tags.h:46
timerStop
void timerStop(const Timer &, const Verbosity &)
Definition: m_general.cc:396
QN_N
@ QN_N
Definition: quantum.h:43
Verbosity
Definition: messages.h:50
define_species_map
void define_species_map()
Define the species data map.
Definition: absorption.cc:322
m_xml.h
Workspace methods and template functions for supergeneric XML IO.
QN_S
@ QN_S
Definition: quantum.h:44
main
int main(int, char *[])
Definition: test_quantum.cc:28
ReadXML
void ReadXML(Workspace &ws, Agenda &v, const String &v_name, const String &f, const String &f_name, const Verbosity &verbosity)
Definition: m_xml.cc:31
matpackII.h
Header file for sparse matrices.
QuantumNumberRecord
Record containing upper and lower quantum numbers.
Definition: quantum.h:94
QuantumNumberRecord::SetLower
void SetLower(const Index i, const Rational r)
Set lower quantum number.
Definition: quantum.h:97
SpeciesTag::Isotopologue
Index Isotopologue() const
Isotopologue species index.
Definition: abs_species_tags.h:71
WriteXML
void WriteXML(Workspace &ws, const String &file_format, const Agenda &v, const String &f, const Index &no_clobber, const String &v_name, const String &f_name, const String &no_clobber_name, const Verbosity &verbosity)
Definition: m_xml.cc:67
QuantumNumbers::Compare
bool Compare(const QuantumNumbers &qn) const
Compare Quantum Numbers.
Definition: quantum.cc:31
QuantumNumberRecord::SetUpper
void SetUpper(const Index i, const Rational r)
Set upper quantum number.
Definition: quantum.h:100
Index
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:35
define_species_data
void define_species_data()
Definition: species_data.cc:158
QuantumNumbers::Set
void Set(Index qn, Rational r)
Set quantum number.
Definition: quantum.h:73
SpeciesTag::Species
Index Species() const
Molecular species index.
Definition: abs_species_tags.h:66
Array::nelem
Index nelem() const
Number of elements.
Definition: array.h:176
Rational
Definition: rational.h:35
arts.h
The global header file for ARTS.
xml_io.h
This file contains basic functions to handle XML data files.