Read parameters Open and read input spectrum file header Open and read QPB calibration file if (withplotfiles) open LUNs for ASCII QDP output Set outer CCFs which will be used as cognates for central CCD Read in actual input spectrum Open and read RMF Set channel ranges for several energy bands (e.g. Au contamination) do i=1,7 (nCCDs) if (selected) then Read in FOV spec for CCDi (areafov(i) and expofov(i)) endif enddo do i=1,7 (nCCDs) if (selected) then Read in FWC spec for CCDi (areafwc(i) and expofwc(i)) Normalize specFWC(1:4096,i) and specFWCunc(1:4096,i) endif enddo Remove any chip's data that has less area than limiting area do i=2,7 Object corner data if (selected) then Read in Obj Corner spec for CCDi (areacoro(i) and expocoro(i)) Calculate hardness Augment spectra Write augmented spectra to output file endif enddo if (ccd1 selected) then create mask for normalizing center chip's spectrum determine how many similar chips have data endif do i=2,7 FWC corner data if (selected) then Read in FWC Corner spec for CCDi (areafwcc(i) and expofwcc(i)) endif enddo if (ccd1 selected) then create corner spectrum for the center chip endif do i=2,7 Create ratio of obj/corner for FWC data enddo if (ccd1 selected) then Determine if center chip has gold gaps endif Create masks to remove strong instrumental lines Remove Al-Si line from all spectra do i=1,7 if (withplotfiles) write spectra to QDP output files Read in FWC images FWC images by ccd are accumulated for the output bkg image Write by ccd FWC images (e.g. mos1S001-fwcimccdN-elow-ehigh.fits) enddo if (withplotfiles) close some QDP files Search for and eliminate hot pixels if (withplotfiles) then create output bkg spec QDP file write bkg spec to QDP file close QDP file endif open output diagnostic bkg image write bkg image close bkg image Bridge the Al-Si gap Fit the spectrum (KDK: describe polfit routine here) if (withplotfiles) write the bridged spectrum to QDP Finish the bridge (KDK: describe here) if (withplotfiles) write augmented spectrum to QDP Create and open template output bkg spectrum write created bkg spectrum to FITS close FITS