def p60photsub(ofile, inlis, refimage, refstars, ot, filter): refstars.set_mag(filter) coofile=open('ot.coo','w') ot.wcs2pix(refimage) coofile.write('%10.3f%10.3f\n' % (ot[0].xval, ot[0].yval)) coofile.close() outfile=open(ofile, 'a+') p60photutils.p60zeropt(inlis, refstars, filter) subimage=iraffiles('@%s' % inlis) for image in subimage: root,ext=image.split('.') iraf.phot('%s.sub' % root, coo='ot.coo', output='%s.grb' % root, interac=no) stars=Starlist('%s.mag' % root) refstars.wcs2pix(image) zp,zpu=stars.zeropt(refstars,method='mean',rejout=0) otstars=Starlist('%s.grb' % root) [mjd,utshut]=get_head(image,['OBSMJD','UTSHUT']) if (len(stars)>0): outfile.write('%s\t%s\t%.3f\t%.3f\t%.3f\t%.3f\n' % (mjd, utshut, otstars[0].mag+zp, sqrt(pow(zpu,2)+pow(otstars[0].magu,2)), otstars[0].magu, zpu)) outfile.close()
def p60sdssresults(inlis, outfile, object, filter, reflist, aperture=10.0): images = iraffiles(inlis) images.sort() outf = open(outfile, 'w') inf = open('%s.lis' % object, 'w') inf.write('%s-%s.fits' % (object, filter)) inf.close() iraf.phot.apertures = aperture refstars = Starlist(reflist) p60photutils.p60zeropt('%s.lis' % object, refstars, '%sMAG' % filter[0].upper()) stars = Starlist('%s-%s.mag' % (object, filter)) zp, zpu = stars.zeropt(refstars, method='mean', rejout=0) for image in images: root = image.split('.')[0] stars = Starlist('%s.mag' % root) [utshut, obsmjd, exptime] = get_head(image, ['UTSHUT', 'OBSMJD', 'EXPTIME']) # If well-detected, use mag/err from IRAF file if (len(stars) == 1) and (float(stars[0].magu) < 0.2): snmag = float(stars[0].mag) + zp snerr = sqrt(pow(float(stars[0].magu), 2) + pow(max(zpu, 0.03), 2)) # For weak detection, provide upper limit elif (len(stars) == 1): magfile = open("%s.mag" % root) lines = magfile.readlines() sky = float(lines[len(lines) - 3].strip().split()[0]) flux = float(lines[len(lines) - 1].strip().split()[3]) npix = float(lines[len(lines) - 1].strip().split()[2]) skystd = float(lines[len(lines) - 3].strip().split()[1]) exp = float(lines[len(lines) - 2].strip().split()[0]) if (flux > 0): flxerr = sqrt(flux + npix * pow(skystd, 2)) snmag = -2.5 * log10((flux + 5.0 * flxerr) / exp) + 25.0 + zp else: flxerr = sqrt(npix) * skystd snmag = -2.5 * log10(5.0 * fluxerr / exp) + 25.0 + zp snerr = 99.00 # For bad subtraction, just give -1.0 else: snmag = -1.0 snerr = -1.0 outf.write('%s\t%15.7f%7.2f%10.2f%10.3f\n' % (utshut, float(obsmjd), exptime, snmag, snerr)) outf.close()
def p60sdssresults(inlis, outfile, object, filter, reflist, aperture=10.0): images=iraffiles(inlis) images.sort() outf=open(outfile,'w') inf=open('%s.lis' % object, 'w') inf.write('%s-%s.fits' % (object, filter)) inf.close() iraf.phot.apertures=aperture refstars=Starlist(reflist) p60photutils.p60zeropt('%s.lis' % object, refstars, '%sMAG' % filter[0].upper()) stars=Starlist('%s-%s.mag' % (object,filter)) zp,zpu = stars.zeropt(refstars,method='mean',rejout=0) for image in images: root=image.split('.')[0] stars=Starlist('%s.mag' % root) [utshut,obsmjd,exptime] = get_head(image, ['UTSHUT','OBSMJD','EXPTIME']) # If well-detected, use mag/err from IRAF file if (len(stars)==1) and (float(stars[0].magu) < 0.2): snmag = float(stars[0].mag)+zp snerr = sqrt(pow(float(stars[0].magu),2)+pow(max(zpu,0.03),2)) # For weak detection, provide upper limit elif (len(stars)==1): magfile = open("%s.mag" % root) lines=magfile.readlines() sky = float(lines[len(lines)-3].strip().split()[0]) flux = float(lines[len(lines)-1].strip().split()[3]) npix = float(lines[len(lines)-1].strip().split()[2]) skystd = float(lines[len(lines)-3].strip().split()[1]) exp = float(lines[len(lines)-2].strip().split()[0]) if (flux > 0): flxerr = sqrt(flux + npix * pow(skystd,2)) snmag = -2.5 * log10((flux + 5.0 * flxerr) / exp) + 25.0 + zp else: flxerr = sqrt(npix) * skystd snmag = -2.5 * log10(5.0 * fluxerr / exp) + 25.0 + zp snerr = 99.00 # For bad subtraction, just give -1.0 else: snmag = -1.0; snerr = -1.0 outf.write('%s\t%15.7f%7.2f%10.2f%10.3f\n' % (utshut, float(obsmjd), exptime, snmag, snerr)) outf.close()
def p60photsub(ofile, inlis, refimage, refstars, ot, filter): refstars.set_mag(filter) coofile = open('ot.coo', 'w') ot.wcs2pix(refimage) coofile.write('%10.3f%10.3f\n' % (ot[0].xval, ot[0].yval)) coofile.close() outfile = open(ofile, 'a+') p60photutils.p60zeropt(inlis, refstars, filter) subimage = iraffiles('@%s' % inlis) for image in subimage: root, ext = image.split('.') iraf.phot('%s.sub' % root, coo='ot.coo', output='%s.grb' % root, interac=no) stars = Starlist('%s.mag' % root) refstars.wcs2pix(image) zp, zpu = stars.zeropt(refstars, method='mean', rejout=0) otstars = Starlist('%s.grb' % root) [mjd, utshut] = get_head(image, ['OBSMJD', 'UTSHUT']) if (len(stars) > 0): outfile.write('%s\t%s\t%.3f\t%.3f\t%.3f\t%.3f\n' % (mjd, utshut, otstars[0].mag + zp, sqrt(pow(zpu, 2) + pow(otstars[0].magu, 2)), otstars[0].magu, zpu)) outfile.close()