Skip to content

Commit

Permalink
only count bad readnoise on amps not already flagged as bad
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephen Bailey authored and Stephen Bailey committed May 3, 2024
1 parent 39b053b commit 624c698
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion py/desispec/scripts/proc.py
Original file line number Diff line number Diff line change
Expand Up @@ -689,16 +689,20 @@ def main(args=None, comm=None):

#- Check if a noisy amp might have corrupted this PSF;
#- if so, rename to *.badreadnoise
#- Only do this for amps not already pre-flagged as bad
#- Currently the data is flagged per amp (25% of pixels), but do
#- more generic test for 12.5% of pixels (half of one amp)
log.info(f'Rank {rank} checking for noisy input CCD amps')
preprocfile = findfile('preproc', args.night, args.expid, camera, readonly=True)
mask = fitsio.read(preprocfile, 'MASK')
noisyfrac = np.sum((mask & ccdmask.BADREADNOISE) != 0) / mask.size
pix_goodamp = (mask & ccdmask.BADAMP) == 0
pix_badnoise = (mask & ccdmask.BADREADNOISE) != 0
noisyfrac = np.sum(pix_badnoise & pix_goodamp) / np.sum(pix_goodamp)
if noisyfrac > 0.25*0.5:
log.error(f"{100*noisyfrac:.0f}% of {camera} input pixels have bad readnoise; don't use this PSF")
if os.path.exists(inpsf):
os.rename(inpsf, inpsf+'.badreadnoise')
error_count += 1
continue

log.info(f'Rank {rank} interpolating {camera} PSF over bad fibers')
Expand Down
2 changes: 1 addition & 1 deletion py/desispec/scripts/proc_joint_fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ def main(args=None, comm=None):
log.error(f'Rank {rank} failed to create {psfnightfile}')
num_err += 1
else:
log.info(f"Fewer than 3 {camera} psfs were provided, can't compute psfnight. Exiting ...")
log.error(f"Fewer than 3 {camera} psfs were provided, can't compute psfnight. Exiting ...")
num_cmd += 1
num_err += 1

Expand Down

0 comments on commit 624c698

Please sign in to comment.