ARTS 2.5.11 (git: 6827797f)
m_oem.cc File Reference

Workspace functions related to making OEM inversions. More...

#include <cmath>
#include <iterator>
#include <sstream>
#include <stdexcept>
#include <string>
#include "array.h"
#include "arts.h"
#include "arts_omp.h"
#include "auto_md.h"
#include "debug.h"
#include "jacobian.h"
#include "math_funcs.h"
#include "physics_funcs.h"
#include "rte.h"
#include "special_interp.h"
#include "surface.h"
#include "check_input.h"

Go to the source code of this file.

Functions

void particle_bulkprop_fieldClip (Tensor4 &particle_bulkprop_field, const ArrayOfString &particle_bulkprop_names, const String &bulkprop_name, const Numeric &limit_low, const Numeric &limit_high, const Verbosity &)
 WORKSPACE METHOD: particle_bulkprop_fieldClip.
 
void vmr_fieldClip (Tensor4 &vmr_field, const ArrayOfArrayOfSpeciesTag &abs_species, const String &species, const Numeric &limit_low, const Numeric &limit_high, const Verbosity &)
 WORKSPACE METHOD: vmr_fieldClip.
 
void xClip (Vector &x, const ArrayOfRetrievalQuantity &jacobian_quantities, const Index &ijq, const Numeric &limit_low, const Numeric &limit_high, const Verbosity &)
 WORKSPACE METHOD: xClip.
 
void xaStandard (Workspace &ws, Vector &xa, const ArrayOfRetrievalQuantity &jacobian_quantities, const Index &atmfields_checked, const Index &atmgeom_checked, const Index &atmosphere_dim, const Vector &p_grid, const Vector &lat_grid, const Vector &lon_grid, const Tensor3 &t_field, const Tensor4 &vmr_field, const ArrayOfArrayOfSpeciesTag &abs_species, const Index &cloudbox_on, const Index &cloudbox_checked, const Tensor4 &particle_bulkprop_field, const ArrayOfString &particle_bulkprop_names, const Tensor3 &wind_u_field, const Tensor3 &wind_v_field, const Tensor3 &wind_w_field, const Tensor3 &mag_u_field, const Tensor3 &mag_v_field, const Tensor3 &mag_w_field, const Tensor3 &surface_props_data, const ArrayOfString &surface_props_names, const Agenda &water_p_eq_agenda, const Verbosity &)
 WORKSPACE METHOD: xaStandard.
 
void x2artsAtmAndSurf (Workspace &ws, Tensor4 &vmr_field, Tensor3 &t_field, Tensor4 &particle_bulkprop_field, Tensor3 &wind_u_field, Tensor3 &wind_v_field, Tensor3 &wind_w_field, Tensor3 &mag_u_field, Tensor3 &mag_v_field, Tensor3 &mag_w_field, Tensor3 &surface_props_data, const ArrayOfRetrievalQuantity &jacobian_quantities, const Vector &x, const Index &atmfields_checked, const Index &atmgeom_checked, const Index &atmosphere_dim, const Vector &p_grid, const Vector &lat_grid, const Vector &lon_grid, const ArrayOfArrayOfSpeciesTag &abs_species, const Index &cloudbox_on, const Index &cloudbox_checked, const ArrayOfString &particle_bulkprop_names, const ArrayOfString &surface_props_names, const Agenda &water_p_eq_agenda, const Verbosity &)
 WORKSPACE METHOD: x2artsAtmAndSurf.
 
void x2artsSensor (Workspace &ws, Matrix &sensor_los, Vector &f_backend, Vector &y_baseline, Sparse &sensor_response, Vector &sensor_response_f, ArrayOfIndex &sensor_response_pol, Matrix &sensor_response_dlos, Vector &sensor_response_f_grid, ArrayOfIndex &sensor_response_pol_grid, Matrix &sensor_response_dlos_grid, Matrix &mblock_dlos, const ArrayOfRetrievalQuantity &jacobian_quantities, const Vector &x, const Agenda &sensor_response_agenda, const Index &sensor_checked, const ArrayOfTime &sensor_time, const Verbosity &)
 WORKSPACE METHOD: x2artsSensor.
 
void x2artsSpectroscopy (const Verbosity &)
 WORKSPACE METHOD: x2artsSpectroscopy.
 
void covmat_soCalc (Matrix &, const Matrix &, const CovarianceMatrix &, const Verbosity &)
 WORKSPACE METHOD: covmat_soCalc.
 
void covmat_ssCalc (Matrix &, const Matrix &, const CovarianceMatrix &, const Verbosity &)
 WORKSPACE METHOD: covmat_ssCalc.
 
void avkCalc (Matrix &, const Matrix &, const Matrix &, const Verbosity &)
 WORKSPACE METHOD: avkCalc.
 
void OEM (Workspace &, Vector &, Vector &, Matrix &, Matrix &, Vector &, Vector &, ArrayOfString &, const Vector &, const CovarianceMatrix &, const Vector &, const CovarianceMatrix &, const Index &, const ArrayOfRetrievalQuantity &, const ArrayOfArrayOfIndex &, const Agenda &, const String &, const Numeric &, const Vector &, const Index &, const Numeric &, const Vector &, const Index &, const Index &, const Verbosity &)
 
void OEM_MPI (Workspace &, Vector &, Vector &, Matrix &, Matrix &, Vector &, Vector &, Matrix &, Matrix &, Vector &, CovarianceMatrix &, CovarianceMatrix &, const Vector &, const Vector &, const Index &, const ArrayOfRetrievalQuantity &, const Agenda &, const String &, const Numeric &, const Vector &, const Index &, const Numeric &, const Vector &, const Index &, const Index &, const Verbosity &)
 

Detailed Description

Workspace functions related to making OEM inversions.

Author
Patrick Eriksson patri.nosp@m.ck.e.nosp@m.rikss.nosp@m.on@c.nosp@m.halme.nosp@m.rs.s.nosp@m.e
Date
2015-09-08

These functions are listed in the doxygen documentation as entries of the file auto_md.h.

Definition in file m_oem.cc.

Function Documentation

◆ avkCalc()

void avkCalc ( Matrix &  avk,
const Matrix &  dxdy,
const Matrix &  jacobian,
const Verbosity verbosity 
)

WORKSPACE METHOD: avkCalc.

Calculates the averaging kernel matrix describing the sensitivity of the OEM retrieval with respect to the true state of the system. A prerequisite for the calculation of the averaging kernel matrix is a successful OEM calculation in which the jacobian and the gain matrix dxdy have been calculated.

Author
Simon Pfreundschuh
Parameters
[out]avkWS Output
[in]dxdyWS Input
[in]jacobianWS Input

Definition at line 1365 of file m_oem.cc.

References ARTS_USER_ERROR.

Referenced by avkCalc_g().

◆ covmat_soCalc()

void covmat_soCalc ( Matrix &  covmat_so,
const Matrix &  dxdy,
const CovarianceMatrix covmat_se,
const Verbosity verbosity 
)

WORKSPACE METHOD: covmat_soCalc.

Calculates the covariance matrix describing the error due to uncertainties in the observation system. The uncertainties of the observation system are described by covmat_se, which must be set by the user to include the relevant contributions from the measurement and the forward model.

Prerequisite for the calculation of covmat_so is a successful OEM computation where also the gain matrix has been computed.

Author
Simon Pfreundschuh
Parameters
[out]covmat_soWS Output
[in]dxdyWS Input
[in]covmat_seWS Input

Definition at line 1347 of file m_oem.cc.

References ARTS_USER_ERROR.

Referenced by covmat_soCalc_g().

◆ covmat_ssCalc()

void covmat_ssCalc ( Matrix &  covmat_ss,
const Matrix &  avk,
const CovarianceMatrix covmat_sx,
const Verbosity verbosity 
)

WORKSPACE METHOD: covmat_ssCalc.

Calculates the covariance matrix describing the error due to smoothing. The calculation of covmat_ss also requires the averaging kernel matrix avk to be computed after a successful OEM calculation.

Author
Simon Pfreundschuh
Parameters
[out]covmat_ssWS Output
[in]avkWS Input
[in]covmat_sxWS Input

Definition at line 1356 of file m_oem.cc.

References ARTS_USER_ERROR.

Referenced by covmat_ssCalc_g().

◆ OEM()

void OEM ( Workspace ,
Vector &  ,
Vector &  ,
Matrix &  ,
Matrix &  ,
Vector &  ,
Vector &  ,
ArrayOfString ,
const Vector &  ,
const CovarianceMatrix ,
const Vector &  ,
const CovarianceMatrix ,
const Index &  ,
const ArrayOfRetrievalQuantity ,
const ArrayOfArrayOfIndex ,
const Agenda ,
const String ,
const Numeric &  ,
const Vector &  ,
const Index &  ,
const Numeric &  ,
const Vector &  ,
const Index &  ,
const Index &  ,
const Verbosity  
)

Definition at line 1374 of file m_oem.cc.

References ARTS_USER_ERROR.

Referenced by OEM_g().

◆ OEM_MPI()

void OEM_MPI ( Workspace ,
Vector &  ,
Vector &  ,
Matrix &  ,
Matrix &  ,
Vector &  ,
Vector &  ,
Matrix &  ,
Matrix &  ,
Vector &  ,
CovarianceMatrix ,
CovarianceMatrix ,
const Vector &  ,
const Vector &  ,
const Index &  ,
const ArrayOfRetrievalQuantity ,
const Agenda ,
const String ,
const Numeric &  ,
const Vector &  ,
const Index &  ,
const Numeric &  ,
const Vector &  ,
const Index &  ,
const Index &  ,
const Verbosity  
)

Definition at line 1624 of file m_oem.cc.

References ARTS_USER_ERROR.

◆ particle_bulkprop_fieldClip()

void particle_bulkprop_fieldClip ( Tensor4 &  particle_bulkprop_field,
const ArrayOfString particle_bulkprop_names,
const String bulkprop_name,
const Numeric &  limit_low,
const Numeric &  limit_high,
const Verbosity verbosity 
)

WORKSPACE METHOD: particle_bulkprop_fieldClip.

Clipping of particle_bulkprop_field.

The method allows you to apply hard limits the values of particle_bulkprop_field*. All values, of the property selected, below limit_low, are simply set to limit_low. And the same is performed with respect to limit_high. That is, the data in x for the retrieval quantity are forced to be inside the range [limit_low,limit_high].

Setting species="ALL", is a shortcut for applying the limits on all properties.

Author
Patrick Eriksson
Parameters
[in,out]particle_bulkprop_fieldWS Input/Output
[in]particle_bulkprop_namesWS Input
[in]bulkprop_nameGeneric Input
[in]limit_lowGeneric Input (Default: "-Inf")
[in]limit_highGeneric Input (Default: "Inf")

Definition at line 45 of file m_oem.cc.

References ARTS_USER_ERROR_IF, Array< base >::nelem(), and Tensor4Clip().

Referenced by particle_bulkprop_fieldClip_g().

◆ vmr_fieldClip()

void vmr_fieldClip ( Tensor4 &  vmr_field,
const ArrayOfArrayOfSpeciesTag abs_species,
const String species,
const Numeric &  limit_low,
const Numeric &  limit_high,
const Verbosity verbosity 
)

WORKSPACE METHOD: vmr_fieldClip.

Clipping of vmr_field.

The method allows you to apply hard limits the values of vmr_field. All values, of the species selected, below limit_low, are simply set to limit_low. And the same is performed with respect to limit_high*. That is, the data in x for the retrieval quantity are forced to be inside the range [limit_low,limit_high].

Setting species="ALL", is a shortcut for applying the limits on all species.

Author
Patrick Eriksson
Parameters
[in,out]vmr_fieldWS Input/Output
[in]abs_speciesWS Input
[in]speciesGeneric Input
[in]limit_lowGeneric Input (Default: "-Inf")
[in]limit_highGeneric Input (Default: "Inf")

Definition at line 71 of file m_oem.cc.

References ARTS_USER_ERROR_IF, Array< base >::nelem(), and Tensor4Clip().

Referenced by vmr_fieldClip_g().

◆ x2artsAtmAndSurf()

void x2artsAtmAndSurf ( Workspace ws,
Tensor4 &  vmr_field,
Tensor3 &  t_field,
Tensor4 &  particle_bulkprop_field,
Tensor3 &  wind_u_field,
Tensor3 &  wind_v_field,
Tensor3 &  wind_w_field,
Tensor3 &  mag_u_field,
Tensor3 &  mag_v_field,
Tensor3 &  mag_w_field,
Tensor3 &  surface_props_data,
const ArrayOfRetrievalQuantity jacobian_quantities,
const Vector &  x,
const Index &  atmfields_checked,
const Index &  atmgeom_checked,
const Index &  atmosphere_dim,
const Vector &  p_grid,
const Vector &  lat_grid,
const Vector &  lon_grid,
const ArrayOfArrayOfSpeciesTag abs_species,
const Index &  cloudbox_on,
const Index &  cloudbox_checked,
const ArrayOfString particle_bulkprop_names,
const ArrayOfString surface_props_names,
const Agenda water_p_eq_agenda,
const Verbosity verbosity 
)

WORKSPACE METHOD: x2artsAtmAndSurf.

Maps x to atmospheric and surface variables.

Maps OEM's state vector, x, to the matching ARTS variables. This method handles atmospheric and surface variables. If you retrieve other variables, make sure that you also call x2artsSensor and/or x2artsSpectroscopy*.

The following retrieval quantities are handled by this method: <br> Temperature <br> Absorption species <br> Scattering species <br> Winds <br> Surface variables

Should only be used inside inversion_iterate_agenda.

Author
Patrick Eriksson
Parameters
[in,out]wsWorkspace
[in,out]vmr_fieldWS Input/Output
[in,out]t_fieldWS Input/Output
[in,out]particle_bulkprop_fieldWS Input/Output
[in,out]wind_u_fieldWS Input/Output
[in,out]wind_v_fieldWS Input/Output
[in,out]wind_w_fieldWS Input/Output
[in,out]mag_u_fieldWS Input/Output
[in,out]mag_v_fieldWS Input/Output
[in,out]mag_w_fieldWS Input/Output
[in,out]surface_props_dataWS Input/Output
[in]jacobian_quantitiesWS Input
[in]xWS Input
[in]atmfields_checkedWS Input
[in]atmgeom_checkedWS Input
[in]atmosphere_dimWS Input
[in]p_gridWS Input
[in]lat_gridWS Input
[in]lon_gridWS Input
[in]abs_speciesWS Input
[in]cloudbox_onWS Input
[in]cloudbox_checkedWS Input
[in]particle_bulkprop_namesWS Input
[in]surface_props_namesWS Input
[in]water_p_eq_agendaWS Input

Definition at line 483 of file m_oem.cc.

References ARTS_ASSERT, ARTS_USER_ERROR, ARTS_USER_ERROR_IF, chk_contains(), find_first(), get_gp_rq_to_atmgrids(), jac_ranges_indices(), Array< base >::nelem(), number_density(), regrid_atmfield_by_gp_oem(), regrid_atmsurf_by_gp_oem(), reshape(), surface_props_check(), transform_x_back(), and water_p_eq_agendaExecute().

Referenced by x2artsAtmAndSurf_g().

◆ x2artsSensor()

void x2artsSensor ( Workspace ws,
Matrix &  sensor_los,
Vector &  f_backend,
Vector &  y_baseline,
Sparse &  sensor_response,
Vector &  sensor_response_f,
ArrayOfIndex sensor_response_pol,
Matrix &  sensor_response_dlos,
Vector &  sensor_response_f_grid,
ArrayOfIndex sensor_response_pol_grid,
Matrix &  sensor_response_dlos_grid,
Matrix &  mblock_dlos,
const ArrayOfRetrievalQuantity jacobian_quantities,
const Vector &  x,
const Agenda sensor_response_agenda,
const Index &  sensor_checked,
const ArrayOfTime sensor_time,
const Verbosity verbosity 
)

WORKSPACE METHOD: x2artsSensor.

Maps x to sensor variables.

Maps OEM's state vector, x, to the matching ARTS variables. This method handles variables associated with the sensor. If you retrieve other variables, make sure that you also call x2artsAtmAndSurf <br> and/or x2artsSpectroscopy.

The following retrieval quantities are handled by this method: <br> Pointing <br> Frequency shift and stretch <br> Baseline fits

Should only be used inside inversion_iterate_agenda.

Elements in x representing pointing corrections are mapped to sensor_los*. Elements representing frequency corrections are mapped to f_backend. Baseline variables are mapped to y_baseline.

The sensor response is recalculated if there is any non-zero frequency correction.

Author
Patrick Eriksson
Parameters
[in,out]wsWorkspace
[in,out]sensor_losWS Input/Output
[in,out]f_backendWS Input/Output
[out]y_baselineWS Output
[in,out]sensor_responseWS Input/Output
[in,out]sensor_response_fWS Input/Output
[in,out]sensor_response_polWS Input/Output
[in,out]sensor_response_dlosWS Input/Output
[in,out]sensor_response_f_gridWS Input/Output
[in,out]sensor_response_pol_gridWS Input/Output
[in,out]sensor_response_dlos_gridWS Input/Output
[in,out]mblock_dlosWS Input/Output
[in]jacobian_quantitiesWS Input
[in]xWS Input
[in]sensor_response_agendaWS Input
[in]sensor_checkedWS Input
[in]sensor_timeWS Input

Definition at line 834 of file m_oem.cc.

References ARTS_ASSERT, ARTS_USER_ERROR_IF, c, calcBaselineFit(), jac_ranges_indices(), Array< base >::nelem(), polynomial_basis_func(), sensor_response_agendaExecute(), time_vector(), transform_x_back(), and w.

Referenced by x2artsSensor_g().

◆ x2artsSpectroscopy()

void x2artsSpectroscopy ( const Verbosity verbosity)

WORKSPACE METHOD: x2artsSpectroscopy.

Just defined to indicate a future extensiom.

Don't call the method, it will just generate an error.

Author
Patrick Eriksson

Definition at line 989 of file m_oem.cc.

References ARTS_USER_ERROR.

Referenced by x2artsSpectroscopy_g().

◆ xaStandard()

void xaStandard ( Workspace ws,
Vector &  xa,
const ArrayOfRetrievalQuantity jacobian_quantities,
const Index &  atmfields_checked,
const Index &  atmgeom_checked,
const Index &  atmosphere_dim,
const Vector &  p_grid,
const Vector &  lat_grid,
const Vector &  lon_grid,
const Tensor3 &  t_field,
const Tensor4 &  vmr_field,
const ArrayOfArrayOfSpeciesTag abs_species,
const Index &  cloudbox_on,
const Index &  cloudbox_checked,
const Tensor4 &  particle_bulkprop_field,
const ArrayOfString particle_bulkprop_names,
const Tensor3 &  wind_u_field,
const Tensor3 &  wind_v_field,
const Tensor3 &  wind_w_field,
const Tensor3 &  mag_u_field,
const Tensor3 &  mag_v_field,
const Tensor3 &  mag_w_field,
const Tensor3 &  surface_props_data,
const ArrayOfString surface_props_names,
const Agenda water_p_eq_agenda,
const Verbosity verbosity 
)

WORKSPACE METHOD: xaStandard.

Standard function for creating xa.

The method creates xa based on jacobian_quantities and the various atmospheric fields. In the case of scattering species, the data are taken from particle_bulkprop_field. The following retrieval quantities are handled: <br> Temperature <br> Absorption species <br> Scattering species <br> Pointing <br> Polynomial baseline fit <br> Sinusoidal baseline fit

Author
Patrick Eriksson
Parameters
[in,out]wsWorkspace
[out]xaWS Output
[in]jacobian_quantitiesWS Input
[in]atmfields_checkedWS Input
[in]atmgeom_checkedWS Input
[in]atmosphere_dimWS Input
[in]p_gridWS Input
[in]lat_gridWS Input
[in]lon_gridWS Input
[in]t_fieldWS Input
[in]vmr_fieldWS Input
[in]abs_speciesWS Input
[in]cloudbox_onWS Input
[in]cloudbox_checkedWS Input
[in]particle_bulkprop_fieldWS Input
[in]particle_bulkprop_namesWS Input
[in]wind_u_fieldWS Input
[in]wind_v_fieldWS Input
[in]wind_w_fieldWS Input
[in]mag_u_fieldWS Input
[in]mag_v_fieldWS Input
[in]mag_w_fieldWS Input
[in]surface_props_dataWS Input
[in]surface_props_namesWS Input
[in]water_p_eq_agendaWS Input

Definition at line 138 of file m_oem.cc.

Referenced by xaStandard_g().

◆ xClip()

void xClip ( Vector &  x,
const ArrayOfRetrievalQuantity jacobian_quantities,
const Index &  ijq,
const Numeric &  limit_low,
const Numeric &  limit_high,
const Verbosity verbosity 
)

WORKSPACE METHOD: xClip.

Clipping of the state vector.

The method allows you to apply hard limits the values of a retrieval quantity. The retrieval quantity is specified by ijq*. All values of the quantity below limit_low, are simply set to limit_low. And the same is performed with respect to limit_high*. That is, the data in x for the retrieval quantity are forced to be inside the range [limit_low,limit_high].

Setting ijq=-1, is a shortcut for applying the limits on all retrieval quantities.

Notice that limits must be specified in the unit used in x.

Author
Patrick Eriksson
Parameters
[in,out]xWS Input/Output
[in]jacobian_quantitiesWS Input
[in]ijqGeneric Input
[in]limit_lowGeneric Input (Default: "-Inf")
[in]limit_highGeneric Input (Default: "Inf")

Definition at line 96 of file m_oem.cc.

References ARTS_USER_ERROR_IF, and Array< base >::nelem().

Referenced by xClip_g().