ARTS 2.5.11 (git: 725533f0)
sensor.cc File Reference

Functions related to sensor modelling. More...

#include "sensor.h"
#include <cmath>
#include <list>
#include <stdexcept>
#include "arts.h"
#include "arts_constants.h"
#include "arts_conversions.h"
#include "auto_md.h"
#include "gridded_fields.h"
#include "logic.h"
#include "matpack_data.h"
#include "matpack_math.h"
#include "messages.h"
#include "rte.h"
#include "sorting.h"

Go to the source code of this file.

Functions

void antenna1d_matrix (Sparse &H, const Index &antenna_dim, ConstVectorView antenna_dza, const GriddedField4 &antenna_response, ConstVectorView za_grid, ConstVectorView f_grid, const Index n_pol, const Index do_norm)
 antenna1d_matrix
 
void antenna2d_gridded_dlos (Sparse &H, const Index &antenna_dim, ConstMatrixView antenna_dlos, const GriddedField4 &antenna_response, ConstMatrixView mblock_dlos, ConstVectorView f_grid, const Index n_pol)
 antenna2d_interp_gridded_dlos
 
void antenna2d_interp_response (Sparse &H, const Index &antenna_dim, ConstMatrixView antenna_dlos, const GriddedField4 &antenna_response, ConstMatrixView mblock_dlos, ConstVectorView solid_angles, ConstVectorView f_grid, const Index n_pol)
 antenna2d_interp_response
 
void mixer_matrix (Sparse &H, Vector &f_mixer, const Numeric &lo, const GriddedField1 &filter, ConstVectorView f_grid, const Index &n_pol, const Index &n_sp, const Index &do_norm)
 mixer_matrix
 
void met_mm_polarisation_hmatrix (Sparse &H, const ArrayOfString &mm_pol, const Numeric dza, const Index stokes_dim, const String &iy_unit)
 Calculate polarisation H-matrix.
 
void sensor_aux_vectors (Vector &sensor_response_f, ArrayOfIndex &sensor_response_pol, Matrix &sensor_response_dlos, ConstVectorView sensor_response_f_grid, const ArrayOfIndex &sensor_response_pol_grid, ConstMatrixView sensor_response_dlos_grid)
 sensor_aux_vectors
 
void spectrometer_matrix (Sparse &H, ConstVectorView ch_f, const ArrayOfGriddedField1 &ch_response, ConstVectorView sensor_f, const Index &n_pol, const Index &n_sp, const Index &do_norm)
 spectrometer_matrix
 
void stokes2pol (VectorView w, const Index &stokes_dim, const Index &ipol_1based, const Numeric nv)
 stokes2pol
 
bool test_and_merge_two_channels (Vector &fmin, Vector &fmax, Index i, Index j)
 Test if two instrument channels overlap, and if so, merge them.
 
void find_effective_channel_boundaries (Vector &fmin, Vector &fmax, const Vector &f_backend, const ArrayOfGriddedField1 &backend_channel_response, const Numeric &delta, const Verbosity &verbosity)
 Calculate channel boundaries from instrument response functions.
 
void integration_func_by_vecmult (VectorView h, ConstVectorView f, ConstVectorView x_f_in, ConstVectorView x_g_in)
 integration_func_by_vecmult
 
void integration_bin_by_vecmult (VectorView h, ConstVectorView x_g_in, const Numeric &limit1, const Numeric &limit2)
 integration_bin_by_vecmult
 
void summation_by_vecmult (VectorView h, ConstVectorView f, ConstVectorView x_f, ConstVectorView x_g, const Numeric x1, const Numeric x2)
 summation_by_vecmult
 

Variables

constexpr Numeric PI =Constant::pi
 
constexpr Numeric NAT_LOG_2 =Constant::ln_2
 
constexpr Numeric DEG2RAD =Conversion::deg2rad(1)
 

Detailed Description

Functions related to sensor modelling.

Author
Mattias Ekstr�m ekstr.nosp@m.om@r.nosp@m.ss.ch.nosp@m.alme.nosp@m.rs.se
Date
2003-02-27

Functions to model sensor behaviour and integration calculated as vector multiplication.

Definition in file sensor.cc.

Function Documentation

◆ antenna1d_matrix()

void antenna1d_matrix ( Sparse &  H,
const Index &  antenna_dim,
ConstVectorView  antenna_dza,
const GriddedField4 antenna_response,
ConstVectorView  za_grid,
ConstVectorView  f_grid,
const Index  n_pol,
const Index  do_norm 
)

antenna1d_matrix

Core function for setting up the response matrix for 1D antenna cases.

Main task is to extract correct antenna pattern, including frequency interpolation. Actual weights are calculated in integration_func_by_vectmult.

Parameters
HThe antenna transfer matrix
antenna_dimAs the WSV with the same name
antenna_dzaThe zenith angle column of antenna_dlos.
antenna_responseAs the WSV with the same name
za_gridZenith angle grid for pencil beam calculations
f_gridFrequency grid for monochromatic calculations
n_polNumber of polarisation states
do_normFlag whether response should be normalised
Author
Mattias Ekstr�m / Patrick Eriksson
Date
2003-05-27 / 2008-06-17

Definition at line 47 of file sensor.cc.

References ARTS_ASSERT, GriddedField4::data, DEBUG_ONLY, GriddedField::get_numeric_grid(), GriddedField::get_string_grid(), gridpos(), integration_func_by_vecmult(), interp(), interpweights(), and Array< base >::nelem().

◆ antenna2d_gridded_dlos()

void antenna2d_gridded_dlos ( Sparse &  H,
const Index &  antenna_dim,
ConstMatrixView  antenna_dlos,
const GriddedField4 antenna_response,
ConstMatrixView  mblock_dlos,
ConstVectorView  f_grid,
const Index  n_pol 
)

antenna2d_interp_gridded_dlos

The radiances are treated as a bi-linear function, but the antenna response is treated as step-wise constant function (in contrast to 1D). See also built-in doc.

Parameters
HThe antenna transfer matrix
antenna_dimAs the WSV with the same name
antenna_dlosAs the WSV with the same name
antenna_responseAs the WSV with the same name
mblock_dlosAs the WSV with the same name
f_gridFrequency grid for monochromatic calculations
n_polNumber of polarisation states
Author
Patrick Eriksson
Date
2020-09-01

Definition at line 188 of file sensor.cc.

References a, ARTS_ASSERT, ARTS_USER_ERROR_IF, b, GriddedField4::data, DEG2RAD, GriddedField::get_numeric_grid(), GriddedField::get_string_grid(), gridpos(), interp(), interpweights(), and Array< base >::nelem().

◆ antenna2d_interp_response()

void antenna2d_interp_response ( Sparse &  H,
const Index &  antenna_dim,
ConstMatrixView  antenna_dlos,
const GriddedField4 antenna_response,
ConstMatrixView  mblock_dlos,
ConstVectorView  solid_angles,
ConstVectorView  f_grid,
const Index  n_pol 
)

antenna2d_interp_response

The antenna pattern is interpolated to the dlos directions and solid beam angles are applied. See also built-in doc.

Parameters
HThe antenna transfer matrix
antenna_dimAs the WSV with the same name
antenna_dlosAs the WSV with the same name
antenna_responseAs the WSV with the same name
mblock_dlosAs the WSV with the same name
solid_anglesThe solid angle of each dlos
f_gridFrequency grid for monochromatic calculations
n_polNumber of polarisation states
Author
Patrick Eriksson
Date
2018-09-12

Definition at line 430 of file sensor.cc.

References ARTS_ASSERT, GriddedField4::data, DEG2RAD, GriddedField::get_numeric_grid(), GriddedField::get_string_grid(), gridpos(), interp(), interpweights(), and Array< base >::nelem().

◆ find_effective_channel_boundaries()

void find_effective_channel_boundaries ( Vector &  fmin,
Vector &  fmax,
const Vector &  f_backend,
const ArrayOfGriddedField1 backend_channel_response,
const Numeric &  delta,
const Verbosity verbosity 
)

Calculate channel boundaries from instrument response functions.

This function finds out the unique channel boundaries from f_backend and backend_channel_response. This is not a trivial task, since channels may overlap, or may be sorted in a strange way. The function tries to take care of all that. If channels overlap, they are combined to one continuous frequency region. therefore the number of elements in the output vectors fmin and fmax can be lower than the number of elements in f_backend and backend_channel_response.

The function also does consistency checking on the two input variables.

The output vectors fmin and fmax will be monotonically increasing.

Author
Stefan Buehler
Parameters
[out]fminVector of lower boundaries of instrument channels.
[out]fmaxVector of upper boundaries of instrument channels.
[in]f_backendNominal backend frequencies.
[in]backend_channel_responseChannel response, relative to nominal frequencies.
[in]deltaExtra margin on both sides of each band. Has a default value of 0.

delta;

Definition at line 1086 of file sensor.cc.

References ARTS_USER_ERROR_IF, CREATE_OUT2, get_sorted_indexes(), last(), Array< base >::nelem(), and test_and_merge_two_channels().

◆ integration_bin_by_vecmult()

void integration_bin_by_vecmult ( VectorView  h,
ConstVectorView  x_g_in,
const Numeric &  limit1,
const Numeric &  limit2 
)

integration_bin_by_vecmult

Calculates the (row) vector that multiplied with an unknown (column) vector, g, approximates the integral between limit1 and limit2, where limit1 >= limit2.

This can be seen as a special case of what is handled by integration_func_by_vecmult*, where the function f is a boxcar function. Or expressed differently, the function g is "binned" between limit1 and limit2.

The limits must be inside the range the x_g.

Parameters
hThe multiplication (row) vector.
x_g_inThe grid points of function g(x). Can be increasing or decreasing. Must cover a wider range than the boxcar function (in both ends).
limit1The lower integration limit.
limit2The upper integration limit.
Author
Patrick Eriksson
Date
2017-06-02

Definition at line 1419 of file sensor.cc.

References ARTS_ASSERT, max(), and min().

Referenced by yRadar().

◆ integration_func_by_vecmult()

void integration_func_by_vecmult ( VectorView  h,
ConstVectorView  f,
ConstVectorView  x_f_in,
ConstVectorView  x_g_in 
)

integration_func_by_vecmult

Calculates the (row) vector that multiplied with an unknown (column) vector approximates the integral of the product between the functions represented by the two vectors: h*g = integral( f(x)*g(x) dx )

Basic principle follows Eriksson et al., Efficient forward modelling by matrix representation of sensor responses, Int. J. Remote Sensing, 27, 1793-1808, 2006. However, while in Eriksson et al. the product between f*g is assumed to vary linearly between the grid point, the expressions applied here are more advanced and are completly exact as long as f and g are piece-wise linear functions. The product f*g is then a quadratic funtion between the grid points.

Parameters
hThe multiplication (row) vector.
fThe values of function f(x).
x_f_inThe grid points of function f(x). Must be increasing.
x_g_inThe grid points of function g(x). Can be increasing or decreasing. Must cover a wider range than x_f (in both ends).
Author
Mattias Ekstr�m and Patrick Eriksson
Date
2003-02-13 / 2008-06-12

Definition at line 1284 of file sensor.cc.

References ARTS_ASSERT, ARTS_USER_ERROR_IF, and min().

Referenced by antenna1d_matrix(), and spectrometer_matrix().

◆ met_mm_polarisation_hmatrix()

void met_mm_polarisation_hmatrix ( Sparse &  H,
const ArrayOfString pol,
const Numeric  dza,
const Index  stokes_dim,
const String iy_unit 
)

Calculate polarisation H-matrix.

Takes into account instrument channel polarisation and zenith angle.

Parameters
[out]HPolarisation matrix
[in]mm_polInstrument channel polarisations
[in]dzaZenith angle, from reference direction
[in]stokes_dimWorkspace variable
[in]iy_unitWorkspace variable

Definition at line 714 of file sensor.cc.

References ARTS_ASSERT, ARTS_USER_ERROR, muellersparse_rotation(), mult(), Array< base >::nelem(), stokes2pol(), and w.

Referenced by sensor_responseMetMM().

◆ mixer_matrix()

void mixer_matrix ( Sparse &  H,
Vector &  f_mixer,
const Numeric &  lo,
const GriddedField1 filter,
ConstVectorView  f_grid,
const Index &  n_pol,
const Index &  n_sp,
const Index &  do_norm 
)

mixer_matrix

Sets up the sparse matrix that models the response from sideband filtering and the mixer.

The size of the transfer matrix is changed in the function as follows: nrows = f_mixer.nelem() ncols = f_grid.nelem()

The returned frequencies are given in IF, so both primary and mirror band is converted down.

Parameters
HThe mixer/sideband filter transfer matrix
f_mixerThe frequency grid of the mixer
loThe local oscillator frequency
filterThe sideband filter data. See sideband_response for format and constraints.
f_gridThe original frequency grid of the spectrum
n_polThe number of polarisations to consider
n_spThe number of spectra (viewing directions)
do_normFlag whether rows should be normalised
Author
Mattias Ekstr�m / Patrick Eriksson
Date
2003-05-27 / 2008-06-17

Definition at line 613 of file sensor.cc.

References a, ARTS_ASSERT, GriddedField1::data, DEBUG_ONLY, GriddedField::get_numeric_grid(), last(), and summation_by_vecmult().

Referenced by sensor_responseMixer().

◆ sensor_aux_vectors()

void sensor_aux_vectors ( Vector &  sensor_response_f,
ArrayOfIndex sensor_response_pol,
Matrix &  sensor_response_dlos,
ConstVectorView  sensor_response_f_grid,
const ArrayOfIndex sensor_response_pol_grid,
ConstMatrixView  sensor_response_dlos_grid 
)

sensor_aux_vectors

Sets up the the auxiliary vectors for sensor_response.

The function assumes that all grids are common, and the full vectors are just the grids repeated.

Parameters
sensor_response_fAs the WSV with same name
sensor_response_polAs the WSV with same name
sensor_response_zaAs the WSV with same name
sensor_response_aaAs the WSV with same name
sensor_response_f_gridAs the WSV with same name
sensor_response_pol_gridAs the WSV with same name
sensor_response_dlos_gridAs the WSV with same name
Author
Patrick Eriksson
Date
2008-06-09

Definition at line 875 of file sensor.cc.

References Array< base >::nelem().

Referenced by sensor_responseFillFgrid(), sensor_responseGenericAMSU(), sensor_responseInit(), sensor_responseMetMM(), sensor_responseMixer(), sensor_responseMixerBackendPrecalcWeights(), sensor_responseMultiMixerBackend(), sensor_responsePolarisation(), and sensor_responseWMRF().

◆ spectrometer_matrix()

void spectrometer_matrix ( Sparse &  H,
ConstVectorView  ch_f,
const ArrayOfGriddedField1 ch_response,
ConstVectorView  sensor_f,
const Index &  n_pol,
const Index &  n_sp,
const Index &  do_norm 
)

spectrometer_matrix

Constructs the sparse matrix that multiplied with the spectral values gives the spectra from the spectrometer.

The input to the function corresponds mainly to WSVs. See f_backend and backend_channel_response for how the backend response is specified.

Parameters
HThe response matrix.
ch_fCorresponds directly to WSV f_backend.
ch_responseCorresponds directly to WSV backend_channel_response.
sensor_fCorresponds directly to WSV sensor_response_f_grid.
n_polThe number of polarisations.
n_spThe number of spectra (viewing directions).
do_normCorresponds directly to WSV sensor_norm.
Author
Mattias Ekstr�m and Patrick Eriksson
Date
2003-08-26 / 2008-06-10

Definition at line 912 of file sensor.cc.

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

◆ stokes2pol()

void stokes2pol ( VectorView  w,
const Index &  stokes_dim,
const Index &  ipol_1based,
const Numeric  nv = 1 
)

stokes2pol

Sets up a vector to convert the Stokes vector to different polarsiations.

The measured value is the sum of the element product of the conversion vector and the Stokes vector. Schematically:

y[iout] = sum( w.*iy(iin,joker)

Vectors for I, Q, U and V are always normalised to have unit length (one value is 1, the remaining ones zero). The first element of remaining vectors is set to nv (and other values normalised accordingly), to allow that calibartion and other normalisation effects can be incorporated.

Parameters
s2pArray of conversion vectors.
nvNorm value for polarisations beside I, Q, U and V.
Author
Patrick Eriksson
Date
2011-11-01 and 2018-03-16

Definition at line 978 of file sensor.cc.

References ARTS_ASSERT, ARTS_USER_ERROR_IF, and w.

Referenced by iy_transmitterMultiplePol(), iy_transmitterSinglePol(), met_mm_polarisation_hmatrix(), sensor_responsePolarisation(), and yRadar().

◆ summation_by_vecmult()

void summation_by_vecmult ( VectorView  h,
ConstVectorView  f,
ConstVectorView  x_f,
ConstVectorView  x_g,
const Numeric  x1,
const Numeric  x2 
)

summation_by_vecmult

Calculates the (row) vector that multiplied with an unknown (column) vector approximates the sum of the product between the functions at two points.

E.g. h*g = f(x1)*g(x1) + f(x2)*g(x2)

The typical application is to set up the combined response matrix for mixer and sideband filter.

See Eriksson et al., Efficient forward modelling by matrix representation of sensor responses, Int. J. Remote Sensing, 27, 1793-1808, 2006, for details.

No normalisation of the response is made.

Parameters
hThe summation (row) vector.
fSideband response.
x_fThe grid points of function f(x).
x_gThe grid for spectral values (normally equal to f_grid)
x1Point 1
x2Point 2
Author
Mattias Ekstr�m / Patrick Eriksson
Date
2003-05-26 / 2008-06-17

Definition at line 1517 of file sensor.cc.

References ARTS_ASSERT, gridpos(), interp(), interpweights(), and last().

Referenced by mixer_matrix().

◆ test_and_merge_two_channels()

bool test_and_merge_two_channels ( Vector &  fmin,
Vector &  fmax,
Index  i,
Index  j 
)

Test if two instrument channels overlap, and if so, merge them.

The channels boundaries are specified in two separate vectors, fmin and fmax. These vectors are both input and output. If merging has happened, they will each be one element shorter.

The positions of the channels to compare is given by the input parameters i and j. It is assumed that the minimum frequency of i is lower than or equal to that of j.

Furthermore, it is assumed that i itself is lower than j.

The range of the first channel (i) will have been extended to accomodate the second channel (j). The second channel will have been removed.

The function also handles the updating of index j: If the two channels do not overlap, j is increased by one.

Function returns true if merging has happened.

Author
Stefan Buehler
Returns
True if channels were merged, otherwise false.
Return values
fminLower channel boundaries.
fmaxUpper channel boundaries.
Parameters
iIndex of first channel.
jIndex of second channel.

Definition at line 1044 of file sensor.cc.

References ARTS_ASSERT.

Referenced by find_effective_channel_boundaries().

Variable Documentation

◆ DEG2RAD

constexpr Numeric DEG2RAD =Conversion::deg2rad(1)
inlineconstexpr

Definition at line 35 of file sensor.cc.

Referenced by antenna2d_gridded_dlos(), and antenna2d_interp_response().

◆ NAT_LOG_2

constexpr Numeric NAT_LOG_2 =Constant::ln_2
inlineconstexpr

Definition at line 34 of file sensor.cc.

◆ PI

constexpr Numeric PI =Constant::pi
inlineconstexpr

Definition at line 33 of file sensor.cc.