subroutine omregion read in source list if (srcnumber > number of sources in list) issue fatal error locate the srcNumber'th source x = XPOS y = YPOS fwhm = FHWM ! obtained from source list rather than the CAL r1 = fwhm * srcRadius nearest = 1.e30 loop over all sources except the selected source if (distance to this source < nearest) then nearest = distance to this source size = fwhm of this source endif endloop if (r1 > (nearest - nfwhm * size)) then r1 = nearest - nfwhm * size warn that the size of the extraction region is begin reduced if (r1 < 0) then warn that the source is unavoidably contaminated r1 = fwhm endif rInner = r1 * bkgInner rOuter = r1 * bkgOuter ncontaminating = 0 loop over all other sources compute distance to source dist if (rInner < (dist - nfwhm * fwhm of this source) < rOuter) then store contaminating source x, y, fwhm ncontaminating++ end loop open source region file write out source region file close source region file open background region file write out background annulus loop over ncontaminating sources write out exclusion circle for this source end loop close background region file end subroutine omregion