def run_apsum(twodimage,refimage,spectrum,customRun=False): # this resets the parameters of apextract.apsum apextract.apsum.unlearn() apextract.apsum.interactive='no' # non-interactive apextract.apsum.review='no' apextract.apsum.background='none' apextract.apsum.format='multispec' # apextract.apsum.clean='yes' # apextract.apsum.weights='variance' apextract.apsum.nsum=50 apextract.apsum.lsigma=2.0 apextract.apsum.usigma=2.0 # need to specify extraction extension (1, not 0) since there are 2 twodimage = twodimage+'[1]' # This runs apextract.apsum apextract.apsum(input=twodimage,output=spectrum,references=refimage)
def run_apsumSci(inputimage,refimage,spectrum,customRun=False): # this resets the parameters of apextract.apsum apextract.apsum.unlearn() apextract.apsum.interactive='no' # non-interactive apextract.apsum.review='no' apextract.apsum.background='fit' # we want the background subtracted for science apextract.apsum.extras = 'yes' # we want the additional spectral bands (sky (3), sigma (4) especially) apextract.apsum.format='multispec' apextract.apsum.clean='yes' # we want cosmic rays and bad pixels cleaned for science apextract.apsum.weights='variance' # we want a weighted extraction for science apextract.apsum.pfit='fit1d' apextract.apsum.nsum=-1000 # should deal with bright and faint spectra equally well apextract.apsum.lsigma=2.0 apextract.apsum.usigma=2.0 # this sets the gain parameter as specified in inputimage's 0-header hduin = pyfits.open(inputimage[:len(inputimage)-3]) # pyfits open fits file, not fits[1] "file" hdr = hduin[0].header thisgain = hdr.get('GAIN',1.0) # default for our usual SALT long-slit spectroscopy settings hduin.close() apextract.apsum.gain=thisgain # This runs apextract.apsum apextract.apsum(input=inputimage,output=spectrum,references=refimage)