Skip to content

Commit

Permalink
Merge pull request #22 from mcara/update-bitmask
Browse files Browse the repository at this point in the history
Update acstools to the latest bitmask in stsci.tools
  • Loading branch information
mcara committed Mar 22, 2017
2 parents b16704f + a695686 commit 125ed47
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
17 changes: 13 additions & 4 deletions acstools/acs_destripe.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,9 +549,17 @@ def perform_correction(image, output, stat="pmode1", maxiter=15, sigrej=2.0,


def _mergeUserMaskAndDQ(dq, mask, dqbits):
from stsci.tools import bitmask # Optional package dependency
# Optional package dependency
try:
from stsci.tools.bitmask import (interpret_bit_flags,
bitfield_to_boolean_mask)
except ImportError:
from stsci.tools.bitmask import (
interpret_bits_value as interpret_bit_flags,
bitmask2mask as bitfield_to_boolean_mask
)

dqbits = bitmask.interpret_bits_value(dqbits)
dqbits = interpret_bit_flags(dqbits)
if dqbits is None:
if mask is None:
return None
Expand All @@ -561,8 +569,9 @@ def _mergeUserMaskAndDQ(dq, mask, dqbits):
if dq is None:
raise ValueError("DQ array is None while 'dqbits' is not None.")

dqmask = bitmask.bitmask2mask(bitmask=dq, ignore_bits=dqbits,
good_mask_value=1, dtype=np.uint8)
dqmask = bitfield_to_boolean_mask(dq, ignore_bits=dqbits,
good_mask_value=1, dtype=np.uint8)

if mask is None:
return dqmask

Expand Down
9 changes: 7 additions & 2 deletions acstools/acs_destripe_plus.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,12 @@ def destripe_plus(inputfile, suffix='strp', stat='pmode1', maxiter=15,
"""
# Optional package dependencies
from stsci.tools import parseinput
from stsci.tools import bitmask
try:
from stsci.tools.bitmask import interpret_bit_flags
except ImportError:
from stsci.tools.bitmask import (
interpret_bits_value as interpret_bit_flags
)

# process input file(s) and if we have multiple input files - recursively
# call acs_destripe_plus for each input image:
Expand Down Expand Up @@ -416,7 +421,7 @@ def destripe_plus(inputfile, suffix='strp', stat='pmode1', maxiter=15,
acsccd.acsccd(inputfile)

# modify user mask with DQ masks if requested
dqbits = bitmask.interpret_bits_value(dqbits)
dqbits = interpret_bit_flags(dqbits)
if dqbits is not None:
# save 'tra' file in memory to trick the log file
# not to save first acs2d log as this is done only
Expand Down

0 comments on commit 125ed47

Please sign in to comment.