Spring2020/PythonPhotometry/Sarah_DiffPhotometry.py
def CaliforniaCoast(Photometry,cPhotometry,comp_num=9,flux_bins=6):
    """
    Find the least-variable stars as a function of star brightness*

    (it's called California Coast because the plot looks like California and we are looking for edge values: the coast)
    
    
    inputs
    --------------
    Photometry  : input Photometry catalog
    cPhotometry : input detrended Photometry catalog
    flux_bins   : (default=10) maximum number of flux bins
    comp_num    : (default=5)  minimum number of comparison stars to use
    
    
    outputs
    --------------
    BinStars      : dictionary of stars in each of the flux partitions
    LeastVariable : dictionary of least variable stars in each of the flux partitions
    
    
    """
    
    tmpX = np.nanmedian(Photometry,axis=0)
    tmpY = np.nanstd(cPhotometry, axis=0)
    
    xvals = tmpX[(np.isfinite(tmpX) & np.isfinite(tmpY))]
    yvals = tmpY[(np.isfinite(tmpX) & np.isfinite(tmpY))]
    kept_vals = np.where((np.isfinite(tmpX) & np.isfinite(tmpY)))[0]
    #print('Keep',kept_vals)
    
    # make the bins in flux, equal in percentile
    flux_percents = np.linspace(0.,100.,flux_bins)
    print('Bin Percentiles to check:',flux_percents)
    
    # make the dictionary to return the best stars
    LeastVariable = {}
    BinStars = {}
    
    for bin_num in range(0,flux_percents.size-1):
        
        # get the flux boundaries for this bin
        min_flux = np.percentile(xvals,flux_percents[bin_num])
        max_flux = np.percentile(xvals,flux_percents[bin_num+1])
        #print('Min/Max',min_flux,max_flux)

        # select the stars meeting the criteria
        w = np.where( (xvals >= min_flux) & (xvals < max_flux))[0]
        
        BinStars[bin_num] = kept_vals[w]
        
        # now look at the least variable X stars
        nstars = w.size
        #print('Number of stars in bin {}:'.format(bin_num),nstars)
        
        # organize stars by flux uncertainty
        binStarsX = xvals[w]
        binStarsY = yvals[w]
                
        # mininum Y stars in the bin:
        lowestY = kept_vals[w[binStarsY.argsort()][0:comp_num]]
        
        #print('Best {} stars in bin {}:'.format(comp_num,bin_num),lowestY)
        LeastVariable[bin_num] = lowestY
        
    return BinStars,LeastVariable

    Find the least-variable stars as a function of star brightness*

    (it's called California Coast because the plot looks like California and we are looking for edge values: the coast)
    
    
    inputs
    --------------
    Photometry  : input Photometry catalog
    cPhotometry : input detrended Photometry catalog
    flux_bins   : (default=10) maximum number of flux bins
    comp_num    : (default=5)  minimum number of comparison stars to use
    
    
    outputs
    --------------
    BinStars      : dictionary of stars in each of the flux partitions
    LeastVariable : dictionary of least variable stars in each of the flux partitions
    
    
    
Find the least-variable stars as a function of star brightness
(it's called California Coast because the plot looks like California and we are looking for edge values: the coast)

inputs

Photometry  : input Photometry catalog
cPhotometry : input detrended Photometry catalog
flux_bins   : (default=10) maximum number of flux bins
comp_num    : (default=5)  minimum number of comparison stars to use

outputs

BinStars      : dictionary of stars in each of the flux partitions
LeastVariable : dictionary of least variable stars in each of the flux partitions
Find the least - variable stars as a function of star brightness ( it ' s called California Coast because the plot looks like California and we are looking for edge values : the coast ) inputs Photometry : input Photometry catalog cPhotometry : input detrended Photometry catalog flux_bins : ( default = 10 ) maximum number of flux bins comp_num : ( default = 5 ) minimum number of comparison stars to use outputs BinStars : dictionary of stars in each of the flux partitions LeastVariable : dictionary of least variable stars in each of the flux partitions
def CaliforniaCoast(Photometry,cPhotometry,comp_num=9,flux_bins=6):
    tmpX = np.nanmedian(Photometry,axis=0)
    tmpY = np.nanstd(cPhotometry, axis=0)
    xvals = tmpX[(np.isfinite(tmpX) & np.isfinite(tmpY))]
    yvals = tmpY[(np.isfinite(tmpX) & np.isfinite(tmpY))]
    kept_vals = np.where((np.isfinite(tmpX) & np.isfinite(tmpY)))[0]
    flux_percents = np.linspace(0.,100.,flux_bins)
    print('Bin Percentiles to check:',flux_percents)
    LeastVariable = {}
    BinStars = {}
    for bin_num in range(0,flux_percents.size-1):
        min_flux = np.percentile(xvals,flux_percents[bin_num])
        max_flux = np.percentile(xvals,flux_percents[bin_num+1])
        w = np.where( (xvals >= min_flux) & (xvals < max_flux))[0]
        BinStars[bin_num] = kept_vals[w]
        nstars = w.size
        binStarsX = xvals[w]
        binStarsY = yvals[w]
        lowestY = kept_vals[w[binStarsY.argsort()][0:comp_num]]
        LeastVariable[bin_num] = lowestY
    return BinStars,LeastVariable
def CaliforniaCoast ( Photometry , cPhotometry , comp_num = 9 , flux_bins = 6 ) : tmpX = np . nanmedian ( Photometry , axis = 0 ) tmpY = np . nanstd ( cPhotometry , axis = 0 ) xvals = tmpX [ ( np . isfinite ( tmpX ) & np . isfinite ( tmpY ) ) ] yvals = tmpY [ ( np . isfinite ( tmpX ) & np . isfinite ( tmpY ) ) ] kept_vals = np . where ( ( np . isfinite ( tmpX ) & np . isfinite ( tmpY ) ) ) [ 0 ] flux_percents = np . linspace ( 0. , 100. , flux_bins ) print ( 'Bin Percentiles to check:' , flux_percents ) LeastVariable = { } BinStars = { } for bin_num in range ( 0 , flux_percents . size - 1 ) : min_flux = np . percentile ( xvals , flux_percents [ bin_num ] ) max_flux = np . percentile ( xvals , flux_percents [ bin_num + 1 ] ) w = np . where ( ( xvals >= min_flux ) & ( xvals < max_flux ) ) [ 0 ] BinStars [ bin_num ] = kept_vals [ w ] nstars = w . size binStarsX = xvals [ w ] binStarsY = yvals [ w ] lowestY = kept_vals [ w [ binStarsY . argsort ( ) ] [ 0 : comp_num ] ] LeastVariable [ bin_num ] = lowestY return BinStars , LeastVariable
Find the least-variable stars as a function of star brightness
(it's called California Coast because the plot looks like California and we are looking for edge values: the coast)
Find the least - variable stars as a function of star brightness ( it ' s called California Coast because the plot looks like California and we are looking for edge values : the coast )
"""
    Find the least-variable stars as a function of star brightness*

    (it's called California Coast because the plot looks like California and we are looking for edge values: the coast)
    
    
    inputs
    --------------
    Photometry  : input Photometry catalog
    cPhotometry : input detrended Photometry catalog
    flux_bins   : (default=10) maximum number of flux bins
    comp_num    : (default=5)  minimum number of comparison stars to use
    
    
    outputs
    --------------
    BinStars      : dictionary of stars in each of the flux partitions
    LeastVariable : dictionary of least variable stars in each of the flux partitions
    
    
    """ #print('Keep',kept_vals) # make the bins in flux, equal in percentile # make the dictionary to return the best stars # get the flux boundaries for this bin #print('Min/Max',min_flux,max_flux) # select the stars meeting the criteria # now look at the least variable X stars #print('Number of stars in bin {}:'.format(bin_num),nstars) # organize stars by flux uncertainty # mininum Y stars in the bin: #print('Best {} stars in bin {}:'.format(comp_num,bin_num),lowestY)
Photometry
cPhotometry
comp_num
flux_bins