Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore nans in staticmask call to stsci.imagestats #1909

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions drizzlepac/staticMask.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
log = logutil.create_logger(__name__, level=logutil.logging.NOTSET)


#this is called by the user
# this is called by the user
def createMask(input=None, static_sig=4.0, group=None, editpars=False, configObj=None, **inputDict):
""" The user can input a list of images if they like to create static masks
as well as optional values for static_sig and inputDict.
Expand All @@ -53,7 +53,7 @@ def createMask(input=None, static_sig=4.0, group=None, editpars=False, configObj
if not editpars:
run(configObj)

#this is called by the TEAL interface
# this is called by the TEAL interface
def run(configObj):

#now we really just need the imageObject list created for the dataset
Expand All @@ -63,7 +63,7 @@ def run(configObj):
createStaticMask(imageObjList,configObj)


#this is the workhorse function called by MultiDrizzle
# this is the workhorse function called by MultiDrizzle
def createStaticMask(imageObjectList=[],configObj=None,procSteps=None):
if procSteps is not None:
procSteps.addStep('Static Mask')
Expand Down Expand Up @@ -167,7 +167,7 @@ def addMember(self, imagePtr=None):
if chips is None:
chips = imagePtr.getExtensions()

#for chip in range(1,numchips+1,1):
# for chip in range(1,numchips+1,1):
for chip in chips:
chipid=imagePtr.scienceExt + ','+ str(chip)
chipimage=imagePtr.getData(chipid)
Expand All @@ -186,8 +186,13 @@ def addMember(self, imagePtr=None):
maskname = self.masknames[s]
break
imagePtr[chipid].outputNames['staticMask'] = maskname

stats = ImageStats(chipimage,nclip=3,fields='mode')
stats = ImageStats(
chipimage,
nclip=3,
fields="mode",
lower=np.nanmin(chipimage),
upper=np.nanmax(chipimage),
)
mode = stats.mode
rms = stats.stddev
nbins = len(stats.histogram)
Expand Down Expand Up @@ -259,10 +264,10 @@ def saveToFile(self,imageObjectList):
virtual = imageObjectList[0].inmemory

for key in self.masklist.keys():
#check to see if the file already exists on disk
# check to see if the file already exists on disk
filename = self.masknames[key]
#create a new fits image with the mask array and a standard header
#open a new header and data unit
# create a new fits image with the mask array and a standard header
# open a new header and data unit
newHDU = fits.PrimaryHDU()
newHDU.data = self.masklist[key]

Expand Down
Loading