subroutine emdiag Read the file names of input and output files Open files Get keyword values parameters read : choice of sub_tasks to execute Loop over input task parameters Read the task parameter / yes to perform the procedure, no not to perform it / End loop Read CCD map SUBROUTINE OFFSET if offset requested then mask out pixels with significant signal compute mean over rows and columns if selectfov then mask out pixels outside the field of view for all rows/columns with more than 4 pixels left recompute offset endif compute variance else read offsets from offset/variance file endif SUBROUTINE EDUSOFT if edusoft requested then simulate EDU action simulate EMDH thresholding mask out pixels belonging to valid events endif SUBROUTINE THRESH if thresh requested then subtract offsets identify pixels above EMDH lower threshold mask them out in map endif Write output files Close files end subroutine emdiag