Skip to content

Commit

Permalink
debugging for a line-mask crash
Browse files Browse the repository at this point in the history
  • Loading branch information
moustakas committed Sep 25, 2024
1 parent 496ec2b commit 6769d4e
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions py/fastspecfit/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,7 @@ def one_spectrum(iobj, specdata, meta, ebv, fastphot,
for icam, camera in enumerate(specdata['cameras']):
# Check whether the camera is fully masked.
if np.sum(specdata['ivar0'][icam]) == 0:
log.warning(f'Dropping fully masked camera {camera}.')
log.warning(f'Dropping fully masked camera {camera} [specdata["uniqueid"]].')
else:
ivar = specdata['ivar0'][icam]
mask = specdata['mask0'][icam]
Expand All @@ -917,7 +917,7 @@ def one_spectrum(iobj, specdata, meta, ebv, fastphot,
ivar[mask != 0] = 0.

if np.all(ivar == 0.):
log.warning(f'Dropping fully masked camera {camera}.')
log.warning(f'Dropping fully masked camera {camera} [specdata["uniqueid"]].')
else:
# interpolate over pixels where the resolution matrix is masked
I = (mask != 0)
Expand Down Expand Up @@ -970,11 +970,14 @@ def one_spectrum(iobj, specdata, meta, ebv, fastphot,

# use the coadded spectrum to build a robust emission-line mask
LM = LineMasker(emline_table)
pix = LM.build_linemask(
specdata['coadd_wave'], specdata['coadd_flux'],
specdata['coadd_ivar'], specdata['coadd_res'],
uniqueid=specdata['uniqueid'], redshift=specdata['redshift'],
debug_plots=debug_plots)
try:
pix = LM.build_linemask(
specdata['coadd_wave'], specdata['coadd_flux'],
specdata['coadd_ivar'], specdata['coadd_res'],
uniqueid=specdata['uniqueid'], redshift=specdata['redshift'],
debug_plots=debug_plots)
except:
raise ValueError('########### LINE-MASKING PROBLEM WITH ', specdata['uniqueid'])

# Map the pixels belonging to individual emission lines onto the
# original per-camera spectra. This works, but maybe there's a better
Expand Down Expand Up @@ -1313,7 +1316,7 @@ def one_stacked_spectrum(iobj, specdata, synthphot):
for icam, camera in enumerate(specdata['cameras']):
# Check whether the camera is fully masked.
if np.sum(specdata['ivar0'][icam]) == 0:
log.warning(f'Dropping fully masked camera {camera}.')
log.warning(f'Dropping fully masked camera {camera} [specdata["uniqueid"]].')
else:
ivar = specdata['ivar0'][icam]
mask = specdata['mask0'][icam]
Expand All @@ -1327,7 +1330,7 @@ def one_stacked_spectrum(iobj, specdata, synthphot):
ivar[mask != 0] = 0

if np.all(ivar == 0):
log.warning(f'Dropping fully masked camera {camera}.')
log.warning(f'Dropping fully masked camera {camera} [specdata["uniqueid"]].')
else:
cameras.append(camera)
npixpercamera.append(len(specdata['wave0'][icam])) # number of pixels in this camera
Expand Down

0 comments on commit 6769d4e

Please sign in to comment.