ARTS 2.5.4 (git: 4c0d3b4d)
xml_io_compound_types.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 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
19// File description
21
29#include "arts.h"
30#include "cloudbox.h"
31#include "global_data.h"
32#include "xml_io.h"
33
35// Overloaded functions for reading/writing data from/to XML stream
37
38//=== CIARecord ================================================
39
41
46void xml_read_from_stream(istream& is_xml,
47 CIARecord& cr,
48 bifstream* pbifs,
49 const Verbosity& verbosity) {
50 ArtsXMLTag tag(verbosity);
51 String name;
52 String molecule1;
53 String molecule2;
54 Species::Species species1;
55 Species::Species species2;
56
57 tag.read_from_stream(is_xml);
58 tag.check_name("CIARecord");
59 tag.get_attribute_value("molecule1", molecule1);
60 tag.get_attribute_value("molecule2", molecule2);
61
62 species1 = Species::fromShortName(molecule1);
63 species2 = Species::fromShortName(molecule2);
64
65 if (not good_enum(species1)) {
66 ostringstream os;
67 os << "Unknown species (1st molecule) in CIARecord: " << molecule1;
68 throw runtime_error(os.str());
69 }
70 if (not good_enum(species2)) {
71 ostringstream os;
72 os << "Unknown species (2nd molecule) in CIARecord: " << molecule2;
73 throw runtime_error(os.str());
74 }
75
76 cr.SetSpecies(species1, species2);
77
78 xml_read_from_stream(is_xml, cr.mdata, pbifs, verbosity);
79
80 tag.read_from_stream(is_xml);
81 tag.check_name("/CIARecord");
82}
83
85
91void xml_write_to_stream(ostream& os_xml,
92 const CIARecord& cr,
93 bofstream* pbofs,
94 const String& name _U_,
95 const Verbosity& verbosity) {
96 ArtsXMLTag open_tag(verbosity);
97 ArtsXMLTag close_tag(verbosity);
98
99 open_tag.set_name("CIARecord");
100 open_tag.add_attribute("molecule1", cr.MoleculeName(0));
101 open_tag.add_attribute("molecule2", cr.MoleculeName(1));
102 open_tag.write_to_stream(os_xml);
103 os_xml << '\n';
104
105 xml_write_to_stream(os_xml, cr.Data(), pbofs, "", verbosity);
106
107 close_tag.set_name("/CIARecord");
108 close_tag.write_to_stream(os_xml);
109 os_xml << '\n';
110}
111
113
119void xml_read_from_stream(istream& is_xml,
120 CovarianceMatrix& covmat,
121 bifstream* pbifs,
122 const Verbosity& verbosity) {
123 ArtsXMLTag tag(verbosity);
124 String name, type;
125 Index n_blocks, row_start, row_extent, column_start, column_extent, row_index,
126 column_index, is_inverse;
127
128 tag.read_from_stream(is_xml);
129 tag.check_name("CovarianceMatrix");
130 tag.get_attribute_value("n_blocks", n_blocks);
131
132 covmat = CovarianceMatrix();
133 for (Index i = 0; i < n_blocks; i++) {
134 tag.read_from_stream(is_xml);
135 tag.check_name("Block");
136
137 tag.get_attribute_value("row_index", row_index);
138 tag.get_attribute_value("column_index", column_index);
139 tag.get_attribute_value("row_start", row_start);
140 tag.get_attribute_value("row_extent", row_extent);
141 tag.get_attribute_value("column_start", column_start);
142 tag.get_attribute_value("column_extent", column_extent);
143 tag.get_attribute_value("type", type);
144 tag.get_attribute_value("is_inverse", is_inverse);
145
146 Range row_range(row_start, row_extent);
147 Range column_range(column_start, column_extent);
148 if (type == "Matrix") {
149 std::shared_ptr<Matrix> M =
150 std::make_shared<Matrix>(row_extent, column_extent);
151 xml_read_from_stream(is_xml, *M, pbifs, verbosity);
152 if (!is_inverse) {
153 covmat.correlations_.emplace_back(
154 row_range,
155 column_range,
156 std::make_pair(row_index, column_index),
157 M);
158 } else {
159 covmat.inverses_.emplace_back(row_range,
160 column_range,
161 std::make_pair(row_index, column_index),
162 M);
163 }
164 } else if (type == "Sparse") {
165 std::shared_ptr<Sparse> M =
166 std::make_shared<Sparse>(row_extent, column_extent);
167 xml_read_from_stream(is_xml, *M, pbifs, verbosity);
168 if (!is_inverse) {
169 covmat.correlations_.emplace_back(
170 row_range,
171 column_range,
172 std::make_pair(row_index, column_index),
173 M);
174 } else {
175 covmat.inverses_.emplace_back(row_range,
176 column_range,
177 std::make_pair(row_index, column_index),
178 M);
179 }
180 }
181 tag.read_from_stream(is_xml);
182 tag.check_name("/Block");
183 }
184 tag.read_from_stream(is_xml);
185 tag.check_name("/CovarianceMatrix");
186}
187
188//=== CovarianceMatrix =========================================================
189
191
198void xml_write_to_stream(ostream& os_xml,
199 const CovarianceMatrix& covmat,
200 bofstream* pbofs,
201 const String& name _U_,
202 const Verbosity& verbosity) {
203 ArtsXMLTag covmat_tag(verbosity);
204 ArtsXMLTag close_tag(verbosity);
205
206 covmat_tag.set_name("CovarianceMatrix");
207 covmat_tag.add_attribute(
208 "n_blocks", Index(covmat.correlations_.size() + covmat.inverses_.size()));
209 covmat_tag.write_to_stream(os_xml);
210 os_xml << '\n';
211 for (const Block& c : covmat.correlations_) {
212 ArtsXMLTag block_tag(verbosity);
213 block_tag.set_name("Block");
214
215 Index i, j;
216 std::tie(i, j) = c.get_indices();
217 block_tag.add_attribute("row_index", i);
218 block_tag.add_attribute("column_index", j);
219
220 Range row_range = c.get_row_range();
221 Range column_range = c.get_column_range();
222 block_tag.add_attribute("row_start", row_range.get_start());
223 block_tag.add_attribute("row_extent", row_range.get_extent());
224 block_tag.add_attribute("column_start", column_range.get_start());
225 block_tag.add_attribute("column_extent", column_range.get_extent());
226 block_tag.add_attribute("is_inverse", Index(0));
227 if (c.get_matrix_type() == Block::MatrixType::dense) {
228 block_tag.add_attribute("type", "Matrix");
229 block_tag.write_to_stream(os_xml);
230 os_xml << '\n';
231 xml_write_to_stream(os_xml, c.get_dense(), pbofs, name, verbosity);
232 } else {
233 block_tag.add_attribute("type", "Sparse");
234 block_tag.write_to_stream(os_xml);
235 os_xml << '\n';
236 xml_write_to_stream(os_xml, c.get_sparse(), pbofs, name, verbosity);
237 }
238 close_tag.set_name("/Block");
239 close_tag.write_to_stream(os_xml);
240 os_xml << '\n';
241 }
242 for (const Block& c : covmat.inverses_) {
243 ArtsXMLTag block_tag(verbosity);
244 block_tag.set_name("Block");
245
246 Index i, j;
247 std::tie(i, j) = c.get_indices();
248 block_tag.add_attribute("row_index", i);
249 block_tag.add_attribute("column_index", j);
250
251 Range row_range = c.get_row_range();
252 Range column_range = c.get_column_range();
253 block_tag.add_attribute("row_start", row_range.get_start());
254 block_tag.add_attribute("row_extent", row_range.get_extent());
255 block_tag.add_attribute("column_start", column_range.get_start());
256 block_tag.add_attribute("column_extent", column_range.get_extent());
257 block_tag.add_attribute("is_inverse", Index(1));
258 if (c.get_matrix_type() == Block::MatrixType::dense) {
259 block_tag.add_attribute("type", "Matrix");
260 block_tag.write_to_stream(os_xml);
261 os_xml << '\n';
262 xml_write_to_stream(os_xml, c.get_dense(), pbofs, name, verbosity);
263 } else {
264 block_tag.add_attribute("type", "Sparse");
265 block_tag.write_to_stream(os_xml);
266 os_xml << '\n';
267 xml_write_to_stream(os_xml, c.get_sparse(), pbofs, name, verbosity);
268 }
269 close_tag.set_name("/Block");
270 close_tag.write_to_stream(os_xml);
271 os_xml << '\n';
272 }
273 os_xml << '\n';
274 close_tag.set_name("/CovarianceMatrix");
275 close_tag.write_to_stream(os_xml);
276}
277
278//=== EnergyLevelMap ===========================================================
279
281
286void xml_read_from_stream(istream& is_xml,
287 EnergyLevelMap& elm,
288 bifstream* pbifs,
289 const Verbosity& verbosity) {
290 ArtsXMLTag tag(verbosity);
291
292 tag.read_from_stream(is_xml);
293
294 tag.check_name("EnergyLevelMap");
295 String type;
296 tag.get_attribute_value("type", type);
298
299 xml_read_from_stream(is_xml, elm.levels, pbifs, verbosity);
300 xml_read_from_stream(is_xml, elm.value, pbifs, verbosity);
301 xml_read_from_stream(is_xml, elm.vib_energy, pbifs, verbosity);
302
303 tag.read_from_stream(is_xml);
304 tag.check_name("/EnergyLevelMap");
305
306 elm.ThrowIfNotOK();
307}
308
310
316void xml_write_to_stream(ostream& os_xml,
317 const EnergyLevelMap& elm,
318 bofstream* pbofs,
319 const String& name,
320 const Verbosity& verbosity) {
321 ArtsXMLTag open_tag(verbosity);
322 ArtsXMLTag close_tag(verbosity);
323
324 open_tag.set_name("EnergyLevelMap");
325 if (name.length()) open_tag.add_attribute("name", name);
326 open_tag.add_attribute("type", toString(elm.type));
327 open_tag.write_to_stream(os_xml);
328
329 xml_write_to_stream(os_xml, elm.levels, pbofs, "Energy Levels", verbosity);
330 xml_write_to_stream(os_xml, elm.value, pbofs, "Level Data", verbosity);
331 xml_write_to_stream(os_xml, elm.vib_energy, pbofs, "Level Energy", verbosity);
332
333 close_tag.set_name("/EnergyLevelMap");
334 close_tag.write_to_stream(os_xml);
335 os_xml << '\n';
336}
337
338//=== GasAbsLookup ===========================================================
339
341
346void xml_read_from_stream(istream& is_xml,
347 GasAbsLookup& gal,
348 bifstream* pbifs,
349 const Verbosity& verbosity) {
350 ArtsXMLTag tag(verbosity);
351
352 tag.read_from_stream(is_xml);
353 tag.check_name("GasAbsLookup");
354
355 xml_read_from_stream(is_xml, gal.species, pbifs, verbosity);
356 xml_read_from_stream(is_xml, gal.nonlinear_species, pbifs, verbosity);
357 xml_read_from_stream(is_xml, gal.f_grid, pbifs, verbosity);
358 xml_read_from_stream(is_xml, gal.p_grid, pbifs, verbosity);
359 xml_read_from_stream(is_xml, gal.vmrs_ref, pbifs, verbosity);
360 xml_read_from_stream(is_xml, gal.t_ref, pbifs, verbosity);
361 xml_read_from_stream(is_xml, gal.t_pert, pbifs, verbosity);
362 xml_read_from_stream(is_xml, gal.nls_pert, pbifs, verbosity);
363 xml_read_from_stream(is_xml, gal.xsec, pbifs, verbosity);
364
365 tag.read_from_stream(is_xml);
366 tag.check_name("/GasAbsLookup");
367}
368
370
376void xml_write_to_stream(ostream& os_xml,
377 const GasAbsLookup& gal,
378 bofstream* pbofs,
379 const String& name,
380 const Verbosity& verbosity) {
381 ArtsXMLTag open_tag(verbosity);
382 ArtsXMLTag close_tag(verbosity);
383
384 open_tag.set_name("GasAbsLookup");
385 if (name.length()) open_tag.add_attribute("name", name);
386 open_tag.write_to_stream(os_xml);
387
388 xml_write_to_stream(os_xml, gal.species, pbofs, "", verbosity);
390 os_xml, gal.nonlinear_species, pbofs, "NonlinearSpecies", verbosity);
391 xml_write_to_stream(os_xml, gal.f_grid, pbofs, "FrequencyGrid", verbosity);
392 xml_write_to_stream(os_xml, gal.p_grid, pbofs, "PressureGrid", verbosity);
394 os_xml, gal.vmrs_ref, pbofs, "ReferenceVmrProfiles", verbosity);
396 os_xml, gal.t_ref, pbofs, "ReferenceTemperatureProfile", verbosity);
398 os_xml, gal.t_pert, pbofs, "TemperaturePerturbations", verbosity);
399 xml_write_to_stream(os_xml,
400 gal.nls_pert,
401 pbofs,
402 "NonlinearSpeciesVmrPerturbations",
403 verbosity);
405 os_xml, gal.xsec, pbofs, "AbsorptionCrossSections", verbosity);
406
407 close_tag.set_name("/GasAbsLookup");
408 close_tag.write_to_stream(os_xml);
409 os_xml << '\n';
410}
411
412//=== GriddedField ===========================================================
413
415
420void xml_read_from_stream(istream& is_xml,
421 GriddedField& gfield,
422 bifstream* pbifs,
423 const Verbosity& verbosity) {
424 XMLTag tag(verbosity);
425
426 for (Index i = 0; i < gfield.get_dim(); i++) {
427 tag.read_from_stream(is_xml);
428 if (tag.get_name() == "Vector") {
429 String s;
430 tag.get_attribute_value("name", s);
431 if (s.length()) gfield.set_grid_name(i, s);
432
433 Vector v;
434 xml_parse_from_stream(is_xml, v, pbifs, tag, verbosity);
435 gfield.set_grid(i, v);
436 tag.read_from_stream(is_xml);
437 tag.check_name("/Vector");
438 } else if (tag.get_name() == "Array") {
439 String s;
440 tag.get_attribute_value("name", s);
441 if (s.length()) gfield.set_grid_name(i, s);
442
443 tag.get_attribute_value("type", s);
444 if (s == "String") {
445 ArrayOfString as;
446 xml_parse_from_stream(is_xml, as, pbifs, tag, verbosity);
447 gfield.set_grid(i, as);
448 tag.read_from_stream(is_xml);
449 tag.check_name("/Array");
450
451 } else {
453 "Grids must be of type *Vector* or *ArrayOfString*\n"
454 "but *ArrayOf" +
455 s + "* found.");
456 }
457 } else {
458 ostringstream os;
459 os << "Grids must be of type *Vector* or *ArrayOfString*\n"
460 << "but tag <" + tag.get_name() + "> found.";
461 if (tag.get_name() == "ArrayOfString")
462 os << "\nCorrect XML tag for *ArrayOfString* is <Array type=\"String\" ...>.";
463 xml_parse_error(os.str());
464 }
465 }
466}
467
469
474void xml_write_to_stream(ostream& os_xml,
475 const GriddedField& gfield,
476 bofstream* pbofs,
477 const String& /* name */,
478 const Verbosity& verbosity) {
479 for (Index i = 0; i < gfield.get_dim(); i++) {
480 switch (gfield.get_grid_type(i)) {
482 xml_write_to_stream(os_xml,
483 gfield.get_numeric_grid(i),
484 pbofs,
485 gfield.get_grid_name(i),
486 verbosity);
487 break;
488 case GRID_TYPE_STRING:
489 xml_write_to_stream(os_xml,
490 gfield.get_string_grid(i),
491 pbofs,
492 gfield.get_grid_name(i),
493 verbosity);
494 break;
495 }
496 }
497}
498
499//=== GriddedField1 ===========================================================
500
502
507void xml_read_from_stream(istream& is_xml,
508 GriddedField1& gfield,
509 bifstream* pbifs,
510 const Verbosity& verbosity) {
511 ArtsXMLTag tag(verbosity);
512
513 tag.read_from_stream(is_xml);
514 tag.check_name("GriddedField1");
515
516 String s;
517 tag.get_attribute_value("name", s);
518 if (s.length()) gfield.set_name(s);
519
520 xml_read_from_stream(is_xml, *((GriddedField*)&gfield), pbifs, verbosity);
521 xml_read_from_stream(is_xml, gfield.data, pbifs, verbosity);
522
523 tag.read_from_stream(is_xml);
524 tag.check_name("/GriddedField1");
525
526 gfield.checksize_strict();
527}
528
530
536void xml_write_to_stream(ostream& os_xml,
537 const GriddedField1& gfield,
538 bofstream* pbofs,
539 const String& name,
540 const Verbosity& verbosity) {
541 ArtsXMLTag open_tag(verbosity);
542 ArtsXMLTag close_tag(verbosity);
543
544 open_tag.set_name("GriddedField1");
545 if (!name.length() && (gfield.get_name().length()))
546 open_tag.add_attribute("name", gfield.get_name());
547 else if (name.length())
548 open_tag.add_attribute("name", name);
549
550 open_tag.write_to_stream(os_xml);
551 os_xml << '\n';
552
553 xml_write_to_stream(os_xml, *((GriddedField*)&gfield), pbofs, "", verbosity);
554 xml_write_to_stream(os_xml, gfield.data, pbofs, "Data", verbosity);
555
556 close_tag.set_name("/GriddedField1");
557 close_tag.write_to_stream(os_xml);
558 os_xml << '\n';
559}
560
561//=== GriddedField2 ===========================================================
562
564
569void xml_read_from_stream(istream& is_xml,
570 GriddedField2& gfield,
571 bifstream* pbifs,
572 const Verbosity& verbosity) {
573 ArtsXMLTag tag(verbosity);
574
575 tag.read_from_stream(is_xml);
576 tag.check_name("GriddedField2");
577
578 String s;
579 tag.get_attribute_value("name", s);
580 if (s.length()) gfield.set_name(s);
581
582 xml_read_from_stream(is_xml, *((GriddedField*)&gfield), pbifs, verbosity);
583 xml_read_from_stream(is_xml, gfield.data, pbifs, verbosity);
584
585 tag.read_from_stream(is_xml);
586 tag.check_name("/GriddedField2");
587
588 gfield.checksize_strict();
589}
590
592
598void xml_write_to_stream(ostream& os_xml,
599 const GriddedField2& gfield,
600 bofstream* pbofs,
601 const String& name,
602 const Verbosity& verbosity) {
603 ArtsXMLTag open_tag(verbosity);
604 ArtsXMLTag close_tag(verbosity);
605
606 open_tag.set_name("GriddedField2");
607 if (!name.length() && (gfield.get_name().length()))
608 open_tag.add_attribute("name", gfield.get_name());
609 else if (name.length())
610 open_tag.add_attribute("name", name);
611
612 open_tag.write_to_stream(os_xml);
613 os_xml << '\n';
614
615 xml_write_to_stream(os_xml, *((GriddedField*)&gfield), pbofs, "", verbosity);
616 xml_write_to_stream(os_xml, gfield.data, pbofs, "Data", verbosity);
617
618 close_tag.set_name("/GriddedField2");
619 close_tag.write_to_stream(os_xml);
620 os_xml << '\n';
621}
622
623//=== GriddedField3 ===========================================================
624
626
631void xml_read_from_stream(istream& is_xml,
632 GriddedField3& gfield,
633 bifstream* pbifs,
634 const Verbosity& verbosity) {
635 ArtsXMLTag tag(verbosity);
636
637 tag.read_from_stream(is_xml);
638 tag.check_name("GriddedField3");
639
640 String s;
641 tag.get_attribute_value("name", s);
642 if (s.length()) gfield.set_name(s);
643
644 xml_read_from_stream(is_xml, *((GriddedField*)&gfield), pbifs, verbosity);
645 xml_read_from_stream(is_xml, gfield.data, pbifs, verbosity);
646
647 tag.read_from_stream(is_xml);
648 tag.check_name("/GriddedField3");
649
650 gfield.checksize_strict();
651}
652
654
660void xml_write_to_stream(ostream& os_xml,
661 const GriddedField3& gfield,
662 bofstream* pbofs,
663 const String& name,
664 const Verbosity& verbosity) {
665 ArtsXMLTag open_tag(verbosity);
666 ArtsXMLTag close_tag(verbosity);
667
668 open_tag.set_name("GriddedField3");
669 if (!name.length() && (gfield.get_name().length()))
670 open_tag.add_attribute("name", gfield.get_name());
671 else if (name.length())
672 open_tag.add_attribute("name", name);
673
674 open_tag.write_to_stream(os_xml);
675 os_xml << '\n';
676
677 xml_write_to_stream(os_xml, *((GriddedField*)&gfield), pbofs, "", verbosity);
678 xml_write_to_stream(os_xml, gfield.data, pbofs, "Data", verbosity);
679
680 close_tag.set_name("/GriddedField3");
681 close_tag.write_to_stream(os_xml);
682 os_xml << '\n';
683}
684
685//=== GriddedField4 ===========================================================
686
688
693void xml_read_from_stream(istream& is_xml,
694 GriddedField4& gfield,
695 bifstream* pbifs,
696 const Verbosity& verbosity) {
697 ArtsXMLTag tag(verbosity);
698
699 tag.read_from_stream(is_xml);
700 tag.check_name("GriddedField4");
701
702 String s;
703 tag.get_attribute_value("name", s);
704 if (s.length()) gfield.set_name(s);
705
706 xml_read_from_stream(is_xml, *((GriddedField*)&gfield), pbifs, verbosity);
707 xml_read_from_stream(is_xml, gfield.data, pbifs, verbosity);
708
709 tag.read_from_stream(is_xml);
710 tag.check_name("/GriddedField4");
711
712 gfield.checksize_strict();
713}
714
716
722void xml_write_to_stream(ostream& os_xml,
723 const GriddedField4& gfield,
724 bofstream* pbofs,
725 const String& name,
726 const Verbosity& verbosity) {
727 ArtsXMLTag open_tag(verbosity);
728 ArtsXMLTag close_tag(verbosity);
729
730 open_tag.set_name("GriddedField4");
731 if (!name.length() && (gfield.get_name().length()))
732 open_tag.add_attribute("name", gfield.get_name());
733 else if (name.length())
734 open_tag.add_attribute("name", name);
735
736 open_tag.write_to_stream(os_xml);
737 os_xml << '\n';
738
739 xml_write_to_stream(os_xml, *((GriddedField*)&gfield), pbofs, "", verbosity);
740 xml_write_to_stream(os_xml, gfield.data, pbofs, "Data", verbosity);
741
742 close_tag.set_name("/GriddedField4");
743 close_tag.write_to_stream(os_xml);
744 os_xml << '\n';
745}
746
747//=== GriddedField5 ===========================================================
748
750
755void xml_read_from_stream(istream& is_xml,
756 GriddedField5& gfield,
757 bifstream* pbifs,
758 const Verbosity& verbosity) {
759 ArtsXMLTag tag(verbosity);
760
761 tag.read_from_stream(is_xml);
762 tag.check_name("GriddedField5");
763
764 String s;
765 tag.get_attribute_value("name", s);
766 if (s.length()) gfield.set_name(s);
767
768 xml_read_from_stream(is_xml, *((GriddedField*)&gfield), pbifs, verbosity);
769 xml_read_from_stream(is_xml, gfield.data, pbifs, verbosity);
770
771 tag.read_from_stream(is_xml);
772 tag.check_name("/GriddedField5");
773
774 gfield.checksize_strict();
775}
776
778
784void xml_write_to_stream(ostream& os_xml,
785 const GriddedField5& gfield,
786 bofstream* pbofs,
787 const String& name,
788 const Verbosity& verbosity) {
789 ArtsXMLTag open_tag(verbosity);
790 ArtsXMLTag close_tag(verbosity);
791
792 open_tag.set_name("GriddedField5");
793 if (!name.length() && (gfield.get_name().length()))
794 open_tag.add_attribute("name", gfield.get_name());
795 else if (name.length())
796 open_tag.add_attribute("name", name);
797
798 open_tag.write_to_stream(os_xml);
799 os_xml << '\n';
800
801 xml_write_to_stream(os_xml, *((GriddedField*)&gfield), pbofs, "", verbosity);
802 xml_write_to_stream(os_xml, gfield.data, pbofs, "Data", verbosity);
803
804 close_tag.set_name("/GriddedField5");
805 close_tag.write_to_stream(os_xml);
806 os_xml << '\n';
807}
808
809//=== GriddedField6 ===========================================================
810
812
817void xml_read_from_stream(istream& is_xml,
818 GriddedField6& gfield,
819 bifstream* pbifs,
820 const Verbosity& verbosity) {
821 ArtsXMLTag tag(verbosity);
822
823 tag.read_from_stream(is_xml);
824 tag.check_name("GriddedField6");
825
826 String s;
827 tag.get_attribute_value("name", s);
828 if (s.length()) gfield.set_name(s);
829
830 xml_read_from_stream(is_xml, *((GriddedField*)&gfield), pbifs, verbosity);
831 xml_read_from_stream(is_xml, gfield.data, pbifs, verbosity);
832
833 tag.read_from_stream(is_xml);
834 tag.check_name("/GriddedField6");
835
836 gfield.checksize_strict();
837}
838
840
846void xml_write_to_stream(ostream& os_xml,
847 const GriddedField6& gfield,
848 bofstream* pbofs,
849 const String& name,
850 const Verbosity& verbosity) {
851 ArtsXMLTag open_tag(verbosity);
852 ArtsXMLTag close_tag(verbosity);
853
854 open_tag.set_name("GriddedField6");
855 if (!name.length() && (gfield.get_name().length()))
856 open_tag.add_attribute("name", gfield.get_name());
857 else if (name.length())
858 open_tag.add_attribute("name", name);
859
860 open_tag.write_to_stream(os_xml);
861 os_xml << '\n';
862
863 xml_write_to_stream(os_xml, *((GriddedField*)&gfield), pbofs, "", verbosity);
864 xml_write_to_stream(os_xml, gfield.data, pbofs, "Data", verbosity);
865
866 close_tag.set_name("/GriddedField6");
867 close_tag.write_to_stream(os_xml);
868 os_xml << '\n';
869}
870
871//=== GridPos =====================================================
872
874
879void xml_read_from_stream(istream& is_xml,
880 GridPos& gpos,
881 bifstream* pbifs,
882 const Verbosity& verbosity) {
883 ArtsXMLTag tag(verbosity);
884
885 tag.read_from_stream(is_xml);
886 tag.check_name("GridPos");
887
888 xml_read_from_stream(is_xml, gpos.idx, pbifs, verbosity);
889 xml_read_from_stream(is_xml, gpos.fd[0], pbifs, verbosity);
890 xml_read_from_stream(is_xml, gpos.fd[1], pbifs, verbosity);
891
892 tag.read_from_stream(is_xml);
893 tag.check_name("/GridPos");
894}
895
897
903void xml_write_to_stream(ostream& os_xml,
904 const GridPos& gpos,
905 bofstream* pbofs,
906 const String& name,
907 const Verbosity& verbosity) {
908 ArtsXMLTag open_tag(verbosity);
909 ArtsXMLTag close_tag(verbosity);
910
911 open_tag.set_name("GridPos");
912 if (name.length()) open_tag.add_attribute("name", name);
913 open_tag.write_to_stream(os_xml);
914
915 xml_write_to_stream(os_xml,
916 gpos.idx,
917 pbofs,
918 "OriginalGridIndexBelowInterpolationPoint",
919 verbosity);
921 os_xml, gpos.fd[0], pbofs, "FractionalDistanceToNextPoint_1", verbosity);
923 os_xml, gpos.fd[1], pbofs, "FractionalDistanceToNextPoint_2", verbosity);
924
925 close_tag.set_name("/GridPos");
926 close_tag.write_to_stream(os_xml);
927 os_xml << '\n';
928}
929
930//=== HitranRelaxationMatrixData ================================================
931
933
938void xml_read_from_stream(istream& is_xml,
940 bifstream* pbifs,
941 const Verbosity& verbosity) {
942 ArtsXMLTag tag(verbosity);
943
944 tag.read_from_stream(is_xml);
945 tag.check_name("HitranRelaxationMatrixData");
946
947 xml_read_from_stream(is_xml, hitran.W0pp, pbifs, verbosity);
948 xml_read_from_stream(is_xml, hitran.B0pp, pbifs, verbosity);
949 xml_read_from_stream(is_xml, hitran.W0rp, pbifs, verbosity);
950 xml_read_from_stream(is_xml, hitran.B0rp, pbifs, verbosity);
951 xml_read_from_stream(is_xml, hitran.W0qp, pbifs, verbosity);
952 xml_read_from_stream(is_xml, hitran.B0qp, pbifs, verbosity);
953 xml_read_from_stream(is_xml, hitran.W0pr, pbifs, verbosity);
954 xml_read_from_stream(is_xml, hitran.B0pr, pbifs, verbosity);
955 xml_read_from_stream(is_xml, hitran.W0rr, pbifs, verbosity);
956 xml_read_from_stream(is_xml, hitran.B0rr, pbifs, verbosity);
957 xml_read_from_stream(is_xml, hitran.W0qr, pbifs, verbosity);
958 xml_read_from_stream(is_xml, hitran.B0qr, pbifs, verbosity);
959 xml_read_from_stream(is_xml, hitran.W0pq, pbifs, verbosity);
960 xml_read_from_stream(is_xml, hitran.B0pq, pbifs, verbosity);
961 xml_read_from_stream(is_xml, hitran.W0rq, pbifs, verbosity);
962 xml_read_from_stream(is_xml, hitran.B0rq, pbifs, verbosity);
963 xml_read_from_stream(is_xml, hitran.W0qq, pbifs, verbosity);
964 xml_read_from_stream(is_xml, hitran.B0qq, pbifs, verbosity);
965
966 tag.read_from_stream(is_xml);
967 tag.check_name("/HitranRelaxationMatrixData");
968}
969
971
977void xml_write_to_stream(ostream& os_xml,
978 const HitranRelaxationMatrixData& hitran,
979 bofstream* pbofs,
980 const String& name,
981 const Verbosity& verbosity) {
982 ArtsXMLTag open_tag(verbosity);
983 ArtsXMLTag close_tag(verbosity);
984
985 open_tag.set_name("HitranRelaxationMatrixData");
986 if (name.length()) open_tag.add_attribute("name", name);
987 open_tag.write_to_stream(os_xml);
988 os_xml << '\n';
989
990 xml_write_to_stream(os_xml, hitran.W0pp, pbofs, "W0pp", verbosity);
991 xml_write_to_stream(os_xml, hitran.B0pp, pbofs, "B0pp", verbosity);
992 xml_write_to_stream(os_xml, hitran.W0rp, pbofs, "W0rp", verbosity);
993 xml_write_to_stream(os_xml, hitran.B0rp, pbofs, "B0rp", verbosity);
994 xml_write_to_stream(os_xml, hitran.W0qp, pbofs, "W0qp", verbosity);
995 xml_write_to_stream(os_xml, hitran.B0qp, pbofs, "B0qp", verbosity);
996 xml_write_to_stream(os_xml, hitran.W0pr, pbofs, "W0pr", verbosity);
997 xml_write_to_stream(os_xml, hitran.B0pr, pbofs, "B0pr", verbosity);
998 xml_write_to_stream(os_xml, hitran.W0rr, pbofs, "W0rr", verbosity);
999 xml_write_to_stream(os_xml, hitran.B0rr, pbofs, "B0rr", verbosity);
1000 xml_write_to_stream(os_xml, hitran.W0qr, pbofs, "W0qr", verbosity);
1001 xml_write_to_stream(os_xml, hitran.B0qr, pbofs, "B0qr", verbosity);
1002 xml_write_to_stream(os_xml, hitran.W0pq, pbofs, "W0pq", verbosity);
1003 xml_write_to_stream(os_xml, hitran.B0pq, pbofs, "B0pq", verbosity);
1004 xml_write_to_stream(os_xml, hitran.W0rq, pbofs, "W0rq", verbosity);
1005 xml_write_to_stream(os_xml, hitran.B0rq, pbofs, "B0rq", verbosity);
1006 xml_write_to_stream(os_xml, hitran.W0qq, pbofs, "W0qq", verbosity);
1007 xml_write_to_stream(os_xml, hitran.B0qq, pbofs, "B0qq", verbosity);
1008
1009 close_tag.set_name("/HitranRelaxationMatrixData");
1010 close_tag.write_to_stream(os_xml);
1011 os_xml << '\n';
1012}
1013
1014//=== Ppath =====================================================
1015
1017
1022void xml_read_from_stream(istream& is_xml,
1023 Ppath& ppath,
1024 bifstream* pbifs,
1025 const Verbosity& verbosity) {
1026 ArtsXMLTag tag(verbosity);
1027
1028 tag.read_from_stream(is_xml);
1029 tag.check_name("Ppath");
1030
1031 xml_read_from_stream(is_xml, ppath.dim, pbifs, verbosity);
1032 xml_read_from_stream(is_xml, ppath.np, pbifs, verbosity);
1033 xml_read_from_stream(is_xml, ppath.constant, pbifs, verbosity);
1034 xml_read_from_stream(is_xml, ppath.background, pbifs, verbosity);
1035 xml_read_from_stream(is_xml, ppath.start_pos, pbifs, verbosity);
1036 xml_read_from_stream(is_xml, ppath.start_los, pbifs, verbosity);
1037 xml_read_from_stream(is_xml, ppath.start_lstep, pbifs, verbosity);
1038 xml_read_from_stream(is_xml, ppath.pos, pbifs, verbosity);
1039 xml_read_from_stream(is_xml, ppath.los, pbifs, verbosity);
1040 xml_read_from_stream(is_xml, ppath.r, pbifs, verbosity);
1041 xml_read_from_stream(is_xml, ppath.lstep, pbifs, verbosity);
1042 xml_read_from_stream(is_xml, ppath.end_pos, pbifs, verbosity);
1043 xml_read_from_stream(is_xml, ppath.end_los, pbifs, verbosity);
1044 xml_read_from_stream(is_xml, ppath.end_lstep, pbifs, verbosity);
1045 xml_read_from_stream(is_xml, ppath.nreal, pbifs, verbosity);
1046 xml_read_from_stream(is_xml, ppath.ngroup, pbifs, verbosity);
1047 xml_read_from_stream(is_xml, ppath.gp_p, pbifs, verbosity);
1048 xml_read_from_stream(is_xml, ppath.gp_lat, pbifs, verbosity);
1049 xml_read_from_stream(is_xml, ppath.gp_lon, pbifs, verbosity);
1050
1051 tag.read_from_stream(is_xml);
1052 tag.check_name("/Ppath");
1053}
1054
1056
1062void xml_write_to_stream(ostream& os_xml,
1063 const Ppath& ppath,
1064 bofstream* pbofs,
1065 const String& name,
1066 const Verbosity& verbosity) {
1067 ArtsXMLTag open_tag(verbosity);
1068 ArtsXMLTag close_tag(verbosity);
1069
1070 open_tag.set_name("Ppath");
1071 if (name.length()) open_tag.add_attribute("name", name);
1072 open_tag.write_to_stream(os_xml);
1073
1075 os_xml, ppath.dim, pbofs, "AtmosphericDimensionality", verbosity);
1077 os_xml, ppath.np, pbofs, "NumberOfPositionInPropagationPath", verbosity);
1079 os_xml, ppath.constant, pbofs, "PropagationPathConstant", verbosity);
1081 os_xml, ppath.background, pbofs, "RadiativeBackground", verbosity);
1082 xml_write_to_stream(os_xml,
1083 ppath.start_pos,
1084 pbofs,
1085 "StartPositionOfPropagationPath",
1086 verbosity);
1088 os_xml, ppath.start_los, pbofs, "StartLOSOfPropagationPath", verbosity);
1089 xml_write_to_stream(os_xml,
1090 ppath.start_lstep,
1091 pbofs,
1092 "StartLstepOfPropagationPath",
1093 verbosity);
1095 os_xml, ppath.pos, pbofs, "PropagationPathPointPositions", verbosity);
1096 xml_write_to_stream(os_xml, ppath.los, pbofs, "LineOfSight", verbosity);
1098 os_xml, ppath.r, pbofs, "PropagationPathPointRadii", verbosity);
1100 os_xml, ppath.lstep, pbofs, "PropagationPathPositionLength", verbosity);
1102 os_xml, ppath.end_pos, pbofs, "EndPositionOfPropagationPath", verbosity);
1104 os_xml, ppath.end_los, pbofs, "EndLOSOfPropagationPath", verbosity);
1106 os_xml, ppath.end_lstep, pbofs, "EndLstepPropagationPath", verbosity);
1108 os_xml, ppath.nreal, pbofs, "RefractiveIndexRealPart", verbosity);
1110 os_xml, ppath.ngroup, pbofs, "GroupRefractiveIndex", verbosity);
1112 os_xml, ppath.gp_p, pbofs, "PressureGridIndexPosition", verbosity);
1114 os_xml, ppath.gp_lat, pbofs, "LatitudeGridIndexPosition", verbosity);
1116 os_xml, ppath.gp_lon, pbofs, "LongitudeGridIndexPosition", verbosity);
1117
1118 close_tag.set_name("/Ppath");
1119 close_tag.write_to_stream(os_xml);
1120 os_xml << '\n';
1121}
1122
1123//=== PropagationMatrix ======================================================
1124
1126
1131void xml_read_from_stream(istream& is_xml,
1133 bifstream* pbifs,
1134 const Verbosity& verbosity) {
1135 ArtsXMLTag tag(verbosity);
1136
1137 tag.read_from_stream(is_xml);
1138 tag.check_name("PropagationMatrix");
1139
1140 try {
1141 Tensor4 d;
1142 xml_read_from_stream(is_xml, d, pbifs, verbosity);
1143 Index naa = d.nbooks();
1144 Index nza = d.npages();
1145 Index nf = d.nrows();
1146 Index nstokes_needed = d.ncols();
1147 pm = PropagationMatrix(nf, need2stokes<true>(nstokes_needed), nza, naa);
1148 pm.Data() = std::move(d); // destructive takeover
1149 } catch (const std::runtime_error& e) {
1150 ostringstream os;
1151 os << "Error reading PropagationMatrix: "
1152 << "\n"
1153 << e.what();
1154 throw runtime_error(os.str());
1155 }
1156
1157 tag.read_from_stream(is_xml);
1158 tag.check_name("/PropagationMatrix");
1159}
1160
1162
1168void xml_write_to_stream(ostream& os_xml,
1169 const PropagationMatrix& pm,
1170 bofstream* pbofs,
1171 const String& name,
1172 const Verbosity& verbosity) {
1173 ArtsXMLTag open_tag(verbosity);
1174 ArtsXMLTag close_tag(verbosity);
1175
1176 open_tag.set_name("PropagationMatrix");
1177 if (name.length()) open_tag.add_attribute("name", name);
1178
1179 open_tag.write_to_stream(os_xml);
1180 os_xml << '\n';
1181
1182 xml_write_to_stream(os_xml, pm.Data(), pbofs, "", verbosity);
1183
1184 close_tag.set_name("/PropagationMatrix");
1185 close_tag.write_to_stream(os_xml);
1186
1187 os_xml << '\n';
1188}
1189
1190//=== QuantumIdentifier =========================================
1191
1193
1198void xml_read_from_stream(istream& is_xml,
1200 bifstream* pbifs _U_,
1201 const Verbosity& verbosity) {
1202 static_assert(QuantumIdentifier::version == 1);
1203
1204 ArtsXMLTag tag(verbosity);
1205
1206 tag.read_from_stream(is_xml);
1207 tag.check_name("QuantumIdentifier");
1208
1209 Index version;
1210 if (tag.has_attribute("version")) {
1211 tag.get_attribute_value("version", version);
1212 } else {
1213 version = 0;
1214 }
1217 "The version of this quantum identifier is too new. You need to upgrade ARTS to use it.")
1218
1219 try {
1220 String qi_str;
1221 parse_xml_tag_content_as_string(is_xml, qi_str);
1222 qi = QuantumIdentifier(qi_str, version);
1223 } catch (const std::runtime_error& e) {
1224 ostringstream os;
1225 os << "Error reading QuantumIdentifier: "
1226 << "\n"
1227 << e.what();
1228 throw runtime_error(os.str());
1229 }
1230
1231 tag.read_from_stream(is_xml);
1232 tag.check_name("/QuantumIdentifier");
1233}
1234
1236
1242void xml_write_to_stream(ostream& os_xml,
1243 const QuantumIdentifier& qi,
1244 bofstream* pbofs _U_,
1245 const String& name,
1246 const Verbosity& verbosity) {
1247 ArtsXMLTag open_tag(verbosity);
1248 ArtsXMLTag close_tag(verbosity);
1249
1250 static_assert(QuantumIdentifier::version == 1);
1251
1252 open_tag.set_name("QuantumIdentifier");
1253 open_tag.add_attribute("version", QuantumIdentifier::version);
1254 if (name.length()) open_tag.add_attribute("name", name);
1255 open_tag.write_to_stream(os_xml);
1256
1257 os_xml << qi;
1258
1259 close_tag.set_name("/QuantumIdentifier");
1260 close_tag.write_to_stream(os_xml);
1261 os_xml << endl;
1262}
1263
1264//=== RetrievalQuantity =========================================
1265
1267
1272void xml_read_from_stream(istream& is_xml,
1274 bifstream* pbifs,
1275 const Verbosity& verbosity) {
1276 ArtsXMLTag tag(verbosity);
1277 Jacobian::Target target;
1278 String subtag;
1279 String subsubtag;
1280 String mode;
1281 ArrayOfVector grids;
1282
1283 tag.read_from_stream(is_xml);
1284 tag.check_name("RetrievalQuantity");
1285
1286 xml_read_from_stream(is_xml, target, pbifs, verbosity);
1287 xml_read_from_stream(is_xml, subtag, pbifs, verbosity);
1288 xml_read_from_stream(is_xml, subsubtag, pbifs, verbosity);
1289 xml_read_from_stream(is_xml, mode, pbifs, verbosity);
1290 xml_read_from_stream(is_xml, grids, pbifs, verbosity);
1291
1292 tag.read_from_stream(is_xml);
1293 tag.check_name("/RetrievalQuantity");
1294
1295 rq = RetrievalQuantity(
1296 target, subtag, subsubtag, mode, target.perturbation, grids);
1297}
1298
1300
1306void xml_write_to_stream(ostream& os_xml,
1307 const RetrievalQuantity& rq,
1308 bofstream* pbofs,
1309 const String& name,
1310 const Verbosity& verbosity) {
1311 ArtsXMLTag open_tag(verbosity);
1312 ArtsXMLTag close_tag(verbosity);
1313
1314 open_tag.set_name("RetrievalQuantity");
1315 if (name.length()) open_tag.add_attribute("name", name);
1316 open_tag.write_to_stream(os_xml);
1317
1318 xml_write_to_stream(os_xml, rq.Target(), pbofs, "", verbosity);
1319 xml_write_to_stream(os_xml, rq.Subtag(), pbofs, "Subtag", verbosity);
1320 xml_write_to_stream(os_xml, rq.SubSubtag(), pbofs, "SubSubtag", verbosity);
1321 xml_write_to_stream(os_xml, rq.Mode(), pbofs, "Mode", verbosity);
1322 xml_write_to_stream(os_xml, rq.Grids(), pbofs, "Grids", verbosity);
1323
1324 close_tag.set_name("/RetrievalQuantity");
1325 close_tag.write_to_stream(os_xml);
1326 os_xml << '\n';
1327}
1328
1329//=== SingleScatteringData ======================================
1330
1332
1337void xml_read_from_stream(istream& is_xml,
1338 SingleScatteringData& ssdata,
1339 bifstream* pbifs,
1340 const Verbosity& verbosity) {
1341 ArtsXMLTag tag(verbosity);
1342 String version;
1343
1344 tag.read_from_stream(is_xml);
1345 tag.check_name("SingleScatteringData");
1346 tag.get_attribute_value("version", version);
1347
1348 if (version == "3") {
1349 String ptype_string;
1350 xml_read_from_stream(is_xml, ptype_string, pbifs, verbosity);
1351 ssdata.ptype = PTypeFromString(ptype_string);
1352 } else if (version == "2") {
1353 String ptype_string;
1354 xml_read_from_stream(is_xml, ptype_string, pbifs, verbosity);
1355 ssdata.ptype = PType2FromString(ptype_string);
1356 } else {
1357 Index ptype;
1358 xml_read_from_stream(is_xml, ptype, pbifs, verbosity);
1359 if (ptype != PTYPE_GENERAL && ptype != PTYPE_TOTAL_RND &&
1360 ptype != PTYPE_AZIMUTH_RND) {
1361 ostringstream os;
1362 os << "Ptype value (" << ptype << ") is wrong."
1363 << "It must be \n"
1364 << PTYPE_TOTAL_RND << " - totally randomly oriented particles,\n"
1366 << " - azimuthally randomly oriented particles, or\n"
1367 << PTYPE_GENERAL << " - arbitrary oriented particles.\n";
1368 throw runtime_error(os.str());
1369 }
1370 ssdata.ptype = PType(ptype);
1371 }
1372 xml_read_from_stream(is_xml, ssdata.description, pbifs, verbosity);
1373 xml_read_from_stream(is_xml, ssdata.f_grid, pbifs, verbosity);
1374 xml_read_from_stream(is_xml, ssdata.T_grid, pbifs, verbosity);
1375 xml_read_from_stream(is_xml, ssdata.za_grid, pbifs, verbosity);
1376 /* Verify that we have a good coverage for the za grid */
1377 if ((ssdata.za_grid[0] > 1) ||
1378 ssdata.za_grid[ssdata.za_grid.nelem() - 1] < 179) {
1379 ostringstream os;
1380 os << "Missing data in xml-stream. Expected za_grid: [0, 180]. "
1381 << "Found za_grid: [" << ssdata.za_grid[0] << ", "
1382 << ssdata.za_grid[ssdata.za_grid.nelem() - 1] << "]";
1383 throw runtime_error(os.str());
1384 }
1385 xml_read_from_stream(is_xml, ssdata.aa_grid, pbifs, verbosity);
1386
1387 xml_read_from_stream(is_xml, ssdata.pha_mat_data, pbifs, verbosity);
1388 if (ssdata.pha_mat_data.nlibraries() != ssdata.f_grid.nelem()) {
1389 throw runtime_error(
1390 "Number of frequencies in f_grid and pha_mat_data "
1391 "not matching!!!");
1392 }
1393
1394 xml_read_from_stream(is_xml, ssdata.ext_mat_data, pbifs, verbosity);
1395 xml_read_from_stream(is_xml, ssdata.abs_vec_data, pbifs, verbosity);
1396
1397 tag.read_from_stream(is_xml);
1398 tag.check_name("/SingleScatteringData");
1399
1400 if (version != "3" && ssdata.ptype == PTYPE_AZIMUTH_RND) {
1402 }
1403
1404 chk_scat_data(ssdata, verbosity);
1405}
1406
1408
1414void xml_write_to_stream(ostream& os_xml,
1415 const SingleScatteringData& ssdata,
1416 bofstream* pbofs,
1417 const String& name,
1418 const Verbosity& verbosity) {
1419 ArtsXMLTag open_tag(verbosity);
1420 ArtsXMLTag close_tag(verbosity);
1421
1422 open_tag.set_name("SingleScatteringData");
1423 if (name.length()) open_tag.add_attribute("name", name);
1424 open_tag.add_attribute("version", "3");
1425 open_tag.write_to_stream(os_xml);
1426
1427 os_xml << '\n';
1429 os_xml, PTypeToString(ssdata.ptype), pbofs, "", verbosity);
1430 xml_write_to_stream(os_xml, ssdata.description, pbofs, "", verbosity);
1431 xml_write_to_stream(os_xml, ssdata.f_grid, pbofs, "", verbosity);
1432 xml_write_to_stream(os_xml, ssdata.T_grid, pbofs, "", verbosity);
1433 xml_write_to_stream(os_xml, ssdata.za_grid, pbofs, "", verbosity);
1434 xml_write_to_stream(os_xml, ssdata.aa_grid, pbofs, "", verbosity);
1435 xml_write_to_stream(os_xml, ssdata.pha_mat_data, pbofs, "", verbosity);
1436 xml_write_to_stream(os_xml, ssdata.ext_mat_data, pbofs, "", verbosity);
1437 xml_write_to_stream(os_xml, ssdata.abs_vec_data, pbofs, "", verbosity);
1438
1439 close_tag.set_name("/SingleScatteringData");
1440 close_tag.write_to_stream(os_xml);
1441 os_xml << '\n';
1442}
1443
1444//=== ScatteringMetaData ======================================
1445
1447
1452void xml_read_from_stream(istream& is_xml,
1453 ScatteringMetaData& smdata,
1454 bifstream* pbifs,
1455 const Verbosity& verbosity) {
1456 ArtsXMLTag tag(verbosity);
1457 String version;
1458
1459 tag.read_from_stream(is_xml);
1460 tag.check_name("ScatteringMetaData");
1461 tag.get_attribute_value("version", version);
1462
1463 if (version != "3") {
1464 ostringstream os;
1465 os << "Only ScatteringMetaData version 3 can be handled. "
1466 << "Versions 1 and 2 are obsolete.";
1467 throw runtime_error(os.str());
1468 }
1469
1470 xml_read_from_stream(is_xml, smdata.description, pbifs, verbosity);
1471 xml_read_from_stream(is_xml, smdata.source, pbifs, verbosity);
1472 xml_read_from_stream(is_xml, smdata.refr_index, pbifs, verbosity);
1473 xml_read_from_stream(is_xml, smdata.mass, pbifs, verbosity);
1474 xml_read_from_stream(is_xml, smdata.diameter_max, pbifs, verbosity);
1475 xml_read_from_stream(is_xml, smdata.diameter_volume_equ, pbifs, verbosity);
1477 is_xml, smdata.diameter_area_equ_aerodynamical, pbifs, verbosity);
1478
1479 tag.read_from_stream(is_xml);
1480 tag.check_name("/ScatteringMetaData");
1481}
1482
1484
1490void xml_write_to_stream(ostream& os_xml,
1491 const ScatteringMetaData& smdata,
1492 bofstream* pbofs,
1493 const String& name,
1494 const Verbosity& verbosity) {
1495 ArtsXMLTag open_tag(verbosity);
1496 ArtsXMLTag close_tag(verbosity);
1497
1498 open_tag.set_name("ScatteringMetaData");
1499 if (name.length()) open_tag.add_attribute("name", name);
1500 open_tag.add_attribute("version", "3");
1501 open_tag.write_to_stream(os_xml);
1502
1503 xml_write_to_stream(os_xml, smdata.description, pbofs, "", verbosity);
1504 xml_write_to_stream(os_xml, smdata.source, pbofs, "", verbosity);
1505 xml_write_to_stream(os_xml, smdata.refr_index, pbofs, "", verbosity);
1506 xml_write_to_stream(os_xml, smdata.mass, pbofs, "", verbosity);
1507 xml_write_to_stream(os_xml, smdata.diameter_max, pbofs, "", verbosity);
1508 xml_write_to_stream(os_xml, smdata.diameter_volume_equ, pbofs, "", verbosity);
1510 os_xml, smdata.diameter_area_equ_aerodynamical, pbofs, "", verbosity);
1511
1512 close_tag.set_name("/ScatteringMetaData");
1513 close_tag.write_to_stream(os_xml);
1514 os_xml << '\n';
1515}
1516
1517//=== SLIData2 =====================================================
1519
1525void xml_read_from_stream(istream& is_xml,
1526 SLIData2& slidata,
1527 bifstream* pbifs,
1528 const Verbosity& verbosity) {
1529 ArtsXMLTag tag(verbosity);
1530
1531 tag.read_from_stream(is_xml);
1532 tag.check_name("SLIData2");
1533
1534 xml_read_from_stream(is_xml, slidata.x1a, pbifs, verbosity);
1535 xml_read_from_stream(is_xml, slidata.x2a, pbifs, verbosity);
1536 xml_read_from_stream(is_xml, slidata.ya, pbifs, verbosity);
1537
1538 tag.read_from_stream(is_xml);
1539 tag.check_name("/SLIData2");
1540}
1541
1542void xml_write_to_stream(ostream& os_xml,
1543 const SLIData2& slidata,
1544 bofstream* pbofs,
1545 const String& name,
1546 const Verbosity& verbosity) {
1547 ArtsXMLTag open_tag(verbosity);
1548 ArtsXMLTag close_tag(verbosity);
1549
1550 open_tag.set_name("SLIData2");
1551 if (name.length()) open_tag.add_attribute("name", name);
1552 open_tag.write_to_stream(os_xml);
1553
1554 xml_write_to_stream(os_xml, slidata.x1a, pbofs, "", verbosity);
1555 xml_write_to_stream(os_xml, slidata.x2a, pbofs, "", verbosity);
1556 xml_write_to_stream(os_xml, slidata.ya, pbofs, "", verbosity);
1557
1558 close_tag.set_name("/SLIData2");
1559 close_tag.write_to_stream(os_xml);
1560 os_xml << '\n';
1561}
1562
1563//=== SpeciesIsotopologueRatios ===========================================
1564
1566
1571void xml_read_from_stream(istream& is_xml,
1573 bifstream* pbifs,
1574 const Verbosity& verbosity) {
1575 ARTS_USER_ERROR_IF(pbifs, "No support for binary IO for (SpeciesIsotopologueRatios)")
1576
1578
1579 iso_rat = SpeciesIsotopologueRatios{};
1580
1581 ArtsXMLTag tag(verbosity);
1582
1583 tag.read_from_stream(is_xml);
1584 tag.check_name("SpeciesIsotopologueRatios");
1585
1586 Index nelem;
1587 tag.get_attribute_value("nelem", nelem);
1588
1589 String name;
1590 Numeric val;
1591 for (Index n = 0; n < nelem; n++) {
1592 is_xml >> name >> double_imanip() >> val;
1593
1594 if (is_xml.fail()) {
1595 ostringstream os;
1596 os << " near "
1597 << "\n Element: " << n;
1598 xml_data_parse_error(tag, os.str());
1599 }
1600
1601 const Index i = Species::find_species_index(Species::Tag(name).Isotopologue());
1602 ARTS_USER_ERROR_IF(i < 0 or i >= iso_rat.maxsize,
1603 "Species: ", name, " cannot be understood as a species by your compiled version of ARTS")
1604
1605 iso_rat.data[i] = val;
1606 }
1607
1608 tag.read_from_stream(is_xml);
1609 tag.check_name("/SpeciesIsotopologueRatios");
1610}
1611
1613
1619void xml_write_to_stream(ostream& os_xml,
1620 const SpeciesIsotopologueRatios& iso_rat,
1621 bofstream* pbofs,
1622 const String& name,
1623 const Verbosity& verbosity)
1624
1625{
1626 ARTS_USER_ERROR_IF(pbofs, "No support for binary IO for (SpeciesIsotopologueRatios)")
1627
1628 ArtsXMLTag open_tag(verbosity);
1629 ArtsXMLTag close_tag(verbosity);
1630
1631 open_tag.set_name("SpeciesIsotopologueRatios");
1632 if (name.length()) open_tag.add_attribute("name", name);
1633 open_tag.add_attribute("nelem", iso_rat.maxsize);
1634
1635 open_tag.write_to_stream(os_xml);
1636 os_xml << '\n';
1637
1639 os_xml << iso_rat << '\n';
1640
1641 close_tag.set_name("/SpeciesIsotopologueRatios");
1642 close_tag.write_to_stream(os_xml);
1643
1644 os_xml << '\n';
1645}
1646
1647//=== SpeciesTag ================================================
1648
1650
1654/* param pbifs Pointer to binary input stream. NULL in case of ASCII file.
1655 Ignored because SpeciesTag is always stored in ASCII format.*/
1656void xml_read_from_stream(istream& is_xml,
1657 SpeciesTag& stag,
1658 bifstream* /* pbifs */,
1659 const Verbosity& verbosity) {
1660 ArtsXMLTag tag(verbosity);
1661 stringbuf strbuf;
1662 char dummy;
1663
1664 tag.read_from_stream(is_xml);
1665 tag.check_name("SpeciesTag");
1666
1667 // Skip whitespaces
1668 bool string_starts_with_quotes = true;
1669 do {
1670 is_xml >> dummy;
1671 switch (dummy) {
1672 case ' ':
1673 case '\"':
1674 case '\n':
1675 case '\r':
1676 case '\t':
1677 break;
1678 default:
1679 string_starts_with_quotes = false;
1680 }
1681 } while (is_xml.good() && dummy != '"' && string_starts_with_quotes);
1682
1683 // Throw exception if first char after whitespaces is not a quote
1684 if (!string_starts_with_quotes) {
1685 xml_parse_error("SpeciesTag must begin with \"");
1686 }
1687
1688 is_xml.get(strbuf, '"');
1689 if (is_xml.fail()) {
1690 xml_parse_error("SpeciesTag must end with \"");
1691 }
1692
1693 stag = SpeciesTag(strbuf.str());
1694
1695 // Ignore quote
1696 is_xml >> dummy;
1697
1698 tag.read_from_stream(is_xml);
1699 tag.check_name("/SpeciesTag");
1700}
1701
1703
1708/* param pbofs Pointer to binary file stream. NULL for ASCII output.
1709 Ignore because SpeciesTag is always stored in ASCII format. */
1710void xml_write_to_stream(ostream& os_xml,
1711 const SpeciesTag& stag,
1712 bofstream* /* pbofs */,
1713 const String& name,
1714 const Verbosity& verbosity) {
1715 ArtsXMLTag open_tag(verbosity);
1716 ArtsXMLTag close_tag(verbosity);
1717
1718 open_tag.set_name("SpeciesTag");
1719 if (name.length()) open_tag.add_attribute("name", name);
1720 open_tag.write_to_stream(os_xml);
1721
1722 os_xml << '\"' << stag.Name() << '\"';
1723
1724 close_tag.set_name("/SpeciesTag");
1725 close_tag.write_to_stream(os_xml);
1726 os_xml << '\n';
1727}
1728
1729//=== StokesVector ======================================================
1730
1732
1737void xml_read_from_stream(istream& is_xml,
1738 StokesVector& sv,
1739 bifstream* pbifs,
1740 const Verbosity& verbosity) {
1741 ArtsXMLTag tag(verbosity);
1742
1743 tag.read_from_stream(is_xml);
1744 tag.check_name("StokesVector");
1745
1746 try {
1747 Tensor4 d;
1748 xml_read_from_stream(is_xml, d, pbifs, verbosity);
1749 Index naa = d.nbooks();
1750 Index nza = d.npages();
1751 Index nf = d.nrows();
1752 Index nstokes_needed = d.ncols();
1753 sv = StokesVector(nf, need2stokes<false>(nstokes_needed), nza, naa);
1754 sv.Data() = std::move(d); // destructive takeover
1755 } catch (const std::runtime_error& e) {
1756 ostringstream os;
1757 os << "Error reading StokesVector: "
1758 << "\n"
1759 << e.what();
1760 throw runtime_error(os.str());
1761 }
1762
1763 tag.read_from_stream(is_xml);
1764 tag.check_name("/StokesVector");
1765}
1766
1768
1774void xml_write_to_stream(ostream& os_xml,
1775 const StokesVector& sv,
1776 bofstream* pbofs,
1777 const String& name,
1778 const Verbosity& verbosity) {
1779 ArtsXMLTag open_tag(verbosity);
1780 ArtsXMLTag close_tag(verbosity);
1781
1782 open_tag.set_name("StokesVector");
1783 if (name.length()) open_tag.add_attribute("name", name);
1784
1785 open_tag.write_to_stream(os_xml);
1786 os_xml << '\n';
1787
1788 xml_write_to_stream(os_xml, sv.Data(), pbofs, "", verbosity);
1789
1790 close_tag.set_name("/StokesVector");
1791 close_tag.write_to_stream(os_xml);
1792
1793 os_xml << '\n';
1794}
1795
1796//=== TelsemAtlas ======================================================
1797
1799
1804void xml_read_from_stream(istream& is_xml,
1805 TelsemAtlas& ta,
1806 bifstream* pbifs,
1807 const Verbosity& verbosity) {
1808 ArtsXMLTag tag(verbosity);
1809
1810 tag.read_from_stream(is_xml);
1811 tag.check_name("TelsemAtlas");
1812
1813 xml_read_from_stream(is_xml, ta.ndat, pbifs, verbosity);
1814 xml_read_from_stream(is_xml, ta.nchan, pbifs, verbosity);
1815 xml_read_from_stream(is_xml, ta.name, pbifs, verbosity);
1816 xml_read_from_stream(is_xml, ta.month, pbifs, verbosity);
1817 xml_read_from_stream(is_xml, ta.dlat, pbifs, verbosity);
1818 xml_read_from_stream(is_xml, ta.emis, pbifs, verbosity);
1819 xml_read_from_stream(is_xml, ta.correl, pbifs, verbosity);
1820 xml_read_from_stream(is_xml, ta.emis_err, pbifs, verbosity);
1821 xml_read_from_stream(is_xml, ta.classes1, pbifs, verbosity);
1822 xml_read_from_stream(is_xml, ta.classes2, pbifs, verbosity);
1823 xml_read_from_stream(is_xml, ta.cellnums, pbifs, verbosity);
1825 tag.read_from_stream(is_xml);
1826 tag.check_name("/TelsemAtlas");
1827}
1828
1830
1836void xml_write_to_stream(ostream& os_xml,
1837 const TelsemAtlas& ta,
1838 bofstream* pbofs,
1839 const String& name,
1840 const Verbosity& verbosity) {
1841 ArtsXMLTag open_tag(verbosity);
1842 ArtsXMLTag close_tag(verbosity);
1843
1844 open_tag.set_name("TelsemAtlas");
1845 if (name.length()) open_tag.add_attribute("name", name);
1846
1847 open_tag.write_to_stream(os_xml);
1848 os_xml << '\n';
1849 xml_write_to_stream(os_xml, ta.ndat, pbofs, "ndat", verbosity);
1850 xml_write_to_stream(os_xml, ta.nchan, pbofs, "nchan", verbosity);
1851 xml_write_to_stream(os_xml, ta.name, pbofs, "name", verbosity);
1852 xml_write_to_stream(os_xml, ta.month, pbofs, "month", verbosity);
1853 xml_write_to_stream(os_xml, ta.dlat, pbofs, "dlat", verbosity);
1854 xml_write_to_stream(os_xml, ta.emis, pbofs, "emis", verbosity);
1855 xml_write_to_stream(os_xml, ta.correl, pbofs, "correl", verbosity);
1856 xml_write_to_stream(os_xml, ta.emis_err, pbofs, "emis_err", verbosity);
1857 xml_write_to_stream(os_xml, ta.classes1, pbofs, "class1", verbosity);
1858 xml_write_to_stream(os_xml, ta.classes2, pbofs, "class2", verbosity);
1859 xml_write_to_stream(os_xml, ta.cellnums, pbofs, "cellnum", verbosity);
1860 close_tag.set_name("/TelsemAtlas");
1861 close_tag.write_to_stream(os_xml);
1862
1863 os_xml << '\n';
1864}
1865
1866//=== XsecRecord ======================================================
1867
1869
1874void xml_read_from_stream(istream& is_xml,
1875 XsecRecord& xd,
1876 bifstream* pbifs,
1877 const Verbosity& verbosity) {
1879 ArtsXMLTag tag(verbosity);
1880 Index version;
1881
1882 tag.read_from_stream(is_xml);
1883 tag.check_name("XsecRecord");
1884 tag.get_attribute_value("version", version);
1885 xd.SetVersion(version);
1886
1887 String species_name;
1888 xml_read_from_stream(is_xml, species_name, pbifs, verbosity);
1889
1890 const Species::Species species = Species::fromShortName(species_name);
1891 if (not good_enum(species)) {
1892 ostringstream os;
1893 os << " Unknown species in XsecRecord: " << species_name;
1894 throw std::runtime_error(os.str());
1895 }
1896 xd.SetSpecies(species);
1897
1898 ARTS_USER_ERROR_IF(version != 2, "Only XsecRecord version 2 is supported")
1899
1900 xml_read_from_stream(is_xml, xd.FitMinPressures(), pbifs, verbosity);
1901 xml_read_from_stream(is_xml, xd.FitMaxPressures(), pbifs, verbosity);
1902 xml_read_from_stream(is_xml, xd.FitMinTemperatures(), pbifs, verbosity);
1903 xml_read_from_stream(is_xml, xd.FitMaxTemperatures(), pbifs, verbosity);
1904 xml_read_from_stream(is_xml, xd.FitCoeffs(), pbifs, verbosity);
1905
1906 for (const auto& fitcoeffs : xd.FitCoeffs()) {
1907 const Index ncoeff = fitcoeffs.data.ncols();
1909 ncoeff != 4, "Wrong number of coefficients, expected 4, found ", ncoeff)
1910 }
1911
1912 tag.read_from_stream(is_xml);
1913 tag.check_name("/XsecRecord");
1914}
1915
1917
1923void xml_write_to_stream(ostream& os_xml,
1924 const XsecRecord& xd,
1925 bofstream* pbofs,
1926 const String& name,
1927 const Verbosity& verbosity) {
1928 ArtsXMLTag open_tag(verbosity);
1929 ArtsXMLTag close_tag(verbosity);
1930
1931 open_tag.set_name("XsecRecord");
1932 if (name.length()) open_tag.add_attribute("name", name);
1933 open_tag.add_attribute("version", xd.Version());
1934
1935 open_tag.write_to_stream(os_xml);
1936 os_xml << '\n';
1937 xml_write_to_stream(os_xml, xd.SpeciesName(), pbofs, "species", verbosity);
1938
1939 xml_write_to_stream(os_xml,
1940 xd.FitMinPressures(),
1941 pbofs,
1942 "Mininum pressures from fit",
1943 verbosity);
1944 xml_write_to_stream(os_xml,
1945 xd.FitMaxPressures(),
1946 pbofs,
1947 "Maximum pressures from fit",
1948 verbosity);
1949 xml_write_to_stream(os_xml,
1950 xd.FitMinTemperatures(),
1951 pbofs,
1952 "Mininum temperatures from fit",
1953 verbosity);
1954 xml_write_to_stream(os_xml,
1955 xd.FitMaxTemperatures(),
1956 pbofs,
1957 "Maximum temperatures from fit",
1958 verbosity);
1960 os_xml, xd.FitCoeffs(), pbofs, "Fit coefficients", verbosity);
1961
1962 close_tag.set_name("/XsecRecord");
1963 close_tag.write_to_stream(os_xml);
1964
1965 os_xml << '\n';
1966}
1967
1968//=== MapOfErrorCorrectedSuddenData ======================================================
1969
1971
1976void xml_read_from_stream(istream& is_xml,
1978 bifstream* pbifs,
1979 const Verbosity& verbosity) {
1980 ARTS_USER_ERROR_IF(pbifs not_eq nullptr, "No binary data")
1981
1983 ArtsXMLTag open_tag(verbosity);
1984 open_tag.read_from_stream(is_xml);
1985 open_tag.check_name("MapOfErrorCorrectedSuddenData");
1986
1987 Index nelem;
1988 open_tag.get_attribute_value("nelem", nelem);
1989
1990 for (Index i=0; i<nelem; i++) {
1991 ArtsXMLTag internal_open_tag(verbosity);
1992 internal_open_tag.read_from_stream(is_xml);
1993 internal_open_tag.check_name("ErrorCorrectedSuddenData");
1994
1995 // Get key
1996 String val;
1997 internal_open_tag.get_attribute_value("key", val);
1998 auto& data = rvb[QuantumIdentifier(val)];
1999
2000 // Get size
2001 Index nelem_specs;
2002 internal_open_tag.get_attribute_value("nelem", nelem_specs);
2003
2004 // Get values
2005 for (Index j=0; j<nelem_specs; j++) {
2007 is_xml >> secds;
2008 data[secds.spec] = secds;
2009 }
2010
2011 ArtsXMLTag internal_close_tag(verbosity);
2012 internal_close_tag.read_from_stream(is_xml);
2013 internal_close_tag.check_name("/ErrorCorrectedSuddenData");
2014
2015 }
2016
2017 ArtsXMLTag close_tag(verbosity);
2018 close_tag.read_from_stream(is_xml);
2019 close_tag.check_name("/MapOfErrorCorrectedSuddenData");
2020
2021 // Sanity check, it is not OK to not have AIR as catch-all broadener
2022 for (auto& x: rvb) {
2023 bool found_air=false;
2024 for (auto& y: x.data) {
2025 found_air = found_air or (y.spec == Species::Species::Bath);
2026 }
2027 ARTS_USER_ERROR_IF(not found_air,
2028 "Incomplete ErrorCorrectedSuddenData, must contain air, contains:\n",
2029 x)
2030 }
2031}
2032
2034
2040void xml_write_to_stream(ostream& os_xml,
2042 bofstream* pbofs,
2043 const String& name,
2044 const Verbosity& verbosity) {
2045 ARTS_USER_ERROR_IF(pbofs not_eq nullptr, "No binary data")
2046
2047 ArtsXMLTag open_tag(verbosity);
2048 ArtsXMLTag close_tag(verbosity);
2049
2050 open_tag.set_name("MapOfErrorCorrectedSuddenData");
2051 if (name.length()) open_tag.add_attribute("name", name);
2052 open_tag.add_attribute("nelem", rvb.nelem());
2053 open_tag.write_to_stream(os_xml);
2054 os_xml << '\n';
2055
2057
2058 for (auto& r: rvb) {
2059 ArtsXMLTag internal_open_tag(verbosity);
2060 internal_open_tag.set_name("ErrorCorrectedSuddenData");
2061 internal_open_tag.add_attribute("key", var_string(r.id));
2062 internal_open_tag.add_attribute("nelem", r.data.nelem());
2063 internal_open_tag.write_to_stream(os_xml);
2064 os_xml << '\n';
2065
2066 // Set values
2067 os_xml << r << '\n';
2068
2069 ArtsXMLTag internal_close_tag(verbosity);
2070 internal_close_tag.set_name("/ErrorCorrectedSuddenData");
2071 internal_close_tag.write_to_stream(os_xml);
2072 os_xml << '\n';
2073 }
2074
2075 close_tag.set_name("/MapOfErrorCorrectedSuddenData");
2076 close_tag.write_to_stream(os_xml);
2077
2078 os_xml << '\n';
2079}
2080
2082// Dummy funtion for groups for which
2083// IO function have not yet been implemented
2085
2086// FIXME: These should be implemented, sooner or later...
2087
2089 Agenda&,
2090 bifstream* /* pbifs */,
2091 const Verbosity&) {
2092 throw runtime_error("Method not implemented!");
2093}
2094
2096 const Agenda&,
2097 bofstream* /* pbofs */,
2098 const String& /* name */,
2099 const Verbosity&) {
2100 throw runtime_error("Method not implemented!");
2101}
2102
2103//=== MCAntenna ================================================
2104
2106 MCAntenna&,
2107 bifstream* /* pbifs */,
2108 const Verbosity&) {
2109 throw runtime_error("Method not implemented!");
2110}
2111
2113 const MCAntenna&,
2114 bofstream* /* pbofs */,
2115 const String& /* name */,
2116 const Verbosity&) {
2117 throw runtime_error("Method not implemented!");
2118}
2119
2120//=== TessemNN ================================================
2121
2123 TessemNN&,
2124 bifstream* /* pbifs */,
2125 const Verbosity&) {
2126 throw runtime_error("Method not implemented!");
2127}
2128
2130 const TessemNN&,
2131 bofstream* /* pbofs */,
2132 const String& /* name */,
2133 const Verbosity&) {
2134 throw runtime_error("Method not implemented!");
2135}
2136
2137//=== Verbosity ================================================
2138
2140 Verbosity&,
2141 bifstream* /* pbifs */,
2142 const Verbosity&) {
2143 throw runtime_error("Method not implemented!");
2144}
2145
2147 const Verbosity&,
2148 bofstream* /* pbofs */,
2149 const String& /* name */,
2150 const Verbosity&) {
2151 throw runtime_error("Method not implemented!");
2152}
2153
2154//=== CallbackFunction =========================================
2155
2158 bifstream* /* pbifs */,
2159 const Verbosity&) {
2160 throw runtime_error("Method not implemented!");
2161}
2162
2164 const CallbackFunction&,
2165 bofstream* /* pbofs */,
2166 const String& /* name */,
2167 const Verbosity&) {
2168 throw runtime_error("Method not implemented!");
2169}
The global header file for ARTS.
The Agenda class.
Definition: agenda_class.h:51
Index nelem() const ARTS_NOEXCEPT
Number of elements.
Definition: array.h:197
The ARTS XML tag class.
Definition: xml_io.h:45
void add_attribute(const String &aname, const std::vector< QuantumNumberType > &value)
Adds value of attribute as type std::vector<QuantumNumberType> to tag.
Definition: xml_io.cc:42
void get_attribute_value(const String &aname, SpeciesTag &value)
Returns value of attribute as type SpeciesTag.
Definition: xml_io.cc:70
CIA data for a single pair of molecules.
Definition: cia.h:68
void SetSpecies(const Species::Species first, const Species::Species second)
Set CIA species.
Definition: cia.h:148
ArrayOfGriddedField2 mdata
The data itself, directly from the HITRAN file.
Definition: cia.h:236
const ArrayOfGriddedField2 & Data() const
Return CIA data.
Definition: cia.h:138
String MoleculeName(const Index i) const
Return each molecule name (as a string) that is associated with this CIARecord.
Definition: cia.cc:266
Index nlibraries() const noexcept
Definition: matpackVII.h:153
Index nelem() const noexcept
Returns the number of elements.
Definition: matpackI.h:541
std::vector< Block > correlations_
std::vector< Block > inverses_
An absorption lookup table.
Vector p_grid
The pressure grid for the table [Pa].
Tensor4 xsec
Absorption cross sections.
Vector t_pert
The vector of temperature perturbations [K].
Vector f_grid
The frequency grid [Hz].
Matrix vmrs_ref
The reference VMR profiles.
Vector nls_pert
The vector of perturbations for the VMRs of the nonlinear species.
Vector t_ref
The reference temperature profile [K].
ArrayOfIndex nonlinear_species
The species tags with non-linear treatment.
ArrayOfArrayOfSpeciesTag species
The species tags for which the table is valid.
void checksize_strict() const final
Strict consistency check.
void checksize_strict() const final
Strict consistency check.
void checksize_strict() const final
Strict consistency check.
void checksize_strict() const final
Strict consistency check.
void checksize_strict() const final
Strict consistency check.
void checksize_strict() const final
Strict consistency check.
const String & get_name() const
Get the name of this gridded field.
void set_name(const String &s)
Set name of this gridded field.
const ArrayOfString & get_string_grid(Index i) const
Get a string grid.
Index get_dim() const
Get the dimension of this gridded field.
void set_grid_name(Index i, const String &s)
Set grid name.
void set_grid(Index i, const Vector &g)
Set a numeric grid.
GridType get_grid_type(Index i) const
Get grid type.
const Vector & get_numeric_grid(Index i) const
Get a numeric grid.
const String & get_grid_name(Index i) const
Get grid name.
Tensor4 & Data()
Get full view to data.
The range class.
Definition: matpackI.h:166
constexpr Index get_extent() const noexcept
Returns the extent of the range.
Definition: matpackI.h:349
constexpr Index get_start() const noexcept
Returns the start index of the range.
Definition: matpackI.h:347
Deals with internal derivatives, Jacobian definition, and OEM calculations.
Definition: jacobian.h:330
const String & Mode() const
Returns the mode.
Definition: jacobian.h:399
Jacobian::Target & Target()
Get the Jacobian Target.
Definition: jacobian.h:436
const String & SubSubtag() const
Returns the sub-sub-tag.
Definition: jacobian.h:384
const ArrayOfVector & Grids() const
Returns the grids of the retrieval.
Definition: jacobian.h:413
const String & Subtag() const
Returns the sub-tag.
Definition: jacobian.h:370
A 2D sequential linear interpolation (SLI) lookup table This class holds the gridded for 2D SLI as we...
Definition: mc_interp.h:56
ArrayOfVector x2a
Definition: mc_interp.h:61
ArrayOfVector ya
Definition: mc_interp.h:63
Vector x1a
Definition: mc_interp.h:59
Stokes vector is as Propagation matrix but only has 4 possible values.
A telsem atlas.
Definition: telsem.h:59
Matrix emis
Definition: telsem.h:367
Tensor3 correl
Definition: telsem.h:371
ArrayOfIndex classes2
Definition: telsem.h:374
Index nchan
Definition: telsem.h:355
Numeric dlat
Definition: telsem.h:361
Matrix emis_err
Definition: telsem.h:369
ArrayOfIndex cellnums
Definition: telsem.h:376
ArrayOfIndex classes1
Definition: telsem.h:373
Index month
Definition: telsem.h:359
void telsem_calc_correspondence()
Definition: telsem.cc:134
Index ndat
Definition: telsem.h:353
String name
Definition: telsem.h:357
The Tensor4 class.
Definition: matpackIV.h:427
The Vector class.
Definition: matpackI.h:908
The ARTS XML tag class.
Definition: xml_io_base.h:68
bool has_attribute(const String &aname) const
Returns if the attribute exists or not.
Definition: xml_io_base.cc:125
void write_to_stream(ostream &os)
Write XML tag.
Definition: xml_io_base.cc:322
void check_name(const String &expected_name)
Check tag name.
Definition: xml_io_base.cc:54
void read_from_stream(istream &is)
Reads next XML tag.
Definition: xml_io_base.cc:201
void get_attribute_value(const String &aname, String &value)
Definition: xml_io_base.cc:140
void set_name(const String &new_name)
Definition: xml_io_base.h:76
String & get_name()
Definition: xml_io_base.h:72
Hitran crosssection class.
Definition: hitran_xsec.h:43
const Vector & FitMinPressures() const
Get mininum pressures from fit.
Definition: hitran_xsec.h:79
const Vector & FitMinTemperatures() const
Get mininum temperatures from fit.
Definition: hitran_xsec.h:89
String SpeciesName() const
Return species name.
Definition: hitran_xsec.cc:38
void SetVersion(Index version)
Set species name.
Definition: hitran_xsec.cc:44
Index Version() const
Return species index.
Definition: hitran_xsec.h:55
const Vector & FitMaxPressures() const
Get maximum pressures from fit.
Definition: hitran_xsec.h:84
const Vector & FitMaxTemperatures() const
Get maximum temperatures.
Definition: hitran_xsec.h:94
void SetSpecies(const Species::Species species)
Set species name.
Definition: hitran_xsec.h:52
const ArrayOfGriddedField2 & FitCoeffs() const
Get coefficients.
Definition: hitran_xsec.h:99
Binary output file stream class.
Definition: bifstream.h:42
Binary output file stream class.
Definition: bofstream.h:42
Input manipulator class for doubles to enable nan and inf parsing.
Definition: double_imanip.h:64
void chk_scat_data(const SingleScatteringData &scat_data_single, const Verbosity &verbosity)
Check single scattering data.
Definition: cloudbox.cc:292
Internal cloudbox functions.
#define _U_
Definition: config.h:180
std::string var_string(Args &&... args)
Definition: debug.h:36
#define ARTS_USER_ERROR_IF(condition,...)
Definition: debug.h:134
EnergyLevelMapType toEnergyLevelMapTypeOrThrow(std::string_view s)
constexpr std::string_view toString(EnergyLevelMapType x) noexcept
constexpr bool good_enum(EnumType x) noexcept
Checks if the enum number is good.
Definition: enums.h:22
@ GRID_TYPE_NUMERIC
@ GRID_TYPE_STRING
NUMERIC Numeric
The type to use for all floating point numbers.
Definition: matpack.h:33
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:39
#define CREATE_OUT2
Definition: messages.h:206
Index nelem(const Lines &l)
Number of lines.
constexpr Index find_species_index(const Species spec, const std::string_view isot) noexcept
invlib::Matrix< ArtsCovarianceMatrixWrapper > CovarianceMatrix
invlib wrapper type for ARTS the ARTS covariance class.
Definition: oem.h:37
PType PType2FromString(const String &ptype_string)
Convert ptype name to enum value.
PType PTypeFromString(const String &ptype_string)
Convert ptype name to enum value.
void ConvertAzimuthallyRandomSingleScatteringData(SingleScatteringData &ssd)
Convert azimuthally-random oriented SingleScatteringData to latest version.
String PTypeToString(const PType &ptype)
Convert particle type enum value to String.
PType
An attribute to classify the particle type (ptype) of a SingleScatteringData.
Definition: optproperties.h:52
@ PTYPE_GENERAL
Definition: optproperties.h:53
@ PTYPE_AZIMUTH_RND
Definition: optproperties.h:54
@ PTYPE_TOTAL_RND
Definition: optproperties.h:55
#define d
#define v
#define c
Quantum::Number::GlobalState QuantumIdentifier
#define M
Definition: rng.cc:165
Species::Tag SpeciesTag
Definition: species_tags.h:101
ArrayOfQuantumIdentifier levels
EnergyLevelMapType type
void ThrowIfNotOK() const ARTS_NOEXCEPT
Structure to store a grid position.
Definition: interpolation.h:73
std::array< Numeric, 2 > fd
Definition: interpolation.h:75
Index idx
Definition: interpolation.h:74
Holds all information required for individual partial derivatives.
Definition: jacobian.h:107
Numeric perturbation
Perturbations for methods where theoretical computations are impossible or plain slow.
Definition: jacobian.h:124
An Antenna object used by MCGeneral.
Definition: mc_antenna.h:50
The structure to describe a propagation path and releated quantities.
Definition: ppath_struct.h:17
Matrix los
Line-of-sight at each ppath point.
Definition: ppath_struct.h:35
ArrayOfGridPos gp_lon
Index position with respect to the longitude grid.
Definition: ppath_struct.h:55
String background
Radiative background.
Definition: ppath_struct.h:25
Index np
Number of points describing the ppath.
Definition: ppath_struct.h:21
Matrix pos
The distance between start pos and the last position in pos.
Definition: ppath_struct.h:33
ArrayOfGridPos gp_lat
Index position with respect to the latitude grid.
Definition: ppath_struct.h:53
Numeric end_lstep
The distance between end pos and the first position in pos.
Definition: ppath_struct.h:45
Vector start_pos
Start position.
Definition: ppath_struct.h:27
Vector lstep
The length between ppath points.
Definition: ppath_struct.h:39
Numeric start_lstep
Length between sensor and atmospheric boundary.
Definition: ppath_struct.h:31
Numeric constant
The propagation path constant (only used for 1D)
Definition: ppath_struct.h:23
Vector r
Radius of each ppath point.
Definition: ppath_struct.h:37
ArrayOfGridPos gp_p
Index position with respect to the pressure grid.
Definition: ppath_struct.h:51
Vector ngroup
The group index of refraction.
Definition: ppath_struct.h:49
Index dim
Atmospheric dimensionality.
Definition: ppath_struct.h:19
Vector end_pos
End position.
Definition: ppath_struct.h:41
Vector start_los
Start line-of-sight.
Definition: ppath_struct.h:29
Vector nreal
The real part of the refractive index at each path position.
Definition: ppath_struct.h:47
Vector end_los
End line-of-sight.
Definition: ppath_struct.h:43
A logical struct for global quantum numbers with species identifiers.
static constexpr Index version
Numeric diameter_area_equ_aerodynamical
Numeric diameter_volume_equ
std::array< Numeric, maxsize > data
static constexpr Index maxsize
void xml_data_parse_error(ArtsXMLTag &tag, String str_error)
Throws XML parser runtime error.
Definition: xml_io.cc:179
This file contains basic functions to handle XML data files.
void xml_parse_from_stream(istream &, Vector &, bifstream *, ArtsXMLTag &, const Verbosity &verbosity)
void parse_xml_tag_content_as_string(std::istream &is_xml, String &content)
Get the content of an xml tag as a string.
Definition: xml_io_base.cc:723
void xml_set_stream_precision(ostream &os)
Definition: xml_io_base.cc:705
void xml_parse_error(const String &str_error)
Throws XML parser runtime error.
Definition: xml_io_base.cc:539
void xml_read_from_stream(istream &is_xml, CIARecord &cr, bifstream *pbifs, const Verbosity &verbosity)
Reads CIARecord from XML input stream.
void xml_write_to_stream(ostream &os_xml, const CIARecord &cr, bofstream *pbofs, const String &name, const Verbosity &verbosity)
Writes CIARecord to XML output stream.