Table Of Contents

Previous topic


Next topic


This Page

phot – photometric functions


mascara.phot contains the functions needed for performing the aperture photometry on the images:
Actually mascara.phot contains three functions to measure the flux from the image: 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. 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 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 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.

White: the aperture radius within the counts are summed. Yellow: the sky annulus used to determine the median sky value around the star

Using GetPhot

Using mascara.phot.GetPhot() is very easy. Let’s continue on the previous example

>>> print 'Number of stars detected on the image: {}'.format(xobs.size)
>>> flux, eflux, sky, esky = mascara.phot.GetPhot(image, xobs, yobs, apr=fwhm, skyrad=[5, 15])
>>> print flux.size

Using OnaPhot

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, 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.


mascara.phot provides a set of photometric routines:
  • find_stars, an export from the DAOPHOT package, to find stars on an image
  • GetPhot, the equivalent of the DAOPHOT APER routine.
  • OnaPhot, an extensive version of GetPhot which performs quick image quality analysis, and returns more informations
mascara.phot.find_stars(image, hmin, fwhm, nsigma=1.5, roundlim=[-1.0, 1.0], sharplim=[0.2, 1.0])[source]

find_stars, adapted from the ASTROLIB-routine to find point sources on an image. To do so, the image is convolved with a Gaussian kernel of fwhm as given. Any remaining sources above the background are then potential stars...

  • image, the 2D image to look at
  • hmin, the noise threshold above which the object is qualified as a star. Typically hmin > 3*std(image)
  • fhwm, the estimated full width half maximum of the stars on the image
  • nsigma, radius of the convolution kernel. Default 1.5
  • roundlim ([-1.,1.]): Threshold for the roundness criterion.
  • sharplim ([0.2,1.]): Threshold for the sharpness criterion.
  • xobs, yobs, the X and Y coordinates of the stars found on the CCD
  • sharp, the sharpness of the stars
  • round, the roundness of the stars
mascara.phot.GetPhot(im, xc, yc, apr=None, skyrad=None, phpadu=1, Flux=True)[source]

Aperture Photometry based on DAOPHOT Aper procedure

Computes concentric aperture photometry for several user specified aperture radii (apr). The sky is evaluated separately using the outer and inner sky radii (skyrad)

Inputs :
  • im, input image array
  • x, y the coordinates of the stars on the array
  • apr, a single value (can be float) for the aperture radius
  • skyrad, a tupple of 2 elements defining the radii of the sky annulus
  • phpadu, the photon per ADU (optional)
  • flux, the measured flux
  • eflux, the errors on the flux
  • sky, the measured background
  • esky, the errors on the background
mascara.phot.OnaPhot(*args, **kwargs)[source]

OnaPhot is an aperture photometry routine based on the APER or GetPhot routine, but developped for the following cases:

  • when one star is treated at the time
  • when the shape of the star is highly dependant of its position on the CCD

OnaPhot adapt the shape of the aperture to the shape of the star. In addition, it runs a diagnostic of the background. OnaPhot accepts one to 10 different aperture radii.

  • im, the 2d complete image
  • xc, yc the coordinates of ONE star.
  • apr, a vector, list or tuple of aperture radii
  • skyrad, a tuple [inner sky rad, outer sky rad]
  • mask, an 2D array. If not provided, it is calculated. It may be interesting to provide mask, (via masphot.makeMask)
  • precise_sky, to do a precise calculation of the sky background
  • onepass, if only one pass of the getSkyValue should be done.
  • flag, a diagnostic for the star noted in binary:
    • 0 -> all went well
    • 1 -> saturated pixel in the aperture
    • 2 -> saturated pixel in the background
    • 4 -> reserved (for astrometry)
    • 8 -> reserved (for clouds)
    • 16 -> Background <= 0
    • 32 -> Flux or sky <= 0 or not finite
    • 64 -> –
    • 128 -> Star potentially outside the aperture
    • 256 -> Sky annulus outside CCD
  • flux, a vector of flux
    • erflux, the corresponding errors
    • sky, the sky background
    • ersky, the corresponding errors
    • xm, ym, the coordinates of the star

The output is expressed under the form: [flag, flux0, erflux0, flux1, erflux1, ..., sky, ersky, xm, ym]

mascara.phot.Photcore(im, xc, yc, apr=4, skyrad=[5, 7], phpadu=1.0)[source]

Photcore contains just the core of the aperture photometric routine. It is design to work only with one star on one image

  • im, the 2d image
  • xc, yc, 2 scalars giving the coordinates of the star. No verification are done to check whether the star is inside the image or not. It is assumed that the star has to be centered or well inside the image.
  • apr, the aperture radius, default = 4
  • skyrad, 2 values defining the radius of the sky annulus. Default = [5,7]
  • phpadu, the photon to analog constant. Default=1
  • a vector containing, the flux, the flux errors, the sky and the sky errors.