예제 #1
0
def stack_ims(path=None,band='gp',source='NGC188',bias=None,dark=None,flat=None):

    
    if not path:
        path = set_path()

    if length(bias) == 1:
        bias = make_bias(path=path)

    if length(dark) == 1:
        dark = make_dark(path=path)

    if length(flat) == 1:
        flat = make_flat(path=path,band=band,bias=bias,dark=dark)

        
    files,sz = tp.get_files(dir=path, tag=source+'.'+band)

    # Designate reference file 
    reffile = files[sz/2]
    image0, header0 = qi.readimage(reffile)
    ysz, xsz = np.shape(image0)
    refim = h.pyfits.open(reffile)
    refh = h.pyfits.getheader(reffile)
    stack = np.zeros((xsz,ysz,sz))
    
    for i in range(sz):
        im = h.pyfits.open(files[i])
        newim = h.hcongrid((im[0].data-dark-bias)/flat, im[0].header,refh)
        stack[:,:,i] = newim
    
    final = np.median(stack, axis=2)


    return final,refh
예제 #2
0
def finish():
    files, fct = tp.get_files(dir='/home/student/nedwards/2017A*/',
                              suffix='solved.fits')
    data = reduc(files, dir='/home/student/nedwards/independent/')
    standard = standards(data)
    tabby = source(stuff, standard)
    save(tabby)
    return
예제 #3
0
def headerplot(fluxdata,ykeyword='airmass',badimindices = [],band = 'gp',titleextra = '',path = None, source = 'BD710031', bias = None, dark=None, flat=None):
    
    if not path:
        path = set_path()

    if length(bias) == 1:
        bias = make_bias(path=path)

    if length(dark) == 1:
        dark = make_dark(path=path)

    if length(flat) == 1:
        flat = make_flat(path=path,band=band,bias=bias,dark=dark)
    
    files,osz = tp.get_files(dir=path, tag=source+'.'+band)
    #remove faulty images
    sz = osz
    if len(badimindices) != 0:
        for g in range(osz):
            if g in badimindices:
                del files[g]
                sz=sz-1
    
    keyworddata = []
    headers = []
    
    #extract headers from each image
    for file in files:
        file,header = cal_image(file,plot=False,path=path,band=band,source=source,bias=bias,dark=dark,flat=flat)
        headers.append(header)
      
    #extract keyword data from each header 
    for j in range(sz):
        header = headers[j]
        keyworddata.append(header[ykeyword])
        
    #determine peak flux value, index, and its header for annotation 
    peakflux = max(fluxdata)
    peakfluxindex = fluxdata.argmax()
    keyworddataofpeakflux = keyworddata[peakfluxindex]
        
    #normalize flux data
    nfluxdata = fluxdata
    for q in range(len(fluxdata)):
        nfluxdata[q] = nfluxdata[q]/peakflux
    
    #display plot; set y axis
    plt.scatter(keyworddata,nfluxdata)
    axes = plt.gca()
    axes.set_ylim([0,1])
    
    #labels
    plt.title(ykeyword.capitalize()+' v. Flux (Band: ' + band + ')'+'\n'+'('+titleextra+')')
    plt.xlabel(ykeyword.capitalize())
    plt.ylabel('Flux')
    xcoord = keyworddataofpeakflux
    ycoord = 1
    plt.annotate('Peak Flux = '+str(peakflux), xy=(xcoord,ycoord), xytext=(xcoord ,ycoord - .05))
예제 #4
0
def display_raws(path=None,band='gp',source='BD710031'):
    
    if not path:
        path = set_path()
    
    files,sz = tp.get_files(dir=path, tag=source+'.'+band)
    
    for i in range(len(files)):
        image = fits.getdata(files[i],0)
        qi.display_image(image,fignum=i)
예제 #5
0
def make_bias(path=None):

    """
    Make master bias from raw data files
    """
    if not path:
        path = set_path()
    
    biases,bct = tp.get_files(dir=path, tag='Bias')
    masterbias = tp.master_bias(biases,outdir='./')

    return masterbias
예제 #6
0
def make_dark(path=None, bias=None):

    """
    Make master dark from raw data files
    """
    if not path:
        path = set_path()
        
    if length(bias) == 1:
        bias = make_bias(path=path)

    darks,dct = tp.get_files(dir = path,tag='Dark')
    masterdark = tp.master_dark(darks,bias=bias,outdir='./')

    return masterdark
예제 #7
0
def make_flat(path=None,band='gp',bias=None,dark=None):

    """
    Make master flat from raw data files in specified band
    """
    if not path:
        path = set_path()

    if length(bias) == 1:
        bias = make_bias(path=path)

    if length(dark) == 1:
        dark = make_dark(path=path, bias=bias)
        
    flats,ct   = tp.get_files(dir=path, tag='SkyFlat.'+band)
    masterflat = tp.master_flat(flats, bias=bias, dark=dark, outdir='./', suffix=band)

    return masterflat
예제 #8
0
def flux_all(path=None,band='gp',extraprecision=True,extraprecisionrange=100,source='BD710031',badimindices = [],bias=None,dark=None,flat=None):

    if not path:
        path = set_path()

    if length(bias) == 1:
        bias = make_bias(path=path)

    if length(dark) == 1:
        dark = make_dark(path=path)

    if length(flat) == 1:
        flat = make_flat(path=path,band=band,bias=bias,dark=dark)
        
    files,osz = tp.get_files(dir=path, tag=source+'.'+band)
    sz = osz
    #remove faulty images
    if len(badimindices) != 0:
        for g in range(osz):
            if g in badimindices:
                del files[g]
                sz=sz-1
            
    flux = []
    
    for file in files:
        image,header = cal_image(file,plot=False,path=path,band=band,source=source,bias=bias,dark=dark,flat=flat)
        w = wcs.WCS(header)
        x,y = w.all_world2pix(float(header['TARGRA']), float(header['TARGDEC']), 1)
        position = (float(x),float(y))
        if extraprecision == True:
            for k in range(extraprecisionrange):
                if check_radii(image,header,position,rin=k+10,rout=k+15) == True:
                    op_ap,xval,yval,fwhm,aspect,snrmax,totflux,totap,chisq = \
                        tp.optimal_aperture(float(x),float(y),image,[k+10,k+15],use_old=True)
                    break
        else:
            op_ap,xval,yval,fwhm,aspect,snrmax,totflux,totap,chisq = \
                    tp.optimal_aperture(float(x),float(y),image,[10,15],use_old=True)
        #print "Final aperture: " + str(op_ap)
        phot = do_phot(image,position,radius=op_ap)
        flux = np.append(flux,phot['aperture_sum_bkgsub'])
        
    return flux
예제 #9
0
image,header = qi.readimage(files[50],plot=True,siglo=2,sighi=2)
w = wcs.WCS(header)

target = SkyCoord('19 51 39.82 +48 19 55.4', unit=(u.hourangle, u.deg))
world0 = np.array([[target.ra.degree, target.dec.degree]])
pix0 = w.wcs_world2pix(world0,1) 
x0 = pix0[0,0]
y0 = pix0[0,1]

plt.figure(1)
plt.plot([x0],[y0],'y+',markersize=30)
plt.xlim(0,2048)
plt.ylim(0,2048)


darks,dct = tp.get_files(tag='Dark')
biases,bct = tp.get_files(tag='Bias')
flats,fct = tp.get_files(tag='SkyFlat')
targetfiles,tct = tp.get_files(tag='KIC10935310')

bias = tp.master_bias(biases,outdir='./Photometry/',readnoise=False)

dark = tp.master_dark(darks,bias=bias,outdir='./Photometry/')

flat = tp.master_flat(flats,bias=bias,dark=dark,outdir='./Photometry/')

cal = (image - dark - bias)/flat
qi.display_image(cal,siglo=2,sighi=2)
plt.plot([x0],[y0],'y+',markersize=30,linewidth=1e6)
plt.xlim(0,2048)
plt.ylim(0,2048)
예제 #10
0
import numpy as np
import matplotlib.pyplot as plt
import thacherphot as tp
import matplotlib as mpl
from matplotlib.dates import DayLocator, HourLocator, DateFormatter, drange
import matplotlib.gridspec as gridspec
import datetime
import jdutil
from astropysics.coords import AngularCoordinate as angcor

path = '/Users/jonswift/Astronomy/ThacherObservatory/data/22Dec2016/'


#path = '/Users/ONeill/astronomy/Data/04Dec2016/'

files,fct = tp.get_files(dir=path, prefix='WASP-50b',suffix='solved.fits')
bfiles,bct = tp.get_files(dir=path,prefix='WASP-50b',suffix='bias.fit')
master_bias = tp.master_bias(bfiles)

data = tp.batch_total_flux(files,object='WASP-50b',mag=11.6,SpT='g8v',bias=master_bias,
                           nearest=True,camera='iKON-L',filter='V',gain=3.0,network='swift')


#tau = data['tau']
#secz = data['secz']
#plt.clf()
#plt.ion()
#plt.figure()
#plt.plot(secz,tau,'o')
#plt.ylabel('tau')
#plt.xlabel('secz')