draco.synthesis.gain

Tasks for generating random gain fluctuations in the data and stacking them.

Functions

constrained_gaussian_realisation(x, ...[, rcond])

Generate a constrained Gaussian random field.

gaussian_realisation(x, corrfunc, n[, rcond])

Generate a Gaussian random field.

generate_fluctuations(x, corrfunc, n, ...)

Generate correlated random streams.

Classes

BaseGains()

Rudimentary class to generate gain timestreams.

GainStacker()

Take sidereal gain data, make products and stack them up.

RandomGains()

Generate random gains.

RandomSiderealGains()

Generate random gains on a Sidereal grid.

SiderealGains()

Task for simulating sidereal gains.

class draco.synthesis.gain.BaseGains[source]

Bases: SingleTask

Rudimentary class to generate gain timestreams.

The gains are drawn for times which match up to an input timestream file.

amp

Generate gain amplitude fluctuations. Default is True.

Type:

bool

phase

Generate gain phase fluctuations. Default is True.

Type:

bool

Initialize pipeline task.

May be overridden with no arguments. Will be called after any config.Property attributes are set and after ‘input’ and ‘requires’ keys are set up.

process(data)[source]

Generate a gain timestream for the inputs and times in data.

Parameters:

data (containers.TimeStream) – Generate gain errors for data.

Returns:

gain

Return type:

containers.GainData

class draco.synthesis.gain.GainStacker[source]

Bases: SingleTask

Take sidereal gain data, make products and stack them up.

only_gains

Whether to return only the stacked gains or the stacked gains mulitplied with the visibilites. Default: False.

Type:

bool

Notes

This task generates products of gain time streams for every sidereal day and stacks them up over the number of days in the simulation.

More formally a gain stack can be described as

\[G_{ij} = \sum_{a}^{Ndays} g_{i}(t)^{a} g_j(t)^{*a}\]

Initialize pipeline task.

May be overridden with no arguments. Will be called after any config.Property attributes are set and after ‘input’ and ‘requires’ keys are set up.

process(gain)[source]

Make sidereal gain products and stack them up.

Parameters:

gain (containers.SiderealGainData or containers.GainData) – Individual sidereal or time ordered gain data.

Returns:

gain_stack – Stacked products of gains.

Return type:

containers.TimeStream or containers.SiderealStream

process_finish()[source]

Multiply summed gain with sidereal stream.

Returns:

data – Stack of sidereal data with gain applied.

Return type:

containers.SiderealStream or containers.TimeStream

setup(stream)[source]

Get the sidereal stream onto which we stack the simulated gain data.

Parameters:

stream (containers.SiderealStream or containers.TimeStream) – The sidereal or time data to use.

class draco.synthesis.gain.RandomGains[source]

Bases: BaseGains

Generate random gains.

Notes

The Random Gains class generates random fluctuations in gain amplitude and phase.

corr_length_amp, corr_length_phase

Correlation length for amplitude and phase fluctuations in seconds.

Type:

float

sigma_amp, sigma_phase

Size of fluctuations for amplitude (fractional), and phase (radians).

Type:

float

Notes

This task generates gain time streams which are Gaussian distributed with covariance

\[C_{ij} = \sigma^2 \exp{\left(-\frac{1}{2 \xi^2}(t_i - t_j)^2\right)}\]

As the time stream is generated in separate pieces, to ensure that there is consistency between them each gain time stream is drawn as a constrained realisation against the previous file.

Initialize pipeline task.

May be overridden with no arguments. Will be called after any config.Property attributes are set and after ‘input’ and ‘requires’ keys are set up.

class draco.synthesis.gain.RandomSiderealGains[source]

Bases: RandomGains, SiderealGains

Generate random gains on a Sidereal grid.

See the documentation for RandomGains and SiderealGains for more detail.

Initialize pipeline task.

May be overridden with no arguments. Will be called after any config.Property attributes are set and after ‘input’ and ‘requires’ keys are set up.

class draco.synthesis.gain.SiderealGains[source]

Bases: BaseGains

Task for simulating sidereal gains.

This base class is useful for generating gain errors in sidereal time. The simulation period is set by start_time and end_time and does not need any input to process.

start_time, end_time

Start and end times of the gain timestream to simulate. Needs to be either a float (UNIX time) or a datetime objects in UTC. This determines the set of LSDs to generate data for.

Type:

float or datetime

Initialize pipeline task.

May be overridden with no arguments. Will be called after any config.Property attributes are set and after ‘input’ and ‘requires’ keys are set up.

process()[source]

Generate a gain timestream for the inputs and times in data.

Returns:

gain – Simulated gain errors in sidereal time.

Return type:

containers.SiderealGainData

setup(bt, sstream)[source]

Set up an observer and the data to use for this simulation.

Parameters:
  • bt (beamtransfer.BeamTransfer or manager.ProductManager) – Sets up an observer holding the geographic location of the telscope.

  • sstream (containers.SiderealStream) – The sidereal data to use for this gain simulation.

draco.synthesis.gain.constrained_gaussian_realisation(x, corrfunc, n, x2, y2, rcond=1e-12)[source]

Generate a constrained Gaussian random field.

Given a correlation function generate a Gaussian random field that is consistent with an existing set of values of parameter y2 located at co-ordinates in parameter x2.

Parameters:
  • x (np.ndarray[npoints] or np.ndarray[npoints, ndim]) – Co-ordinates of points to generate.

  • corrfunc (function(x) -> covariance matrix) – Function that take (vectorized) co-ordinates and returns their covariance functions.

  • n (integer) – Number of realisations to generate.

  • x2 (np.ndarray[npoints] or np.ndarray[npoints, ndim]) – Co-ordinates of existing points.

  • y2 (np.ndarray[npoints] or np.ndarray[n, npoints]) – Existing values of the random field.

  • rcond (float, optional) – Ignore eigenmodes smaller than rcond times the largest eigenvalue.

Returns:

y – Realisations of the gaussian field.

Return type:

np.ndarray[n, npoints]

draco.synthesis.gain.gaussian_realisation(x, corrfunc, n, rcond=1e-12)[source]

Generate a Gaussian random field.

Parameters:
  • x (np.ndarray[npoints] or np.ndarray[npoints, ndim]) – Co-ordinates of points to generate.

  • corrfunc (function(x) -> covariance matrix) – Function that take (vectorized) co-ordinates and returns their covariance functions.

  • n (integer) – Number of realisations to generate.

  • rcond (float, optional) – Ignore eigenmodes smaller than rcond times the largest eigenvalue.

Returns:

y – Realisations of the gaussian field.

Return type:

np.ndarray[n, npoints]

draco.synthesis.gain.generate_fluctuations(x, corrfunc, n, prev_x, prev_fluc)[source]

Generate correlated random streams.

Generates a Gaussian field from the given correlation function and (potentially) correlated with prior data.

Parameters:
  • x (np.ndarray[npoints]) – Coordinates of samples in the new stream.

  • corrfunc (function) – See documentation of gaussian_realisation.

  • prev_x (np.ndarray[npoints]) – Coordinates of previous samples. Ignored if prev_fluc is None.

  • prev_fluc (np.ndarray[npoints]) – Values of previous samples. If None the stream is initialised.

  • n (int) – Number of realisations to generate.

Returns:

y – Realisations of the stream.

Return type:

np.ndarray[n, npoints]