DP3
Namespaces | Classes | Typedefs | Enumerations | Functions
dp3::base Namespace Reference

Namespaces

 DP3MS
 
 test
 

Classes

class  BaselineSelection
 Class containing a few static functions to parse a baseline selection string. More...
 
class  BdaBuffer
 
class  ComponentInfo
 Class for visitors that visit model component to extract information. More...
 
class  const_cursor
 
class  cursor
 Multi-dimensional iterators. More...
 
struct  Direction
 A direction on the celestial sphere. More...
 
class  DPBuffer
 Buffer holding the data of a timeslot/band. More...
 
class  DPInfo
 General info about DP3 data processing attributes like averaging. More...
 
class  FlagCounter
 Class to keep counts of nr of flagged points. More...
 
class  GainCalAlgorithm
 DPPP step class to apply a calibration correction to the data. More...
 
class  GaussianSource
 Gaussian source model component. More...
 
class  LogAntennaParseErrors
 RAII object for temporarily overriding MSAntennaParse::thisMSAErrorHandler. More...
 
class  ModelComponent
 Base class for model components. More...
 
class  ModelComponentVisitor
 Base class for visitors that visit model component hierarchies. More...
 
class  ParsetATerms
 Parses the parameter settings (parset) related to the aterm settings in an EveryBeam-acceptable format. More...
 
class  PointSource
 Point source model component with optional spectral index and rotation measure. More...
 
class  PredictBuffer
 
class  PredictModel
 
class  ProgressMeter
 Visual indication of a tasks progress. More...
 
class  RcuMode
 
struct  StManParsetKeys
 
class  Stokes
 Complex Stokes vector. More...
 
class  SubtableWriter
 
class  UVWCalculator
 Class to calculate UVW coordinates. More...
 

Typedefs

typedef std::pair< size_t, size_t > Baseline
 
typedef std::complex< double > dcomplex
 

Enumerations

enum class  CalType {
  kScalar , kScalarAmplitude , kScalarPhase , kDiagonal ,
  kDiagonalAmplitude , kDiagonalPhase , kFullJones , kTec ,
  kTecAndDelay , kTecAndPhase , kTecPhaseAndDelay , kTecScreen ,
  kRotationAndDiagonal , kRotation , kFaradayRotation , kLeakage ,
  kLeakageAmplitude
}
 
enum class  SiscoMode { Full , Diagonal , StokesI }
 

Functions

template<typename T >
const_cursor< T > casa_const_cursor (const casacore::Array< T > &array)
 
template<typename T >
cursor< T > casa_cursor (casacore::Array< T > &array)
 
bool estimate (size_t nDirection, size_t nStation, size_t nBaseline, size_t nChannel, const_cursor< Baseline > baselines, std::vector< const_cursor< std::complex< float >>> data, std::vector< const_cursor< std::complex< double >>> model, const_cursor< bool > flag, const_cursor< float > weight, const_cursor< std::complex< double >> mix, double *unknowns, size_t maxiter=50)
 
void Execute (const std::string &parsetName, const std::vector< std::string > &arguments={})
 
void ExecuteFromCommandLine (const std::vector< std::string > &arguments)
 Command-line interface. More...
 
void ExecuteFromCommandLine (int argc, char *argv[])
 Command-line interface. More...
 
std::vector< size_t > GetBaselineSelection (size_t n_antennas, const std::vector< size_t > &bl_idx_sorted, const std::vector< int > &antennas1, const std::vector< int > &antennas2)
 
std::vector< size_t > GetBaselinesSortedByLength (const std::vector< int > &antennas1, const std::vector< int > &antennas2, const std::vector< std::array< double, 3 >> &antenna_positions)
 
dp3::common::Fields GetChainRequiredFields (std::shared_ptr< steps::Step > first_step)
 
std::string GetCompressionString (const StManParsetKeys &st_man_keys)
 
constexpr size_t GetNPolarizations (CalType cal_type)
 
size_t GetNThreads ()
 
SiscoMode GetSiscoMode (const std::string &mode_str)
 
std::unique_ptr< everybeam::telescope::Telescope > GetTelescope (const std::string &ms_name, const everybeam::ElementResponseModel element_response_model, bool use_channel_frequency, const std::string &coefficients_file)
 
bool IsHomogeneous (const everybeam::telescope::Telescope &telescope)
 
void makeIndex (std::size_t n_direction, std::size_t n_station, const Baseline &baseline, unsigned int *index)
 
std::shared_ptr< steps::InputStepMakeMainSteps (const common::ParameterSet &parset)
 
std::shared_ptr< steps::StepMakeSingleStep (const std::string &type, const common::ParameterSet &parset, const std::string &prefix, steps::Step::MsType input_type)
 
std::shared_ptr< steps::StepMakeStepsFromParset (const common::ParameterSet &parset, const std::string &prefix, const std::string &step_names_key, const std::string &input_ms_name, bool terminateChain, steps::Step::MsType initial_step_output)
 
void radec2lmn (const Direction &reference, const Direction &direction, double *lmn)
 
std::string ReadAntennaSet (const casacore::MeasurementSet &ms)
 
void rotateUVW (const Direction &from, const Direction &to, size_t nUVW, double *uvw)
 
std::vector< size_t > SelectStationIndices (const everybeam::telescope::Telescope &telescope, const std::vector< std::string > &station_names)
 
dp3::common::Fields SetChainProvidedFields (std::shared_ptr< steps::Step > first_step, dp3::common::Fields provided_fields=dp3::common::Fields())
 
void SetNThreads (size_t n_threads)
 
std::vector< int > SetupUvwSplitting (unsigned int nant, const std::vector< int > &ant1, const std::vector< int > &ant2)
 
std::vector< int > SetupUvwSplitting (unsigned int nant, const std::vector< int > &ant1, const std::vector< int > &ant2, const std::vector< std::array< double, 3 >> &antenna_positions)
 
void ShowUsage ()
 
void simulate (const Direction &reference, const std::shared_ptr< const sky_model::Patch > &patch, size_t nStation, size_t nBaseline, size_t nChannel, const_cursor< Baseline > baselines, const_cursor< double > freq, const_cursor< double > uvw, cursor< std::complex< double >> buffer)
 
void SplitUvw (const std::vector< int > &baseline_indices, const std::vector< Baseline > &baselines, const DPBuffer::UvwType &uvw_bl, xt::xtensor< double, 2 > &uvw_ant)
 
CalType StringToCalType (const std::string &mode)
 Convert string to a CalType. More...
 
void subtract (size_t nBaseline, size_t nChannel, const_cursor< Baseline > baselines, cursor< std::complex< float >> data, const_cursor< std::complex< double >> model, const_cursor< std::complex< double >> weight, float &var_before, float &var_after)
 
std::string ToString (CalType caltype)
 Convert CalType to a string. More...
 
std::string ToString (SiscoMode mode)
 
void apply (size_t nBaseline, size_t nChannel, const_cursor< Baseline > baselines, const_cursor< double > coeff, cursor< std::complex< double >> data)
 Apply station Jones matrices to a set of visibilities. More...
 

Detailed Description

This code was taken from https://git.astron.nl/RD/aartfaac-tools/-/raw/master/common/aartfaac/aartfaacmode.h?ref_type=heads and adapted to fit into DP3 codebase.

The Receiver Unit Mode, hereafter RCU mode, is the mode in which the receiver units are set in a LOFAR station. The mode determines the amount of frequency ranges the RCU is sensitive towards. The RcuMode class provides the the frequency, bandwidth, antenna type, and a descriptive string of the RCU mode given a mode code. A reference for this modes can be found in https://science.astron.nl/telescopes/lofar/lofar-system-overview/technical-specification/frequency-subband-selection-and-rfi/.

This class is responsible to create ancillary tables such as ANTENNA or SPECTRAL_WINDOW In the future this could be part of the DP3 writer step it was a choice to keep it separate to avoid changing core DP3 functionalities Most of this code was taken from https://git.astron.nl/RD/aartfaac-tools.git and adapted to fit into the DP3 codebase.

Typedef Documentation

◆ Baseline

typedef std::pair<size_t, size_t> dp3::base::Baseline

◆ dcomplex

typedef std::complex<double> dp3::base::dcomplex

Enumeration Type Documentation

◆ CalType

enum dp3::base::CalType
strong
Enumerator
kScalar 
kScalarAmplitude 
kScalarPhase 
kDiagonal 
kDiagonalAmplitude 
kDiagonalPhase 
kFullJones 
kTec 
kTecAndDelay 
kTecAndPhase 
kTecPhaseAndDelay 
kTecScreen 
kRotationAndDiagonal 
kRotation 
kFaradayRotation 
kLeakage 
kLeakageAmplitude 

◆ SiscoMode

enum dp3::base::SiscoMode
strong
Enumerator
Full 
Diagonal 
StokesI 

Function Documentation

◆ apply()

void dp3::base::apply ( size_t  nBaseline,
size_t  nChannel,
const_cursor< Baseline baselines,
const_cursor< double >  coeff,
cursor< std::complex< double >>  data 
)

Apply station Jones matrices to a set of visibilities.

Apply station Jones matrices to a set of visibilities.

Parameters
[in]nBaselineNumber of baselines.
[in]nChannelNumber of frequency channels.
[in]baselinesA cursor for a 1-D buffer of baselines of shape (nBaseline).
[in]coeffA cursor for a 2-D buffer of Jones matrix coefficients of shape (No. of stations, 8). Each station index contained in baselines should be a valid index for the first axis of coeff.
[in]dataA cursor for a 3-D buffer of visibilities of shape (nBaseline, nChannel, 4).

◆ casa_const_cursor()

template<typename T >
const_cursor<T> dp3::base::casa_const_cursor ( const casacore::Array< T > &  array)

◆ casa_cursor()

template<typename T >
cursor<T> dp3::base::casa_cursor ( casacore::Array< T > &  array)

◆ estimate()

bool dp3::base::estimate ( size_t  nDirection,
size_t  nStation,
size_t  nBaseline,
size_t  nChannel,
const_cursor< Baseline baselines,
std::vector< const_cursor< std::complex< float >>>  data,
std::vector< const_cursor< std::complex< double >>>  model,
const_cursor< bool >  flag,
const_cursor< float >  weight,
const_cursor< std::complex< double >>  mix,
double *  unknowns,
size_t  maxiter = 50 
)

Estimate Jones matrices for several directions simultaneously. A separate data stream is used for each direction. The mixing coefficients quantify the influence of each direction on each of the other directions (including time and frequency smearing).

Parameters
[in]nDirectionNumber of directions to estimate Jones matrices for.
[in]nStationNumber of stations.
[in]nBaselineNumber of baselines.
[in]nChannelNumber of frequency channels.
[in]dataVector of length nDirection of cursors for 3-D buffers of observed visiblity data of shape (nBaseline, nChannel, 4).
[in]modelVector of length nDirection of cursors for 3-D buffers of simulated visiblity data of shape (nBaseline, nChannel, 4).
[in]baselinesA cursor for a 1-D buffer of baselines of shape (nBaseline).
[in]flagA cursor for a 3-D buffer of observed visibility flags of shape (nBaseline, nChannel, 4).
[in]weightA cursor for a 3-D buffer of observed visibility weights of shape (nBaseline, nChannel, 4).
[in]mixA cursor for a 5-D buffer of mixing weights of shape (nBaseline, nChannel, 4, nDirection, nDirection).
[in]unknownsA pointer to a buffer of unknowns of size nDirection * nStation * 8.

◆ Execute()

void dp3::base::Execute ( const std::string &  parsetName,
const std::vector< std::string > &  arguments = {} 
)

Execute the steps defined in the parset file. Possible parameters given at the command line are taken into account.

◆ ExecuteFromCommandLine() [1/2]

void dp3::base::ExecuteFromCommandLine ( const std::vector< std::string > &  arguments)

Command-line interface.

◆ ExecuteFromCommandLine() [2/2]

void dp3::base::ExecuteFromCommandLine ( int  argc,
char *  argv[] 
)

Command-line interface.

◆ GetBaselineSelection()

std::vector<size_t> dp3::base::GetBaselineSelection ( size_t  n_antennas,
const std::vector< size_t > &  bl_idx_sorted,
const std::vector< int > &  antennas1,
const std::vector< int > &  antennas2 
)

Helper function for SetupUvwSplitting(). Was put in header so it can be tested.

◆ GetBaselinesSortedByLength()

std::vector<size_t> dp3::base::GetBaselinesSortedByLength ( const std::vector< int > &  antennas1,
const std::vector< int > &  antennas2,
const std::vector< std::array< double, 3 >> &  antenna_positions 
)

Helper function for SetupUvwSplitting(). Was put in header so it can be tested.

◆ GetChainRequiredFields()

dp3::common::Fields dp3::base::GetChainRequiredFields ( std::shared_ptr< steps::Step first_step)

Go through the steps to define which fields of the measurement set should be read by the input step.

Parameters
first_stepThe first step of a chain of steps.
Returns
The combined required fields of the step chain.

◆ GetCompressionString()

std::string dp3::base::GetCompressionString ( const StManParsetKeys st_man_keys)
inline

◆ GetNPolarizations()

constexpr size_t dp3::base::GetNPolarizations ( CalType  cal_type)
constexpr

◆ GetNThreads()

size_t dp3::base::GetNThreads ( )

Get the number of threads used in DP3. This function is needed since each library / application has its own aocommon Threadpool object.

◆ GetSiscoMode()

SiscoMode dp3::base::GetSiscoMode ( const std::string &  mode_str)
inline

◆ GetTelescope()

std::unique_ptr<everybeam::telescope::Telescope> dp3::base::GetTelescope ( const std::string &  ms_name,
const everybeam::ElementResponseModel  element_response_model,
bool  use_channel_frequency,
const std::string &  coefficients_file 
)
inline

Retrieve the everybeam telescope from a Measurement Set.

◆ IsHomogeneous()

bool dp3::base::IsHomogeneous ( const everybeam::telescope::Telescope &  telescope)

◆ makeIndex()

void dp3::base::makeIndex ( std::size_t  n_direction,
std::size_t  n_station,
const Baseline baseline,
unsigned int *  index 
)

Compute a map that contains the index of the unknowns related to the specified baseline in the list of all unknowns.

Parameters
[in]n_direction
[in]n_station
[in]baselineA tuple of baseline station ids
[out]indexA vector of size 4*8*n_direction to store the indices

◆ MakeMainSteps()

std::shared_ptr<steps::InputStep> dp3::base::MakeMainSteps ( const common::ParameterSet parset)

Create a chain of step objects that are connected together. A writer will be added to the steps if it is not defined, and a terminating NullStep is added.

◆ MakeSingleStep()

std::shared_ptr<steps::Step> dp3::base::MakeSingleStep ( const std::string &  type,
const common::ParameterSet parset,
const std::string &  prefix,
steps::Step::MsType  input_type 
)

Create a step

Parameters
typeType of the step.
parsetParameterSet containing the configuration for the step.
prefixPrefix, including trailing dot ("."), to use for looking up parameters in the ParameterSet.
input_typeType of input data, BDA or regular.
Returns
Pointer to the newly created step, or a null pointer if the type not recognized.

◆ MakeStepsFromParset()

std::shared_ptr<steps::Step> dp3::base::MakeStepsFromParset ( const common::ParameterSet parset,
const std::string &  prefix,
const std::string &  step_names_key,
const std::string &  input_ms_name,
bool  terminateChain,
steps::Step::MsType  initial_step_output 
)

Create a chain of step objects that are connected together. Unlike MakeMainSteps(), this does neither add a writer nor terminate the chain with a NullStep.

Parameters
step_names_keyParset key for getting the step names.
Returns
The first step of the step chain or a null pointer if the chain is empty.

◆ radec2lmn()

void dp3::base::radec2lmn ( const Direction reference,
const Direction direction,
double *  lmn 
)
inline

Compute LMN coordinates of direction relative to reference.

Parameters
[in]referenceReference direction on the celestial sphere.
[in]directionDirection of interest on the celestial sphere.
[out]lmnPointer to a buffer of (at least) length three into which the computed LMN coordinates will be written.

\begin{eqnarray*} \ell &= \cos(\delta) \sin(\alpha - \alpha_0) \\ m &= \sin(\delta) \cos(\delta_0) - \cos(\delta) \sin(\delta_0) \cos(\alpha - \alpha_0) \end{eqnarray*}

◆ ReadAntennaSet()

std::string dp3::base::ReadAntennaSet ( const casacore::MeasurementSet &  ms)

Read the antenna set (e.g. LBA_OUTER, HBA_DUAL_INNER) from the OBSERVATION table in the MS. This is a LOFAR-specific extension.

Parameters
msA measurement set, which may contain the antenna set field.
Returns
The antenna set of the MS, or an empty string if not found.

◆ rotateUVW()

void dp3::base::rotateUVW ( const Direction from,
const Direction to,
size_t  nUVW,
double *  uvw 
)

Transform UVW coordinates from phase reference position from to phase reference position to. The transformation is performed in place.

Parameters
[in]fromCurrent phase reference position for the UVW coordinates.
[in]toNew phase reference position for the UVW coordinates.
[in]nUVWThe number of UVW coordinates to transform.
[in]uvwA 2-D buffer of UVW coordinates of shape (UVW, 3).

◆ SelectStationIndices()

std::vector<size_t> dp3::base::SelectStationIndices ( const everybeam::telescope::Telescope &  telescope,
const std::vector< std::string > &  station_names 
)

Find stations in a telescope by name and return their indices.

Parameters
telescopeThe telescope, which contains antennae / stations.
station_namesA list of station names. The order of the names in this list should match the order in which they occur in the telescope.
Returns
The indices corresponding to the station names. Because of the ordering restriction, the list always has increasing indices only.

◆ SetChainProvidedFields()

dp3::common::Fields dp3::base::SetChainProvidedFields ( std::shared_ptr< steps::Step first_step,
dp3::common::Fields  provided_fields = dp3::common::Fields() 
)

Go through a step chain, combine provided fields of non-output steps and call SetFieldsToWrite for all output steps.

Parameters
first_stepThe first step of a chain of steps.
provided_fieldsThe provided fields before the step chain. Steps that have sub-steps should use this argument.
Returns
The remaining provided fields after the last step in the chain.

◆ SetNThreads()

void dp3::base::SetNThreads ( size_t  n_threads)

Set the number of threads used in DP3. This function is needed since each library / application has its own aocommon Threadpool object.

◆ SetupUvwSplitting() [1/2]

std::vector<int> dp3::base::SetupUvwSplitting ( unsigned int  nant,
const std::vector< int > &  ant1,
const std::vector< int > &  ant2 
)

Setup the splitting of the baseline UVWs into station UVWs. It returns the indices of the baselines needed to split the baseline UVWs into station UVWs. They are in such an order that the UVW of a station is known before used in another baseline to derive the UVW of the other station. It can handle cases where baselines occur in disjoint station groups like 0-1, 0-2, 1-2 and 3-4, 4-5, 5-6. Note that the first station of a group gets UVW=0. All other station UVWs are relative to it using the baseline UVWs. Also note that nr of groups can be derived from the size of the returned vector (because it contains no entry for the first antenna in a group).

◆ SetupUvwSplitting() [2/2]

std::vector<int> dp3::base::SetupUvwSplitting ( unsigned int  nant,
const std::vector< int > &  ant1,
const std::vector< int > &  ant2,
const std::vector< std::array< double, 3 >> &  antenna_positions 
)

Same as the other SetupUvwSplitting() overload, except that this version accepts antenna_positions as extra argument. It uses the antenna positions to select the long baselines. This is needed in case of BDA data to prevent loss of information. See UVW splitting of BDA expanded data for details.

◆ ShowUsage()

void dp3::base::ShowUsage ( )

◆ simulate()

void dp3::base::simulate ( const Direction reference,
const std::shared_ptr< const sky_model::Patch > &  patch,
size_t  nStation,
size_t  nBaseline,
size_t  nChannel,
const_cursor< Baseline baselines,
const_cursor< double >  freq,
const_cursor< double >  uvw,
cursor< std::complex< double >>  buffer 
)

Simulate visibilities for a patch of sources. The computed visibilities are added to vis.

Parameters
[in]referencePhase reference position.
[in]patchPatch of sources to simulate visibilities for.
[in]nStationThe number of stations.
[in]nBaselineThe number of baselines.
[in]nChannelThe number of frequency channels.
[in]baselinesA cursor for a 1-D buffer of baselines of shape (nBaseline).
[in]freqA cursor for a 1-D buffer of channel frequencies of shape (nChannel).
[in]uvwA cursor for a 2-D buffer of station UVW coordinates of shape (nStation, 3).
[in]bufferA cursor for a 3-D buffer of shape (nBaseline, nChannel, 4) into which the simulated visibilities will be written.

◆ SplitUvw()

void dp3::base::SplitUvw ( const std::vector< int > &  baseline_indices,
const std::vector< Baseline > &  baselines,
const DPBuffer::UvwType uvw_bl,
xt::xtensor< double, 2 > &  uvw_ant 
)

Do the actual splitting of baseline UVWs into station UVWs using the index vector generated by SetupUvwSplitting.

◆ StringToCalType()

CalType dp3::base::StringToCalType ( const std::string &  mode)

Convert string to a CalType.

◆ subtract()

void dp3::base::subtract ( size_t  nBaseline,
size_t  nChannel,
const_cursor< Baseline baselines,
cursor< std::complex< float >>  data,
const_cursor< std::complex< double >>  model,
const_cursor< std::complex< double >>  weight,
float &  var_before,
float &  var_after 
)

Subtract visibilities from a buffer after weighting by mixing coefficients.

Parameters
[in]nBaselineNumber of baselines.
[in]nChannelNumber of frequency channels.
[in]baselinesA cursor for a 1-D buffer of baselines of shape (nBaseline).
[in]dataA cursor for a 3-D buffer of observed visibilities of shape (nBaseline, nChannel, 4).
[in]modelA cursor for a 3-D buffer of simulated visibilities of shape (nBaseline, nChannel, 4).
[in]weightA cursor for a 3-D buffer of mixing weight of shape (nBaseline, nChannel, 4).
[out]var_beforevariance before subtraction
[out]var_aftervariance after subtraction

◆ ToString() [1/2]

std::string dp3::base::ToString ( CalType  caltype)

Convert CalType to a string.

◆ ToString() [2/2]

std::string dp3::base::ToString ( SiscoMode  mode)
inline