18 from __future__
import division, print_function
19 from .measurement_images
import MeasurementImage, MeasurementGroup
21 import _SourceXtractorPy
as cpp
23 apertures_for_image = {}
26 Aperture = cpp.Aperture
31 Flux measurement from the image above the background inside a circular aperture. 35 target : MeasurementImage object, or leaf MeasurementGroup object with a single image, or a list of either 36 Target images on which to measure the aperture photometry. Leaf MeasurementGroup with a single image 37 are accepted as a convenience. 39 apertures : float, or list of float 40 Diameter of the aperture. As different MeasurementImage may not be aligned, nor have equivalent pixel size, 41 the aperture is interpreted as diameter in pixels of a circle on the detection image. 42 A transformation will be applied for each frame, so the covered area is equivalent. 46 list of Aperture objects 47 An Aperture object is an internal representation of a property on the measurement frame that contains the 48 apertures. To actually get the measurements on the output catalog, you need to add explicitly them to the 57 This property will generate five columns with the prefix specified by `add_output_column`: 58 - ``_flux`` and ``_flux_err``, for the flux and its associated error 59 - ``_mag`` and ``_mag_err``, for the magnitude and its associated error 60 - ``_flags``, to mark, for instance, saturation, boundary conditions, etc. 62 For M apertures and N images, the cells on the output column will be an array of MxN fluxes. 66 >>> measurement_group = MeasurementGroup(load_fits_images(frames, psfs)) 67 >>> all_apertures = [] 68 >>> for img in measurement_group: 69 >>> all_apertures.extend(add_aperture_photometry(img, [5, 10, 20])) 70 >>> add_output_column('aperture', all_apertures) 72 if not isinstance(target, list):
74 if not isinstance(apertures, list):
75 apertures = [apertures]
77 apertures = [float(a)
for a
in apertures]
81 if isinstance(t, MeasurementGroup):
83 raise Exception(
'The MeasurementGroup is not a leaf')
85 raise Exception(
'The MeasurementGroup contains {} images'.format(len(t)))
88 if not isinstance(t, MeasurementImage):
89 raise Exception(
'Only MeasurementImage supported as targets, got {}'.format(type(t)))
91 if t.id
in apertures_for_image:
92 raise Exception(
'Apertures already set for the image {}'.format(t.id))
93 apertures_for_image[t.id] = cpp.Aperture(apertures)
94 outputs.append(apertures_for_image[t.id])