pixreplace: Replace pixels which have one value with another value

This task allows a user to replace pixels in an image or set of images which have one value with a new value; for example, replace all NaNs with a value of -999.9.

Pixreplace – Replace pixels which have one value with another value

License:

License

drizzlepac.pixreplace.replace(input, **pars)[source]

Replace pixels in input that have a value of pixvalue with a value given by newvalue.

Parameters:
inputstr, @-file, list of filenames

Filename(s) of image to be processed.

pixvaluefloat

Pixel value from input file to be replaced. [Default: np.nan]

newvaluefloat

New pixel value to use to replace pixvalue. [Default: 0.0]

extint, list of ints, None

Extensions from input file to process with new pixel values. If None (default), all image extensions (and only image extensions) will be processed.

Notes

It can be called from within Python using the syntax:

>>> from drizzlepac import pixreplace
>>> pixreplace.replace('adriz_nanSCI_drz.fits')
or
>>> epar pixreplace

Examples

These examples show how this function can be used in a few different ways.

  1. Replace all pixels in all extensions which have a value of NaN in ‘adriz_nanSCI_drz.fits’ with a constant value of 0.0.

    >>> from drizzlepac import pixreplace
    >>> pixreplace.replace('adriz_nanSCI_drz.fits')
    
  2. Replace pixels in first extension only which have a value of NaN in both ‘j8c061vnq_drc.fits’ and ‘j8c061nyq_drc.fits’ with a constant value of 0.0.

    >>> pixreplace.replace('j8c061vnq_drc.fits,j8c061nyq_drc.fits', ext=1)
    
  3. Replace pixels in first and fourth extensions which have a value of 0.0 in ‘adriz_nanSCI_drz.fits’ with a value of -999.

    >>> pixreplace.replace('adriz_nanSCI_drz.fits',pixvalue=0.0, newvalue=-999, ext=[1,4])
    
drizzlepac.pixreplace.help(file=None)

Print out syntax help for running pixreplace.

Parameters:
filestr (Default = None)

If given, write out help to the filename specified by this parameter Any previously existing file with this name will be deleted before writing out the help.