.. _masphot: ***************************** phot -- photometric functions ***************************** Introduction ============ :mod:`mascara.phot` contains the functions needed for performing the aperture photometry on the images: - :func:`mascara.phot.find_stars` to find the stars on the images - :func:`mascara.phot.GetPhot` to calculate the flux of the stars based on their coordinates on the CCD. Actually :mod:`mascara.phot` contains three functions to measure the flux from the image: :func:`mascara.phot.GetPhot` is close to the DAOPHOT Aper function: it takes as an input a list of coordinates, and returns the measured flux, error and associated sky for those coordinates. :func:`mascara.phot.OnaPhot` is a specific for MASCARA photometric routine which returns more information about the star: - the flux, and error on the flux - the associated sky and sky errors - the peak value of the pixels inside the aperture - a flag which defines the quality of the photometry. Finally the past function :func:`mascara.phot.PhotCore` which performs the photometry for one star, and one aperture. Finding the stars ================= Though MASCARA doesn't need to find the stars on the CCD, the :func:`mascara.phot.find_stars` function is mainly used when evaluating the accuracy of the astrometric solution. The call of the function is : >>> import mascara >>> import numpy >>> hmin = numpy.nanstd(image) * 4 >>> fwhm = 3.5 # Estimated fwhm at 3.5 pixels >>> xobs, yobs, sharp, round = mascara.phot.find_stars(image, hmin, fwhm, nsigma=1.5) The inputs are : - the image to anaylize, it has to be a 2D array - hmin, this scalar set the value of the threshold for the detection of the stars. Usually it is evaluated as 3 of 4 times the background noise. - fwhm, the estimated full width half maximum of the stars on the CCD, Measuring the flux ================== All functions are using aperture photometry to evaluate the flux of the star. This means that the user has to define an aperture radius (the red circle in the image below), inside which all the counts of all pixels are added, and two sky radii which shall define a sky annulus (in yellow below). The true flux of the star is then estimated by subtracting the median value of all counts inside the sky annulus to the sum of the counts inside the aperture radius. .. _aperture: .. figure:: aperture.png :alt: White: the aperture radius within the counts are summed. Yellow: the sky annulus used to determine the median sky value around the star :scale: 50% :align: center Using GetPhot ------------- Using :func:`mascara.phot.GetPhot` is very easy. Let's continue on the previous example >>> print 'Number of stars detected on the image: {}'.format(xobs.size) 1543 >>> flux, eflux, sky, esky = mascara.phot.GetPhot(image, xobs, yobs, apr=fwhm, skyrad=[5, 15]) >>> print flux.size 1543 Using OnaPhot ------------- :func:`mascara.phot.OnaPhot` deals only with one star at the time, but returns a more complete output about the star. The quality of the sky around the star is analyzed and returned under the form of a integer flag value. For instance, should there be a second bright object in the sky annulus, the flux would be flagged as having an uneven sky background. Similarly, if the star were over exposed resulting in a saturation of the CCD, the measurement would be flagged as overexposed. In addition to the flag, :func:`mascara.phot.OnaPhot` returns also the peak value inside the aperture, i.e. the highest pixel value inside the aperture, which can be used as diagnostic tool in further analyses. References/APIS =============== .. automodule:: mascara.phot .. autofunction:: mascara.phot.find_stars .. autofunction:: mascara.phot.GetPhot .. autofunction:: mascara.phot.OnaPhot .. autofunction:: mascara.phot.Photcore