示例#1
0
    def testefflam(self):
        iraf.calcphot(obsmode=self.obsmode,spectrum=self.spectrum,
                      form='photlam', func='efflerg')
        rlam=iraf.calcphot.getParam('calcphot.result',native=1)
        obs=S.Observation(self.sptest,self.bp,force=self.Extrap)
        tlam=obs.efflam()
        if rlam != 0:
            self.discrep=(tlam-rlam)/rlam
        else:
            self.discrep=tlam-rlam
        self.tra['Discrep']=self.discrep
        if abs(self.discrep)>self.superthresh:
            self.tra['Extreme']=True
        self.tra['Syn']=rlam
        self.tra['Pysyn']=tlam

        self.failUnless(abs(self.discrep) < self.thresh,msg="Discrep=%f"%self.discrep)
示例#2
0
    def testeffstim(self):
        iraf.calcphot(obsmode=self.obsmode,spectrum=self.spectrum,
                      form=self.form,func='effstim')
        rcounts=iraf.calcphot.getParam('calcphot.result',native=1)
        obs=S.Observation(self.sptest,self.bp)
        tcounts=obs.effstim(self.form)
        self.tra['Syn']=rcounts
        self.tra['Pysyn']=tcounts

        if rcounts != 0:
            self.discrep=(tcounts-rcounts)/rcounts
        else:
            self.discrep=tcounts-rcounts
        self.tra['Discrep']=self.discrep
        if abs(self.discrep)>self.superthresh:
            self.tra['Extreme']=True

        self.failUnless(abs(self.discrep) < self.thresh,msg="Discrep=%f"%self.discrep)
示例#3
0
    def testefflam(self):
        iraf.calcphot(obsmode=self.obsmode,
                      spectrum=self.spectrum,
                      form='photlam',
                      func='efflerg')
        rlam = iraf.calcphot.getParam('calcphot.result', native=1)
        obs = S.Observation(self.sptest, self.bp, force=self.Extrap)
        tlam = obs.efflam()
        if rlam != 0:
            self.discrep = (tlam - rlam) / rlam
        else:
            self.discrep = tlam - rlam
        self.tra['Discrep'] = self.discrep
        if abs(self.discrep) > self.superthresh:
            self.tra['Extreme'] = True
        self.tra['Syn'] = rlam
        self.tra['Pysyn'] = tlam

        self.failUnless(abs(self.discrep) < self.thresh,
                        msg="Discrep=%f" % self.discrep)
示例#4
0
    def testeffstim(self):
        iraf.calcphot(obsmode=self.obsmode,
                      spectrum=self.spectrum,
                      form=self.form,
                      func='effstim')
        rcounts = iraf.calcphot.getParam('calcphot.result', native=1)
        obs = S.Observation(self.sptest, self.bp)
        tcounts = obs.effstim(self.form)
        self.tra['Syn'] = rcounts
        self.tra['Pysyn'] = tcounts

        if rcounts != 0:
            self.discrep = (tcounts - rcounts) / rcounts
        else:
            self.discrep = tcounts - rcounts
        self.tra['Discrep'] = self.discrep
        if abs(self.discrep) > self.superthresh:
            self.tra['Extreme'] = True

        self.failUnless(abs(self.discrep) < self.thresh,
                        msg="Discrep=%f" % self.discrep)
示例#5
0
                    baseName, ccdint, ampint)
            else:
                print "Unrecognized file format"

            #This copies the file into a more organized way
            copyfile(filterBandFileName, newBandFileName)

            #This will prevent crashes
            try:
                #This does the calcphot
                print newBandFileName
                print calspecFileName
                print outFileName
                iraf.calcphot(newBandFileName,
                              calspecFileName,
                              'abmag',
                              out=outFileName,
                              append='yes')
            except:
                print "****Calcphot failed for star " + calspecFileName + "****"

            #This deletes the file we made
            os.remove(newBandFileName)

            #This continues the loop
            line1 = fd1.readline()

        #end while

    #end for
示例#6
0
        #print starName, iccd, filter, filterFileName, outputString

        if os.path.isfile(outputString):
            oldOutputString = outputString + "~"
            os.rename(outputString, oldOutputString)

        # Loop over filters...
        for filter in filterList:

            filterFileName = '%s/%s_band_20150601a_syn.ccd%d.fits' % (
                filterDirName, filter, iccd)

            try:
                iraf.calcphot(obsmode=filterFileName,
                              spectrum="temp.txt",
                              output=outputString,
                              form="abmag",
                              append="yes")
            except:
                print "calcphot failed skipping..."
                continue

        # endfor (filter)

    # endfor (iccd)

    os.remove('temp.txt')

# endfor (starFileName)
exit()
示例#7
0
                print tmpFilterFileName
                hdulist = pyfits.open(newBandFileName)
                hdulist[1].data[
                    'WAVELENGTH'] = hdulist[1].data['WAVELENGTH'] + angstroms
                hdulist.writeto(tmpFilterFileName, clobber=True)
                hdulist.close()

                #This will prevent crashes
                try:
                    #This does the calcphot
                    print newBandFileName
                    print calspecFileName
                    print outFileName
                    iraf.calcphot(tmpFilterFileName,
                                  calspecFileName,
                                  'abmag',
                                  out=outFileName,
                                  append='yes')
                except:
                    print "****Calcphot failed for star " + calspecFileName + "****"

                #end for

            #This deletes the file we made
            os.remove(newBandFileName)

            #This continues the loop
            line1 = fd1.readline()

        #end while
示例#8
0
    # Skip those calspec spectra that do not fully
    #  cover the range of the DES Y3A2 grizY filter
    #  standard bandpass tables...
    if ((wavemin > 3000.) or (wavemax < 11000.)):
        print 'Spectrum does not fully cover DES Y3A2 grizY filter standard bandpasses...  Skipping...'
        continue

    for band in bandList:
        print band,
        bandFileName = bandsDir + '/y3a2_std_passband_' + band + '.fits'
        print bandFileName
        try:
            iraf.calcphot(obsmode=bandFileName,
                          spectrum=specFileName,
                          out=rawOutputFile,
                          form='abmag',
                          append='yes')
        except:
            print 'Synphot command calcphot failed on this spectrum... continuing...'

# Read in rawOutputFile to create a reformatted version in CSV format...
hdulist = pyfits.open(rawOutputFile)
tbdata = hdulist[1].data

# Extact spectrum names as a list...
snameList = tbdata['TARGETID'].tolist()
snameList = [(os.path.split(sname)[1].strip()) for sname in snameList]

# Extact filter names as a list...
fnameList = tbdata['OBSMODE'].tolist()
示例#9
0
starFileNameList = [x.strip() for x in stars]

# Loop over starFileNameList...
for starFileName in starFileNameList:

    starName=starFileName.split('.newformat')[0]

    copyfile(starFileName, 'temp.fits')

    outputString = "mag." + starName + ".ugriz.fits"
    print starName, outputString
            
    #if os.path.isfile(outputString):
    #	oldOutputString = outputString + "~"
    #	os.rename(outputString, oldOutputString)

    try:
        iraf.calcphot(obsmode = "sdss,u", spectrum = "temp.fits", output = outputString, form="abmag", append="yes")
	iraf.calcphot(obsmode = "sdss,g", spectrum = "temp.fits", output = outputString, form="abmag", append="yes")
	iraf.calcphot(obsmode = "sdss,r", spectrum = "temp.fits", output = outputString, form="abmag", append="yes")
	iraf.calcphot(obsmode = "sdss,i", spectrum = "temp.fits", output = outputString, form="abmag", append="yes")
	iraf.calcphot(obsmode = "sdss,z", spectrum = "temp.fits", output = outputString, form="abmag", append="yes")
	print "success!"
    except:
        print "calcphot failed skipping..."
        continue

    os.remove('temp.fits')

exit()