# Step 7: Cosmic-ray identification

The cosmic rays and bad pixels are now identified by comparing the input images with the associated blotted,median-cleaned images created.

Mask blemishes in dithered data by comparison of an image with a model image and the derivative of the model image.

Authors: | Warren Hack
License: | http://www.stsci.edu/resources/software_hardware/pyraf/LICENSE

`drizzlepac.drizCR.``createCorrFile`(outfile, arrlist, template)

  Create a _cor file with the same format as the original input image

  The DQ array will be replaced with the mask array used to create the _cor file.

`drizzlepac.drizCR.``drizCR`(input=None, configObj=None, editpars=False, **inputDict)

  The blotted median images that are now transformed back into the original reference frame, get compared to the original input images to detect any spurious pixels (which may include pixels impacted by cosmic rays) in each input. Those spurious pixels then get flagged as ‘bad’ in the output cosmic ray mask files, which get used as input for the final combination so that they do not show up in the final product. The identified bad pixels get flagged by updating the input mask files. Optionally, copies of the original images with the bad pixels removed can be created through the use of the `driz_cr_corr` parameter.

  Parameters:

  input : str or list of str (Default = None)

  > A python list of blotted median image filenames, or just a single filename.

  configObj : configObject (Default = None)

  > An instance of `configObject` which overrides default parameter settings.

  editpars : bool (Default = False)

  > A parameter that allows user to edit input parameters by hand in the GUI. True to use the GUI to edit parameters.

  inputDict : dict, optional

  > An optional list of parameters specified by the user, which can also be used to override the defaults.

  Other Parameters:

  driz_cr : bool (Default = False)

  > Perform cosmic-ray detection? If set to `True`, cosmic-rays will be detected and used to create cosmic-ray masks based on the algorithms from `deriv` and `driz_cr`.

  driz_cr_corr : bool (Default = False)

  > Create a cosmic-ray cleaned input image? I set to `True`, a cosmic-ray cleaned `_cor` image will be generated directly from the input image, and a corresponding `_crmask` file will be written to document detected pixels affected by cosmic-rays.

  driz_cr_snr : list of floats (Default = ‘3.5 3.0’)

  > The values for this parameter specify the signal-to-noise ratios for the `driz_cr` task to be used in detecting cosmic rays. See the help file for `driz_cr` for further discussion of this parameter.

  driz_cr_grow : int (Default = 1)

  > The radius, in pixels, around each detected cosmic-ray, in which more stringent detection criteria for additional cosmic rays will be used.

  driz_cr_ctegrow : int (Default = 0)

  > Length, in pixels, of the CTE tail that should be masked in the drizzled output.

  driz_cr_scale : str (Default = ‘1.2 0.7’)

  > Scaling factor applied to the derivative in `driz_cr` when detecting cosmic-rays. See the help file for `driz_cr` for further discussion of this parameter.

  Notes

  These tasks are designed to work together seemlessly when run in the full `AstroDrizzle` interface. More advanced users may wish to create specialized scripts for their own datasets, making use of only a subset of the predefined AstroDrizzle tasks, or add additional processing, which may be usefull for their particular data. In these cases, individual access to the tasks is important.

  Something to keep in mind is that the full `AstroDrizzle` interface will make backup copies of your original files and place them in the `OrIg/` directory of your current working directory. If you are working with the stand alone interfaces, it is assumed that the user has already taken care of backing up their original datafiles as the input file with be directly altered.

  Examples

  Basic example of how to call drizCR yourself from a python command line using the default parameters for the task.

      >>> from drizzlepac import drizCR
      >>> drizCR.drizCR('*flt.fits')

`drizzlepac.drizCR.``getHelpAsString`(docstring=False, show_ver=True)

  return useful help from a file in the script directory called __taskname__.help

`drizzlepac.drizCR.``help`(file=None)

  Print out syntax help for running astrodrizzle

  Parameters:

  file : str (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.

`drizzlepac.drizCR.``run`(configObj)

`drizzlepac.drizCR.``rundrizCR`(imgObjList, configObj, procSteps=None)

`drizzlepac.drizCR.``setDefaults`(configObj={})

  Return a dictionary of the default parameters which also been updated with the user overrides.