subroutine badpix * get input events, if required, make a copy of this file * get instrument, datamode, ccdid and node from events file * get badpix modes (1,2,3)? * enter CCF, and get bad pixel list (from CCF) * if mode3 (getnewbadpix), find size of mode3 file (output from badpixfind), and check if compatible with events file * check and purge mode3 file for double entries * get total size of badpix table, combining modes 1,2 and 3 * check if badpix extension already exists, and if not, allocate columns for badpix information * fill columns with relevant mode1/mode2 (i.e.\ getuplnkbadpix/ getotherbadpix) information * as above, for mode 3 pixels (if required) * check mode 3 pixels against information in CCF * purge mode 3 entries for doubles in CCF * check each pixel for common (though not identical) entries * if filterwindow mode, filter bad pixels for entries within X/Y window * add extension to input events file, fill in badpix information * add attributes (instrument, ccdid etc) and history information end subroutine badpix