Skip to content

Commit

Permalink
Ignore nans in staticmask call to stsci.imagestats (#1909)
Browse files Browse the repository at this point in the history
  • Loading branch information
s-goldman authored Nov 6, 2024
1 parent 6d54f1d commit c4161f9
Showing 1 changed file with 14 additions and 9 deletions.
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

0 comments on commit c4161f9

Please sign in to comment.