subroutine badpixfind * Get input file, parameters, instrument, mode, ccdid, exposure, obsid * set state of CAL * exit if no modes chosen (searchbadpix=N, userflagbadpix=N) * check userflagbadpix lists are of equal size * open output file * get uplinked bad pixels from CCF * get `image' sizes and origin values, start times and end times * form images in memory from input events file, selecting energy band if required (in case of MOS, call pattern backprojecting and selecting subroutines to get true image) * if MOS and flicker, get timestep indices - form `flicker' array * calculate and output (to screen) initial pixel statistics * if required, calculate and output (to screen) initial column statistics * call mode_1 (searchbadpix), and mode_1 column analysis (withbadcolumnsearch) (+ PSF comparison), if required. set of procedures (max/min threshold) techniques performed on image * if hot pixel found - check edge effects - compare with PSF, using only good pixels (no uplinked or found bad pixels) - return measure of comparison with PSF * if requested, perform flickering analysis (low and high count cases) * Obtain badpix set (for mode1) (RAWX, RAWY, Y-extent, fault type) * calculate and output (to screen) new pixel statistics * call mode_2, if required explicitly flag pixels as bad, the user having given RAWX, RAWY, Y-extent and type of fault as input lists * Obtain badpix set (for mode2) (RAWX, RAWY, Y-extent, fault type) * Check badpix sets (mode1 and mode2) for redundancy/duplication * calculate and output (to screen) final pixel statistics * Combine individual badpix sets into output file * Create, if required, bad pixel map (with optional FOV masking) * Add attributes and history end subroutine badpixfind