Skip to content

Commit

Permalink
fix input formatting bug to calwf3 executables (#13)
Browse files Browse the repository at this point in the history
* fixed input string bug for calwf3 executable calls
  • Loading branch information
sosey committed Nov 16, 2016
1 parent 62442b9 commit 38e8687
Show file tree
Hide file tree
Showing 9 changed files with 121 additions and 30 deletions.
6 changes: 4 additions & 2 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
1.3.3
1.3.4
-----
- bugfix for input string to calwf3 executables

1.3.3
-----
This release incorporates documentations changes for CALWF3 which will increase from v3.3 to v3.4 with the installation of HSTDP 2016.2 in the Space Telescope Data processing system. Included are:

- updated information on CTE correction for subarray images
Expand All @@ -10,7 +13,6 @@ This release incorporates documentations changes for CALWF3 which will increase

1.3.2
-----

- package reorganization
- addition of output capture/logging to the calwf3 executables, help display text in jupyter notebook
- moved the documentation to readthedocs and removed the local build, users will now be pointed to RTD from the display_help() function
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ all_files = 1
upload-dir = docs/_build/html
show-response = 1

[pytest]
[tool:pytest]
minversion = 2.2
norecursedirs = build docs/_build relic

Expand Down
22 changes: 15 additions & 7 deletions wfc3tools/calwf3.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def calwf3(input=None, output=None, printtime=False, save_tmp=False,
log_func=print):

call_list = ['calwf3.e']
return_code = None

if version and input is None:
call_list.append('-r')
Expand All @@ -43,12 +44,18 @@ def calwf3(input=None, output=None, printtime=False, save_tmp=False,
if not parallel:
call_list.append('-1')

infiles, dummy_out = parseinput.parseinput(input)
infiles, dummy = parseinput.parseinput(input)
if len(parseinput.irafglob(input)) == 0:
raise IOError("No valid image specified")
if len(parseinput.irafglob(input)) > 1:
raise IOError("calwf3 can only accept 1 file for"
"input at a time: {0}".format(infiles))

for image in infiles:
if not os.path.exists(image):
raise IOError('Input file not found: ' + image)
raise IOError("Input file not found: {0}".format(image))

call_list.append(','.join(infiles))
call_list.append(input)

if output:
call_list.append(str(output))
Expand All @@ -64,10 +71,11 @@ def calwf3(input=None, output=None, printtime=False, save_tmp=False,
log_func(line.decode('utf8'))

return_code = proc.wait()
ec = None
if return_code:
ec = error_code(return_code)
print(return_code)
ec = error_code(return_code)
if ec:
if ec is None:
print("Unknown return code found!")
ec = return_code
raise RuntimeError("calwf3.e exited with code {}".format(ec))


Expand Down
6 changes: 3 additions & 3 deletions wfc3tools/tests/test_calwf3.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
from wfc3tools import calwf3


def test_no_input():
def test_no_valid_input():
"""Run a very simple aliveness test."""
with pytest.raises(RuntimeError) as e:
with pytest.raises(IOError) as e:
def cal():
calwf3()
cal()
assert 'ERROR_RETURN' in str(e.value)
assert 'No valid image specified' in str(e.value)


def test_version_print():
Expand Down
4 changes: 3 additions & 1 deletion wfc3tools/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,7 @@ def error_code(code=None):

if code is None:
return codes
else:
elif code in codes:
return codes[code]
else:
return None
27 changes: 23 additions & 4 deletions wfc3tools/wf32d.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

# STSCI
from stsci.tools import parseinput
from .util import error_code
try:
from stsci.tools import teal
has_teal = True
Expand All @@ -25,6 +26,7 @@ def wf32d(input, output=None, dqicorr="PERFORM", darkcorr="PERFORM",
""" Call the wf32d.e executable."""

call_list = ['wf32d.e']
return_code = None

if verbose:
call_list += ['-v', '-t']
Expand All @@ -47,8 +49,21 @@ def wf32d(input, output=None, dqicorr="PERFORM", darkcorr="PERFORM",
if (photcorr == "PERFORM"):
call_list.append('-phot')

infiles, dummpy_out = parseinput.parseinput(input)
call_list.append(','.join(infiles))
infiles, dummy = parseinput.parseinput(input)
if "_asn" in input:
raise IOError("wf32d does not accept association tables")
if len(parseinput.irafglob(input)) == 0:
raise IOError("No valid image specified")
if len(parseinput.irafglob(input)) > 1:
raise IOError("wf32d can only accept 1 file for"
"input at a time: {0}".format(infiles))

for image in infiles:
if not os.path.exists(image):
raise IOError("Input file not found: {0}".format(image))

call_list.append(input)

if output:
call_list.append(str(output))

Expand All @@ -62,8 +77,12 @@ def wf32d(input, output=None, dqicorr="PERFORM", darkcorr="PERFORM",
log_func(line.decode('utf8'))

return_code = proc.wait()
if return_code != 0:
raise RuntimeError("calwf3.e exited with code {}".format(return_code))
ec = error_code(return_code)
if return_code:
if ec is None:
print("Unknown return code found!")
ec = return_code
raise RuntimeError("wf32d.e exited with code {}".format(ec))


def help(file=None):
Expand Down
26 changes: 23 additions & 3 deletions wfc3tools/wf3ccd.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

# STSCI
from stsci.tools import parseinput
from .util import error_code

try:
from stsci.tools import teal
has_teal = True
Expand All @@ -26,6 +28,7 @@ def wf3ccd(input, output=None, dqicorr="PERFORM", atodcorr="PERFORM",
"""Run the ``wf3ccd.e`` executable as from the shell."""

call_list = ['wf3ccd.e']
return_code = None

if verbose:
call_list += ['-v', '-t']
Expand All @@ -45,8 +48,21 @@ def wf3ccd(input, output=None, dqicorr="PERFORM", atodcorr="PERFORM",
if (flashcorr == "PERFORM"):
call_list.append('-flash')

infiles, dummpy_out = parseinput.parseinput(input)
call_list.append(','.join(infiles))
infiles, dummy = parseinput.parseinput(input)
if "_asn" in input:
raise IOError("wf3ccd does not accept association tables")
if len(parseinput.irafglob(input)) == 0:
raise IOError("No valid image specified")
if len(parseinput.irafglob(input)) > 1:
raise IOError("wf3ccd can only accept 1 file for"
"input at a time: {0}".format(infiles))

for image in infiles:
if not os.path.exists(image):
raise IOError("Input file not found: {0}".format(image))

call_list.append(input)

if output:
call_list.append(str(output))

Expand All @@ -60,8 +76,12 @@ def wf3ccd(input, output=None, dqicorr="PERFORM", atodcorr="PERFORM",
log_func(line.decode('utf8'))

return_code = proc.wait()
ec = error_code(return_code)
if return_code:
raise RuntimeError("wf3ccd.e exited with code {}".format(return_code))
if ec is None:
print("Unknown return code found!")
ec = return_code
raise RuntimeError("wf3ccd.e exited with code {}".format(ec))


def help(file=None):
Expand Down
27 changes: 23 additions & 4 deletions wfc3tools/wf3ir.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

# STSCI
from stsci.tools import parseinput
from .util import error_code
try:
from stsci.tools import teal
has_teal = True
Expand All @@ -23,12 +24,26 @@ def wf3ir(input, output=None, verbose=False, quiet=True, log_func=print):
"""Call the wf3ir.e executable """

call_list = ['wf3ir.e']
return_code = None

if verbose:
call_list += ['-v', '-t']

infiles, dummpy_out = parseinput.parseinput(input)
call_list.append(','.join(infiles))
infiles, dummy = parseinput.parseinput(input)
if "_asn" in input:
raise IOError("wf3ir does not accept association tables")
if len(parseinput.irafglob(input)) == 0:
raise IOError("No valid image specified")
if len(parseinput.irafglob(input)) > 1:
raise IOError("wf3ir can only accept 1 file for"
"input at a time: {0}".format(infiles))

for image in infiles:
if not os.path.exists(image):
raise IOError("Input file not found: {0}".format(image))

call_list.append(input)

if output:
call_list.append(str(output))

Expand All @@ -42,8 +57,12 @@ def wf3ir(input, output=None, verbose=False, quiet=True, log_func=print):
log_func(line.decode('utf8'))

return_code = proc.wait()
if return_code != 0:
raise RuntimeError("wf3ir.e exited with code {}".format(return_code))
ec = error_code(return_code)
if return_code:
if ec is None:
print("Unknown return code found!")
ec = return_code
raise RuntimeError("wf3ir.e exited with code {}".format(ec))


def run(configobj=None):
Expand Down
31 changes: 26 additions & 5 deletions wfc3tools/wf3rej.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

# STSCI
from stsci.tools import parseinput
from .util import error_code

try:
from stsci.tools import teal
has_teal = True
Expand All @@ -26,10 +28,25 @@ def wf3rej(input, output="", crrejtab="", scalense="", initgues="",
"""call the calwf3.e executable"""

call_list = ["wf3rej.e"]
return_code = None

infiles, dummy = parseinput.parseinput(input)
if "_asn" in input:
raise IOError("wf3rej does not accept association tables")
if len(parseinput.irafglob(input)) == 0:
raise IOError("No valid image specified")
if len(parseinput.irafglob(input)) > 1:
raise IOError("wf3rej can only accept 1 file for"
"input at a time: {0}".format(infiles))

for image in infiles:
if not os.path.exists(image):
raise IOError("Input file not found: {0}".format(image))

call_list.append(input)

infiles, dummy_out = parseinput.parseinput(input)
call_list.append(','.join(infiles))
call_list.append(str(output))
if output:
call_list.append(str(output))

if verbose:
call_list.append("-v")
Expand Down Expand Up @@ -96,8 +113,12 @@ def wf3rej(input, output="", crrejtab="", scalense="", initgues="",
log_func(line.decode('utf8'))

return_code = proc.wait()
if return_code != 0:
raise RuntimeError("wf3rej.e exited with code {}".format(return_code))
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))


def help(file=None):
Expand Down

0 comments on commit 38e8687

Please sign in to comment.