The procedure points the telescope slightly east of the zenith (so the dome is pointed away from the setting sun) and strives to take exposures with an average count rate of 10,000 adu's. After each exposure the telescope is offset slightly so that background stars will be eliminated by the subsequent median. If the sky is too bright, the procedure sleeps and will try again. If the sky is too dark (exposure greater than 60 seconds) the procedure exits with a non-zero code. The images are written to the files `flat$FILTERS$num.fts'. If the median is successful, the image is given a unique id using mkid and the image is copied into DATA_DIR/flats/flat$FILTERS.fts.