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 }
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:35
bool Compare(const QuantumNumbers &qn) const
Compare Quantum Numbers.
Definition: quantum.cc:31
void Print(Workspace &ws, const Agenda &x, const Index &level, const Verbosity &verbosity)
Definition: m_general.cc:81
Index nelem() const
Number of elements.
Definition: array.h:176
String Name() const
Return the full name of the tag.
Definition: quantum.h:44
Index Species() const
Molecular species index.
This file contains basic functions to handle XML data files.
void timerStart(Timer &, const Verbosity &)
WORKSPACE METHOD: timerStart.
Definition: m_general.cc:369
The global header file for ARTS.
Record containing upper and lower quantum numbers.
Definition: quantum.h:93
Header file for sparse matrices.
The declarations of all the exception classes.
A tag group can consist of the sum of several of these.
void SetUpper(const Index i, const Rational r)
Set upper quantum number.
Definition: quantum.h:100
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
Declarations required for the calculation of absorption coefficients.
int main(int, char *[])
Definition: test_quantum.cc:28
#define q1
Definition: continua.cc:21197
void Set(Index qn, Rational r)
Set quantum number.
Definition: quantum.h:73
void SetLower(const Index i, const Rational r)
Set lower quantum number.
Definition: quantum.h:97
void define_species_data()
Container class for Quantum Numbers.
Definition: quantum.h:57
This can be used to make arrays out of anything.
Definition: array.h:40
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
Definition: quantum.h:42
Workspace methods and template functions for supergeneric XML IO.
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
Definition: quantum.h:43
void define_species_map()
Define the species data map.
Definition: absorption.cc:322
Index Isotopologue() const
Isotopologue species index.
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
void timerStop(const Timer &, const Verbosity &)
Definition: m_general.cc:396