Spring2020/PythonPhotometry/Sarah_DiffPhotometry.py
def findComparisonStars(Photometry, cPhotometry, accuracy_threshold = 0.2, plot=True,comp_num=6): #0.025
    '''
    findComparisonStars*
    
    finds stars that are similar over the various nights to use as comparison stars
    
    inputs
    --------
    Photometry: list - photometric values taken from detrend() function. 
    cPhotometry: list - detrended photometric values from detrend() function
    accuracy_threshold: float - level of accuracy in fluxes between various nights
    plot: boolean - True/False plot various stars and highlight comparison stars

    outputs
    --------
    most_accurate: list - list of indices of the locations in Photometry which have the best stars to use as comparisons
    '''

    BinStars,LeastVariable = CaliforniaCoast(Photometry,cPhotometry,comp_num=comp_num)

    star_err = np.nanstd(cPhotometry, axis=0)

    if plot:
        xvals = np.log10(np.nanmedian(Photometry,axis=0))
        yvals = np.log10(np.nanstd(cPhotometry, axis=0))

        plt.figure()
        plt.scatter(xvals,yvals,color='black',s=1.)
        plt.xlabel('log Median Flux per star')
        plt.ylabel('log De-trended Standard Deviation')
        plt.text(np.nanmin(np.log10(np.nanmedian(Photometry,axis=0))),np.nanmin(np.log10(star_err[star_err>0.])),\
            'Less Variable',color='red',ha='left',va='bottom')
        plt.text(np.nanmax(np.log10(np.nanmedian(Photometry,axis=0))),np.nanmax(np.log10(star_err[star_err>0.])),\
            'More Variable',color='red',ha='right',va='top')

        for k in LeastVariable.keys():
            plt.scatter(xvals[LeastVariable[k]],yvals[LeastVariable[k]],color='red')


    # this is the middle key for safety
    middle_key = np.array(list(LeastVariable.keys()))[len(LeastVariable.keys())//2]

    # but now let's select the brightest one
    best_key = np.array(list(LeastVariable.keys()))[-1]
    
    return LeastVariable[best_key]

    findComparisonStars*
    
    finds stars that are similar over the various nights to use as comparison stars
    
    inputs
    --------
    Photometry: list - photometric values taken from detrend() function. 
    cPhotometry: list - detrended photometric values from detrend() function
    accuracy_threshold: float - level of accuracy in fluxes between various nights
    plot: boolean - True/False plot various stars and highlight comparison stars

    outputs
    --------
    most_accurate: list - list of indices of the locations in Photometry which have the best stars to use as comparisons
    
findComparisonStars
finds stars that are similar over the various nights to use as comparison stars

inputs

photometric values taken from detrend() function.
cPhotometry: list - detrended photometric values from detrend() function
accuracy_threshold: float - level of accuracy in fluxes between various nights
plot: boolean - True/False plot various stars and highlight comparison stars

outputs

list of indices of the locations in Photometry which have the best stars to use as comparisons
findComparisonStars finds stars that are similar over the various nights to use as comparison stars inputs photometric values taken from detrend () function . cPhotometry : list - detrended photometric values from detrend () function accuracy_threshold : float - level of accuracy in fluxes between various nights plot : boolean - True / False plot various stars and highlight comparison stars outputs list of indices of the locations in Photometry which have the best stars to use as comparisons
def findComparisonStars(Photometry, cPhotometry, accuracy_threshold = 0.2, plot=True,comp_num=6): 
    BinStars,LeastVariable = CaliforniaCoast(Photometry,cPhotometry,comp_num=comp_num)
    star_err = np.nanstd(cPhotometry, axis=0)
    if plot:
        xvals = np.log10(np.nanmedian(Photometry,axis=0))
        yvals = np.log10(np.nanstd(cPhotometry, axis=0))
        plt.figure()
        plt.scatter(xvals,yvals,color='black',s=1.)
        plt.xlabel('log Median Flux per star')
        plt.ylabel('log De-trended Standard Deviation')
        plt.text(np.nanmin(np.log10(np.nanmedian(Photometry,axis=0))),np.nanmin(np.log10(star_err[star_err>0.])),\
            'Less Variable',color='red',ha='left',va='bottom')
        plt.text(np.nanmax(np.log10(np.nanmedian(Photometry,axis=0))),np.nanmax(np.log10(star_err[star_err>0.])),\
            'More Variable',color='red',ha='right',va='top')
        for k in LeastVariable.keys():
            plt.scatter(xvals[LeastVariable[k]],yvals[LeastVariable[k]],color='red')
    middle_key = np.array(list(LeastVariable.keys()))[len(LeastVariable.keys())//2]
    best_key = np.array(list(LeastVariable.keys()))[-1]
    return LeastVariable[best_key]
def findComparisonStars ( Photometry , cPhotometry , accuracy_threshold = 0.2 , plot = True , comp_num = 6 ) : BinStars , LeastVariable = CaliforniaCoast ( Photometry , cPhotometry , comp_num = comp_num ) star_err = np . nanstd ( cPhotometry , axis = 0 ) if plot : xvals = np . log10 ( np . nanmedian ( Photometry , axis = 0 ) ) yvals = np . log10 ( np . nanstd ( cPhotometry , axis = 0 ) ) plt . figure ( ) plt . scatter ( xvals , yvals , color = 'black' , s = 1. ) plt . xlabel ( 'log Median Flux per star' ) plt . ylabel ( 'log De-trended Standard Deviation' ) plt . text ( np . nanmin ( np . log10 ( np . nanmedian ( Photometry , axis = 0 ) ) ) , np . nanmin ( np . log10 ( star_err [ star_err > 0. ] ) ) , 'Less Variable' , color = 'red' , ha = 'left' , va = 'bottom' ) plt . text ( np . nanmax ( np . log10 ( np . nanmedian ( Photometry , axis = 0 ) ) ) , np . nanmax ( np . log10 ( star_err [ star_err > 0. ] ) ) , 'More Variable' , color = 'red' , ha = 'right' , va = 'top' ) for k in LeastVariable . keys ( ) : plt . scatter ( xvals [ LeastVariable [ k ] ] , yvals [ LeastVariable [ k ] ] , color = 'red' ) middle_key = np . array ( list ( LeastVariable . keys ( ) ) ) [ len ( LeastVariable . keys ( ) ) // 2 ] best_key = np . array ( list ( LeastVariable . keys ( ) ) ) [ - 1 ] return LeastVariable [ best_key ]
findComparisonStars
finds stars that are similar over the various nights to use as comparison stars
findComparisonStars finds stars that are similar over the various nights to use as comparison stars
#0.025 '''
    findComparisonStars*
    
    finds stars that are similar over the various nights to use as comparison stars
    
    inputs
    --------
    Photometry: list - photometric values taken from detrend() function. 
    cPhotometry: list - detrended photometric values from detrend() function
    accuracy_threshold: float - level of accuracy in fluxes between various nights
    plot: boolean - True/False plot various stars and highlight comparison stars

    outputs
    --------
    most_accurate: list - list of indices of the locations in Photometry which have the best stars to use as comparisons
    ''' # this is the middle key for safety # but now let's select the brightest one
Photometry
cPhotometry
accuracy_threshold
plot
comp_num