[PIPE2D-1268] Fibre 316 is in the wrong place in r1 Created: 21/Jul/23  Updated: 25/Jul/23  Resolved: 25/Jul/23

Status: Done
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: Done Votes: 0
Labels: engRun12
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: PNG File Figure 1 - 2023-07-20T183607.679.png     PNG File image (15).png     PNG File image (15).png    

 Description   

something looks very wrong with the new r1 DetectorMap. Note the double line, and many of the pixels seem to be associated with 316 according to findFiberId, and in fact I can get it to crash (see jupyter screen shot ).

The problem is that 316 is in the wrong place (see attachments), although its spatialOffset is 0.0. 



 Comments   
Comment by price [ 25/Jul/23 ]

This is intrinsic to the base detectorMap from the simulator, and has been present ever since we included the engineering fibers: interpolating across the chip gap led to an inaccurate position. I have a fix for the detectorMap generation in the simulator. Then I need to generate new base detectorMaps for drp_pfs_data and correct the existing detectorMaps in the current calib.

Comment by price [ 25/Jul/23 ]

Merged drp_instmodel and drp_pfs_data.

Updated CALIB-2023-07-v2 detectorMaps and renamed to CALIB-2023-07-v3:

(lsst-scipipe-3.0.0) price@pfsa-usr02-gb:/work/price/pipe2d-1268 $ cp -r /work/drp/CALIB-2023-07-v2 .


from glob import glob
import numpy as np
from pfs.drp.stella import DetectorMap
from pfs.utils.fiberids import FiberIds

def interpolate(x, x1, x2, y1, y2):
    weight2 = (x - x1)/(x2 - x1)
    weight1 = 1.0 - weight2
    return y1*weight1 + y2*weight2

def fixDetectorMap(detMap):
    base = detMap
    distortion = None
    if hasattr(detMap, "getBase"):
        base = detMap.getBase()
        distortion = detMap.getDistortion()
    fibers = FiberIds()
    isEngFiber = np.isin(detMap.fiberId, fibers.fiberId[fibers.scienceFiberId == fibers.ENGINEERING])
    engFibers = detMap.fiberId[isEngFiber]
    scienceFibers = detMap.fiberId[~isEngFiber]
    for fiberId in engFibers:
        lowIndex, highIndex = np.argpartition(np.abs(scienceFibers - fiberId), [0, 1])[:2]
        low = scienceFibers[lowIndex]
        high = scienceFibers[highIndex]
        xCenterKnots = interpolate(fiberId, low, high, base.getXCenterSpline(low).getX(), base.getXCenterSpline(high).getX())
        xCenterValues = interpolate(fiberId, low, high, base.getXCenterSpline(low).getY(), base.getXCenterSpline(high).getY())
        wavelengthKnots = interpolate(fiberId, low, high, base.getWavelengthSpline(low).getX(), base.getWavelengthSpline(high).getX())
        wavelengthValues = interpolate(fiberId, low, high, base.getWavelengthSpline(low).getY(), base.getWavelengthSpline(high).getY())
        base.setXCenter(fiberId, xCenterKnots, xCenterValues)
        base.setWavelength(fiberId, wavelengthKnots, wavelengthValues)
    if distortion is None:
        return base
    return type(detMap)(base, distortion, detMap.visitInfo, detMap.metadata)

for filename in glob("/work/price/pipe2d-1268/CALIB-2023-07-v2/DETECTORMAP/pfsDetectorMap-*.fits"):
    detMap = DetectorMap.readFits(filename)
    detMap = fixDetectorMap(detMap)
    detMap.writeFits(filename)


(lsst-scipipe-3.0.0) price@pfsa-usr02-gb:/work/drp $ cp -r /work/price/pipe2d-1268/CALIB-2023-07-v2 CALIB-2023-07-v3
(lsst-scipipe-3.0.0) price@pfsa-usr02-gb:/work/drp $ rm CALIB
(lsst-scipipe-3.0.0) price@pfsa-usr02-gb:/work/drp $ ln -s CALIB-2023-07-v3 CALIB
(lsst-scipipe-3.0.0) price@pfsa-usr02-gb:/work/drp/CALIB-2023-07-v3 $ rm -r DETECTORMAP-bad-r1-316/

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