ARTS  2.3.1285(git:92a29ea9-dirty)
arts_api.cc
Go to the documentation of this file.
1 #include "arts_api.h"
2 
3 #include "agenda_class.h"
4 #include "arts.h"
5 #include "auto_md.h"
6 #include "auto_version.h"
7 #include "global_data.h"
9 #include "parameters.h"
10 #include "parser.h"
11 #include "workspace_ng.h"
12 
15 extern Parameters parameters;
17 extern String out_basename;
18 Index get_wsv_id(const char *);
19 
20 using global_data::MdMap;
21 
22 std::string string_buffer;
23 
24 //extern "C" {
25 
27 // Internal Helper Functions
29 
31  ArrayOfIndex &input,
32  unsigned long n_args_out,
33  const long *args_out,
34  unsigned long n_args_in,
35  const long *args_in) {
36  output.reserve(n_args_out);
37  for (size_t i = 0; i < n_args_out; ++i) {
38  output.push_back(args_out[i]);
39  }
40  input.reserve(n_args_in);
41  for (size_t i = 0; i < n_args_in; ++i) {
42  input.push_back(args_in[i]);
43  }
44 }
45 
47 // Setup and Finalization.
49 
50 void include_path_push(const char *path) {
51  parameters.includepath.push_back(path);
52 }
53 
54 void include_path_pop() { parameters.includepath.pop_back(); }
55 
56 void data_path_push(const char *path) { parameters.datapath.push_back(path); }
57 
58 void data_path_pop() { parameters.datapath.pop_back(); }
59 
61 
62 void finalize() {
63  // Nothing to do here.
64 }
65 
66 const char *get_error() { return string_buffer.c_str(); }
67 
68 void set_basename(const char *name) { out_basename = name; }
69 
71 // Parsing and executing agendas.
73 Agenda *parse_agenda(const char *filename) {
74  Agenda *a = new Agenda;
75  ArtsParser parser = ArtsParser(*a, filename, verbosity_at_launch);
76 
77  try {
78  parser.parse_tasklist();
79  a->set_name(filename);
80  a->set_main_agenda();
81  } catch (const std::exception &e) {
82  string_buffer = std::string(e.what());
83  return nullptr;
84  }
85  return a;
86 }
87 
88 Agenda *create_agenda(const char *name) {
89  Agenda *ptr = new Agenda;
90  ptr->set_name(name);
91  return ptr;
92 }
93 
95  Agenda *a,
96  long id,
97  long group_id) {
98  TokVal t{};
99  ArrayOfIndex output(1), input(0);
100  output[0] = id;
102  s << wsv_group_names[group_id] << "Set";
103  Index m_id = MdMap.at(String(s.str()));
104  MRecord mr;
105 
106  // Agenda
107  if (wsv_group_names[group_id] == "Agenda") {
108  const Agenda &agenda =
109  *reinterpret_cast<Agenda *>(workspace->operator[](id));
110  mr = MRecord(m_id, output, input, t, agenda);
111  } else {
112  // Index
113  if (wsv_group_names[group_id] == "Index") {
114  t = TokVal(*reinterpret_cast<Index *>(workspace->operator[](id)));
115  }
116  // Numeric
117  if (wsv_group_names[group_id] == "Numeric") {
118  t = TokVal(*reinterpret_cast<Numeric *>(workspace->operator[](id)));
119  }
120  // ArrayOfIndex
121  if (wsv_group_names[group_id] == "ArrayOfIndex") {
122  t = TokVal(*reinterpret_cast<ArrayOfIndex *>(workspace->operator[](id)));
123  }
124  // String
125  if (wsv_group_names[group_id] == "String") {
126  t = TokVal(*reinterpret_cast<String *>(workspace->operator[](id)));
127  }
128  // ArrayOfString
129  if (wsv_group_names[group_id] == "ArrayOfString") {
130  t = TokVal(*reinterpret_cast<ArrayOfString *>(workspace->operator[](id)));
131  }
132  // ArrayOfIndex
133  if (wsv_group_names[group_id] == "ArrayOfIndex") {
134  t = TokVal(*reinterpret_cast<ArrayOfIndex *>(workspace->operator[](id)));
135  }
136  // Vector
137  if (wsv_group_names[group_id] == "Vector") {
138  t = TokVal(*reinterpret_cast<Vector *>(workspace->operator[](id)));
139  }
140  // Matrix
141  if (wsv_group_names[group_id] == "Matrix") {
142  t = TokVal(*reinterpret_cast<Matrix *>(workspace->operator[](id)));
143  }
144  mr = MRecord(m_id, output, input, t, Agenda{});
145  }
146  a->push_back(mr);
147 }
148 
150  ArrayOfIndex output(0), input(0);
151  Index id = md_data.size() - 1;
152  Callback *pc = new Callback(f);
153  Index callback_id = InteractiveWorkspace::add_callback(pc);
154  a->push_back(MRecord(id, output, input, TokVal(callback_id), Agenda{}));
155 }
156 
158  const long id,
159  unsigned long n_output_args,
160  const long *output_args,
161  unsigned long n_input_args,
162  const long *input_args) {
163  ArrayOfIndex output, input;
164  TokVal t{};
166  output, input, n_output_args, output_args, n_input_args, input_args);
167  MRecord mr(id, output, input, t, Agenda{});
168  a->push_back(mr);
169 }
170 
171 void agenda_append(Agenda *dst, const Agenda *src) {
172  auto methods = src->Methods();
173  for (auto m : methods) {
174  dst->push_back(m);
175  }
176 }
177 
178 void agenda_clear(Agenda *a) { a->operator=(Agenda()); }
179 
180 const char *execute_agenda(InteractiveWorkspace *workspace, const Agenda *a) {
181  Agenda b(*a);
182  b.set_main_agenda();
183  return workspace->execute_agenda(&b);
184 }
185 
186 void destroy_agenda(Agenda *a) { delete a; }
187 
189 // Creating Workspaces
192  const Index agenda_verbosity) {
193  return new InteractiveWorkspace(verbosity, agenda_verbosity);
194 }
195 
196 void destroy_workspace(InteractiveWorkspace *workspace) { delete workspace; }
197 
199 // Accessing WSV Group Information
201 
202 unsigned long get_number_of_groups() { return wsv_group_names.size(); }
203 
204 const char *get_group_name(int i) { return wsv_group_names[i].c_str(); }
205 
207 // Accessing and Executing WSMs
209 unsigned long get_number_of_methods() { return md_data.size(); }
210 
212  MethodStruct m{i,
213  md_data[i].Name().c_str(),
214  md_data[i].Description().c_str(),
215  // Output
216  md_data[i].Out().size(),
217  nullptr,
218  // Generic Output
219  md_data[i].GOut().size(),
220  nullptr,
221  // Input
222  md_data[i].In().size(),
223  nullptr,
224  // Generic Input
225  md_data[i].GIn().size(),
226  nullptr};
227  if (m.n_out > 0) {
228  m.out = &md_data[i].Out()[0];
229  }
230  if (m.n_g_in > 0) {
231  m.g_in_types = &md_data[i].GInType()[0];
232  }
233  if (m.n_in > 0) {
234  m.in = &md_data[i].In()[0];
235  }
236  if (m.n_g_out > 0) {
237  m.g_out_types = &md_data[i].GOutType()[0];
238  }
239  return m;
240 }
241 
242 const char *get_method_in(Index i, Index j) {
243  return md_data[i].GIn()[j].c_str();
244 }
245 
246 const char *get_method_g_in(Index i, Index j) {
247  return md_data[i].GIn()[j].c_str();
248 }
249 
251  return md_data[i].GInDefault()[j].c_str();
252 }
253 
254 const char *get_method_out(Index i, Index j) {
255  return md_data[i].GIn()[j].c_str();
256 }
257 
258 const char *get_method_g_out(Index i, Index j) {
259  return md_data[i].GOut()[j].c_str();
260 }
261 
263  long id,
264  unsigned long n_args_out,
265  const long *args_out,
266  unsigned long n_args_in,
267  const long *args_in) {
268  ArrayOfIndex output, input;
270  output, input, n_args_out, args_out, n_args_in, args_in);
271  return workspace->execute_workspace_method(id, output, input);
272 }
273 
274 const char *method_print_doc(long id) {
276  ;
277  ss << md_data[id];
278  string_buffer = ss.str();
279  return string_buffer.c_str();
280 }
281 
283 // Accessing and Manipulating WSVs
285 long lookup_workspace_variable(const char *s) {
286  auto it = Workspace::WsvMap.find(s);
287  if (it == Workspace::WsvMap.end()) {
288  return -1;
289  }
290  return it->second;
291 }
292 
293 unsigned long get_number_of_variables() { return Workspace::wsv_data.size(); }
294 
296  const WsvRecord &r = Workspace::wsv_data[i];
297  return VariableStruct{r.Name().c_str(), r.Description().c_str(), r.Group()};
298 }
299 
301  Index id,
302  Index group_id) {
303  VariableValueStruct value{nullptr,
304  workspace->is_initialized(id),
305  {0, 0, 0, 0, 0, 0},
306  nullptr,
307  nullptr};
308  // Index
309  if (wsv_group_names[group_id] == "Index") {
310  if (value.initialized) {
311  value.ptr = workspace->operator[](id);
312  }
313  }
314  // ArrayOfIndex
315  else if (wsv_group_names[group_id] == "ArrayOfIndex") {
316  if (value.initialized) {
317  ArrayOfIndex *a =
318  reinterpret_cast<ArrayOfIndex *>(workspace->operator[](id));
319  value.dimensions[0] = a->size();
320  value.ptr = a->data();
321  }
322  }
323  // String
324  else if (wsv_group_names[group_id] == "String") {
325  if (value.initialized) {
326  value.ptr =
327  reinterpret_cast<String *>(workspace->operator[](id))->c_str();
328  }
329  }
330  // Numeric
331  else if (wsv_group_names[group_id] == "Numeric") {
332  if (value.initialized) {
333  value.ptr = reinterpret_cast<Numeric *>(workspace->operator[](id));
334  }
335  }
336  // Vector
337  else if (wsv_group_names[group_id] == "Vector") {
338  if (value.initialized) {
339  Vector *v = reinterpret_cast<Vector *>(workspace->operator[](id));
340  value.dimensions[0] = v->nelem();
341  if (!v->empty()) {
342  value.ptr = v->get_c_array();
343  }
344  }
345  }
346  // Matrix
347  else if (wsv_group_names[group_id] == "Matrix") {
348  if (value.initialized) {
349  Matrix *m = reinterpret_cast<Matrix *>(workspace->operator[](id));
350  value.dimensions[0] = m->nrows();
351  value.dimensions[1] = m->ncols();
352  if (!m->empty()) {
353  value.ptr = m->get_c_array();
354  }
355  }
356  }
357  // Tensor3
358  else if (wsv_group_names[group_id] == "Tensor3") {
359  if (value.initialized) {
360  Tensor3 *t = reinterpret_cast<Tensor3 *>(workspace->operator[](id));
361  value.dimensions[0] = t->npages();
362  value.dimensions[1] = t->nrows();
363  value.dimensions[2] = t->ncols();
364  if (!t->empty()) {
365  value.ptr = t->get_c_array();
366  }
367  }
368  }
369  // Tensor4
370  else if (wsv_group_names[group_id] == "Tensor4") {
371  if (value.initialized) {
372  Tensor4 *t = reinterpret_cast<Tensor4 *>(workspace->operator[](id));
373  value.dimensions[0] = t->nbooks();
374  value.dimensions[1] = t->npages();
375  value.dimensions[2] = t->nrows();
376  value.dimensions[3] = t->ncols();
377  if (!t->empty()) {
378  value.ptr = t->get_c_array();
379  }
380  }
381  }
382  // Tensor5
383  else if (wsv_group_names[group_id] == "Tensor5") {
384  if (value.initialized) {
385  Tensor5 *t = reinterpret_cast<Tensor5 *>(workspace->operator[](id));
386  value.dimensions[0] = t->nshelves();
387  value.dimensions[1] = t->nbooks();
388  value.dimensions[2] = t->npages();
389  value.dimensions[3] = t->nrows();
390  value.dimensions[4] = t->ncols();
391  if (!t->empty()) {
392  value.ptr = t->get_c_array();
393  }
394  }
395  }
396  // Tensor6
397  else if (wsv_group_names[group_id] == "Tensor6") {
398  if (value.initialized) {
399  Tensor6 *t = reinterpret_cast<Tensor6 *>(workspace->operator[](id));
400  value.dimensions[0] = t->nvitrines();
401  value.dimensions[1] = t->nshelves();
402  value.dimensions[2] = t->nbooks();
403  value.dimensions[3] = t->npages();
404  value.dimensions[4] = t->nrows();
405  value.dimensions[5] = t->ncols();
406 
407  if (!t->empty()) {
408  value.ptr = t->get_c_array();
409  }
410  }
411  }
412  // Tensor7
413  else if (wsv_group_names[group_id] == "Tensor7") {
414  if (value.initialized) {
415  Tensor7 *t = reinterpret_cast<Tensor7 *>(workspace->operator[](id));
416  value.dimensions[0] = t->nlibraries();
417  value.dimensions[1] = t->nvitrines();
418  value.dimensions[2] = t->nshelves();
419  value.dimensions[3] = t->nbooks();
420  value.dimensions[4] = t->npages();
421  value.dimensions[5] = t->nrows();
422  value.dimensions[6] = t->ncols();
423 
424  if (!t->empty()) {
425  value.ptr = t->get_c_array();
426  }
427  }
428  }
429  // Sparse
430  else if (wsv_group_names[group_id] == "Sparse") {
431  if (value.initialized) {
432  Sparse *s = reinterpret_cast<Sparse *>(workspace->operator[](id));
433  value.dimensions[0] = s->nrows();
434  value.dimensions[1] = s->ncols();
435  value.dimensions[2] = s->nnz();
436  value.ptr = s->get_element_pointer();
437  value.inner_ptr = s->get_column_index_pointer();
438  value.outer_ptr = s->get_row_start_pointer();
439  }
440  }
441  // Covariance Matrix
442  else if (wsv_group_names[group_id] == "CovarianceMatrix") {
443  if (value.initialized) {
444  CovarianceMatrix *c =
445  reinterpret_cast<CovarianceMatrix *>(workspace->operator[](id));
446 
447  auto &blocks = c->get_blocks();
448  auto &inv_blocks = c->get_inverse_blocks();
449 
450  value.ptr = c;
451  value.dimensions[0] = blocks.size();
452  value.dimensions[1] = inv_blocks.size();
453  value.inner_ptr = reinterpret_cast<int *>(blocks.data());
454  }
455  } else {
456  if (value.initialized) {
457  value.ptr = workspace->operator[](id);
458  }
459  }
460  return value;
461 }
462 
464  return workspace->operator[](id);
465 }
466 
468  long block_index,
469  bool inverse) {
470  std::vector<Block> &blocks =
471  inverse ? m->get_inverse_blocks() : m->get_blocks();
472 
473  if ((block_index < 0) || ((size_t)block_index >= blocks.size())) {
474  throw std::runtime_error("The block index is invalid.");
475  }
476  Block &block = blocks[block_index];
477 
478  Index i, j;
479  std::tie(i, j) = block.get_indices();
480  Range rr = block.get_row_range();
481  Range cr = block.get_column_range();
482 
483  void *ptr = nullptr;
484  int *inner_ptr = nullptr;
485  int *outer_ptr = nullptr;
486  long nnz = 0;
487 
488  if (block.get_matrix_type() == Block::MatrixType::dense) {
489  ptr = block.get_dense().get_c_array();
490  } else {
491  Sparse &s = block.get_sparse();
492  ptr = s.get_element_pointer();
493  inner_ptr = s.get_column_index_pointer();
494  outer_ptr = s.get_row_start_pointer();
495  nnz = s.nnz();
496  }
497 
499  b.indices[0] = i;
500  b.indices[1] = j;
501  b.dimensions[0] = rr.get_extent();
502  b.dimensions[1] = cr.get_extent();
503  b.position[0] = rr.get_start();
504  b.position[1] = cr.get_start();
505  b.ptr = ptr;
506  b.nnz = nnz;
507  b.inner_ptr = inner_ptr;
508  b.outer_ptr = outer_ptr;
509  return b;
510 }
511 
513  long id,
514  long group_id,
515  VariableValueStruct value) {
516  // If ptr is null empty variable
517  if (value.ptr == nullptr) {
518  workspace->initialize_variable(id);
519  }
520  // Agenda
521  else if (wsv_group_names[group_id] == "Agenda") {
522  try {
523  const Agenda *ptr = reinterpret_cast<const Agenda *>(value.ptr);
524  workspace->set_agenda_variable(id, *ptr);
525  } catch (const std::exception &e) {
526  string_buffer = std::string(e.what());
527  return string_buffer.c_str();
528  }
529  }
530  // Index
531  else if (wsv_group_names[group_id] == "Index") {
532  const Index *ptr = reinterpret_cast<const Index *>(value.ptr);
533  workspace->set_index_variable(id, *ptr);
534  }
535  // Numeric
536  else if (wsv_group_names[group_id] == "Numeric") {
537  const Numeric *ptr = reinterpret_cast<const Numeric *>(value.ptr);
538  workspace->set_numeric_variable(id, *ptr);
539  }
540  // String
541  else if (wsv_group_names[group_id] == "String") {
542  const char *ptr = reinterpret_cast<const char *>(value.ptr);
543  workspace->set_string_variable(id, ptr);
544  }
545  // Array of String
546  else if (wsv_group_names[group_id] == "ArrayOfString") {
547  const char *const *ptr = reinterpret_cast<const char *const *>(value.ptr);
548  workspace->set_array_of_string_variable(id, value.dimensions[0], ptr);
549  }
550  // Array of Index
551  else if (wsv_group_names[group_id] == "ArrayOfIndex") {
552  const Index *ptr = reinterpret_cast<const Index *>(value.ptr);
553  workspace->set_array_of_index_variable(id, value.dimensions[0], ptr);
554  }
555  // Vector
556  else if (wsv_group_names[group_id] == "Vector") {
557  const Numeric *ptr = reinterpret_cast<const Numeric *>(value.ptr);
558  workspace->set_vector_variable(id, value.dimensions[0], ptr);
559  }
560  // Matrix
561  else if (wsv_group_names[group_id] == "Matrix") {
562  const Numeric *ptr = reinterpret_cast<const Numeric *>(value.ptr);
563  workspace->set_matrix_variable(
564  id, value.dimensions[0], value.dimensions[1], ptr);
565  }
566  // Tensor3
567  else if (wsv_group_names[group_id] == "Tensor3") {
568  const Numeric *ptr = reinterpret_cast<const Numeric *>(value.ptr);
569  workspace->set_tensor3_variable(
570  id, value.dimensions[0], value.dimensions[1], value.dimensions[2], ptr);
571  }
572  // Tensor4
573  else if (wsv_group_names[group_id] == "Tensor4") {
574  const Numeric *ptr = reinterpret_cast<const Numeric *>(value.ptr);
575  workspace->set_tensor4_variable(id,
576  value.dimensions[0],
577  value.dimensions[1],
578  value.dimensions[2],
579  value.dimensions[3],
580  ptr);
581  }
582  // Tensor5
583  else if (wsv_group_names[group_id] == "Tensor5") {
584  const Numeric *ptr = reinterpret_cast<const Numeric *>(value.ptr);
585  workspace->set_tensor5_variable(id,
586  value.dimensions[0],
587  value.dimensions[1],
588  value.dimensions[2],
589  value.dimensions[3],
590  value.dimensions[4],
591  ptr);
592  }
593  // Tensor6
594  else if (wsv_group_names[group_id] == "Tensor6") {
595  const Numeric *ptr = reinterpret_cast<const Numeric *>(value.ptr);
596  workspace->set_tensor6_variable(id,
597  value.dimensions[0],
598  value.dimensions[1],
599  value.dimensions[2],
600  value.dimensions[3],
601  value.dimensions[4],
602  value.dimensions[5],
603  ptr);
604  }
605  // Tensor7
606  else if (wsv_group_names[group_id] == "Tensor7") {
607  const Numeric *ptr = reinterpret_cast<const Numeric *>(value.ptr);
608  workspace->set_tensor7_variable(id,
609  value.dimensions[0],
610  value.dimensions[1],
611  value.dimensions[2],
612  value.dimensions[3],
613  value.dimensions[4],
614  value.dimensions[5],
615  value.dimensions[6],
616  ptr);
617  }
618  // Sparse
619  else if (wsv_group_names[group_id] == "Sparse") {
620  const Numeric *ptr = reinterpret_cast<const Numeric *>(value.ptr);
621  workspace->set_sparse_variable(id,
622  value.dimensions[0],
623  value.dimensions[1],
624  value.dimensions[2],
625  ptr,
626  value.inner_ptr,
627  value.outer_ptr);
628  } else {
629  string_buffer = std::string(
630  "This variable can currently not be set through the C API."
631  " Signal your need to ARTS dev mailing list.");
632  return string_buffer.c_str();
633  }
634  return nullptr;
635 }
636 
638  long group_id,
639  const char *name) {
640  return workspace->add_variable(group_id, name);
641 }
642 
644 void erase_variable(InteractiveWorkspace *workspace, long id, long group_id) {
645  return workspace->erase_variable(id, group_id);
646 }
647 
650  VersionStruct version;
651  std::string version_string(ARTS_FULL_VERSION);
652 
653  version_string = version_string.substr(5, std::string::npos);
654  size_t dash_pos = version_string.find('.');
655  version.major =
656  static_cast<Index>(std::stoi(version_string.substr(0, dash_pos)));
657 
658  version_string = version_string.substr(dash_pos + 1, std::string::npos);
659  dash_pos = version_string.find('.');
660  version.minor =
661  static_cast<Index>(std::stoi(version_string.substr(0, dash_pos)));
662 
663  version_string = version_string.substr(dash_pos + 1, std::string::npos);
664  version.revision = static_cast<Index>(
665  std::stoi(version_string.substr(0, std::string::npos)));
666 
667  return version;
668 }
669 //}
Index npages() const
Returns the number of pages.
Definition: matpackV.cc:50
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:39
static Array< WsvRecord > wsv_data
Global WSV data.
Definition: workspace_ng.h:58
Agenda * parse_agenda(const char *filename)
Parse Controlfile.
Definition: arts_api.cc:73
Index nnz() const
Returns the number of nonzero elements.
Definition: matpackII.cc:72
const char * get_method_out(Index i, Index j)
Definition: arts_api.cc:254
void destroy_agenda(Agenda *a)
Destroy Agenda.
Definition: arts_api.cc:186
Range get_column_range() const
Index nrows() const
Returns the number of rows.
Definition: matpackV.cc:53
long indices[2]
Quantity indices.
Definition: arts_api.h:178
bool empty() const
Check if variable is empty.
Definition: matpackV.cc:38
External callbacks.
The Agenda class.
Definition: agenda_class.h:44
VariableStruct get_variable(Index i)
Get WSV by index.
Definition: arts_api.cc:295
DLL_PUBLIC VersionStruct get_version()
Get ARTS Version.
Definition: arts_api.cc:649
const char * execute_agenda(const Agenda *a)
Execute agenda.
long dimensions[7]
Dimensions of array data.
Definition: arts_api.h:78
This file contains all declarations of the ARTS C API.
bool empty() const
Returns true if variable size is zero.
Definition: matpackI.cc:426
#define ARTS_FULL_VERSION
Definition: auto_version.h:1
const Matrix & get_dense() const
MethodStruct get_method(Index i)
Return MethodStruct describing method with index i.
Definition: arts_api.cc:211
InteractiveWorkspace * create_workspace(const Index verbosity, const Index agenda_verbosity)
Create new workspace.
Definition: arts_api.cc:191
Index Group() const
The wsv group to which this variable belongs.
Definition: wsv_aux.h:106
void set_tensor7_variable(Index id, size_t k, size_t l, size_t m, size_t n, size_t o, size_t p, size_t q, const Numeric *src)
Deep-copy of Tensor5 variable into workspace.
const Numeric * get_c_array() const
Conversion to plain C-array.
Definition: matpackI.cc:735
The Vector class.
Definition: matpackI.h:860
Index nvitrines() const
Returns the number of vitrines.
Definition: matpackVI.cc:42
const char * get_group_name(int i)
Get pointer to name of given group.
Definition: arts_api.cc:204
const Sparse & get_sparse() const
const int * inner_ptr
Additional array data for sparse matrices.
Definition: arts_api.h:84
The Sparse class.
Definition: matpackII.h:60
void parse_tasklist()
Public interface to the main function of the parser.
Definition: parser.cc:50
String out_basename
The basename for the report file and for all other output files.
Definition: messages.cc:42
bool empty() const
Check if variable is empty.
Definition: matpackVII.cc:36
const char * set_variable_value(InteractiveWorkspace *workspace, long id, long group_id, VariableValueStruct value)
Sets the value of a WSV in a given workspace.
Definition: arts_api.cc:512
The Tensor4 class.
Definition: matpackIV.h:421
The range class.
Definition: matpackI.h:160
void * get_variable_data_pointer(InteractiveWorkspace *workspace, Index id)
Get data pointer to the WSV variable.
Definition: arts_api.cc:463
std::string string_buffer
Definition: arts_api.cc:22
Index nrows() const
Returns the number of rows.
Definition: matpackVII.cc:57
Index npages() const
Returns the number of pages.
Definition: matpackIV.cc:60
bool empty() const
Returns true if variable size is zero.
Definition: matpackI.cc:49
Index ncols() const
Returns the number of columns.
Definition: matpackII.cc:69
bool is_initialized(Index i)
Checks existence of the given WSV.
Definition: workspace_ng.h:118
int * get_column_index_pointer()
Definition: matpackII.h:123
bool empty() const
Check if variable is empty.
Definition: matpackIII.cc:38
VariableValueStruct get_variable_value(InteractiveWorkspace *workspace, Index id, Index group_id)
Get value WSV in given workspace.
Definition: arts_api.cc:300
void set_index_variable(Index id, const Index &src)
Deep-copy of Index variable into workspace.
The Tensor7 class.
Definition: matpackVII.h:2382
void initialize()
Initalize ARTS runtime.
Definition: arts_api.cc:60
void agenda_insert_callback(Agenda *a, void(*f)(InteractiveWorkspace *))
Insert callback into agenda.
Definition: arts_api.cc:149
Structure to hold all command line Parameters.
Definition: parameters.h:42
Index nbooks() const
Returns the number of books.
Definition: matpackV.cc:47
const char * get_method_g_in_default(Index i, Index j)
Get default value of generic input argument.
Definition: arts_api.cc:250
void agenda_insert_set(InteractiveWorkspace *workspace, Agenda *a, long id, long group_id)
Insert a set method into an agenda.
Definition: arts_api.cc:94
void copy_output_and_input(ArrayOfIndex &output, ArrayOfIndex &input, unsigned long n_args_out, const long *args_out, unsigned long n_args_in, const long *args_in)
Definition: arts_api.cc:30
Index nrows() const
Returns the number of rows.
Definition: matpackIII.h:147
unsigned long get_number_of_methods()
Return number of WSMs.
Definition: arts_api.cc:209
constexpr Index get_start() const
Returns the start index of the range.
Definition: matpackI.h:327
const Verbosity & verbosity
Definition: messages.h:134
void set_matrix_variable(Index id, size_t m, size_t n, const Numeric *src)
Deep-copy of Matrix variable into workspace.
Index nrows() const
Returns the number of rows.
Definition: matpackIV.cc:63
void initialize_variable(Index id)
Initialize workspace variable.
Index nelem() const
Returns the number of elements.
Definition: matpackI.cc:51
const String & Name() const
Name of this workspace variable.
Definition: wsv_aux.h:102
basic_stringstream< char, string_char_traits< char >, alloc > stringstream
Definition: sstream.h:205
ArrayOfString includepath
List of paths to search for include files.
Definition: parameters.h:106
Covariance matrix block.
Definition: arts_api.h:172
const char * execute_workspace_method(InteractiveWorkspace *workspace, long id, unsigned long n_args_out, const long *args_out, unsigned long n_args_in, const long *args_in)
Execute workspace method.
Definition: arts_api.cc:262
const map< String, Index > MdMap
The map associated with md_data.
Definition: methods_aux.cc:39
MatrixType get_matrix_type() const
const char * get_method_g_in(Index i, Index j)
Get name of generic input argument.
Definition: arts_api.cc:246
This file contains the Workspace class.
ArrayOfString datapath
List of paths to search for data files.
Definition: parameters.h:108
const void * ptr
Data pointer.
Definition: arts_api.h:64
Index ncols() const
Returns the number of columns.
Definition: matpackI.cc:432
void finalize()
Finalize ARTS runtime.
Definition: arts_api.cc:62
const Numeric * get_c_array() const
Conversion to plain C-array, const-version.
Definition: matpackI.cc:272
The Tensor3 class.
Definition: matpackIII.h:339
The global header file for ARTS.
Index nshelves() const
Returns the number of shelves.
Definition: matpackV.cc:44
const char * get_error()
Get most recent error.
Definition: arts_api.cc:66
void set_basename(const char *name)
Set the ARTS basename.
Definition: arts_api.cc:68
std::vector< Block > & get_inverse_blocks()
Blocks of the inverse covariance matrix.
Agenda * create_agenda(const char *name)
Create Agenda.
Definition: arts_api.cc:88
std::vector< Block > & get_blocks()
Block in the covariance matrix.
#define DLL_PUBLIC
Definition: arts_api.h:32
void set_agenda_variable(Index id, const Agenda &src)
Set agenda variable into workspace.
void set_vector_variable(Index id, size_t n, const Numeric *src)
Deep-copy of Vector variable into workspace.
unsigned long get_number_of_variables()
Number of defined WSVs.
Definition: arts_api.cc:293
Parameters parameters
Holds the command line parameters.
Definition: parameters.cc:41
long lookup_workspace_variable(const char *s)
Lookup workspace variable by name.
Definition: arts_api.cc:285
const char * get_method_g_out(Index i, Index j)
Get name value of generic output argument.
Definition: arts_api.cc:258
Index get_wsv_id(const char *)
Get index of WSV.
Definition: workspace.cc:5771
void set_tensor5_variable(Index id, size_t k, size_t l, size_t m, size_t n, size_t o, const Numeric *src)
Deep-copy of Tensor5 variable into workspace.
Index ncols() const
Returns the number of columns.
Definition: matpackIII.h:150
void agenda_append(Agenda *dst, const Agenda *src)
Append agendas.
Definition: arts_api.cc:171
static void initialize()
Workspace intialization.
Declarations for agendas.
const String & Description() const
A text describing this workspace variable.
Definition: wsv_aux.h:104
constexpr Index get_extent() const
Returns the extent of the range.
Definition: matpackI.h:329
void set_tensor6_variable(Index id, size_t k, size_t l, size_t m, size_t n, size_t o, size_t p, const Numeric *src)
Deep-copy of Tensor6 variable into workspace.
void include_path_push(const char *path)
Add include path.
Definition: arts_api.cc:50
const char * get_method_in(Index i, Index j)
Definition: arts_api.cc:242
Method runtime data.
Definition: agenda_class.h:121
Index nrows() const
Returns the number of rows.
Definition: matpackII.cc:66
void include_path_pop()
Remove last include path.
Definition: arts_api.cc:54
Representation of workspace methods.
Definition: arts_api.h:97
Representation of ARTS WSVs.
Definition: arts_api.h:44
std::vector< Method > methods()
void agenda_clear(Agenda *a)
Clear Agenda.
Definition: arts_api.cc:178
void set_numeric_variable(Index id, const Numeric &src)
Deep-copy of Numeric variable into workspace.
Index nrows() const
Returns the number of rows.
Definition: matpackVI.cc:54
void set_sparse_variable(Index id, Index m, Index n, Index nnz, const Numeric *src, const int *row_indices, const int *column_indices)
Deep-copy of Sparse matrix into workspace.
unsigned long get_number_of_groups()
Return number of WSV groups.
Definition: arts_api.cc:202
ARTS version.
Definition: arts_api.h:157
void set_array_of_index_variable(Index id, size_t n, const Index *src)
Deep-copy of ArrayOfIndex variable into workspace.
NUMERIC Numeric
The type to use for all floating point numbers.
Definition: matpack.h:33
The Matrix class.
Definition: matpackI.h:1193
Range get_row_range() const
Index nlibraries() const
Returns the number of libraries.
Definition: matpackVII.cc:42
int * get_row_start_pointer()
Definition: matpackII.h:124
Interactive ARTS workspace.
const Numeric * get_c_array() const
Conversion to plain C-array.
Definition: matpackVII.cc:5012
const Numeric * get_c_array() const
Conversion to plain C-array.
Definition: matpackV.cc:675
const char * method_print_doc(long id)
Print method documentation.
Definition: arts_api.cc:274
void set_tensor3_variable(Index id, size_t l, size_t m, size_t n, const Numeric *src)
Deep-copy of Tensor3 variable into workspace.
Index npages() const
Returns the number of pages.
Definition: matpackIII.h:144
Index nshelves() const
Returns the number of shelves.
Definition: matpackVI.cc:45
Index ncols() const
Returns the number of columns.
Definition: matpackVI.cc:57
long minor
Minor version number of this ARTS major version.
Definition: arts_api.h:161
const ArrayOfString wsv_group_names
The names associated with Wsv groups as Strings.
Definition: global_data.h:93
void set_name(const String &nname)
Set agenda name.
bool empty() const
Check if variable is empty.
Definition: matpackVI.cc:36
static map< String, Index > WsvMap
Global map associated with wsv_data.
Definition: workspace_ng.h:61
const Numeric * get_c_array() const
Conversion to plain C-array.
Definition: matpackVI.cc:1734
void data_path_push(const char *path)
Add data path.
Definition: arts_api.cc:56
long add_variable(InteractiveWorkspace *workspace, long group_id, const char *name)
Add variable of given type to workspace.
Definition: arts_api.cc:637
void set_tensor4_variable(Index id, size_t k, size_t l, size_t m, size_t n, const Numeric *src)
Deep-copy of Tensor4 variable into workspace.
Representation of ARTS values.
Definition: arts_api.h:58
bool empty() const
Check if variable is empty.
Definition: matpackIV.cc:52
static Index add_callback(Callback *cb)
Add callback to workspace.
void agenda_add_method(Agenda *a, const long id, unsigned long n_output_args, const long *output_args, unsigned long n_input_args, const long *input_args)
Definition: arts_api.cc:157
void set_array_of_string_variable(Index id, size_t n, const char *const *src)
Deep-copy of ArrayOfString variable into workspace.
const Array< MRecord > & Methods() const
Definition: agenda_class.h:74
The Tensor6 class.
Definition: matpackVI.h:1088
Index npages() const
Returns the number of pages.
Definition: matpackVI.cc:51
void destroy_workspace(InteractiveWorkspace *workspace)
Destroy given workspace.
Definition: arts_api.cc:196
Index nshelves() const
Returns the number of shelves.
Definition: matpackVII.cc:48
const int * outer_ptr
Additional array data for sparse matrices.
Definition: arts_api.h:90
const char * execute_agenda(InteractiveWorkspace *workspace, const Agenda *a)
Execute Agenda.
Definition: arts_api.cc:180
void set_main_agenda()
Definition: agenda_class.h:88
const char * execute_workspace_method(long id, const ArrayOfIndex &output, const ArrayOfIndex &input)
Execute workspace method.
Index npages() const
Returns the number of pages.
Definition: matpackVII.cc:54
Index nbooks() const
Returns the number of books.
Definition: matpackIV.cc:57
void data_path_pop()
Remove last data path.
Definition: arts_api.cc:58
long revision
Revision number.
Definition: arts_api.h:163
const Array< MdRecord > md_data
Lookup information for workspace methods.
Verbosity verbosity_at_launch
The global message verbosity settings:
Definition: messages.cc:34
Index ncols() const
Returns the number of columns.
Definition: matpackV.cc:56
Index add_variable(Index group_id, const char *name)
Push a stack for a new variable to the workspace.
const Numeric * get_c_array() const
Conversion to plain C-array.
Definition: matpackIII.cc:321
CovarianceMatrixBlockStruct get_covariance_matrix_block(CovarianceMatrix *m, long block_index, bool inverse)
Return block of covariance matrix.
Definition: arts_api.cc:467
Index nvitrines() const
Returns the number of vitrines.
Definition: matpackVII.cc:45
void erase_variable(Index i, Index group_id)
Remove a variable stack from the workspace.
This class contains all static information for one workspace variable.
Definition: wsv_aux.h:56
Index ncols() const
Returns the number of columns.
Definition: matpackVII.cc:60
This file contains header information for the dealing with command line parameters.
constexpr Rational end(Rational Ju, Rational Jl, Polarization type) noexcept
Gives the largest M for a polarization type of this transition.
Definition: zeemandata.h:108
Index ncols() const
Returns the number of columns.
Definition: matpackIV.cc:66
IndexPair get_indices() const
This stores arbitrary token values and remembers the type.
Definition: token.h:40
Numeric * get_element_pointer()
Definition: matpackII.h:122
Index nrows() const
Returns the number of rows.
Definition: matpackI.cc:429
Index nbooks() const
Returns the number of books.
Definition: matpackVII.cc:51
DLL_PUBLIC void erase_variable(InteractiveWorkspace *workspace, long id, long group_id)
Erase variable from workspace.
Definition: arts_api.cc:644
my_basic_string< char > String
The String type for ARTS.
Definition: mystring.h:280
The Tensor5 class.
Definition: matpackV.h:506
void set_string_variable(Index id, const char *src)
Deep-copy of String variable into workspace.
const Numeric * get_c_array() const
Conversion to plain C-array.
Definition: matpackIV.cc:358
long major
Major version number of ARTS.
Definition: arts_api.h:159
void push_back(const MRecord &n)
Append a new method to end of list.
Definition: agenda_class.h:274
Index nbooks() const
Returns the number of books.
Definition: matpackVI.cc:48