Spring2020/PythonPhotometry/Sarah_DiffPhotometry.py
def StarFind(imname, FWHM, nsigma, aprad, skywidth, border_scale = 2):
    '''
    StarFind*
    
    find all stars in a .fits image
    
    inputs
    ----------
    imname: name of .fits image to open.  
    FWHM: fwhm of stars in field
    nsigma: number of sigma above background above which to select sources.  (~3 to 4 is a good estimate)
    
    outputs
    --------
    xpos: x positions of sources
    ypos: y positions of sources
    nstars: number of stars found in image
    '''
    
    #open image
    im,hdr=fits.getdata(imname, header=True)

    # sarah: check to see if this breaks the original version. -mp
    im = np.array(im).astype('float')
    
    #determine background
    bkg_sigma = mad_std(im)
    
    print('begin: DAOStarFinder')
    
    daofind = DAOStarFinder(fwhm=FWHM, threshold=nsigma*bkg_sigma, exclude_border=True)
    sources = daofind(im)
    
    #x and y positions
    xpos = sources['xcentroid']
    ypos = sources['ycentroid']
    
    # get rid of stars on border which could have NaN photometry
    diameter = border_scale * (aprad + skywidth) 
    
    xmax = np.shape(im)[1]
    ymax = np.shape(im)[0]

    xpos2 = xpos[(xpos > diameter) & (xpos < (xmax-diameter)) & (ypos > diameter) & (ypos < (ymax -diameter))]
    ypos2 = ypos[(xpos > diameter) & (xpos < (xmax-diameter)) & (ypos > diameter) & (ypos < (ymax -diameter))]
    
    #number of stars found
    nstars = len(xpos2)
    
    print('found ' + str(nstars) + ' stars')
    return xpos2, ypos2, nstars

    StarFind*
    
    find all stars in a .fits image
    
    inputs
    ----------
    imname: name of .fits image to open.  
    FWHM: fwhm of stars in field
    nsigma: number of sigma above background above which to select sources.  (~3 to 4 is a good estimate)
    
    outputs
    --------
    xpos: x positions of sources
    ypos: y positions of sources
    nstars: number of stars found in image
    
StarFind
find all stars in a .fits image

inputs

name of .fits image to open.
FWHM: fwhm of stars in field
nsigma: number of sigma above background above which to select sources.  (~3 to 4 is a good estimate)

outputs

x positions of sources
ypos: y positions of sources
nstars: number of stars found in image
StarFind find all stars in a . fits image inputs name of . fits image to open . FWHM : fwhm of stars in field nsigma : number of sigma above background above which to select sources . ( ~3 to 4 is a good estimate ) outputs x positions of sources ypos : y positions of sources nstars : number of stars found in image
def StarFind(imname, FWHM, nsigma, aprad, skywidth, border_scale = 2):
    im,hdr=fits.getdata(imname, header=True)
    im = np.array(im).astype('float')
    bkg_sigma = mad_std(im)
    print('begin: DAOStarFinder')
    daofind = DAOStarFinder(fwhm=FWHM, threshold=nsigma*bkg_sigma, exclude_border=True)
    sources = daofind(im)
    xpos = sources['xcentroid']
    ypos = sources['ycentroid']
    diameter = border_scale * (aprad + skywidth) 
    xmax = np.shape(im)[1]
    ymax = np.shape(im)[0]
    xpos2 = xpos[(xpos > diameter) & (xpos < (xmax-diameter)) & (ypos > diameter) & (ypos < (ymax -diameter))]
    ypos2 = ypos[(xpos > diameter) & (xpos < (xmax-diameter)) & (ypos > diameter) & (ypos < (ymax -diameter))]
    nstars = len(xpos2)
    print('found ' + str(nstars) + ' stars')
    return xpos2, ypos2, nstars
def StarFind ( imname , FWHM , nsigma , aprad , skywidth , border_scale = 2 ) : im , hdr = fits . getdata ( imname , header = True ) im = np . array ( im ) . astype ( 'float' ) bkg_sigma = mad_std ( im ) print ( 'begin: DAOStarFinder' ) daofind = DAOStarFinder ( fwhm = FWHM , threshold = nsigma * bkg_sigma , exclude_border = True ) sources = daofind ( im ) xpos = sources [ 'xcentroid' ] ypos = sources [ 'ycentroid' ] diameter = border_scale * ( aprad + skywidth ) xmax = np . shape ( im ) [ 1 ] ymax = np . shape ( im ) [ 0 ] xpos2 = xpos [ ( xpos > diameter ) & ( xpos < ( xmax - diameter ) ) & ( ypos > diameter ) & ( ypos < ( ymax - diameter ) ) ] ypos2 = ypos [ ( xpos > diameter ) & ( xpos < ( xmax - diameter ) ) & ( ypos > diameter ) & ( ypos < ( ymax - diameter ) ) ] nstars = len ( xpos2 ) print ( 'found ' + str ( nstars ) + ' stars' ) return xpos2 , ypos2 , nstars
StarFind
find all stars in a .fits image
StarFind find all stars in a . fits image
'''
    StarFind*
    
    find all stars in a .fits image
    
    inputs
    ----------
    imname: name of .fits image to open.  
    FWHM: fwhm of stars in field
    nsigma: number of sigma above background above which to select sources.  (~3 to 4 is a good estimate)
    
    outputs
    --------
    xpos: x positions of sources
    ypos: y positions of sources
    nstars: number of stars found in image
    ''' #open image # sarah: check to see if this breaks the original version. -mp #determine background #x and y positions # get rid of stars on border which could have NaN photometry #number of stars found
imname
FWHM
nsigma
aprad
skywidth
border_scale