autolens.twins.SimulatedTwin#

class SimulatedTwin[source]#

Bases: Frozen

A simulated observation of twin.

Parameters:
  • dataset (Imaging) – The simulated al.Imaging, masked and over-sampled like the twin’s setup.

  • truth – The ground-truth tracer that was observed (twin.tracer).

  • seed (int) – The noise seed.

  • noise (str) – "observed" or "poisson".

  • simulator (Dict) – The route and settings used (route, exposure_time, …).

  • twin (Twin) – The twin that was simulated.

Methods

dict

The autonerves.dictable dictionary.

from_directory

Reload a simulated twin written by output_to.

output_to

Write the observation and everything needed to reproduce it:

resimulate

Simulate the same twin again with the stored seed and noise route.

twin_json

The provenance written to twin.json: the reference provenance (lens id, fit path, hashes, ingest time, labels, roles, library versions at ingest), the library versions now, the transformation records (dictable dictionaries), the setup fields that differ from the reference setup, and the seed, noise route and simulator settings.

dict()[source]#

The autonerves.dictable dictionary.

al.Imaging does not round-trip through the dictable contract, so the dataset argument is written as a call of dataset_via_setup_from (a function al.from_dict resolves by class path and calls with its arguments) holding the setup, data and noise map; reloading rebuilds the masked, over-sampled dataset with ObservationSetup.dataset_from.

resimulate()[source]#

Simulate the same twin again with the stored seed and noise route.

twin_json()[source]#

The provenance written to twin.json: the reference provenance (lens id, fit path, hashes, ingest time, labels, roles, library versions at ingest), the library versions now, the transformation records (dictable dictionaries), the setup fields that differ from the reference setup, and the seed, noise route and simulator settings.

"truth" lists, flat and in chain order, the ground-truth parameters each transformation reports (TransformationRecord.truth), each with its "transformation" name and "record_index"; records with none are skipped.

output_to(directory)[source]#

Write the observation and everything needed to reproduce it:

  • data.fits, noise_map.fits, psf.fits, mask.fits: native arrays (no visualisation zoom) with the mask’s pixel scales in the header.

  • truth_tracer.json: the ground truth.

  • twin.json: see twin_json.

  • setup.json: the twin’s complete setup. The FITS files alone cannot rebuild it (over-sampling, cosmology, exposure time and sky level are not in them, and a Poisson noise map differs from the setup’s).

  • reference_setup.json / reference_tracer.json: only when the twin’s setup / tracer differ from the reference’s, so the reference can be rebuilt without the original fit directory.

classmethod from_directory(directory)[source]#

Reload a simulated twin written by output_to.

The reference is resolved from its fit_path when that directory still holds a dataset.fits and tracer.json whose SHA-256 match the stored provenance (setup fields not in the FITS are taken from the stored reference setup); otherwise it is rebuilt from the embedded provenance, the stored reference tracer (or the truth tracer, when they are the same) and the stored reference setup (or the twin setup).