ARTS 2.5.0 (git: 9ee3ac6c)
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 "xml_io.h"
32#include "global_data.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.Data(), pbifs, verbosity);
301 xml_read_from_stream(is_xml, elm.Energies(), 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", energylevelmaptype2string(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.Data(), pbofs, "Level Data", verbosity);
331 xml_write_to_stream(os_xml, elm.Energies(), 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 ArtsXMLTag tag(verbosity);
1203
1204 tag.read_from_stream(is_xml);
1205 tag.check_name("QuantumIdentifier");
1206
1207 try {
1208 String qi_str;
1209 parse_xml_tag_content_as_string(is_xml, qi_str);
1210 qi.SetFromString(qi_str);
1211 } catch (const std::runtime_error& e) {
1212 ostringstream os;
1213 os << "Error reading QuantumIdentifier: "
1214 << "\n"
1215 << e.what();
1216 throw runtime_error(os.str());
1217 }
1218
1219 tag.read_from_stream(is_xml);
1220 tag.check_name("/QuantumIdentifier");
1221}
1222
1224
1230void xml_write_to_stream(ostream& os_xml,
1231 const QuantumIdentifier& qi,
1232 bofstream* pbofs _U_,
1233 const String& name,
1234 const Verbosity& verbosity) {
1235 ArtsXMLTag open_tag(verbosity);
1236 ArtsXMLTag close_tag(verbosity);
1237
1238 open_tag.set_name("QuantumIdentifier");
1239 if (name.length()) open_tag.add_attribute("name", name);
1240 open_tag.write_to_stream(os_xml);
1241
1242 os_xml << qi;
1243
1244 close_tag.set_name("/QuantumIdentifier");
1245 close_tag.write_to_stream(os_xml);
1246 os_xml << endl;
1247}
1248
1249//=== QuantumNumbers =========================================
1250
1252
1257void xml_read_from_stream(istream& is_xml,
1258 QuantumNumbers& qn,
1259 bifstream* pbifs _U_,
1260 const Verbosity& verbosity) {
1261 ArtsXMLTag tag(verbosity);
1262 Index nelem;
1263
1264 tag.read_from_stream(is_xml);
1265 tag.check_name("QuantumNumbers");
1266
1267 tag.get_attribute_value("nelem", nelem);
1268
1269 Index n;
1270 try {
1271 for (n = 0; n < nelem; n++) is_xml >> qn;
1272 } catch (const std::runtime_error& e) {
1273 ostringstream os;
1274 os << "Error reading QuantumNumbers: "
1275 << "\n Element: " << n << "\n"
1276 << e.what();
1277 throw runtime_error(os.str());
1278 }
1279
1280 tag.read_from_stream(is_xml);
1281 tag.check_name("/QuantumNumbers");
1282}
1283
1285
1291void xml_write_to_stream(ostream& os_xml,
1292 const QuantumNumbers& qn,
1293 bofstream* pbofs _U_,
1294 const String& name,
1295 const Verbosity& verbosity) {
1296 ArtsXMLTag open_tag(verbosity);
1297 ArtsXMLTag close_tag(verbosity);
1298
1299 open_tag.set_name("QuantumNumbers");
1300 if (name.length()) open_tag.add_attribute("name", name);
1301 open_tag.add_attribute("nelem", Index(qn.GetNumbers().size()));
1302 open_tag.write_to_stream(os_xml);
1303
1304 os_xml << " " << qn << " ";
1305
1306 close_tag.set_name("/QuantumNumbers");
1307 close_tag.write_to_stream(os_xml);
1308}
1309
1310//=== RetrievalQuantity =========================================
1311
1313
1318void xml_read_from_stream(istream& is_xml,
1320 bifstream* pbifs,
1321 const Verbosity& verbosity) {
1322 ArtsXMLTag tag(verbosity);
1323 Jacobian::Target target;
1324 String subtag;
1325 String subsubtag;
1326 String mode;
1327 ArrayOfVector grids;
1328
1329 tag.read_from_stream(is_xml);
1330 tag.check_name("RetrievalQuantity");
1331
1332 xml_read_from_stream(is_xml, target, pbifs, verbosity);
1333 xml_read_from_stream(is_xml, subtag, pbifs, verbosity);
1334 xml_read_from_stream(is_xml, subsubtag, pbifs, verbosity);
1335 xml_read_from_stream(is_xml, mode, pbifs, verbosity);
1336 xml_read_from_stream(is_xml, grids, pbifs, verbosity);
1337
1338 tag.read_from_stream(is_xml);
1339 tag.check_name("/RetrievalQuantity");
1340
1341 rq = RetrievalQuantity(
1342 target, subtag, subsubtag, mode, target.Perturbation(), grids);
1343}
1344
1346
1352void xml_write_to_stream(ostream& os_xml,
1353 const RetrievalQuantity& rq,
1354 bofstream* pbofs,
1355 const String& name,
1356 const Verbosity& verbosity) {
1357 ArtsXMLTag open_tag(verbosity);
1358 ArtsXMLTag close_tag(verbosity);
1359
1360 open_tag.set_name("RetrievalQuantity");
1361 if (name.length()) open_tag.add_attribute("name", name);
1362 open_tag.write_to_stream(os_xml);
1363
1364 xml_write_to_stream(os_xml, rq.Target(), pbofs, "", verbosity);
1365 xml_write_to_stream(os_xml, rq.Subtag(), pbofs, "Subtag", verbosity);
1366 xml_write_to_stream(os_xml, rq.SubSubtag(), pbofs, "SubSubtag", verbosity);
1367 xml_write_to_stream(os_xml, rq.Mode(), pbofs, "Mode", verbosity);
1368 xml_write_to_stream(os_xml, rq.Grids(), pbofs, "Grids", verbosity);
1369
1370 close_tag.set_name("/RetrievalQuantity");
1371 close_tag.write_to_stream(os_xml);
1372 os_xml << '\n';
1373}
1374
1375//=== SingleScatteringData ======================================
1376
1378
1383void xml_read_from_stream(istream& is_xml,
1384 SingleScatteringData& ssdata,
1385 bifstream* pbifs,
1386 const Verbosity& verbosity) {
1387 ArtsXMLTag tag(verbosity);
1388 String version;
1389
1390 tag.read_from_stream(is_xml);
1391 tag.check_name("SingleScatteringData");
1392 tag.get_attribute_value("version", version);
1393
1394 if (version == "3") {
1395 String ptype_string;
1396 xml_read_from_stream(is_xml, ptype_string, pbifs, verbosity);
1397 ssdata.ptype = PTypeFromString(ptype_string);
1398 } else if (version == "2") {
1399 String ptype_string;
1400 xml_read_from_stream(is_xml, ptype_string, pbifs, verbosity);
1401 ssdata.ptype = PType2FromString(ptype_string);
1402 } else {
1403 Index ptype;
1404 xml_read_from_stream(is_xml, ptype, pbifs, verbosity);
1405 if (ptype != PTYPE_GENERAL && ptype != PTYPE_TOTAL_RND &&
1406 ptype != PTYPE_AZIMUTH_RND) {
1407 ostringstream os;
1408 os << "Ptype value (" << ptype << ") is wrong."
1409 << "It must be \n"
1410 << PTYPE_TOTAL_RND << " - totally randomly oriented particles,\n"
1412 << " - azimuthally randomly oriented particles, or\n"
1413 << PTYPE_GENERAL << " - arbitrary oriented particles.\n";
1414 throw runtime_error(os.str());
1415 }
1416 ssdata.ptype = PType(ptype);
1417 }
1418 xml_read_from_stream(is_xml, ssdata.description, pbifs, verbosity);
1419 xml_read_from_stream(is_xml, ssdata.f_grid, pbifs, verbosity);
1420 xml_read_from_stream(is_xml, ssdata.T_grid, pbifs, verbosity);
1421 xml_read_from_stream(is_xml, ssdata.za_grid, pbifs, verbosity);
1422 /* Verify that we have a good coverage for the za grid */
1423 if ((ssdata.za_grid[0] > 1) ||
1424 ssdata.za_grid[ssdata.za_grid.nelem() - 1] < 179) {
1425 ostringstream os;
1426 os << "Missing data in xml-stream. Expected za_grid: [0, 180]. "
1427 << "Found za_grid: [" << ssdata.za_grid[0] << ", "
1428 << ssdata.za_grid[ssdata.za_grid.nelem() - 1] << "]";
1429 throw runtime_error(os.str());
1430 }
1431 xml_read_from_stream(is_xml, ssdata.aa_grid, pbifs, verbosity);
1432
1433 xml_read_from_stream(is_xml, ssdata.pha_mat_data, pbifs, verbosity);
1434 if (ssdata.pha_mat_data.nlibraries() != ssdata.f_grid.nelem()) {
1435 throw runtime_error(
1436 "Number of frequencies in f_grid and pha_mat_data "
1437 "not matching!!!");
1438 }
1439
1440 xml_read_from_stream(is_xml, ssdata.ext_mat_data, pbifs, verbosity);
1441 xml_read_from_stream(is_xml, ssdata.abs_vec_data, pbifs, verbosity);
1442
1443 tag.read_from_stream(is_xml);
1444 tag.check_name("/SingleScatteringData");
1445
1446 if (version != "3" && ssdata.ptype == PTYPE_AZIMUTH_RND) {
1448 }
1449
1450 chk_scat_data(ssdata, verbosity);
1451}
1452
1454
1460void xml_write_to_stream(ostream& os_xml,
1461 const SingleScatteringData& ssdata,
1462 bofstream* pbofs,
1463 const String& name,
1464 const Verbosity& verbosity) {
1465 ArtsXMLTag open_tag(verbosity);
1466 ArtsXMLTag close_tag(verbosity);
1467
1468 open_tag.set_name("SingleScatteringData");
1469 if (name.length()) open_tag.add_attribute("name", name);
1470 open_tag.add_attribute("version", "3");
1471 open_tag.write_to_stream(os_xml);
1472
1473 os_xml << '\n';
1475 os_xml, PTypeToString(ssdata.ptype), pbofs, "", verbosity);
1476 xml_write_to_stream(os_xml, ssdata.description, pbofs, "", verbosity);
1477 xml_write_to_stream(os_xml, ssdata.f_grid, pbofs, "", verbosity);
1478 xml_write_to_stream(os_xml, ssdata.T_grid, pbofs, "", verbosity);
1479 xml_write_to_stream(os_xml, ssdata.za_grid, pbofs, "", verbosity);
1480 xml_write_to_stream(os_xml, ssdata.aa_grid, pbofs, "", verbosity);
1481 xml_write_to_stream(os_xml, ssdata.pha_mat_data, pbofs, "", verbosity);
1482 xml_write_to_stream(os_xml, ssdata.ext_mat_data, pbofs, "", verbosity);
1483 xml_write_to_stream(os_xml, ssdata.abs_vec_data, pbofs, "", verbosity);
1484
1485 close_tag.set_name("/SingleScatteringData");
1486 close_tag.write_to_stream(os_xml);
1487 os_xml << '\n';
1488}
1489
1490//=== ScatteringMetaData ======================================
1491
1493
1498void xml_read_from_stream(istream& is_xml,
1499 ScatteringMetaData& smdata,
1500 bifstream* pbifs,
1501 const Verbosity& verbosity) {
1502 ArtsXMLTag tag(verbosity);
1503 String version;
1504
1505 tag.read_from_stream(is_xml);
1506 tag.check_name("ScatteringMetaData");
1507 tag.get_attribute_value("version", version);
1508
1509 if (version != "3") {
1510 ostringstream os;
1511 os << "Only ScatteringMetaData version 3 can be handled. "
1512 << "Versions 1 and 2 are obsolete.";
1513 throw runtime_error(os.str());
1514 }
1515
1516 xml_read_from_stream(is_xml, smdata.description, pbifs, verbosity);
1517 xml_read_from_stream(is_xml, smdata.source, pbifs, verbosity);
1518 xml_read_from_stream(is_xml, smdata.refr_index, pbifs, verbosity);
1519 xml_read_from_stream(is_xml, smdata.mass, pbifs, verbosity);
1520 xml_read_from_stream(is_xml, smdata.diameter_max, pbifs, verbosity);
1521 xml_read_from_stream(is_xml, smdata.diameter_volume_equ, pbifs, verbosity);
1523 is_xml, smdata.diameter_area_equ_aerodynamical, pbifs, verbosity);
1524
1525 tag.read_from_stream(is_xml);
1526 tag.check_name("/ScatteringMetaData");
1527}
1528
1530
1536void xml_write_to_stream(ostream& os_xml,
1537 const ScatteringMetaData& smdata,
1538 bofstream* pbofs,
1539 const String& name,
1540 const Verbosity& verbosity) {
1541 ArtsXMLTag open_tag(verbosity);
1542 ArtsXMLTag close_tag(verbosity);
1543
1544 open_tag.set_name("ScatteringMetaData");
1545 if (name.length()) open_tag.add_attribute("name", name);
1546 open_tag.add_attribute("version", "3");
1547 open_tag.write_to_stream(os_xml);
1548
1549 xml_write_to_stream(os_xml, smdata.description, pbofs, "", verbosity);
1550 xml_write_to_stream(os_xml, smdata.source, pbofs, "", verbosity);
1551 xml_write_to_stream(os_xml, smdata.refr_index, pbofs, "", verbosity);
1552 xml_write_to_stream(os_xml, smdata.mass, pbofs, "", verbosity);
1553 xml_write_to_stream(os_xml, smdata.diameter_max, pbofs, "", verbosity);
1554 xml_write_to_stream(os_xml, smdata.diameter_volume_equ, pbofs, "", verbosity);
1556 os_xml, smdata.diameter_area_equ_aerodynamical, pbofs, "", verbosity);
1557
1558 close_tag.set_name("/ScatteringMetaData");
1559 close_tag.write_to_stream(os_xml);
1560 os_xml << '\n';
1561}
1562
1563//=== SLIData2 =====================================================
1565
1571void xml_read_from_stream(istream& is_xml,
1572 SLIData2& slidata,
1573 bifstream* pbifs,
1574 const Verbosity& verbosity) {
1575 ArtsXMLTag tag(verbosity);
1576
1577 tag.read_from_stream(is_xml);
1578 tag.check_name("SLIData2");
1579
1580 xml_read_from_stream(is_xml, slidata.x1a, pbifs, verbosity);
1581 xml_read_from_stream(is_xml, slidata.x2a, pbifs, verbosity);
1582 xml_read_from_stream(is_xml, slidata.ya, pbifs, verbosity);
1583
1584 tag.read_from_stream(is_xml);
1585 tag.check_name("/SLIData2");
1586}
1587
1588void xml_write_to_stream(ostream& os_xml,
1589 const SLIData2& slidata,
1590 bofstream* pbofs,
1591 const String& name,
1592 const Verbosity& verbosity) {
1593 ArtsXMLTag open_tag(verbosity);
1594 ArtsXMLTag close_tag(verbosity);
1595
1596 open_tag.set_name("SLIData2");
1597 if (name.length()) open_tag.add_attribute("name", name);
1598 open_tag.write_to_stream(os_xml);
1599
1600 xml_write_to_stream(os_xml, slidata.x1a, pbofs, "", verbosity);
1601 xml_write_to_stream(os_xml, slidata.x2a, pbofs, "", verbosity);
1602 xml_write_to_stream(os_xml, slidata.ya, pbofs, "", verbosity);
1603
1604 close_tag.set_name("/SLIData2");
1605 close_tag.write_to_stream(os_xml);
1606 os_xml << '\n';
1607}
1608
1609//=== SpeciesIsotopologueRatios ===========================================
1610
1612
1617void xml_read_from_stream(istream& is_xml,
1619 bifstream* pbifs,
1620 const Verbosity& verbosity) {
1621 ARTS_USER_ERROR_IF(pbifs, "No support for binary IO for (SpeciesIsotopologueRatios)")
1622
1624
1625 iso_rat = SpeciesIsotopologueRatios{};
1626
1627 ArtsXMLTag tag(verbosity);
1628
1629 tag.read_from_stream(is_xml);
1630 tag.check_name("SpeciesIsotopologueRatios");
1631
1632 Index nelem;
1633 tag.get_attribute_value("nelem", nelem);
1634
1635 String name;
1636 Numeric val;
1637 for (Index n = 0; n < nelem; n++) {
1638 is_xml >> name >> double_imanip() >> val;
1639
1640 if (is_xml.fail()) {
1641 ostringstream os;
1642 os << " near "
1643 << "\n Element: " << n;
1644 xml_data_parse_error(tag, os.str());
1645 }
1646
1647 const Index i = Species::find_species_index(Species::Tag(name).Isotopologue());
1648 ARTS_USER_ERROR_IF(i < 0 or i >= iso_rat.maxsize,
1649 "Species: ", name, " cannot be understood as a species by your compiled version of ARTS")
1650
1651 iso_rat.data[i] = val;
1652 }
1653
1654 tag.read_from_stream(is_xml);
1655 tag.check_name("/SpeciesIsotopologueRatios");
1656}
1657
1659
1665void xml_write_to_stream(ostream& os_xml,
1666 const SpeciesIsotopologueRatios& iso_rat,
1667 bofstream* pbofs,
1668 const String& name,
1669 const Verbosity& verbosity)
1670
1671{
1672 ARTS_USER_ERROR_IF(pbofs, "No support for binary IO for (SpeciesIsotopologueRatios)")
1673
1674 ArtsXMLTag open_tag(verbosity);
1675 ArtsXMLTag close_tag(verbosity);
1676
1677 open_tag.set_name("SpeciesIsotopologueRatios");
1678 if (name.length()) open_tag.add_attribute("name", name);
1679 open_tag.add_attribute("nelem", iso_rat.maxsize);
1680
1681 open_tag.write_to_stream(os_xml);
1682 os_xml << '\n';
1683
1685 os_xml << iso_rat << '\n';
1686
1687 close_tag.set_name("/SpeciesIsotopologueRatios");
1688 close_tag.write_to_stream(os_xml);
1689
1690 os_xml << '\n';
1691}
1692
1693//=== SpeciesTag ================================================
1694
1696
1700/* param pbifs Pointer to binary input stream. NULL in case of ASCII file.
1701 Ignored because SpeciesTag is always stored in ASCII format.*/
1702void xml_read_from_stream(istream& is_xml,
1703 SpeciesTag& stag,
1704 bifstream* /* pbifs */,
1705 const Verbosity& verbosity) {
1706 ArtsXMLTag tag(verbosity);
1707 stringbuf strbuf;
1708 char dummy;
1709
1710 tag.read_from_stream(is_xml);
1711 tag.check_name("SpeciesTag");
1712
1713 // Skip whitespaces
1714 bool string_starts_with_quotes = true;
1715 do {
1716 is_xml >> dummy;
1717 switch (dummy) {
1718 case ' ':
1719 case '\"':
1720 case '\n':
1721 case '\r':
1722 case '\t':
1723 break;
1724 default:
1725 string_starts_with_quotes = false;
1726 }
1727 } while (is_xml.good() && dummy != '"' && string_starts_with_quotes);
1728
1729 // Throw exception if first char after whitespaces is not a quote
1730 if (!string_starts_with_quotes) {
1731 xml_parse_error("SpeciesTag must begin with \"");
1732 }
1733
1734 is_xml.get(strbuf, '"');
1735 if (is_xml.fail()) {
1736 xml_parse_error("SpeciesTag must end with \"");
1737 }
1738
1739 stag = SpeciesTag(strbuf.str());
1740
1741 // Ignore quote
1742 is_xml >> dummy;
1743
1744 tag.read_from_stream(is_xml);
1745 tag.check_name("/SpeciesTag");
1746}
1747
1749
1754/* param pbofs Pointer to binary file stream. NULL for ASCII output.
1755 Ignore because SpeciesTag is always stored in ASCII format. */
1756void xml_write_to_stream(ostream& os_xml,
1757 const SpeciesTag& stag,
1758 bofstream* /* pbofs */,
1759 const String& name,
1760 const Verbosity& verbosity) {
1761 ArtsXMLTag open_tag(verbosity);
1762 ArtsXMLTag close_tag(verbosity);
1763
1764 open_tag.set_name("SpeciesTag");
1765 if (name.length()) open_tag.add_attribute("name", name);
1766 open_tag.write_to_stream(os_xml);
1767
1768 os_xml << '\"' << stag.Name() << '\"';
1769
1770 close_tag.set_name("/SpeciesTag");
1771 close_tag.write_to_stream(os_xml);
1772 os_xml << '\n';
1773}
1774
1775//=== StokesVector ======================================================
1776
1778
1783void xml_read_from_stream(istream& is_xml,
1784 StokesVector& sv,
1785 bifstream* pbifs,
1786 const Verbosity& verbosity) {
1787 ArtsXMLTag tag(verbosity);
1788
1789 tag.read_from_stream(is_xml);
1790 tag.check_name("StokesVector");
1791
1792 try {
1793 Tensor4 d;
1794 xml_read_from_stream(is_xml, d, pbifs, verbosity);
1795 Index naa = d.nbooks();
1796 Index nza = d.npages();
1797 Index nf = d.nrows();
1798 Index nstokes_needed = d.ncols();
1799 sv = PropagationMatrix(nf, need2stokes<false>(nstokes_needed), nza, naa);
1800 sv.Data() = std::move(d); // destructive takeover
1801 } catch (const std::runtime_error& e) {
1802 ostringstream os;
1803 os << "Error reading StokesVector: "
1804 << "\n"
1805 << e.what();
1806 throw runtime_error(os.str());
1807 }
1808
1809 tag.read_from_stream(is_xml);
1810 tag.check_name("/StokesVector");
1811}
1812
1814
1820void xml_write_to_stream(ostream& os_xml,
1821 const StokesVector& sv,
1822 bofstream* pbofs,
1823 const String& name,
1824 const Verbosity& verbosity) {
1825 ArtsXMLTag open_tag(verbosity);
1826 ArtsXMLTag close_tag(verbosity);
1827
1828 open_tag.set_name("StokesVector");
1829 if (name.length()) open_tag.add_attribute("name", name);
1830
1831 open_tag.write_to_stream(os_xml);
1832 os_xml << '\n';
1833
1834 xml_write_to_stream(os_xml, sv.Data(), pbofs, "", verbosity);
1835
1836 close_tag.set_name("/StokesVector");
1837 close_tag.write_to_stream(os_xml);
1838
1839 os_xml << '\n';
1840}
1841
1842//=== TelsemAtlas ======================================================
1843
1845
1850void xml_read_from_stream(istream& is_xml,
1851 TelsemAtlas& ta,
1852 bifstream* pbifs,
1853 const Verbosity& verbosity) {
1854 ArtsXMLTag tag(verbosity);
1855
1856 tag.read_from_stream(is_xml);
1857 tag.check_name("TelsemAtlas");
1858
1859 xml_read_from_stream(is_xml, ta.ndat, pbifs, verbosity);
1860 xml_read_from_stream(is_xml, ta.nchan, pbifs, verbosity);
1861 xml_read_from_stream(is_xml, ta.name, pbifs, verbosity);
1862 xml_read_from_stream(is_xml, ta.month, pbifs, verbosity);
1863 xml_read_from_stream(is_xml, ta.dlat, pbifs, verbosity);
1864 xml_read_from_stream(is_xml, ta.emis, pbifs, verbosity);
1865 xml_read_from_stream(is_xml, ta.correl, pbifs, verbosity);
1866 xml_read_from_stream(is_xml, ta.emis_err, pbifs, verbosity);
1867 xml_read_from_stream(is_xml, ta.classes1, pbifs, verbosity);
1868 xml_read_from_stream(is_xml, ta.classes2, pbifs, verbosity);
1869 xml_read_from_stream(is_xml, ta.cellnums, pbifs, verbosity);
1871 tag.read_from_stream(is_xml);
1872 tag.check_name("/TelsemAtlas");
1873}
1874
1876
1882void xml_write_to_stream(ostream& os_xml,
1883 const TelsemAtlas& ta,
1884 bofstream* pbofs,
1885 const String& name,
1886 const Verbosity& verbosity) {
1887 ArtsXMLTag open_tag(verbosity);
1888 ArtsXMLTag close_tag(verbosity);
1889
1890 open_tag.set_name("TelsemAtlas");
1891 if (name.length()) open_tag.add_attribute("name", name);
1892
1893 open_tag.write_to_stream(os_xml);
1894 os_xml << '\n';
1895 xml_write_to_stream(os_xml, ta.ndat, pbofs, "ndat", verbosity);
1896 xml_write_to_stream(os_xml, ta.nchan, pbofs, "nchan", verbosity);
1897 xml_write_to_stream(os_xml, ta.name, pbofs, "name", verbosity);
1898 xml_write_to_stream(os_xml, ta.month, pbofs, "month", verbosity);
1899 xml_write_to_stream(os_xml, ta.dlat, pbofs, "dlat", verbosity);
1900 xml_write_to_stream(os_xml, ta.emis, pbofs, "emis", verbosity);
1901 xml_write_to_stream(os_xml, ta.correl, pbofs, "correl", verbosity);
1902 xml_write_to_stream(os_xml, ta.emis_err, pbofs, "emis_err", verbosity);
1903 xml_write_to_stream(os_xml, ta.classes1, pbofs, "class1", verbosity);
1904 xml_write_to_stream(os_xml, ta.classes2, pbofs, "class2", verbosity);
1905 xml_write_to_stream(os_xml, ta.cellnums, pbofs, "cellnum", verbosity);
1906 close_tag.set_name("/TelsemAtlas");
1907 close_tag.write_to_stream(os_xml);
1908
1909 os_xml << '\n';
1910}
1911
1912//=== XsecRecord ======================================================
1913
1915
1920void xml_read_from_stream(istream& is_xml,
1921 XsecRecord& xd,
1922 bifstream* pbifs,
1923 const Verbosity& verbosity) {
1925 ArtsXMLTag tag(verbosity);
1926
1927 tag.read_from_stream(is_xml);
1928 tag.check_name("XsecRecord");
1929
1930 String species_name;
1931 xml_read_from_stream(is_xml, species_name, pbifs, verbosity);
1932
1933 const Species::Species species = Species::fromShortName(species_name);
1934 if (not good_enum(species)) {
1935 ostringstream os;
1936 os << " Unknown species in XsecRecord: " << species_name;
1937 throw std::runtime_error(os.str());
1938 }
1939 xd.mspecies = species;
1940
1941 Vector fmin, fmax;
1942 xml_read_from_stream(is_xml, xd.mcoeffs, pbifs, verbosity);
1943 xml_read_from_stream(is_xml, fmin, pbifs, verbosity);
1944 xml_read_from_stream(is_xml, fmax, pbifs, verbosity);
1945 xml_read_from_stream(is_xml, xd.mrefpressure, pbifs, verbosity);
1946 xml_read_from_stream(is_xml, xd.mreftemperature, pbifs, verbosity);
1947 xml_read_from_stream(is_xml, xd.mxsecs, pbifs, verbosity);
1948
1949 xml_read_from_stream(is_xml, xd.mtslope, pbifs, verbosity);
1950 xml_read_from_stream(is_xml, xd.mtintersect, pbifs, verbosity);
1951 if (xd.mtslope.nelem() != xd.mxsecs.nelem() ||
1952 xd.mtintersect.nelem() != xd.mxsecs.nelem()) {
1953 std::ostringstream os;
1954 os << " Bugged input data for " << species_name << ". "
1955 << "Number of bands mismatch.\n"
1956 << "Cross sections: " << xd.mxsecs.nelem() << "\n"
1957 << "Tfit slope data: " << xd.mtslope.nelem() << "\n"
1958 << "Tfit intersect data: " << xd.mtintersect.nelem() << "\n";
1959 throw std::runtime_error(os.str());
1960 }
1961 for (Index i = 0; i < xd.mxsecs.nelem(); i++) {
1962 if (xd.mtslope[i].nelem() <= 1) {
1963 out2 << " Warning: No temperature fit available for " << species_name
1964 << " band " << i << "\n";
1965 } else if (xd.mtslope[i].nelem() != xd.mxsecs[i].nelem()) {
1966 std::ostringstream os;
1967 os << " Bugged input data for " << species_name << ". "
1968 << "Length of cross sections (" << xd.mxsecs[i].nelem()
1969 << ") does not match length of temperature fit data ("
1970 << xd.mtslope[i].nelem() << ").";
1971 throw std::runtime_error(os.str());
1972 }
1973
1974 if (xd.mtslope[i].nelem() != xd.mtintersect[i].nelem()) {
1975 std::ostringstream os;
1976 os << " Bugged input data for " << species_name << ". "
1977 << "Length of temperature fit slope data (" << xd.mtslope[i].nelem()
1978 << ") does not match length of temperature fit intersect data ("
1979 << xd.mtintersect[i].nelem() << ") for band " << i << ".";
1980 throw std::runtime_error(os.str());
1981 }
1982 }
1983 tag.read_from_stream(is_xml);
1984
1985 const Index ndatasets = xd.mxsecs.nelem();
1986 xd.mfgrids.resize(ndatasets);
1987 for (Index i = 0; i < ndatasets; i++) {
1988 nlinspace(xd.mfgrids[i], fmin[i], fmax[i], xd.mxsecs[i].nelem());
1989 }
1990 tag.check_name("/XsecRecord");
1991}
1992
1994
2000void xml_write_to_stream(ostream& os_xml,
2001 const XsecRecord& xd,
2002 bofstream* pbofs,
2003 const String& name,
2004 const Verbosity& verbosity) {
2005 ArtsXMLTag open_tag(verbosity);
2006 ArtsXMLTag close_tag(verbosity);
2007
2008 open_tag.set_name("XsecRecord");
2009 if (name.length()) open_tag.add_attribute("name", name);
2010
2011 open_tag.write_to_stream(os_xml);
2012 os_xml << '\n';
2013 const Index ndatasets = xd.Coeffs().nelem();
2014 Vector fmin(ndatasets), fmax(ndatasets);
2015 for (Index i = 0; i < ndatasets; i++) {
2016 fmin[i] = xd.Fgrids()[i][0];
2017 fmax[i] = xd.Fgrids()[i][xd.Fgrids()[i].nelem() - 1];
2018 }
2019
2020 xml_write_to_stream(os_xml, xd.SpeciesName(), pbofs, "species", verbosity);
2021 xml_write_to_stream(os_xml, (Vector)xd.Coeffs(), pbofs, "coefs", verbosity);
2022 xml_write_to_stream(os_xml, fmin, pbofs, "fmin", verbosity);
2023 xml_write_to_stream(os_xml, fmax, pbofs, "fmax", verbosity);
2025 os_xml, (Vector)xd.RefPressure(), pbofs, "refpressure", verbosity);
2027 os_xml, (Vector)xd.RefTemperature(), pbofs, "reftemperature", verbosity);
2028 xml_write_to_stream(os_xml, xd.Xsecs(), pbofs, "xsec", verbosity);
2029 xml_write_to_stream(os_xml, xd.TemperatureSlope(), pbofs, "xsec", verbosity);
2031 os_xml, xd.TemperatureIntersect(), pbofs, "xsec", verbosity);
2032 close_tag.set_name("/XsecRecord");
2033 close_tag.write_to_stream(os_xml);
2034
2035 os_xml << '\n';
2036}
2037
2038//=== MapOfErrorCorrectedSuddenData ======================================================
2039
2041
2046void xml_read_from_stream(istream& is_xml,
2048 bifstream* pbifs,
2049 const Verbosity& verbosity) {
2050 ARTS_USER_ERROR_IF(pbifs not_eq nullptr, "No binary data")
2051
2053 ArtsXMLTag open_tag(verbosity);
2054 open_tag.read_from_stream(is_xml);
2055 open_tag.check_name("MapOfErrorCorrectedSuddenData");
2056
2057 Index nelem;
2058 open_tag.get_attribute_value("nelem", nelem);
2059
2060 for (Index i=0; i<nelem; i++) {
2061 ArtsXMLTag internal_open_tag(verbosity);
2062 internal_open_tag.read_from_stream(is_xml);
2063 internal_open_tag.check_name("ErrorCorrectedSuddenData");
2064
2065 // Get key
2066 String val;
2067 internal_open_tag.get_attribute_value("key", val);
2068 auto& data = rvb[QuantumIdentifier(val)];
2069
2070 // Get size
2071 Index nelem_specs;
2072 internal_open_tag.get_attribute_value("nelem", nelem_specs);
2073
2074 // Get values
2075 for (Index j=0; j<nelem_specs; j++) {
2077 is_xml >> secds;
2078 data[secds.spec] = secds;
2079 }
2080
2081 ArtsXMLTag internal_close_tag(verbosity);
2082 internal_close_tag.read_from_stream(is_xml);
2083 internal_close_tag.check_name("/ErrorCorrectedSuddenData");
2084
2085 }
2086
2087 ArtsXMLTag close_tag(verbosity);
2088 close_tag.read_from_stream(is_xml);
2089 close_tag.check_name("/MapOfErrorCorrectedSuddenData");
2090
2091 // Sanity check, it is not OK to not have AIR as catch-all broadener
2092 for (auto& x: rvb) {
2093 bool found_air=false;
2094 for (auto& y: x.data) {
2095 found_air = found_air or (y.spec == Species::Species::Bath);
2096 }
2097 ARTS_USER_ERROR_IF(not found_air,
2098 "Incomplete ErrorCorrectedSuddenData, must contain air, contains:\n",
2099 x)
2100 }
2101}
2102
2104
2110void xml_write_to_stream(ostream& os_xml,
2112 bofstream* pbofs,
2113 const String& name,
2114 const Verbosity& verbosity) {
2115 ARTS_USER_ERROR_IF(pbofs not_eq nullptr, "No binary data")
2116
2117 ArtsXMLTag open_tag(verbosity);
2118 ArtsXMLTag close_tag(verbosity);
2119
2120 open_tag.set_name("MapOfErrorCorrectedSuddenData");
2121 if (name.length()) open_tag.add_attribute("name", name);
2122 open_tag.add_attribute("nelem", rvb.nelem());
2123 open_tag.write_to_stream(os_xml);
2124 os_xml << '\n';
2125
2127
2128 for (auto& r: rvb) {
2129 ArtsXMLTag internal_open_tag(verbosity);
2130 internal_open_tag.set_name("ErrorCorrectedSuddenData");
2131 internal_open_tag.add_attribute("key", r.id.GetString());
2132 internal_open_tag.add_attribute("nelem", r.data.nelem());
2133 internal_open_tag.write_to_stream(os_xml);
2134 os_xml << '\n';
2135
2136 // Set values
2137 os_xml << r << '\n';
2138
2139 ArtsXMLTag internal_close_tag(verbosity);
2140 internal_close_tag.set_name("/ErrorCorrectedSuddenData");
2141 internal_close_tag.write_to_stream(os_xml);
2142 os_xml << '\n';
2143 }
2144
2145 close_tag.set_name("/MapOfErrorCorrectedSuddenData");
2146 close_tag.write_to_stream(os_xml);
2147
2148 os_xml << '\n';
2149}
2150
2152// Dummy funtion for groups for which
2153// IO function have not yet been implemented
2155
2156// FIXME: These should be implemented, sooner or later...
2157
2159 Agenda&,
2160 bifstream* /* pbifs */,
2161 const Verbosity&) {
2162 throw runtime_error("Method not implemented!");
2163}
2164
2166 const Agenda&,
2167 bofstream* /* pbofs */,
2168 const String& /* name */,
2169 const Verbosity&) {
2170 throw runtime_error("Method not implemented!");
2171}
2172
2173//=== MCAntenna ================================================
2174
2176 MCAntenna&,
2177 bifstream* /* pbifs */,
2178 const Verbosity&) {
2179 throw runtime_error("Method not implemented!");
2180}
2181
2183 const MCAntenna&,
2184 bofstream* /* pbofs */,
2185 const String& /* name */,
2186 const Verbosity&) {
2187 throw runtime_error("Method not implemented!");
2188}
2189
2190//=== TessemNN ================================================
2191
2193 TessemNN&,
2194 bifstream* /* pbifs */,
2195 const Verbosity&) {
2196 throw runtime_error("Method not implemented!");
2197}
2198
2200 const TessemNN&,
2201 bofstream* /* pbofs */,
2202 const String& /* name */,
2203 const Verbosity&) {
2204 throw runtime_error("Method not implemented!");
2205}
2206
2207//=== Verbosity ================================================
2208
2210 Verbosity&,
2211 bifstream* /* pbifs */,
2212 const Verbosity&) {
2213 throw runtime_error("Method not implemented!");
2214}
2215
2217 const Verbosity&,
2218 bofstream* /* pbofs */,
2219 const String& /* name */,
2220 const Verbosity&) {
2221 throw runtime_error("Method not implemented!");
2222}
The global header file for ARTS.
void * data
The Agenda class.
Definition: agenda_class.h:44
Index nelem() const ARTS_NOEXCEPT
Number of elements.
Definition: array.h:195
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:233
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:265
Index nlibraries() const
Returns the number of libraries.
Definition: matpackVII.cc:42
Index nelem() const ARTS_NOEXCEPT
Returns the number of elements.
Definition: matpackI.cc:48
std::vector< Block > correlations_
std::vector< Block > inverses_
const ArrayOfQuantumIdentifier & Levels() const noexcept
Energy level type.
const Vector & Energies() const noexcept
Energy level type.
EnergyLevelMapType Type() const noexcept
Energy level type.
const Tensor4 & Data() const noexcept
Energy level type.
void ThrowIfNotOK() const ARTS_NOEXCEPT
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.
An Antenna object used by MCGeneral.
Definition: mc_antenna.h:51
Tensor4 & Data()
Get full view to data.
Container class for Quantum Numbers.
Definition: quantum.h:112
constexpr const QuantumContainer & GetNumbers() const
Get the numbers.
Definition: quantum.h:225
The range class.
Definition: matpackI.h:165
constexpr Index get_start() const ARTS_NOEXCEPT
Returns the start index of the range.
Definition: matpackI.h:332
constexpr Index get_extent() const ARTS_NOEXCEPT
Returns the extent of the range.
Definition: matpackI.h:334
Deals with internal derivatives, Jacobian definition, and OEM calculations.
Definition: jacobian.h:345
const String & Mode() const
Returns the mode.
Definition: jacobian.h:414
Jacobian::Target & Target()
Get the Jacobian Target.
Definition: jacobian.h:451
const String & SubSubtag() const
Returns the sub-sub-tag.
Definition: jacobian.h:399
const ArrayOfVector & Grids() const
Returns the grids of the retrieval.
Definition: jacobian.h:428
const String & Subtag() const
Returns the sub-tag.
Definition: jacobian.h:385
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:421
The Vector class.
Definition: matpackI.h:876
The ARTS XML tag class.
Definition: xml_io_base.h:68
void write_to_stream(ostream &os)
Write XML tag.
Definition: xml_io_base.cc:300
void check_name(const String &expected_name)
Check tag name.
Definition: xml_io_base.cc:48
void read_from_stream(istream &is)
Reads next XML tag.
Definition: xml_io_base.cc:179
void get_attribute_value(const String &aname, String &value)
Returns value of attribute as String.
Definition: xml_io_base.cc:124
void set_name(const String &new_name)
Definition: xml_io_base.h:76
String & get_name()
Definition: xml_io_base.h:72
const ArrayOfVector & TemperatureIntersect() const
Get intersect of temperature fit.
Definition: hitran_xsec.h:67
ArrayOfVector mtintersect
Definition: hitran_xsec.h:123
Vector mrefpressure
Definition: hitran_xsec.h:118
Species::Species mspecies
Definition: hitran_xsec.h:116
Vector mcoeffs
Definition: hitran_xsec.h:117
String SpeciesName() const
Return species name.
Definition: hitran_xsec.cc:53
ConstVectorView RefPressure() const
Get reference pressures.
Definition: hitran_xsec.h:52
Vector mreftemperature
Definition: hitran_xsec.h:119
const ArrayOfVector & Fgrids() const
Get frequency grids of cross sections.
Definition: hitran_xsec.h:58
ConstVectorView Coeffs() const
Get coefficients.
Definition: hitran_xsec.h:49
ConstVectorView RefTemperature() const
Get reference temperatures.
Definition: hitran_xsec.h:55
const ArrayOfVector & Xsecs() const
Get cross sections.
Definition: hitran_xsec.h:61
ArrayOfVector mxsecs
Definition: hitran_xsec.h:121
ArrayOfVector mtslope
Definition: hitran_xsec.h:122
ArrayOfVector mfgrids
Definition: hitran_xsec.h:120
const ArrayOfVector & TemperatureSlope() const
Get slope of temperature fit.
Definition: hitran_xsec.h:64
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
#define ARTS_USER_ERROR_IF(condition,...)
Definition: debug.h:134
String energylevelmaptype2string(EnergyLevelMapType type)
EnergyLevelMapType string2energylevelmaptype(const String &s)
constexpr bool good_enum(EnumType x) noexcept
Checks if the enum number is good.
Definition: enums.h:21
@ GRID_TYPE_NUMERIC
@ GRID_TYPE_STRING
void nlinspace(Vector &x, const Numeric start, const Numeric stop, const Index n)
nlinspace
Definition: math_funcs.cc:225
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:39
NUMERIC Numeric
The type to use for all floating point numbers.
Definition: matpack.h:33
#define CREATE_OUT2
Definition: messages.h:206
Index nelem(const Lines &l)
Number of lines.
char Type type
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::Identifier QuantumIdentifier
Definition: quantum.h:471
#define M
Definition: rng.cc:165
Species::Tag SpeciesTag
Definition: species_tags.h:99
Structure to store a grid position.
Definition: interpolation.h:73
Numeric fd[2]
Definition: interpolation.h:75
Index idx
Definition: interpolation.h:74
The structure to describe a propagation path and releated quantities.
Definition: ppath.h:48
Matrix los
Line-of-sight at each ppath point.
Definition: ppath.h:66
ArrayOfGridPos gp_lon
Index position with respect to the longitude grid.
Definition: ppath.h:86
String background
Radiative background.
Definition: ppath.h:56
Index np
Number of points describing the ppath.
Definition: ppath.h:52
Matrix pos
The distance between start pos and the last position in pos.
Definition: ppath.h:64
ArrayOfGridPos gp_lat
Index position with respect to the latitude grid.
Definition: ppath.h:84
Numeric end_lstep
The distance between end pos and the first position in pos.
Definition: ppath.h:76
Vector start_pos
Start position.
Definition: ppath.h:58
Vector lstep
The length between ppath points.
Definition: ppath.h:70
Numeric start_lstep
Length between sensor and atmospheric boundary.
Definition: ppath.h:62
Numeric constant
The propagation path constant (only used for 1D)
Definition: ppath.h:54
Vector r
Radius of each ppath point.
Definition: ppath.h:68
ArrayOfGridPos gp_p
Index position with respect to the pressure grid.
Definition: ppath.h:82
Vector ngroup
The group index of refraction.
Definition: ppath.h:80
Index dim
Atmospheric dimensionality.
Definition: ppath.h:50
Vector end_pos
End position.
Definition: ppath.h:72
Vector start_los
Start line-of-sight.
Definition: ppath.h:60
Vector nreal
The real part of the refractive index at each path position.
Definition: ppath.h:78
Vector end_los
End line-of-sight.
Definition: ppath.h:74
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:197
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:701
void xml_set_stream_precision(ostream &os)
Definition: xml_io_base.cc:683
void xml_parse_error(const String &str_error)
Throws XML parser runtime error.
Definition: xml_io_base.cc:517
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.