Skip to content

virgil.simulate

Simulated observations of a scene with another observation's sampling, errors and times, and bias tests that fit a model to many noise draws.

Simulated observations of a scene, and bias tests across instruments.

simulate observes a scene with the sampling, errors and times of a template: real data from one instrument, or the synthetic coverage of virgil.coverage. It answers "what would instrument B measure for the scene instrument A sees?", and, with shift_days, "what would the same coverage give at other epochs?". bias_test fits a model to many noise draws and reports the spread of the fitted parameters, which shows biases from a model that is simpler than the scene (e.g. two point sources fitted to a star with extended emission) and how well the coverage constrains a parameter.

simulate(scene, template, key=None, noise_scale=1.0, shift_days=None)

Observe scene with the sampling, errors and times of template.

Parameters:

Name Type Description Default
scene SourceModel

The scene. A time-dependent scene (one with Attached components) is evaluated at each sample's own time, so the template needs times.

required
template OIData

The observation to copy: its uv samples, wavelengths, observables, closure-phase correlations and projections, and errors.

required
key PRNGKey

For Gaussian noise drawn with the template's errors (closure phases correlated as in the template); noiseless without it.

None
noise_scale float

Multiplies the noise (not the stored errors).

1.0
shift_days float

Move every sample's time by this many days, e.g. to see what the same coverage would give at a later epoch of an orbit.

None

Returns:

Type Description
OIData

The template with its observables replaced by the scene's.

bias_test(scene, template, model, priors, n, key, **fit_kwargs)

Fit model to n noisy simulations of scene.

Parameters:

Name Type Description Default
scene SourceModel

The truth, simulated with simulate.

required
template OIData

The observation to simulate.

required
model

The model fitted to each simulation and its priors, as in fit. The model may differ from the scene (that is the point of a bias test).

required
priors

The model fitted to each simulation and its priors, as in fit. The model may differ from the scene (that is the point of a bias test).

required
n int

Number of noise draws.

required
key PRNGKey

Seed for the draws.

required
**fit_kwargs

Passed to fit (e.g. init, method).

{}

Returns:

Type Description
dict

For each fitted path, the n fitted values as an array; and chi2_red, the reduced χ² of each fit. Compare their means and spreads with the truth.