[PIPE2D-1342] Slit offsets should be applied _before_ modelling the optics and detectors Created: 21/Dec/23  Updated: 20/Jan/24

Status: Open
Project: DRP 2-D Pipeline
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Story Priority: Normal
Reporter: rhl Assignee: price
Resolution: Unresolved Votes: 0
Labels: EngRun
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

The DetectorMap code to adjust the spatial (and spectral) offsets of individual fibres appears to adjust the position of the traces on the detector rather than moving the trace relative to the full optical model (including the gap between the two CCDs in the optical arms).

This didn't matter when we were making small adjustments, but to model the drift flat data we need to handle the higher-order corrections, and the chip gaps.

On slack I'd complained that there was structure in the resulting images, but on further consideration I think that this is beating between the non-integral step and the fact that the motion is treated as a set of steps (i.e. there is structure on the scale of the step, but it appears at a larger scale). This is not a problem.

The code to make this model looks like this (using rerun rhl/tmp in Hilo).

from pfs.datamodel import TargetType
from pfs.drp.stella import SpectrumSet, FiberTraceSet
from pfs.drp.stella.buildFiberProfiles import BuildFiberProfilesTask

dataId = {'visit': 103274, 'arm': 'r', 'spectrograph': 3}

exp = butler.get("calexp", dataId)
detMap = butler.get("detectorMap_used", dataId)
pfsConfig = butler.get("pfsConfig", dataId).select(spectrograph=dataId["spectrograph"])

fiberId = pfsConfig.select(spectrograph=dataId["spectrograph"], targetType=TargetType.DCB).fiberId

spec = butler.get("pfsArm", dataId)
spec.flux[(spec.mask & ~spec.flags["REFLINE"]) != 0x0] = np.NaN
spectra = SpectrumSet.fromPfsArm(spec)
#
# Build the profiles
#
config = BuildFiberProfilesTask.ConfigClass()
config.profileRadius = 5
buildFiberProfilesTask = BuildFiberProfilesTask(config)

fiberProfiles = buildFiberProfilesTask.run(exp, None, detectorMap=detMap, pfsConfig=pfsConfig).profiles    
#
# Simulate drifted data
#
driftedModel = None
for dx in np.arange(-20, 20, 0.55):
    detMap = butler.get("detectorMap_used", dataId)

    for fid in fiberId:
        detMap.setSlitOffsets(fid, detMap.getSpatialOffset(fid) + dx, detMap.getSpectralOffset(fid))

    fts = fiberProfiles.makeFiberTracesFromDetectorMap(detMap)

    image = spectra.makeImage(exp.getDimensions(), fts)
    if driftedModel is None:
        driftedModel = image
    else:
        driftedModel += image

Generated at Sat Feb 10 16:06:20 JST 2024 using Jira 8.3.4#803005-sha1:1f96e09b3c60279a408a2ae47be3c745f571388b.