Skip to content

Commit

Permalink
Merge pull request #2053 from desihub/tsnr_nan
Browse files Browse the repository at this point in the history
avoid TSNR,EFFTIME NaN
  • Loading branch information
sbailey committed May 26, 2023
2 parents d2df543 + e82cc86 commit 52ae484
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
13 changes: 12 additions & 1 deletion py/desispec/exposure_qa.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def get_qa_params() :
_qa_params = yaml.safe_load(f)
return _qa_params

def compute_exposure_qa(night, expid, specprod_dir):
def compute_exposure_qa(night, expid, specprod_dir=None):
"""
Computes the exposure_qa
Expand All @@ -48,6 +48,9 @@ def compute_exposure_qa(night, expid, specprod_dir):

log=get_logger()

if specprod_dir is None:
specprod_dir = specprod_root()

##################################################################
qa_params=get_qa_params()["exposure_qa"]
##################################################################
Expand Down Expand Up @@ -331,6 +334,14 @@ def compute_exposure_qa(night, expid, specprod_dir):
tsnr2_for_efftime_vals += scores[tsnr2_for_efftime_key+"_"+band]
target_type=tsnr2_for_efftime_key.split("_")[1].upper()
efftime = tsnr2_to_efftime(tsnr2_for_efftime_vals,target_type)

#- Be robust to NaN and Inf; treat as efftime=0
bad = ~np.isfinite(efftime)
if np.any(bad):
nbad = np.sum(bad)
log.error(f'Petal {petal} has {nbad} NaN/Inf efftime values; setting to 0')
efftime[bad] = 0.0

fiberqa_table['EFFTIME_SPEC'][entries]=efftime
petalqa_table['EFFTIME_SPEC'][petal]=np.median(efftime)

Expand Down
3 changes: 2 additions & 1 deletion py/desispec/tsnr.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,8 @@ def fb_rdnoise(fibers, frame, tset):
xtrans = ccdsizes[0] / 2.
ytrans = ccdsizes[1] / 2.

rdnoise = np.zeros_like(frame.flux)
#- default to a huge readnoise for traces off of amps
rdnoise = np.zeros_like(frame.flux) + 1000

amp_ids = desispec.preproc.get_amp_ids(frame.meta)
amp_sec = { amp : desispec.preproc.parse_sec_keyword(frame.meta['CCDSEC'+amp]) for amp in amp_ids }
Expand Down

0 comments on commit 52ae484

Please sign in to comment.