Raw simulation DPU recipe
DPU/LPU recipes are possible with !315 (merged). The next step for #251 (closed) is a recipe to simulate raw data.
Raw data is generated in a similar way to processed data, simply with make()
, but it does not have any image data as dependencies, only database instances that describe the hardware (and that do not have a make()
method themselves). (Note that all database objects in MicadoWISE are derived from DataObject, even though they do not necessarily have files attached to them.)
This recipe can then probably easily be extended to processed data with only fixed dependencies. So perhaps in the long run it is not even necessary to have a dedicated simulate-raw-data recipe, but only a fixed-settings-and-fixed-dependencies-recipe that can create any data.
The following code should approximate a test for the new functionality:
from micado.main.ObservingBlock import ObservingBlock
from micado.dataitems.Dark import Dark
from micado.dataitems.DarkExtension import DarkExtension
from micado.templates.MicadoImgCalDark import MicadoImgCalDark
from micado.test.functional.detector_test import generate_detectorarray
from micado.util.Processor import LocalProcessor
# Hardware and observation setup.
# Template start doubles as RNG seed.
tpl__start=now.timestamp()
# Detector array
mydetectorarray = generate_detectorarray(dark=dark_real, size=size, n_det=1)
# A template
dark_template = MicadoImgCalDark(det__dit=1, det__ndit=1)
# An observingblock
dark_ob = ObservingBlock(
name="MyDarkTest",
instrument="MICADO",
target="empty_sky",
templates=[dark_template],
)
mydetectorarray.commit()
dark_template.commit()
dark_ob.commit()
# Generate a dark through the recipe.
lpu = LocalProcessor() # or dpu
jobid = lpu.run(
"the_new_recipe",
..., # something referencing the mydetectorarray, dark_template, dark_ob objects
..., # something setting tpl__start value
)
lpu.wait_for_jobs()
dark_through_lpu = lpu.get_job_result(jobid)[0][0] # If I understand correctly.
# Generate a dark here.
# DarkExtensions, this is probably something that should be moved to the make method though
myextensions = [
DarkExtension(detector=det, BITPIX=-64, NAXIS=2)
for det in mydetectorarray.detector_array_list
]
dark_manually = Dark(
detector=mydetectorarray,
template=dark_template,
observing_block=dark_ob,
tpl__start=tpl__start,
extensions=myextensions,
)
dark_manually.make()
# Tests
assert dark_through_lpu.observing_block is dark_ob
assert dark_through_lpu.template is dark_template
assert dark_through_lpu.detector is mydetectorarray
# The tpl__start should ensure all the pixel values are identical.
assert dark_through_lpu == dark_manually
# Cleanup.
# Delete test objects from database.