subroutine emldetect Read in EBOXDETECT source list (map detect) and sort by source count rate Loop over sorted source list (begin with brightest source): Selection of sources for simultaneous multi-source fitting: 1) Search close neighbours within source cut radius of current source. Don't consider sources which have been processed already; mark selected sources as processed. 2) Repeat (1) for each close neighbour until the maximum number of sources for simultaneous fitting (max. 8; specified in parameter file) is reached. I.e., the selection of additional sources for the multi-source fitting terminates when either the maximum number of sources (parameter max_fit) is reached or when no additional sources fulfil the distance criterium (parameter scut). Determine data area (2d-mask array) to be used for multi-source fitting: Loop over mask array: Set to 1 if pixel is (a) within event cut radius of selected source and (b) within the area marked in the detection mask; set to 0 otherwise. Read in data: Fill (x, y, count) data records: Binned mode: x,y: image pixel coordinates count: number of events in pixel Single photon mode: x,y: event coordinates count:=1 Feed data records, background maps, and exposure maps into Maximum Likelihood PSF fitting algorithm: Use Marquarth-algorithm to minimize likelihood function of multi-source PSF fit. Remove sources from fit which do not significantly improve goodness of fit (required improvement in likelihood specified by parameter mlmin). Set source extent to 0 if extent does not significantly improve goodness of fit (required improvement in likelihood specified by parameter dmlextmin). Add best-fit source models (PSF + source extent) to background maps. I.e., sources which have already been fitted by the program are treated as background for the remaining sources. Note that the sources are processed in the order of decreasing count rate such that all the bright sources will have been modeled into the background map once the weak sources are processed. If likelihood of detection exceeds threshold THEN Write source parameters to EMLDETECT source list. Add fluxes and hardness ratios. END IF END Loop end subroutine emldetect