Skip to content

Commit

Permalink
Implemented changes, as appropriate, suggested by the code review.
Browse files Browse the repository at this point in the history
  • Loading branch information
mdlpstsci committed Apr 17, 2023
1 parent 493b5d8 commit 180ba7d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 17 deletions.
2 changes: 1 addition & 1 deletion docs/wfc3tools/wf3rej.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ statistical detection algorithm developed for ACS (`acsrej`), STIS (`ocrrej`),
and WFPC2 data (`crrej`), providing a well-tested and robust procedure.

First, `wf3rej` temporarily removes the sky background from each input image
(if requested via the SKYSUB in the CRREJTAB or by a parameter passed
(if specified via the SKYSUB parameter in the CRREJTAB, or by a parameter passed
to the Python script or C executable), usually computed using the mathematical
mode of each image. Sky subtraction is performed before any
statistical checks are made for cosmic rays. Next, `wf3rej` constructs an
Expand Down
26 changes: 10 additions & 16 deletions wfc3tools/wf3rej.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"""
wf3rej:
Background discussion cn the wf3rej algorithm can be found in the following locations:
https://wfc3tools.readthedocs.io/en/latest/wfc3tools/wf3rej.html,
Background discussion on the wf3rej algorithm can be found in the following locations:
https://wfc3tools.readthedocs.io/en/latest/wfc3tools/wf3rej.html, and Section 3.4.5 of
the WFC3 Data Handbook.
This routine performs the cosmic ray rejection on input FLT/FLC images and will
produce an output CRJ/CRC image. In contrast to this module, wf3rej.py, which is
Expand Down Expand Up @@ -160,17 +161,14 @@ def wf3rej(input, output, crrejtab="", scalense=0., initgues="",
if (initgues != ""):
options = ["min", "med"]
if initgues not in options:
print("Invalid option for intigues")
return ValueError
raise ValueError("Invalid option for initgues")
else:
call_list += ["-init", str(initgues)]

if (skysub != ""):
options = ["none", "mode", "median"]
if skysub not in options:
print(("Invalid skysub option: %s") % (skysub))
print(options)
return ValueError
raise ValueError(f"Invalid skysub option {options}: {skysub}")
else:
call_list += ["-sky", str(skysub)]

Expand All @@ -180,21 +178,18 @@ def wf3rej(input, output, crrejtab="", scalense=0., initgues="",
if (crradius >= 0.):
call_list += ["-radius", str(crradius)]
else:
print("Invalid crradius specified")
return ValueError
raise ValueError("Invalid crradius specified")

if (crthresh >= 0.):
call_list += ["-thresh", str(crthresh)]
else:
print("Invalid crthresh specified")
return ValueError
raise ValueError("Invalid crthresh specified")

if (badinpdq >= 0):
call_list += ["-pdq", str(badinpdq)]

else:
print("Invalid DQ value specified")
return ValueError
raise ValueError("Invalid DQ value specified")

proc = subprocess.Popen(
call_list,
Expand All @@ -209,6 +204,5 @@ def wf3rej(input, output, crrejtab="", scalense=0., initgues="",
ec = error_code(return_code)
if return_code:
if ec is None:
print("Unknown return code found!")
ec = return_code
raise RuntimeError("wf3rej.e exited with code {}".format(ec))
raise RuntimeError(f"wf3rej.e exited with unknown return code {return_code}.")
raise RuntimeError(f"wf3rej.e exited with return code {ec}.")

0 comments on commit 180ba7d

Please sign in to comment.