DifferentialPhotometry_functions_student.py
def runDifferentialPhotometry(photometry, ephotometry, nstars, most_accurate):
    '''
    runDifferentialPhotometry
    
    as the name says!
    
    inputs
    ----------
    Photometry: list - list of photometric values from detrend() function
    ePhotometry: list - list of photometric error values
    nstars: float - number of stars 
    most_accurate: list - list of indices of non variable comparison stars
    
    outputs
    ---------
    dPhotometry: list - differential photometry list
    edPhotometry: list - scaling factors to photometry error
    tePhotometry: list - differential photometry error
    
    '''
    
    #mask bad photometry
    Photometry = ma.masked_where(photometry <= 0, photometry)
    ePhotometry = ma.masked_where(photometry <= 0, ephotometry)
    
    
    #number of nights of photometry
    nimages = len(Photometry)
    
    #range of number of nights
    imgindex = np.arange(0,nimages,1)

    #create lists for diff photometry
    dPhotometry = ma.ones([nimages, len(Photometry[0])])
    edPhotometry = ma.ones([nimages, len(Photometry[0])])
    eedPhotometry = ma.ones([nimages, len(Photometry[0])])
    tePhotometry = ma.ones([nimages, len(Photometry[0])])
    
    checknum = np.linspace(0,nstars,10).astype(int)

    for star in np.arange(nstars):
        if star in checknum:
            print('running differential photometry on star: ', star+1, '/', nstars)
        starPhotometry = Photometry[:,star]
        starPhotometryerr = ePhotometry[:,star]
         #create temporary photometry list for each comparison star
        tmp_phot = ma.ones([nimages,len(most_accurate)])
        #go through comparison stars and determine differential photometry
        for ind, i in enumerate(most_accurate):
             #pull out each star's photometry + error Photometry for each night and place in list 
            compStarPhotometry = Photometry[:,i]
             #calculate differential photometry
            tmp = starPhotometry*ma.median(compStarPhotometry)/(compStarPhotometry*ma.median(starPhotometry))
            tmp_phot[:,ind] = tmp
        
        #median combine differential photometry found with each comparison star for every other star
        dPhotometry[:,star] = ma.median(tmp_phot,axis=1)

        # apply final scaling factors to the photometric error
        edPhotometry[:,star] = starPhotometryerr*(ma.median(tmp_phot,axis=1)/starPhotometry)
        
        # the differential photometry error
        eedPhotometry[:,star] = ma.std(tmp_phot,axis=1)

        # the differential photometry error
        tePhotometry[:,star] = ((starPhotometryerr*(ma.median(tmp_phot,axis=1)/starPhotometry))**2. + (ma.std(tmp_phot,axis=1))**2.)**0.5

    return dPhotometry, edPhotometry, tePhotometry

    runDifferentialPhotometry
    
    as the name says!
    
    inputs
    ----------
    Photometry: list - list of photometric values from detrend() function
    ePhotometry: list - list of photometric error values
    nstars: float - number of stars 
    most_accurate: list - list of indices of non variable comparison stars
    
    outputs
    ---------
    dPhotometry: list - differential photometry list
    edPhotometry: list - scaling factors to photometry error
    tePhotometry: list - differential photometry error
    
    
runDifferentialPhotometry
as the name says!

inputs

list of photometric values from detrend() function
ePhotometry: list - list of photometric error values
nstars: float - number of stars
most_accurate: list - list of indices of non variable comparison stars

outputs

differential photometry list
edPhotometry: list - scaling factors to photometry error
tePhotometry: list - differential photometry error
runDifferentialPhotometry as the name says! inputs list of photometric values from detrend () function ePhotometry : list - list of photometric error values nstars : float - number of stars most_accurate : list - list of indices of non variable comparison stars outputs differential photometry list edPhotometry : list - scaling factors to photometry error tePhotometry : list - differential photometry error
def runDifferentialPhotometry(photometry, ephotometry, nstars, most_accurate):
    Photometry = ma.masked_where(photometry <= 0, photometry)
    ePhotometry = ma.masked_where(photometry <= 0, ephotometry)
    nimages = len(Photometry)
    imgindex = np.arange(0,nimages,1)
    dPhotometry = ma.ones([nimages, len(Photometry[0])])
    edPhotometry = ma.ones([nimages, len(Photometry[0])])
    eedPhotometry = ma.ones([nimages, len(Photometry[0])])
    tePhotometry = ma.ones([nimages, len(Photometry[0])])
    checknum = np.linspace(0,nstars,10).astype(int)
    for star in np.arange(nstars):
        if star in checknum:
            print('running differential photometry on star: ', star+1, '/', nstars)
        starPhotometry = Photometry[:,star]
        starPhotometryerr = ePhotometry[:,star]
        tmp_phot = ma.ones([nimages,len(most_accurate)])
        for ind, i in enumerate(most_accurate):
            compStarPhotometry = Photometry[:,i]
            tmp = starPhotometry*ma.median(compStarPhotometry)/(compStarPhotometry*ma.median(starPhotometry))
            tmp_phot[:,ind] = tmp
        dPhotometry[:,star] = ma.median(tmp_phot,axis=1)
        edPhotometry[:,star] = starPhotometryerr*(ma.median(tmp_phot,axis=1)/starPhotometry)
        eedPhotometry[:,star] = ma.std(tmp_phot,axis=1)
        tePhotometry[:,star] = ((starPhotometryerr*(ma.median(tmp_phot,axis=1)/starPhotometry))**2. + (ma.std(tmp_phot,axis=1))**2.)**0.5
    return dPhotometry, edPhotometry, tePhotometry
def runDifferentialPhotometry ( photometry , ephotometry , nstars , most_accurate ) : Photometry = ma . masked_where ( photometry <= 0 , photometry ) ePhotometry = ma . masked_where ( photometry <= 0 , ephotometry ) nimages = len ( Photometry ) imgindex = np . arange ( 0 , nimages , 1 ) dPhotometry = ma . ones ( [ nimages , len ( Photometry [ 0 ] ) ] ) edPhotometry = ma . ones ( [ nimages , len ( Photometry [ 0 ] ) ] ) eedPhotometry = ma . ones ( [ nimages , len ( Photometry [ 0 ] ) ] ) tePhotometry = ma . ones ( [ nimages , len ( Photometry [ 0 ] ) ] ) checknum = np . linspace ( 0 , nstars , 10 ) . astype ( int ) for star in np . arange ( nstars ) : if star in checknum : print ( 'running differential photometry on star: ' , star + 1 , '/' , nstars ) starPhotometry = Photometry [ : , star ] starPhotometryerr = ePhotometry [ : , star ] tmp_phot = ma . ones ( [ nimages , len ( most_accurate ) ] ) for ind , i in enumerate ( most_accurate ) : compStarPhotometry = Photometry [ : , i ] tmp = starPhotometry * ma . median ( compStarPhotometry ) / ( compStarPhotometry * ma . median ( starPhotometry ) ) tmp_phot [ : , ind ] = tmp dPhotometry [ : , star ] = ma . median ( tmp_phot , axis = 1 ) edPhotometry [ : , star ] = starPhotometryerr * ( ma . median ( tmp_phot , axis = 1 ) / starPhotometry ) eedPhotometry [ : , star ] = ma . std ( tmp_phot , axis = 1 ) tePhotometry [ : , star ] = ( ( starPhotometryerr * ( ma . median ( tmp_phot , axis = 1 ) / starPhotometry ) ) ** 2. + ( ma . std ( tmp_phot , axis = 1 ) ) ** 2. ) ** 0.5 return dPhotometry , edPhotometry , tePhotometry
runDifferentialPhotometry
as the name says!
runDifferentialPhotometry as the name says!
'''
    runDifferentialPhotometry
    
    as the name says!
    
    inputs
    ----------
    Photometry: list - list of photometric values from detrend() function
    ePhotometry: list - list of photometric error values
    nstars: float - number of stars 
    most_accurate: list - list of indices of non variable comparison stars
    
    outputs
    ---------
    dPhotometry: list - differential photometry list
    edPhotometry: list - scaling factors to photometry error
    tePhotometry: list - differential photometry error
    
    ''' #mask bad photometry #number of nights of photometry #range of number of nights #create lists for diff photometry #create temporary photometry list for each comparison star #go through comparison stars and determine differential photometry #pull out each star's photometry + error Photometry for each night and place in list  #calculate differential photometry #median combine differential photometry found with each comparison star for every other star # apply final scaling factors to the photometric error # the differential photometry error # the differential photometry error
photometry
ephotometry
nstars
most_accurate