ARTS 2.5.0 (git: 9ee3ac6c)
m_retrieval.cc
Go to the documentation of this file.
1#include <algorithm>
2
3#include "auto_md.h"
4#include "covariance_matrix.h"
5#include "jacobian.h"
6
8// Helper Functions
10
12 const RetrievalQuantity& jq,
13 const Index rq_index,
14 const Index grid_dimensions,
15 const Sparse& covmat_block,
16 const Sparse& covmat_inv_block) {
17 Index start = covmat.nrows();
18 Index extent = covmat_block.nrows();
19 Range range(start, extent);
20 Index n_gps = 1;
21 for (Index j = 0; j < grid_dimensions; ++j) {
22 n_gps *= jq.Grids()[j].nelem();
23 }
24
25 if (!covmat_block.empty()) {
26 if ((n_gps == extent) && (n_gps == covmat_block.ncols())) {
27 std::shared_ptr<Sparse> mat = make_shared<Sparse>(covmat_block);
28 covmat.add_correlation(
29 Block(range, range, std::make_pair(rq_index, rq_index), mat));
30 } else {
32 "The matrix in covmat_block was expected to have dimensions [",
33 n_gps, ", ", n_gps, "] but found to have dimensions [",
34 covmat_block.nrows(), ", ", covmat_block.ncols(), "].")
35 }
36 }
37 if (!covmat_inv_block.empty()) {
38 if ((n_gps == covmat_inv_block.nrows()) &&
39 (n_gps == covmat_inv_block.ncols())) {
40 std::shared_ptr<Sparse> mat = make_shared<Sparse>(covmat_inv_block);
42 Block(range, range, std::make_pair(rq_index, rq_index), mat));
43 } else {
45 "The matrix in covmat_inv_block was expected to have dimensions [",
46 n_gps, ", ", n_gps, "] but found to have dimensions [",
47 covmat_block.nrows(), ", ", covmat_block.ncols(), "].")
48 }
49 }
50}
51
53 ArrayOfRetrievalQuantity& jacobian_quantities,
54 Numeric var) {
55 Index i = jacobian_quantities.size() - 1;
56 Index start = covmat.nrows();
57 Index extent = 1;
58 Range range(start, extent);
59 std::shared_ptr<Matrix> mat = make_shared<Matrix>(1, 1);
60 mat->operator()(0, 0) = var;
61 covmat.add_correlation(Block(range, range, std::make_pair(i, i), mat));
62 mat = make_shared<Matrix>(1, 1);
63 mat->operator()(0, 0) = 1.0 / var;
65 Block(range, range, std::make_pair(i, i), mat));
66}
67
69// Simple Pressure-Height Conversion
71
72void ZFromPSimple(Vector& z_grid, const Vector& p_grid, const Verbosity&) {
73 z_grid = Vector(p_grid.nelem());
74
75 for (Index i = 0; i < p_grid.nelem(); ++i) {
76 ARTS_USER_ERROR_IF (p_grid[i] < 0.01,
77 "Pressures below 0.01 Pa are not accedpted.");
78 }
79
80 for (Index i = 0; i < p_grid.nelem(); ++i) {
81 z_grid[i] = 16e3 * (5.0 - log10(p_grid[i]));
82 }
83}
84
85void PFromZSimple(Vector& p_grid, const Vector& z_grid, const Verbosity&) {
86 p_grid = Vector(z_grid.nelem());
87
88 for (Index i = 0; i < p_grid.nelem(); ++i) {
89 ARTS_USER_ERROR_IF (z_grid[i] > 120e3,
90 "Altitudes above 120 km are not accepted.");
91 }
92
93 for (Index i = 0; i < z_grid.nelem(); ++i) {
94 p_grid[i] = pow(10.0, 5.0 - z_grid[i] / 16e3);
95 }
96}
97
99// Creation of Correlation Blocks
101
102template <typename MatrixType>
104 Index /*m*/,
105 Index /*n*/,
106 const ArrayOfIndex& row_indices,
107 const ArrayOfIndex& column_indices,
108 const Vector& elements) {
109 matrix.insert_elements(
110 row_indices.nelem(), row_indices, column_indices, elements);
111}
112
113template <>
115 Index m,
116 Index n,
117 const ArrayOfIndex& row_indices,
118 const ArrayOfIndex& column_indices,
119 const Vector& elements) {
120 ARTS_ASSERT(row_indices.nelem() == column_indices.nelem());
121 ARTS_ASSERT(column_indices.nelem() == elements.nelem());
122
123 matrix.resize(m, n);
124
125 for (Index i = 0; i < elements.nelem(); ++i) {
126 matrix(row_indices[i], column_indices[i]) = elements[i];
127 }
128}
129
130template <typename MatrixType>
132 MatrixType& block_inv,
133 const Vector& vars,
134 const Verbosity&) {
136 "Cannot pass empty vector of variances to covmat_blockSetDiagonal");
137 Index n = vars.nelem();
138 block = MatrixType(n, n);
139 block_inv = MatrixType(n, n);
140
141 ArrayOfIndex indices(n);
142 Vector elements(n), elements_inv(n);
143 for (Index i = 0; i < n; ++i) {
144 indices[i] = i;
145 elements[i] = vars[i];
146 elements_inv[i] = 1.0 / vars[i];
147 }
148
149 insert_elements(block, n, n, indices, indices, elements);
150 insert_elements(block_inv, n, n, indices, indices, elements_inv);
151}
152
153template void covmatDiagonal(Matrix& block,
154 Matrix& block_inv,
155 const Vector& vars,
156 const Verbosity&);
157template void covmatDiagonal(Sparse& block,
158 Sparse& block_inv,
159 const Vector& vars,
160 const Verbosity&);
161
162template <typename MatrixType>
164 MatrixType& block_inv,
165 const Vector& grid,
166 const Vector& sigma,
167 const Numeric& lc,
168 const Numeric& /*co*/,
169 const Verbosity&) {
170 Index n = grid.nelem();
171 ArrayOfIndex row_indices, column_indices;
172 Vector elements, elements_inv;
173
174 ARTS_USER_ERROR_IF (n != sigma.nelem(),
175 "Size of grid incompatible with given variances.");
176
177 elements = Vector(row_indices.size());
178 for (size_t i = 0; i < row_indices.size(); ++i) {
179 Numeric dz = abs(grid[row_indices[i]] - grid[column_indices[i]]);
180 Numeric e =
181 sigma[row_indices[i]] * sigma[column_indices[i]] * exp(-dz / lc);
182 elements[i] = e;
183 }
184
185 block = MatrixType(n, n);
186 insert_elements(block, n, n, row_indices, column_indices, elements);
187 row_indices = ArrayOfIndex{};
188 column_indices = ArrayOfIndex{};
189 elements = Vector(3 * n - 2);
190
191 Numeric dz = abs(grid[1] - grid[0]);
192 Numeric alpha = exp(-dz / lc);
193 Numeric c1 = -alpha / (1.0 - alpha * alpha);
194 Numeric c2 = 1.0 / (1.0 - alpha * alpha);
195
196 for (Index i = 0; i < n; ++i) {
197 // Lower Tri-diagonal
198 if (i > 0) {
199 column_indices.push_back(i - 1);
200 row_indices.push_back(i);
201 elements[i * 3 - 1] = c1;
202 elements[i * 3 - 1] /= (sigma[i] * sigma[i - 1]);
203 }
204
205 // Diagonal Elements
206 column_indices.push_back(i);
207 row_indices.push_back(i);
208 if (i == 0 || i == n - 1) {
209 elements[i * 3] = c2;
210 } else {
211 elements[i * 3] = c2 * (1.0 + alpha * alpha);
212 }
213 elements[i * 3] /= (sigma[i] * sigma[i]);
214
215 // Upper Tri-diagonal
216 if (i < n - 1) {
217 column_indices.push_back(i + 1);
218 row_indices.push_back(i);
219 elements[i * 3 + 1] = c1;
220 elements[i * 3 + 1] /= (sigma[i] * sigma[i + 1]);
221 }
222 }
223 block_inv = MatrixType(n, n);
224 insert_elements(block_inv, n, n, row_indices, column_indices, elements);
225}
226
227template void covmat1DMarkov(Matrix& block,
228 Matrix& block_inv,
229 const Vector& grid,
230 const Vector& sigma,
231 const Numeric& lc,
232 const Numeric& /*co*/,
233 const Verbosity&);
234
235template void covmat1DMarkov(Sparse& block,
236 Sparse& block_inv,
237 const Vector& grid,
238 const Vector& sigma,
239 const Numeric& lc,
240 const Numeric& /*co*/,
241 const Verbosity&);
242
243template <typename MatrixType>
245 const Vector& grid1,
246 const Vector& grid2,
247 const Vector& sigma1,
248 const Vector& sigma2,
249 const Vector& lc1,
250 const Vector& lc2,
251 const Numeric& co,
252 const String& fname,
253 const Verbosity&) {
254 Index m = grid1.nelem();
255 Vector sigma1_copy(sigma1), lc1_copy(lc1);
256
257 ARTS_ASSERT((sigma1.nelem() == m) || (sigma1.nelem() == 1));
258 if (sigma1.nelem() == 1) {
259 Numeric v = sigma1[0];
260 sigma1_copy = Vector(m);
261 sigma1_copy = v;
262 }
263
264 ARTS_ASSERT((lc1.nelem() == m) || (lc1.nelem() == 1));
265 if (lc1.nelem() == 1) {
266 Numeric v = lc1[0];
267 lc1_copy = Vector(m);
268 lc1_copy = v;
269 };
270
271 Index n = grid2.nelem();
272 Vector sigma2_copy(sigma2), lc2_copy(lc2);
273
274 ARTS_ASSERT((sigma2.nelem() == n) || (sigma2.nelem() == 1));
275 if (sigma2.nelem() == 1) {
276 Numeric v = sigma2[0];
277 sigma2_copy = Vector(n);
278 sigma2_copy = v;
279 }
280
281 ARTS_ASSERT((lc2.nelem() == n) || (lc2.nelem() == 1));
282 if (lc2.nelem() == 1) {
283 Numeric v = lc2[0];
284 lc2_copy = Vector(n);
285 lc2_copy = v;
286 };
287
288 ConstVectorView grid_view_1(grid1), sigma_view_1(sigma1_copy),
289 cls_view_1(lc1_copy);
290 ConstVectorView grid_view_2(grid2), sigma_view_2(sigma2_copy),
291 cls_view_2(lc2_copy);
292
293 if (n == 0) {
294 n = m;
295 grid_view_2 = grid_view_1;
296 sigma_view_2 = sigma_view_1;
297 cls_view_2 = cls_view_1;
298 }
299
300 // Correlation Functions
301 auto f_lin = [&](Index i, Index j) {
302 Numeric d = abs(grid_view_1[i] - grid_view_2[j]);
303 Numeric cl = 0.5 * (cls_view_1[i] + cls_view_2[j]);
304 return 1.0 - (1.0 - exp(-1.0)) * (d / cl);
305 };
306
307 auto f_exp = [&](Index i, Index j) {
308 Numeric d = abs(grid_view_1[i] - grid_view_2[j]);
309 Numeric cl = 0.5 * (cls_view_1[i] + cls_view_2[j]);
310 return exp(-d / cl);
311 };
312
313 auto f_gau = [&](Index i, Index j) {
314 Numeric d = abs(grid_view_1[i] - grid_view_2[j]);
315 Numeric cl = 0.5 * (cls_view_1[i] + cls_view_2[j]);
316 Numeric x = d / cl;
317 x *= x;
318 return exp(-x);
319 };
320
321 ArrayOfIndex row_indices;
322 ArrayOfIndex column_indices;
323
324 row_indices.reserve(n * m);
325 column_indices.reserve(n * m);
326
327 std::function<Numeric(Index, Index)> f;
328
329 if (fname == "exp") {
330 f = f_exp;
331 } else if (fname == "lin") {
332 f = f_lin;
333 } else if (fname == "gau") {
334 f = f_gau;
335 } else {
336 ostringstream os;
337 os << fname << " is not a known function name. Supported names"
338 << "are: exp, lin, gau.";
339 std::runtime_error(os.str());
340 }
341
342 for (Index i = 0; i < m; ++i) {
343 for (Index j = 0; j < n; ++j) {
344 Numeric e = f(i, j);
345 if (e >= co) {
346 row_indices.push_back(i);
347 column_indices.push_back(j);
348 }
349 }
350 }
351
352 Vector elements(row_indices.size());
353 for (size_t i = 0; i < row_indices.size(); ++i) {
354 Index ii = row_indices[i];
355 Index jj = column_indices[i];
356 elements[i] = sigma_view_1[ii] * sigma_view_2[jj] * f(ii, jj);
357 }
358
359 block = MatrixType(m, n);
360 insert_elements(block, m, n, row_indices, column_indices, elements);
361}
362
363template void covmat1D(Matrix& block,
364 const Vector& grid1,
365 const Vector& grid2,
366 const Vector& sigma1,
367 const Vector& sigma2,
368 const Vector& lc1,
369 const Vector& lc2,
370 const Numeric& co,
371 const String& fname,
372 const Verbosity&);
373
374template void covmat1D(Sparse& block,
375 const Vector& grid1,
376 const Vector& grid2,
377 const Vector& sigma1,
378 const Vector& sigma2,
379 const Vector& lc1,
380 const Vector& lc2,
381 const Numeric& co,
382 const String& fname,
383 const Verbosity&);
384
386// Manipulation of covmat_se and covmat_sx
388
389template <typename MatrixType>
391 const MatrixType& block,
392 const Index& i,
393 const Index& j,
394 const Verbosity&) {
395 Index m = block.nrows();
396 Index n = block.ncols();
397
398 Index ii(i), jj(j);
399 if ((ii < 0) && (jj < 0)) {
400 ii = covmat_se.ndiagblocks();
401 jj = ii;
402 }
403
404 ARTS_USER_ERROR_IF (j < i,
405 "The block must be on or above the diagonal, "
406 " i.e. *i* <= *j*.");
407
408 Index ndiagblocks = covmat_se.ndiagblocks();
409
410 if ((ii >= ndiagblocks)) {
411 if (ii > ndiagblocks) {
412 ARTS_USER_ERROR_IF (jj > ii,
413 "Off-diagonal block can only be added to rows that already "
414 "have a block on the diagonal.");
416 "Diagonal block must be added row-by-row starting in the "
417 " upper left of the matrix.");
418 }
419 }
420
421 ARTS_USER_ERROR_IF (covmat_se.has_block(ii, jj),
422 "Block already present in covariance matrix.");
423
424 if (ii == jj) {
425 ARTS_USER_ERROR_IF (m != n,
426 "Diagonal blocks must be square.");
427 Index start = covmat_se.nrows();
428 Range range(start, m);
429 std::shared_ptr<MatrixType> mat = std::make_shared<MatrixType>(block);
430 covmat_se.add_correlation(Block(range, range, std::make_pair(ii, ii), mat));
431
432 } else {
433 const Block* b = covmat_se.get_block(ii, ii);
435 "Trying to add an off-diagonal block that"
436 " lacks corresponding diagonal block in the "
437 " same row.");
438 Range row_range = b->get_row_range();
439
440 b = covmat_se.get_block(jj, jj);
442 "Trying to add an off-diagonal block that"
443 " lacks corresponding diagonal block in the "
444 " same column.");
445 Range column_range = b->get_column_range();
446
447 ARTS_USER_ERROR_IF ((row_range.get_extent() != m) || (column_range.get_extent() != n),
448 "The off-diagonal block is inconsistent "
449 "with the corresponding diagonal blocks.");
450
451 std::shared_ptr<MatrixType> mat = std::make_shared<MatrixType>(block);
452 covmat_se.add_correlation(
453 Block(row_range, column_range, std::make_pair(ii, jj), mat));
454 }
455}
456
457template void covmat_seAddBlock(CovarianceMatrix& covmat_se,
458 const Matrix& block,
459 const Index& i,
460 const Index& j,
461 const Verbosity&);
462
463template void covmat_seAddBlock(CovarianceMatrix& covmat_se,
464 const Sparse& block,
465 const Index& i,
466 const Index& j,
467 const Verbosity&);
468
469template <typename MatrixType>
471 const MatrixType& inv_block,
472 const Index& i,
473 const Index& j,
474 const Verbosity&) {
475 ARTS_USER_ERROR_IF (covmat_se.ndiagblocks() == 0,
476 "Need at least one non-inverse block in the matrix"
477 " before an inverse block can be added.");
478 Index ii(i), jj(j);
479 if ((ii < 0) && (jj < 0)) {
480 ii = covmat_se.ndiagblocks() - 1;
481 jj = ii;
482 }
483
484 Index m = inv_block.nrows();
485 Index n = inv_block.ncols();
486
487 const Block* block = covmat_se.get_block(ii, jj);
488
489 ARTS_USER_ERROR_IF (!block,
490 "Cannot add inverse block to the covariance "
491 " without corresponding non-inverse block.");
492
493 ARTS_USER_ERROR_IF ((m != inv_block.nrows()) || (n != inv_block.ncols()),
494 "Dimensions of block are inconsistent with "
495 " non-inverse block.");
496
497 Range row_range = block->get_row_range();
498 Range column_range = block->get_column_range();
499
500 std::shared_ptr<MatrixType> mat = std::make_shared<MatrixType>(inv_block);
501 covmat_se.add_correlation_inverse(
502 Block(row_range, column_range, std::make_pair(ii, jj), mat));
503}
504
506 const Matrix& block,
507 const Index& i,
508 const Index& j,
509 const Verbosity&);
510
512 const Sparse& block,
513 const Index& i,
514 const Index& j,
515 const Verbosity&);
516
517template <typename MatrixType>
519 Index m = block.nrows();
520 Index n = block.ncols();
521
522 ARTS_USER_ERROR_IF (n != m,
523 "Covariance matrix must be square!");
524
525 covmat = CovarianceMatrix();
526 IndexPair indices = std::make_pair(0, 0);
527 Range range = Range(0, n);
528 std::shared_ptr<MatrixType> mat_ptr = std::make_shared<MatrixType>(block);
529 covmat.add_correlation(Block(range, range, indices, mat_ptr));
530}
531
532template <>
534 const CovarianceMatrix& block) {
535 covmat = block;
536}
537
538template <typename MatrixType>
540 const MatrixType& block,
541 const Verbosity& /*v*/) {
542 setCovarianceMatrix(covmat, block);
543}
544
545template void covmat_seSet(CovarianceMatrix& covmat,
546 const CovarianceMatrix& block,
547 const Verbosity& /*v*/);
548
549template void covmat_seSet(CovarianceMatrix& covmat,
550 const Matrix& block,
551 const Verbosity& /*v*/);
552
553template void covmat_seSet(CovarianceMatrix& covmat,
554 const Sparse& block,
555 const Verbosity& /*v*/);
556
557template <typename MatrixType>
559 const MatrixType& block,
560 const Verbosity& /*v*/) {
561 setCovarianceMatrix(covmat, block);
562}
563
564template void covmat_sxSet(CovarianceMatrix& covmat,
565 const CovarianceMatrix& block,
566 const Verbosity& /*v*/);
567
568template void covmat_sxSet(CovarianceMatrix& covmat,
569 const Matrix& block,
570 const Verbosity& /*v*/);
571
572template void covmat_sxSet(CovarianceMatrix& covmat,
573 const Sparse& block,
574 const Verbosity& /*v*/);
575
576template <typename MatrixType>
578 const ArrayOfRetrievalQuantity& jq,
579 const MatrixType& block,
580 const Index& i,
581 const Index& j,
582 const Verbosity& /*v*/) {
583 Index ii(i), jj(j);
584 if ((ii < 0) && (jj < 0)) {
585 ii = covmat_sx.ndiagblocks();
586 jj = ii;
587 ARTS_USER_ERROR_IF ((ii >= jq.nelem()) || (jj >= jq.nelem()),
588 "*covmat_sx* already contains more or as many diagonal"
589 " blocks as there are retrieval quantities.");
590 } else {
591 ARTS_USER_ERROR_IF ((ii >= jq.nelem()) || (jj >= jq.nelem()),
592 "The block indices must either be both -1 (default) or\n"
593 "non-negative and smaller than the number of retrieval \n"
594 "quantities.");
595 ARTS_USER_ERROR_IF (ii > jj,
596 "Only blocks above the diagonal can be set, hence"
597 "*i* must be less than or equal to *j*.");
598 }
599
600 Index m = block.nrows();
601 Index n = block.ncols();
602
603 Index jq_m = jq[ii].nelem();
604 if (jq[ii].HasAffine()) {
605 jq_m = jq[ii].TransformationMatrix().ncols();
606 }
607 Index jq_n = jq[jj].nelem();
608 if (jq[jj].HasAffine()) {
609 jq_n = jq[jj].TransformationMatrix().ncols();
610 }
611
612 ARTS_USER_ERROR_IF ((m != jq_m) || (n != jq_n),
613 "The covariance block for retrieval quantities ", ii, " and ",
614 jj, " was expected to have dimensions [", jq_m, ", ", jq_n,
615 "] but found to have dimensions "
616 "[", m, ", ", n, "].")
617
619 bool any_affine;
620 jac_ranges_indices(ji, any_affine, jq);
621 Index row_start = ji[ii][0];
622 Index row_extent = ji[ii][1] - ji[ii][0] + 1;
623 Range row_range(row_start, row_extent);
624
625 Index col_start = ji[jj][0];
626 Index col_extent = ji[jj][1] - ji[jj][0] + 1;
627 Range col_range(col_start, col_extent);
628
629 std::shared_ptr<MatrixType> mat = make_shared<MatrixType>(block);
630 covmat_sx.add_correlation(
631 Block(row_range, col_range, std::make_pair(ii, jj), mat));
632}
633
636 const Matrix&,
637 const Index&,
638 const Index&,
639 const Verbosity&);
640
643 const Sparse&,
644 const Index&,
645 const Index&,
646 const Verbosity&);
647
648template <typename MatrixType>
650 const ArrayOfRetrievalQuantity& jq,
651 const MatrixType& block_inv,
652 const Index& i,
653 const Index& j,
654 const Verbosity& /*v*/) {
655 ARTS_USER_ERROR_IF (covmat_sx.ndiagblocks() == 0,
656 "Need at least one non-inverse block in the matrix"
657 " before an inverse block can be added.");
658 Index ii(i), jj(j);
659 if ((ii < 0) && (jj < 0)) {
660 ii = covmat_sx.ndiagblocks() - 1;
661 jj = ii;
662 } else {
663 ARTS_USER_ERROR_IF ((ii >= jq.nelem()) || (jj >= jq.nelem()),
664 "The block indices must either be both -1 (default) or\n"
665 "non-negative and smaller than the number of retrieval \n"
666 "quantities.");
667 ARTS_USER_ERROR_IF (ii > jj,
668 "Only blocks above the diagonal can be set, hence"
669 "*i* must be less than or equal to *j*.");
670 }
671
672 Index m = block_inv.nrows();
673 Index n = block_inv.ncols();
674
675 Index jq_m = jq[ii].nelem();
676 if (jq[ii].HasAffine()) {
677 jq_m = jq[ii].TransformationMatrix().ncols();
678 }
679
680 Index jq_n = jq[jj].nelem();
681 if (jq[jj].HasAffine()) {
682 jq_n = jq[jj].TransformationMatrix().ncols();
683 }
684
685 ARTS_USER_ERROR_IF (!((m == jq_m) && (n == jq_n)),
686 "The dimensions of the covariance block ( ", m,
687 " x ", n, " )"
688 " with the dimensionality of "
689 " retrieval quantity ", ii, " and ", jj, ", respectively.")
690
691 ARTS_USER_ERROR_IF (!covmat_sx.has_block(ii, jj),
692 "To add the inverse of a block the non-inverse"
693 " block must be added first.");
694
696 bool any_affine;
697 jac_ranges_indices(ji, any_affine, jq);
698 Index row_start = ji[ii][0];
699 Index row_extent = ji[ii][1] - ji[ii][0] + 1;
700 Range row_range(row_start, row_extent);
701
702 Index col_start = ji[jj][0];
703 Index col_extent = ji[jj][1] - ji[jj][0] + 1;
704 Range col_range(col_start, col_extent);
705
706 std::shared_ptr<MatrixType> mat = make_shared<MatrixType>(block_inv);
707 covmat_sx.add_correlation_inverse(
708 Block(row_range, col_range, std::make_pair(ii, jj), mat));
709}
710
713 const Matrix&,
714 const Index&,
715 const Index&,
716 const Verbosity&);
717
720 const Sparse&,
721 const Index&,
722 const Index&,
723 const Verbosity&);
724
726 const CovarianceMatrix& covmat_sx,
727 const Verbosity&) {
728 x_norm = covmat_sx.diagonal();
729 for (Index i = 0; i < x_norm.nelem(); ++i) {
730 x_norm[i] = sqrt(x_norm[i]);
731 }
732}
733
735// retrievalAdd Functions
737
739 CovarianceMatrix& covmat_sx,
740 ArrayOfRetrievalQuantity& jacobian_quantities,
741 Agenda& jacobian_agenda,
742 const Index& atmosphere_dim,
743 const Sparse& covmat_block,
744 const Sparse& covmat_inv_block,
745 const Vector& p_grid,
746 const Vector& lat_grid,
747 const Vector& lon_grid,
748 const Vector& rq_p_grid,
749 const Vector& rq_lat_grid,
750 const Vector& rq_lon_grid,
751 const String& species,
752 const String& mode,
753 const Index& for_species_tag,
754 const Verbosity& verbosity) {
756 jacobian_quantities,
757 jacobian_agenda,
758 atmosphere_dim,
759 p_grid,
760 lat_grid,
761 lon_grid,
762 rq_p_grid,
763 rq_lat_grid,
764 rq_lon_grid,
765 species,
766 mode,
767 for_species_tag,
768 verbosity);
769 check_and_add_block(covmat_sx,
770 jacobian_quantities.back(),
771 jacobian_quantities.nelem() - 1,
772 atmosphere_dim,
773 covmat_block,
774 covmat_inv_block);
775}
776
778 CovarianceMatrix& covmat_sx,
779 ArrayOfRetrievalQuantity& jacobian_quantities,
780 Agenda& jacobian_agenda,
781 const Sparse& covmat_block,
782 const Sparse& covmat_inv_block,
783 const Vector& f_grid,
784 const Numeric& df,
785 const Verbosity& verbosity) {
787 ws, jacobian_quantities, jacobian_agenda, f_grid, df, verbosity);
788 check_and_add_block(covmat_sx,
789 jacobian_quantities.back(),
790 jacobian_quantities.nelem() - 1,
791 1,
792 covmat_block,
793 covmat_inv_block);
794}
795
797 CovarianceMatrix& covmat_sx,
798 ArrayOfRetrievalQuantity& jacobian_quantities,
799 Agenda& jacobian_agenda,
800 const Vector& f_grid,
801 const Sparse& covmat_block,
802 const Sparse& covmat_inv_block,
803 const Numeric& df,
804 const Verbosity& verbosity) {
806 ws, jacobian_quantities, jacobian_agenda, f_grid, df, verbosity);
807 check_and_add_block(covmat_sx,
808 jacobian_quantities.back(),
809 jacobian_quantities.nelem() - 1,
810 1,
811 covmat_block,
812 covmat_inv_block);
813}
814
816 CovarianceMatrix& covmat_sx,
817 ArrayOfRetrievalQuantity& jacobian_quantities,
818 Agenda& jacobian_agenda,
819 const QuantumIdentifier& catalog_identity,
820 const String& catalog_parameter,
821 const Numeric& var,
822 const Verbosity& verbosity) {
824 jacobian_quantities,
825 jacobian_agenda,
826 catalog_identity,
827 catalog_parameter,
828 verbosity);
829 add_scalar_variance(covmat_sx, jacobian_quantities, var);
830}
831
833 Workspace& ws,
834 CovarianceMatrix& covmat_sx,
835 ArrayOfRetrievalQuantity& jacobian_quantities,
836 Agenda& jacobian_agenda,
837 const Sparse& covmat_block,
838 const Sparse& covmat_inv_block,
839 const ArrayOfQuantumIdentifier& catalog_identities,
840 const ArrayOfString& catalog_parameters,
841 const Verbosity& verbosity) {
843 jacobian_quantities,
844 jacobian_agenda,
845 catalog_identities,
846 catalog_parameters,
847 verbosity);
848 check_and_add_block(covmat_sx,
849 jacobian_quantities.back(),
850 jacobian_quantities.nelem() - 1,
851 0,
852 covmat_block,
853 covmat_inv_block);
854}
855
857 CovarianceMatrix& covmat_sx,
858 ArrayOfRetrievalQuantity& jacobian_quantities,
859 Agenda& jacobian_agenda,
860 const Index& atmosphere_dim,
861 const Sparse& covmat_block,
862 const Sparse& covmat_inv_block,
863 const Vector& p_grid,
864 const Vector& lat_grid,
865 const Vector& lon_grid,
866 const Vector& rq_p_grid,
867 const Vector& rq_lat_grid,
868 const Vector& rq_lon_grid,
869 const String& component,
870 const Numeric& dB,
871 const Verbosity& verbosity) {
873 jacobian_quantities,
874 jacobian_agenda,
875 atmosphere_dim,
876 p_grid,
877 lat_grid,
878 lon_grid,
879 rq_p_grid,
880 rq_lat_grid,
881 rq_lon_grid,
882 component,
883 dB,
884 verbosity);
885 check_and_add_block(covmat_sx,
886 jacobian_quantities.back(),
887 jacobian_quantities.nelem() - 1,
888 atmosphere_dim,
889 covmat_block,
890 covmat_inv_block);
891}
892
894 CovarianceMatrix& covmat_sx,
895 ArrayOfRetrievalQuantity& jacobian_quantities,
896 Agenda& jacobian_agenda,
897 const Sparse& covmat_block,
898 const Sparse& covmat_inv_block,
899 const Matrix& sensor_pos,
900 const ArrayOfTime& sensor_time,
901 const Index& poly_order,
902 const String& calcmode,
903 const Numeric& dza,
904 const Verbosity& verbosity) {
906 jacobian_quantities,
907 jacobian_agenda,
908 sensor_pos,
909 sensor_time,
910 poly_order,
911 calcmode,
912 dza,
913 verbosity);
914 check_and_add_block(covmat_sx,
915 jacobian_quantities.back(),
916 jacobian_quantities.nelem() - 1,
917 1,
918 covmat_block,
919 covmat_inv_block);
920}
921
923 CovarianceMatrix& covmat_sx,
924 ArrayOfRetrievalQuantity& jacobian_quantities,
925 Agenda& jacobian_agenda,
926 const Sparse& covmat_block,
927 const Sparse& covmat_inv_block,
928 const ArrayOfIndex& sensor_response_pol_grid,
929 const Matrix& sensor_response_dlos_grid,
930 const Matrix& sensor_pos,
931 const Index& poly_order,
932 const Index& no_pol_variation,
933 const Index& no_los_variation,
934 const Index& no_mblock_variation,
935 const Verbosity& verbosity) {
936 size_t jq_start = jacobian_quantities.size();
938 jacobian_quantities,
939 jacobian_agenda,
940 sensor_response_pol_grid,
941 sensor_response_dlos_grid,
942 sensor_pos,
943 poly_order,
944 no_pol_variation,
945 no_los_variation,
946 no_mblock_variation,
947 verbosity);
948 for (Index i = 0; i <= poly_order; ++i) {
949 check_and_add_block(covmat_sx,
950 jacobian_quantities[jq_start + i],
951 jq_start + i,
952 4,
953 covmat_block,
954 covmat_inv_block);
955 }
956}
957
959 CovarianceMatrix& covmat_sx,
960 ArrayOfRetrievalQuantity& jacobian_quantities,
961 Agenda& jacobian_agenda,
962 const Index& atmosphere_dim,
963 const Sparse& covmat_block,
964 const Sparse& covmat_inv_block,
965 const Vector& p_grid,
966 const Vector& lat_grid,
967 const Vector& lon_grid,
968 const Vector& rq_p_grid,
969 const Vector& rq_lat_grid,
970 const Vector& rq_lon_grid,
971 const String& species,
972 const String& quantity,
973 const Verbosity& verbosity) {
975 jacobian_quantities,
976 jacobian_agenda,
977 atmosphere_dim,
978 p_grid,
979 lat_grid,
980 lon_grid,
981 rq_p_grid,
982 rq_lat_grid,
983 rq_lon_grid,
984 species,
985 quantity,
986 verbosity);
987 check_and_add_block(covmat_sx,
988 jacobian_quantities.back(),
989 jacobian_quantities.nelem() - 1,
990 atmosphere_dim,
991 covmat_block,
992 covmat_inv_block);
993}
994
996 CovarianceMatrix& covmat_sx,
997 ArrayOfRetrievalQuantity& jacobian_quantities,
998 Agenda& jacobian_agenda,
999 const Sparse& covmat_block,
1000 const Sparse& covmat_inv_block,
1001 const ArrayOfIndex& sensor_response_pol_grid,
1002 const Matrix& sensor_response_dlos_grid,
1003 const Matrix& sensor_pos,
1004 const Vector& period_lengths,
1005 const Index& no_pol_variation,
1006 const Index& no_los_variation,
1007 const Index& no_mblock_variation,
1008 const Verbosity& verbosity) {
1009 size_t jq_start = jacobian_quantities.size();
1011 jacobian_quantities,
1012 jacobian_agenda,
1013 sensor_response_pol_grid,
1014 sensor_response_dlos_grid,
1015 sensor_pos,
1016 period_lengths,
1017 no_pol_variation,
1018 no_los_variation,
1019 no_mblock_variation,
1020 verbosity);
1021 for (Index i = 0; i < period_lengths.nelem(); ++i) {
1022 check_and_add_block(covmat_sx,
1023 jacobian_quantities[jq_start + i],
1024 jq_start + i,
1025 4,
1026 covmat_block,
1027 covmat_inv_block);
1028 }
1029}
1030
1032 CovarianceMatrix& covmat_sx,
1033 ArrayOfRetrievalQuantity& jacobian_quantities,
1034 Agenda& jacobian_agenda,
1035 const Index& atmosphere_dim,
1036 const Sparse& covmat_block,
1037 const Sparse& covmat_inv_block,
1038 const Vector& p_grid,
1039 const Vector& lat_grid,
1040 const Vector& lon_grid,
1041 const Vector& rq_p_grid,
1042 const Vector& rq_lat_grid,
1043 const Vector& rq_lon_grid,
1044 const String& species,
1045 const Verbosity& verbosity) {
1047 jacobian_quantities,
1048 jacobian_agenda,
1049 atmosphere_dim,
1050 p_grid,
1051 lat_grid,
1052 lon_grid,
1053 rq_p_grid,
1054 rq_lat_grid,
1055 rq_lon_grid,
1056 species,
1057 verbosity);
1058 check_and_add_block(covmat_sx,
1059 jacobian_quantities.back(),
1060 jacobian_quantities.nelem() - 1,
1061 atmosphere_dim,
1062 covmat_block,
1063 covmat_inv_block);
1064}
1065
1067 CovarianceMatrix& covmat_sx,
1068 ArrayOfRetrievalQuantity& jacobian_quantities,
1069 Agenda& jacobian_agenda,
1070 const Index& atmosphere_dim,
1071 const Sparse& covmat_block,
1072 const Sparse& covmat_inv_block,
1073 const Vector& p_grid,
1074 const Vector& lat_grid,
1075 const Vector& lon_grid,
1076 const Vector& rq_p_grid,
1077 const Vector& rq_lat_grid,
1078 const Vector& rq_lon_grid,
1079 const String& component,
1080 const Numeric& dfrequency,
1081 const Verbosity& verbosity) {
1082 jacobianAddWind(ws,
1083 jacobian_quantities,
1084 jacobian_agenda,
1085 atmosphere_dim,
1086 p_grid,
1087 lat_grid,
1088 lon_grid,
1089 rq_p_grid,
1090 rq_lat_grid,
1091 rq_lon_grid,
1092 component,
1093 dfrequency,
1094 verbosity);
1095 check_and_add_block(covmat_sx,
1096 jacobian_quantities.back(),
1097 jacobian_quantities.nelem() - 1,
1098 atmosphere_dim,
1099 covmat_block,
1100 covmat_inv_block);
1101}
1102
1104 CovarianceMatrix& covmat_sx,
1105 ArrayOfRetrievalQuantity& jacobian_quantities,
1106 Agenda& jacobian_agenda,
1107 const Index& atmosphere_dim,
1108 const Sparse& covmat_block,
1109 const Sparse& covmat_inv_block,
1110 const Vector& p_grid,
1111 const Vector& lat_grid,
1112 const Vector& lon_grid,
1113 const Vector& rq_p_grid,
1114 const Vector& rq_lat_grid,
1115 const Vector& rq_lon_grid,
1116 const String& hse,
1117 const Verbosity& verbosity) {
1119 jacobian_quantities,
1120 jacobian_agenda,
1121 atmosphere_dim,
1122 p_grid,
1123 lat_grid,
1124 lon_grid,
1125 rq_p_grid,
1126 rq_lat_grid,
1127 rq_lon_grid,
1128 hse,
1129 verbosity);
1130 check_and_add_block(covmat_sx,
1131 jacobian_quantities.back(),
1132 jacobian_quantities.nelem() - 1,
1133 atmosphere_dim,
1134 covmat_block,
1135 covmat_inv_block);
1136}
1137
1139 CovarianceMatrix& covmat_sx,
1140 ArrayOfRetrievalQuantity& jacobian_quantities,
1141 Agenda& jacobian_agenda,
1142 const Sparse& covmat_block,
1143 const Sparse& covmat_inv_block,
1144 const Index& atmosphere_dim,
1145 const Vector& lat_grid,
1146 const Vector& lon_grid,
1147 const Vector& rq_lat_grid,
1148 const Vector& rq_lon_grid,
1149 const String& quantity,
1150 const Verbosity& verbosity) {
1152 jacobian_quantities,
1153 jacobian_agenda,
1154 atmosphere_dim,
1155 lat_grid,
1156 lon_grid,
1157 rq_lat_grid,
1158 rq_lon_grid,
1159 quantity,
1160 verbosity);
1161
1162 check_and_add_block(covmat_sx,
1163 jacobian_quantities.back(),
1164 jacobian_quantities.nelem() - 1,
1165 atmosphere_dim - 1,
1166 covmat_block,
1167 covmat_inv_block);
1168}
1169
1170/* Workspace method: Doxygen documentation will be auto-generated */
1172 Index& jacobian_do,
1173 Agenda& jacobian_agenda,
1174 Index& retrieval_checked,
1175 const CovarianceMatrix& covmat_sx,
1176 const ArrayOfRetrievalQuantity& jacobian_quantities,
1177 const Verbosity& verbosity) {
1179 ws, jacobian_do, jacobian_agenda, jacobian_quantities, verbosity);
1180
1182 bool any_affine;
1183 jac_ranges_indices(ji_t, any_affine, jacobian_quantities);
1184 ARTS_USER_ERROR_IF (!covmat_sx.has_diagonal_blocks(ji_t),
1185 "*covmat_sx* does not contain a diagonal block for each retrieval"
1186 " quantity in the Jacobian.\n"
1187 " Fails test (!covmat_sx.has_diagonal_blocks(ji_t)) for ji_t ", ji_t,
1188 "\n")
1189 ARTS_USER_ERROR_IF (!covmat_sx.is_consistent(ji_t),
1190 "The blocks in *covmat_sx* are not consistent with the retrieval"
1191 " quantities in the Jacobian.");
1192 retrieval_checked = true;
1193}
1194
1195/* Workspace method: Doxygen documentation will be auto-generated */
1197 CovarianceMatrix& covmat_sx,
1198 Sparse& covmat_block,
1199 Sparse& covmat_inv_block,
1200 ArrayOfRetrievalQuantity& jacobian_quantities,
1201 Agenda& jacobian_agenda,
1202 const Index& initialize_jacobian,
1203 const Verbosity& verbosity) {
1204 if (initialize_jacobian == 1) {
1205 jacobianInit(jacobian_quantities, jacobian_agenda, verbosity);
1206 }
1207
1208 covmat_block = Sparse();
1209 covmat_inv_block = Sparse();
1210 covmat_sx = CovarianceMatrix();
1211 covmat_se = CovarianceMatrix();
1212}
1213
1215 Vector& retrieval_ss,
1216 const Matrix& covmat_so,
1217 const Matrix& covmat_ss,
1218 const Verbosity& /*v*/) {
1219 Index n_so = covmat_so.nrows();
1220 Index n_ss = covmat_ss.nrows();
1221
1222 retrieval_eo.resize(n_so);
1223 for (Index i = 0; i < n_so; ++i) {
1224 retrieval_eo[i] = sqrt(covmat_so(i, i));
1225 }
1226
1227 retrieval_ss.resize(n_ss);
1228 for (Index i = 0; i < n_ss; ++i) {
1229 retrieval_ss[i] = sqrt(covmat_ss(i, i));
1230 }
1231}
void jacobianAddSurfaceQuantity(Workspace &ws, ArrayOfRetrievalQuantity &jacobian_quantities, Agenda &jacobian_agenda, const Index &atmosphere_dim, const Vector &lat_grid, const Vector &lon_grid, const Vector &g1, const Vector &g2, const String &quantity, const Verbosity &verbosity)
WORKSPACE METHOD: jacobianAddSurfaceQuantity.
Definition: m_jacobian.cc:1236
void jacobianAddAbsSpecies(Workspace &ws, ArrayOfRetrievalQuantity &jacobian_quantities, Agenda &jacobian_agenda, const Index &atmosphere_dim, const Vector &p_grid, const Vector &lat_grid, const Vector &lon_grid, const Vector &g1, const Vector &g2, const Vector &g3, const String &species, const String &unit, const Index &for_species_tag, const Verbosity &verbosity)
WORKSPACE METHOD: jacobianAddAbsSpecies.
Definition: m_jacobian.cc:104
void jacobianAddFreqStretch(Workspace &ws, ArrayOfRetrievalQuantity &jacobian_quantities, Agenda &jacobian_agenda, const Vector &f_grid, const Numeric &df, const Verbosity &verbosity)
WORKSPACE METHOD: jacobianAddFreqStretch.
Definition: m_jacobian.cc:343
void jacobianAddPolyfit(Workspace &ws, ArrayOfRetrievalQuantity &jacobian_quantities, Agenda &jacobian_agenda, const ArrayOfIndex &sensor_response_pol_grid, const Matrix &sensor_response_dlos_grid, const Matrix &sensor_pos, const Index &poly_order, const Index &no_pol_variation, const Index &no_los_variation, const Index &no_mblock_variation, const Verbosity &verbosity)
WORKSPACE METHOD: jacobianAddPolyfit.
Definition: m_jacobian.cc:838
void jacobianAddScatSpecies(Workspace &ws, ArrayOfRetrievalQuantity &jacobian_quantities, Agenda &jacobian_agenda, const Index &atmosphere_dim, const Vector &p_grid, const Vector &lat_grid, const Vector &lon_grid, const Vector &g1, const Vector &g2, const Vector &g3, const String &species, const String &quantity, const Verbosity &verbosity)
WORKSPACE METHOD: jacobianAddScatSpecies.
Definition: m_jacobian.cc:999
void jacobianAddMagField(Workspace &ws, ArrayOfRetrievalQuantity &jacobian_quantities, Agenda &jacobian_agenda, const Index &atmosphere_dim, const Vector &p_grid, const Vector &lat_grid, const Vector &lon_grid, const Vector &g1, const Vector &g2, const Vector &g3, const String &component, const Numeric &dB, const Verbosity &verbosity)
WORKSPACE METHOD: jacobianAddMagField.
Definition: m_jacobian.cc:1448
void jacobianAddBasicCatalogParameter(Workspace &ws, ArrayOfRetrievalQuantity &jacobian_quantities, Agenda &jacobian_agenda, const QuantumIdentifier &catalog_identity, const String &catalog_parameter, const Verbosity &verbosity)
WORKSPACE METHOD: jacobianAddBasicCatalogParameter.
Definition: m_jacobian.cc:1606
void jacobianAddSpecialSpecies(Workspace &ws, ArrayOfRetrievalQuantity &jacobian_quantities, Agenda &jacobian_agenda, const Index &atmosphere_dim, const Vector &p_grid, const Vector &lat_grid, const Vector &lon_grid, const Vector &g1, const Vector &g2, const Vector &g3, const String &species, const Verbosity &verbosity)
WORKSPACE METHOD: jacobianAddSpecialSpecies.
Definition: m_jacobian.cc:1761
void jacobianAddSinefit(Workspace &ws, ArrayOfRetrievalQuantity &jacobian_quantities, Agenda &jacobian_agenda, const ArrayOfIndex &sensor_response_pol_grid, const Matrix &sensor_response_dlos_grid, const Matrix &sensor_pos, const Vector &period_lengths, const Index &no_pol_variation, const Index &no_los_variation, const Index &no_mblock_variation, const Verbosity &verbosity)
WORKSPACE METHOD: jacobianAddSinefit.
Definition: m_jacobian.cc:1066
void jacobianAddTemperature(Workspace &ws, ArrayOfRetrievalQuantity &jacobian_quantities, Agenda &jacobian_agenda, const Index &atmosphere_dim, const Vector &p_grid, const Vector &lat_grid, const Vector &lon_grid, const Vector &g1, const Vector &g2, const Vector &g3, const String &hse, const Verbosity &verbosity)
WORKSPACE METHOD: jacobianAddTemperature.
Definition: m_jacobian.cc:1294
void jacobianClose(Workspace &ws, Index &jacobian_do, Agenda &jacobian_agenda, const ArrayOfRetrievalQuantity &jacobian_quantities, const Verbosity &verbosity)
WORKSPACE METHOD: jacobianClose.
Definition: m_jacobian.cc:67
void jacobianInit(ArrayOfRetrievalQuantity &jacobian_quantities, Agenda &jacobian_agenda, const Verbosity &verbosity)
WORKSPACE METHOD: jacobianInit.
Definition: m_jacobian.cc:82
void jacobianAddWind(Workspace &ws, ArrayOfRetrievalQuantity &jacobian_quantities, Agenda &jacobian_agenda, const Index &atmosphere_dim, const Vector &p_grid, const Vector &lat_grid, const Vector &lon_grid, const Vector &g1, const Vector &g2, const Vector &g3, const String &component, const Numeric &dfrequency, const Verbosity &verbosity)
WORKSPACE METHOD: jacobianAddWind.
Definition: m_jacobian.cc:1369
void jacobianAddFreqShift(Workspace &ws, ArrayOfRetrievalQuantity &jacobian_quantities, Agenda &jacobian_agenda, const Vector &f_grid, const Numeric &df, const Verbosity &verbosity)
WORKSPACE METHOD: jacobianAddFreqShift.
Definition: m_jacobian.cc:198
void jacobianAddBasicCatalogParameters(Workspace &ws, ArrayOfRetrievalQuantity &jacobian_quantities, Agenda &jacobian_agenda, const ArrayOfQuantumIdentifier &catalog_identities, const ArrayOfString &catalog_parameters, const Verbosity &verbosity)
WORKSPACE METHOD: jacobianAddBasicCatalogParameters.
Definition: m_jacobian.cc:1647
void jacobianAddPointingZa(Workspace &ws, ArrayOfRetrievalQuantity &jacobian_quantities, Agenda &jacobian_agenda, const Matrix &sensor_pos, const ArrayOfTime &sensor_time, const Index &poly_order, const String &calcmode, const Numeric &dza, const Verbosity &verbosity)
WORKSPACE METHOD: jacobianAddPointingZa.
Definition: m_jacobian.cc:510
The Agenda class.
Definition: agenda_class.h:44
This can be used to make arrays out of anything.
Definition: array.h:107
Index nelem() const ARTS_NOEXCEPT
Number of elements.
Definition: array.h:195
Range get_row_range() const
Range get_column_range() const
Index nrows() const ARTS_NOEXCEPT
Returns the number of rows.
Definition: matpackI.cc:433
A constant view of a Vector.
Definition: matpackI.h:489
bool empty() const ARTS_NOEXCEPT
Returns true if variable size is zero.
Definition: matpackI.cc:46
Index nelem() const ARTS_NOEXCEPT
Returns the number of elements.
Definition: matpackI.cc:48
void add_correlation(Block c)
Add block to covariance matrix.
bool has_block(Index i, Index j)
Check if the block with indices (i, j) is contained in the covariance matrix.
const Block * get_block(Index i=-1, Index j=-1)
Return a pointer to the block with indices (i,j).
bool is_consistent(const ArrayOfArrayOfIndex &jis) const
Checks that the dimensions of the blocks in the covariance matrix are consistent with ranges occupied...
Vector diagonal() const
Diagonal elements as vector.
bool has_diagonal_blocks(const ArrayOfArrayOfIndex &jis) const
Checks that the covariance matrix contains one diagonal block per retrieval quantity.
void add_correlation_inverse(Block c)
Add block inverse to covariance matrix.
Index ndiagblocks() const
! The number of diagonal blocks in the matrix excluding inverses.
The Matrix class.
Definition: matpackI.h:1225
void resize(Index r, Index c)
Resize function.
Definition: matpackI.cc:1056
The range class.
Definition: matpackI.h:165
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 ArrayOfVector & Grids() const
Returns the grids of the retrieval.
Definition: jacobian.h:428
The Sparse class.
Definition: matpackII.h:67
Index nrows() const
Returns the number of rows.
Definition: matpackII.cc:66
Index ncols() const
Returns the number of columns.
Definition: matpackII.cc:69
bool empty() const
Returns true if variable size is zero.
Definition: matpackII.cc:61
The Vector class.
Definition: matpackI.h:876
void resize(Index n)
Resize function.
Definition: matpackI.cc:408
Workspace class.
Definition: workspace_ng.h:40
Header files of CovarianceMatrix class.
std::pair< Index, Index > IndexPair
#define ARTS_ASSERT(condition,...)
Definition: debug.h:83
#define ARTS_USER_ERROR(...)
Definition: debug.h:150
#define ARTS_USER_ERROR_IF(condition,...)
Definition: debug.h:134
void jac_ranges_indices(ArrayOfArrayOfIndex &jis, bool &any_affine, const ArrayOfRetrievalQuantity &jqs, const bool &before_affine)
Determines the index range inside x and the Jacobian for each retrieval quantity.
Definition: jacobian.cc:45
Routines for setting up the jacobian.
#define abs(x)
void add_scalar_variance(CovarianceMatrix &covmat, ArrayOfRetrievalQuantity &jacobian_quantities, Numeric var)
Definition: m_retrieval.cc:52
void retrievalDefClose(Workspace &ws, Index &jacobian_do, Agenda &jacobian_agenda, Index &retrieval_checked, const CovarianceMatrix &covmat_sx, const ArrayOfRetrievalQuantity &jacobian_quantities, const Verbosity &verbosity)
WORKSPACE METHOD: retrievalDefClose.
void check_and_add_block(CovarianceMatrix &covmat, const RetrievalQuantity &jq, const Index rq_index, const Index grid_dimensions, const Sparse &covmat_block, const Sparse &covmat_inv_block)
Definition: m_retrieval.cc:11
void covmat1DMarkov(MatrixType &block, MatrixType &block_inv, const Vector &grid, const Vector &sigma, const Numeric &lc, const Numeric &, const Verbosity &)
Definition: m_retrieval.cc:163
void covmat1D(MatrixType &block, const Vector &grid1, const Vector &grid2, const Vector &sigma1, const Vector &sigma2, const Vector &lc1, const Vector &lc2, const Numeric &co, const String &fname, const Verbosity &)
Definition: m_retrieval.cc:244
void covmat_sxAddBlock(CovarianceMatrix &covmat_sx, const ArrayOfRetrievalQuantity &jq, const MatrixType &block, const Index &i, const Index &j, const Verbosity &)
Definition: m_retrieval.cc:577
void insert_elements(MatrixType &matrix, Index, Index, const ArrayOfIndex &row_indices, const ArrayOfIndex &column_indices, const Vector &elements)
Definition: m_retrieval.cc:103
void retrievalAddFreqShift(Workspace &ws, CovarianceMatrix &covmat_sx, ArrayOfRetrievalQuantity &jacobian_quantities, Agenda &jacobian_agenda, const Sparse &covmat_block, const Sparse &covmat_inv_block, const Vector &f_grid, const Numeric &df, const Verbosity &verbosity)
WORKSPACE METHOD: retrievalAddFreqShift.
Definition: m_retrieval.cc:777
void retrievalAddCatalogParameters(Workspace &ws, CovarianceMatrix &covmat_sx, ArrayOfRetrievalQuantity &jacobian_quantities, Agenda &jacobian_agenda, const Sparse &covmat_block, const Sparse &covmat_inv_block, const ArrayOfQuantumIdentifier &catalog_identities, const ArrayOfString &catalog_parameters, const Verbosity &verbosity)
WORKSPACE METHOD: retrievalAddCatalogParameters.
Definition: m_retrieval.cc:832
void retrievalDefInit(CovarianceMatrix &covmat_se, CovarianceMatrix &covmat_sx, Sparse &covmat_block, Sparse &covmat_inv_block, ArrayOfRetrievalQuantity &jacobian_quantities, Agenda &jacobian_agenda, const Index &initialize_jacobian, const Verbosity &verbosity)
WORKSPACE METHOD: retrievalDefInit.
void PFromZSimple(Vector &p_grid, const Vector &z_grid, const Verbosity &)
WORKSPACE METHOD: PFromZSimple.
Definition: m_retrieval.cc:85
void ZFromPSimple(Vector &z_grid, const Vector &p_grid, const Verbosity &)
WORKSPACE METHOD: ZFromPSimple.
Definition: m_retrieval.cc:72
void retrievalAddPolyfit(Workspace &ws, CovarianceMatrix &covmat_sx, ArrayOfRetrievalQuantity &jacobian_quantities, Agenda &jacobian_agenda, const Sparse &covmat_block, const Sparse &covmat_inv_block, const ArrayOfIndex &sensor_response_pol_grid, const Matrix &sensor_response_dlos_grid, const Matrix &sensor_pos, const Index &poly_order, const Index &no_pol_variation, const Index &no_los_variation, const Index &no_mblock_variation, const Verbosity &verbosity)
WORKSPACE METHOD: retrievalAddPolyfit.
Definition: m_retrieval.cc:922
void covmat_sxSet(CovarianceMatrix &covmat, const MatrixType &block, const Verbosity &)
Definition: m_retrieval.cc:558
void covmat_seSet(CovarianceMatrix &covmat, const MatrixType &block, const Verbosity &)
Definition: m_retrieval.cc:539
void retrievalAddAbsSpecies(Workspace &ws, CovarianceMatrix &covmat_sx, ArrayOfRetrievalQuantity &jacobian_quantities, Agenda &jacobian_agenda, const Index &atmosphere_dim, const Sparse &covmat_block, const Sparse &covmat_inv_block, const Vector &p_grid, const Vector &lat_grid, const Vector &lon_grid, const Vector &rq_p_grid, const Vector &rq_lat_grid, const Vector &rq_lon_grid, const String &species, const String &mode, const Index &for_species_tag, const Verbosity &verbosity)
WORKSPACE METHOD: retrievalAddAbsSpecies.
Definition: m_retrieval.cc:738
void retrievalAddSpecialSpecies(Workspace &ws, CovarianceMatrix &covmat_sx, ArrayOfRetrievalQuantity &jacobian_quantities, Agenda &jacobian_agenda, const Index &atmosphere_dim, const Sparse &covmat_block, const Sparse &covmat_inv_block, const Vector &p_grid, const Vector &lat_grid, const Vector &lon_grid, const Vector &rq_p_grid, const Vector &rq_lat_grid, const Vector &rq_lon_grid, const String &species, const Verbosity &verbosity)
WORKSPACE METHOD: retrievalAddSpecialSpecies.
void retrievalAddPointingZa(Workspace &ws, CovarianceMatrix &covmat_sx, ArrayOfRetrievalQuantity &jacobian_quantities, Agenda &jacobian_agenda, const Sparse &covmat_block, const Sparse &covmat_inv_block, const Matrix &sensor_pos, const ArrayOfTime &sensor_time, const Index &poly_order, const String &calcmode, const Numeric &dza, const Verbosity &verbosity)
WORKSPACE METHOD: retrievalAddPointingZa.
Definition: m_retrieval.cc:893
void retrievalAddMagField(Workspace &ws, CovarianceMatrix &covmat_sx, ArrayOfRetrievalQuantity &jacobian_quantities, Agenda &jacobian_agenda, const Index &atmosphere_dim, const Sparse &covmat_block, const Sparse &covmat_inv_block, const Vector &p_grid, const Vector &lat_grid, const Vector &lon_grid, const Vector &rq_p_grid, const Vector &rq_lat_grid, const Vector &rq_lon_grid, const String &component, const Numeric &dB, const Verbosity &verbosity)
WORKSPACE METHOD: retrievalAddMagField.
Definition: m_retrieval.cc:856
void retrievalAddWind(Workspace &ws, CovarianceMatrix &covmat_sx, ArrayOfRetrievalQuantity &jacobian_quantities, Agenda &jacobian_agenda, const Index &atmosphere_dim, const Sparse &covmat_block, const Sparse &covmat_inv_block, const Vector &p_grid, const Vector &lat_grid, const Vector &lon_grid, const Vector &rq_p_grid, const Vector &rq_lat_grid, const Vector &rq_lon_grid, const String &component, const Numeric &dfrequency, const Verbosity &verbosity)
WORKSPACE METHOD: retrievalAddWind.
void retrievalAddSinefit(Workspace &ws, CovarianceMatrix &covmat_sx, ArrayOfRetrievalQuantity &jacobian_quantities, Agenda &jacobian_agenda, const Sparse &covmat_block, const Sparse &covmat_inv_block, const ArrayOfIndex &sensor_response_pol_grid, const Matrix &sensor_response_dlos_grid, const Matrix &sensor_pos, const Vector &period_lengths, const Index &no_pol_variation, const Index &no_los_variation, const Index &no_mblock_variation, const Verbosity &verbosity)
WORKSPACE METHOD: retrievalAddSinefit.
Definition: m_retrieval.cc:995
void retrievalAddSurfaceQuantity(Workspace &ws, CovarianceMatrix &covmat_sx, ArrayOfRetrievalQuantity &jacobian_quantities, Agenda &jacobian_agenda, const Sparse &covmat_block, const Sparse &covmat_inv_block, const Index &atmosphere_dim, const Vector &lat_grid, const Vector &lon_grid, const Vector &rq_lat_grid, const Vector &rq_lon_grid, const String &quantity, const Verbosity &verbosity)
WORKSPACE METHOD: retrievalAddSurfaceQuantity.
void covmat_sxAddInverseBlock(CovarianceMatrix &covmat_sx, const ArrayOfRetrievalQuantity &jq, const MatrixType &block_inv, const Index &i, const Index &j, const Verbosity &)
Definition: m_retrieval.cc:649
void covmat_seAddInverseBlock(CovarianceMatrix &covmat_se, const MatrixType &inv_block, const Index &i, const Index &j, const Verbosity &)
Definition: m_retrieval.cc:470
void retrievalAddTemperature(Workspace &ws, CovarianceMatrix &covmat_sx, ArrayOfRetrievalQuantity &jacobian_quantities, Agenda &jacobian_agenda, const Index &atmosphere_dim, const Sparse &covmat_block, const Sparse &covmat_inv_block, const Vector &p_grid, const Vector &lat_grid, const Vector &lon_grid, const Vector &rq_p_grid, const Vector &rq_lat_grid, const Vector &rq_lon_grid, const String &hse, const Verbosity &verbosity)
WORKSPACE METHOD: retrievalAddTemperature.
void retrievalAddFreqStretch(Workspace &ws, CovarianceMatrix &covmat_sx, ArrayOfRetrievalQuantity &jacobian_quantities, Agenda &jacobian_agenda, const Vector &f_grid, const Sparse &covmat_block, const Sparse &covmat_inv_block, const Numeric &df, const Verbosity &verbosity)
WORKSPACE METHOD: retrievalAddFreqStretch.
Definition: m_retrieval.cc:796
void covmat_seAddBlock(CovarianceMatrix &covmat_se, const MatrixType &block, const Index &i, const Index &j, const Verbosity &)
Definition: m_retrieval.cc:390
void covmatDiagonal(MatrixType &block, MatrixType &block_inv, const Vector &vars, const Verbosity &)
Definition: m_retrieval.cc:131
void setCovarianceMatrix(CovarianceMatrix &covmat, const MatrixType &block)
Definition: m_retrieval.cc:518
void retrievalAddScatSpecies(Workspace &ws, CovarianceMatrix &covmat_sx, ArrayOfRetrievalQuantity &jacobian_quantities, Agenda &jacobian_agenda, const Index &atmosphere_dim, const Sparse &covmat_block, const Sparse &covmat_inv_block, const Vector &p_grid, const Vector &lat_grid, const Vector &lon_grid, const Vector &rq_p_grid, const Vector &rq_lat_grid, const Vector &rq_lon_grid, const String &species, const String &quantity, const Verbosity &verbosity)
WORKSPACE METHOD: retrievalAddScatSpecies.
Definition: m_retrieval.cc:958
void covmat_sxExtractSqrtDiagonal(Vector &x_norm, const CovarianceMatrix &covmat_sx, const Verbosity &)
WORKSPACE METHOD: covmat_sxExtractSqrtDiagonal.
Definition: m_retrieval.cc:725
void retrievalErrorsExtract(Vector &retrieval_eo, Vector &retrieval_ss, const Matrix &covmat_so, const Matrix &covmat_ss, const Verbosity &)
WORKSPACE METHOD: retrievalErrorsExtract.
void retrievalAddCatalogParameter(Workspace &ws, CovarianceMatrix &covmat_sx, ArrayOfRetrievalQuantity &jacobian_quantities, Agenda &jacobian_agenda, const QuantumIdentifier &catalog_identity, const String &catalog_parameter, const Numeric &var, const Verbosity &verbosity)
WORKSPACE METHOD: retrievalAddCatalogParameter.
Definition: m_retrieval.cc:815
Eigen::Matrix< Numeric, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > MatrixType
Definition: matpackI.h:114
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
Matrix matrix(const std::array< Numeric, 196 > data)
Create the square matrix from the static data.
Definition: igrf13.cc:206
VectorView var(VectorView var, const Vector &y, const ArrayOfVector &ys, const Index start, const Index end_tmp)
Compute the variance of the ranged ys.
Definition: raw.cc:159
constexpr Rational start(Rational Ju, Rational Jl, Polarization type) noexcept
Gives the lowest M for a polarization type of this transition.
Definition: zeemandata.h:78
invlib::Matrix< ArtsCovarianceMatrixWrapper > CovarianceMatrix
invlib wrapper type for ARTS the ARTS covariance class.
Definition: oem.h:37
invlib::Vector< ArtsVector > Vector
invlib wrapper type for ARTS vectors.
Definition: oem.h:31
#define d
#define v
#define b
Quantum::Identifier QuantumIdentifier
Definition: quantum.h:471
Numeric pow(const Rational base, Numeric exp)
Power of.
Definition: rational.h:747
Numeric sqrt(const Rational r)
Square root.
Definition: rational.h:739