Skip to content

Commit

Permalink
Skip detectors with missing WCS
Browse files Browse the repository at this point in the history
  • Loading branch information
cmsaunders committed Feb 14, 2023
1 parent 4aed058 commit 6b1ff94
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions python/lsst/drp/tasks/gbdesAstrometricFit.py
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,12 @@ def _get_exposure_info(self, inputVisitSummaries, instrument, fieldNumber=0, ins
observatories.append(observatory_icrs.cartesian.xyz.to(u.AU).value)

for row in visitSummary:
wcs = row.getWcs()
# Skip this detector if the preliminary fit of the wcs failed.
if wcs is None:
continue
wcss.append(_get_wcs_from_sip(wcs))

detector = row['id']
if detector not in detectors:
detectors.append(detector)
Expand All @@ -684,9 +690,6 @@ def _get_exposure_info(self, inputVisitSummaries, instrument, fieldNumber=0, ins
extensionDetectors.append(detector)
extensionType.append('SCIENCE')

wcs = row.getWcs()
wcss.append(_get_wcs_from_sip(wcs))

fieldNumbers = list(np.ones(len(exposureNames), dtype=int) * fieldNumber)
instrumentNumbers = list(np.ones(len(exposureNames), dtype=int) * instrumentNumber)

Expand Down Expand Up @@ -870,6 +873,17 @@ class `wcsfit.FoFClass`, associating them into matches as you go.
detectors = np.unique(inputCatalog['detector'])

for detector in detectors:
extensionIndex = np.flatnonzero((extensionInfo.visit == visit)
& (extensionInfo.detector == detector))[0]
detectorIndex = extensionInfo.detectorIndex[extensionIndex]
visitIndex = extensionInfo.visitIndex[extensionIndex]

wcs = extensionInfo.wcs[extensionIndex]
# Skip this detector if the preliminary fit of the wcs failed.
if wcs is None:
continue
associations.reprojectWCS(wcs, fieldIndex)

detectorSources = inputCatalog[inputCatalog['detector'] == detector]
xCov = detectorSources['xErr']**2
yCov = detectorSources['yErr']**2
Expand All @@ -881,16 +895,9 @@ class `wcsfit.FoFClass`, associating them into matches as you go.
goodInds = selected.selected & goodShapes

isStar = np.ones(goodInds.sum())
extensionIndex = np.flatnonzero((extensionInfo.visit == visit)
& (extensionInfo.detector == detector))[0]
detectorIndex = extensionInfo.detectorIndex[extensionIndex]
visitIndex = extensionInfo.visitIndex[extensionIndex]

sourceIndices[extensionIndex] = goodInds

wcs = extensionInfo.wcs[extensionIndex]
associations.reprojectWCS(wcs, fieldIndex)

associations.addCatalog(wcs, 'STELLAR', visitIndex, fieldIndex,
instrumentIndex, detectorIndex, extensionIndex, isStar,
detectorSources[goodInds]['x'].to_list(),
Expand Down

0 comments on commit 6b1ff94

Please sign in to comment.