imProc.sources - EranOfek/AstroPack GitHub Wiki

Description

The imProc.sources package contains functions to find sources in images and measure their properties including photometry.

Functions

  • imProc.sources.allFunList - Functions and Classes list for the imProc.sources package
  • imProc.sources.addMagCols - Given flux columns in AstroCatalog/AstroImage catalog, add mag and mag err columns.
  • imProc.sources.classifySources - Classify sources found by findMeasureSources.
  • imProc.sources.cleanSources - Clean sources found by findMeasureSources (bad S/N and CR).
  • imProc.sources.findMeasureSources - Basic sources finder and measurements on AstroImage object.
  • imProc.sources.findSources - Find sources (only) in AstroImage using imUtil.sources.findSources
  • imProc.sources.forcedPhot - Perform forced photometry on images in an AstroImage object.
  • imProc.sources.psfFitPhot - Execute PSF photometry on a list of coordinates and add the results

imProc.sources.findMeasureSources

This is the main function that can be used for source finding using matched filtering, and measuring sources' aperture photometry, and convolution-based PSF photometry. For adding columns of PSF-fit photometry see the imProc.sources.psfFitPhot function. This function uses the imUtil.sources.find_measure_sources function.

The source-finding routine is implemented by cross-correlating (see imUtil.filter package) the background subtracted image with several filters. The default filters are Gaussians with 5 widths (sigma-width of [0.1; 1.0; 1.5; 2.6; 5] pixels). The filtered image is normalized by the std of the filtered image and local maxima above a threshold (default is 5-sigma) are searched (see imUtil.sources.findLocalMax). Next, for each local maxima the 1st and 2nd Gaussian-weighted moments are calculated (using imUtil.image.moment2). In addition, aperture photometry is calculated (using imUtil.sources.aperPhotCube). The aperture photometry is implemented by fft-shifting (see imUtil.trans.shift_fft) pixelated aperture to the sub-pixel position of the source. Furthermore, PSF-convolution-based photometry is calculated for each source (Note that this is not as accurate as PSF-fit photometry; see below).

Simulated example:

% Create an image with a Gaussian source
Im=imUtil.kernel2.gauss(2,[128 128]);
% add noise
Im=Im.*1000 +randn(size(Im));       
% store in an AstroImage: 
AI = AstroImage({Im});
% call the findMeasureSources function:
AI = imProc.sources.findMeasureSources(AI);

A full example:

AI = AstroImage(FileName);
% pupulate the Back abd Var fields in the AstroImage:
AI = imProc.background.background;
% source finding:
AI = imProc.sources.findMeasureSources(AI);

The output AstroImage object contains the source catalog found in the image in its CatData property stored as an AstroCatalog object.

More examples:

% use only two filters.
% Note it is recommended to always add a 0.1 pix filter that can be used for cosmic-ray detection (see FlagCR argument):
AI = imProc.sources.findMeasureSources(AI, 'PsfFunPar',{[0.1;1.5]});

To modify the output columns:

AI = imProc.sources.findMeasureSources(AI, 'ColCell'{'XPEAK','YPEAK',...
                                                 'X1', 'Y1',...
                                                 'X2','Y2','XY',...
                                                 'SN','BACK_IM','VAR_IM',...  
                                                 'BACK_ANNULUS', 'STD_ANNULUS', ...
                                                 'FLUX_APER', 'FLUXERR_APER',...
                                                 'MAG_APER', 'MAGERR_APER'});

The ForcedList and OnlyForced arguments can be used to feed the function with a list of targets for forced photometry.

imProc.sources.psfFitPhot

This function can be used to perform PSF-fit photometry on the sources detected in an image (listed in the CatData property of the AstroImage) and add the PSF magnitude columns to the catalog.

AI=AstroImage('PTF_201411204943_i_p_scie_t115144_u023050379_f02_p100037_c02.fits');
AI=imProc.background.background(AI);
AI=imProc.sources.findMeasureSources(AI);
% Construct a PSF and store it in the PSFData property:
AI=imProc.psf.constructPSF(AI);
% Perform PSF photometry:
R = imProc.sources.psfFitPhot(AI);

imProc.sources.forcedPhot

This function can be used to perform PSF-fit forced photometry on the position of stationary or moving sources. The output of this function is a MatchedSources object that contains the photometry of the sources.

By default, the forced photometry is allowd to shift the best fit position by up to 0.5 pixels. To relax or change this default you can use the: MomentMaxIter, UseMomCoo, SmallStep, MaxStep, MaxIter arguments.

Forced photometry by pixel positions:

R=imProc.sources.forcedPhot(AI, 'Coo',[X Y], 'CooUnits','pix');

Forced photometry by RA/Dec positions:

R=imProc.sources.forcedPhot(AI, 'Coo',[RA, Dec]);

In the case the coordinates are in RA/Dec then by default, the function will also perform forced photometry on all GAIA-DR3 catalog positions within 300 arcseconds from the target position. The following arguments can be used to control this behavior: AddRefStarsDist, AddCatName, and RefColNames.

Forced photometry for moving source:

R=imProc.sources.forcedPhot(AI, 'Coo',[RA, Dec], 'Moving',true);

For this case, Moving=true, the 'Coo' argument contains an entry per each AstroImage element (which we refer as epoch), and the forced photometry is performed on each image in a different location.

In order to generate a list of coordinates for a moving target for each image in an AstroImage object:

% read FITS images into an AstroImage object.
% Note: we assume that the images are fully calibrated and contain astrometric solution.
AI = AstroImage('*.fits');

% get the JD of all the images:
JD = AI.julday;

% get predicted position of your moving target between min(JD) and max(JD):
[Cat]=celestial.SolarSys.jpl_horizons('ObjectInd','9804','StartJD',floor(min(JD)-1),'StopJD',ceil(min(JD)+1), 'StepSizeUnits','h');

% Interpolate the columns of Cat onto the times in JD:
Cat.interp1('JD',{'RA','Dec','r','Delta'}, JD);

R=imProc.sources.forcedPhot(AI, 'Coo',Cat, 'Moving',true);