Skip to content

Example: source extraction

EranOfek edited this page Apr 22, 2023 · 9 revisions

Source extraction examples

Here we assume we start with a bias subtracted and flat corrected image (see examples in imProc.flat and CalibImages).
We provide examples that include background estimation, source extraction, PSF estimation, PSF fitting, and astrometry. We also assume that the images are in units of electrons (i.e., the image is multiplied by the gain). Finally, we assume that the images are stored in an AstroImage object.

Step-by-step example:

background and variance estimation

The first step is to estimate the background and variance:

% assuming the images we would like to analyze are stored in an AstroImage object named AI:
AI = imProc.background.background(AI);
% You can control the background estimation parameters:
% for more info see the background help.
AI = imProc.background.background(AI, 'SubSizeXY',[256 256], 'BackFun',@median);

Source finding and aperture photometry

After applying the background function, the background and variance images are stored in the AI AstroImage object. Next, we can find sources. This can be done using imProc.sources.findSources to locate the X,Y position of candidate sources. In order to find sources and to measure their properties, including first and second moments, aperture photometry, convolutional-based photometry, and flags propagation.

AI = imProc.sources.findMeasureSources(AI);

The catalog of sources found in the image is stored in the AstroImage object in the CatData property.

findMeasureSources find sources by cross-correlating the image with some PSFs. The user can control the PSF using the 'Psf', 'PsfFun', and 'PsfFunPar' arguments. By default, the function uses Gaussian PSF with sigma-width of [0.1, 1, 1.5, 2.6, 5] pixels.

Note that the 0.1 pixels PSF is usually used for cosmic-ray detection via hypothesis testing. I.e., the S/N of the 0.1 pixel is compared to the S/N of the other PSFs.

% The following example, will use only two PSFs:
AI = imProc.sources.findMeasureSources(AI, 'PsfFunPar',[0.1; 2]);

You can also control the catalog columns output using the 'ColCell' arguments. For example,

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'});

For complete information see the function help.

The function can also be used to perform forced photometry, or to mix detection of sources with forced photometry (controled via the 'ForcedList' and 'OnlyForced' arguments).

AI = imProc.sources.findMeasureSources(AI, 'ForcedList',[100 100;200 102]);

PSF photometry

In the following example, we construct the mean PSF for all the images in the AI AstroImage object, and perform PSF fitting for all the sources in the catalog of the AstroImage. Additional PSF photometry tools like iterative PSF fitting (i.e., subtract bright sources, and refind faint sources) are available in the imProc.sources package.

% Construct PSF
% After this step the PSFData property in the Astrocatalog will be
% populated with a PSF
AI = imProc.psf.constructPSF(AI);
% To see the PSF of the first image
AI(1).PSFData.surface
% Estimate the FWHM of the PSF of the fisrt image
AI(1).PSFData.fwhm
% Perform PSF photometry and add it to the AstroCatalog
AI = imProc.sources.psfFitPhot(AI);

After this step, the PSF of each image will be populated in the AstroImage object (PSFData property), and the PSF photometry for each source will be added to the catalogs (i.e., new columns with PSF photometry will be added). Specifically, for each catalog, the following columns will be added:

  • X - Best fit X position.
  • Y - Best Fit Y position.
  • FLUX_PSF - PSF flux.
  • MAG_PSF - PSF magnitude.
  • PSF_CHI2DOF - chi^2/dof for PSF fitting.
  • SN - S/N for detection.

The PSF photometry program has several important arguments. For example, using the 'FitRadius' argument, the user can control the radius relative to the PSF center, of the pixels that will be used in the PSF fitting process (i.e., not using the entire PSF). This is important in order to avoid blended sources to effect the fitting.

Astrometry

Given an AI AstroImage object that contains the image and catalog, we can solve the astrometry of the image, populated the WCS object and the WCS data in the header, and add the RA and Dec information for each source in the catalog. For more details on astrometry see the imProc.astrometry package.

Note that the astrometry requires to install the GAIA-DR3 of catsHTM (see install).

[Res, AI, AstrometricCat] = imProc.astrometry.astrometryCore(AI);

By default the astrometryCore function will look for the first guess RA/Dec coordinates in the header. However, the use can specify the header keywords to use, or the coordinates:

[Res, AI, AstrometricCat] = imProc.astrometry.astrometryCore(AI, 'RA','RA2000', 'Dec','DE2000');
[Res, AI, AstrometricCat] = imProc.astrometry.astrometryCore(AI, 'RA',120.1, 'Dec',-12.3);

The output include the Res structure that contains general information on the fit. The AI object with the updated WCS information, and the Astrometric catalog used. This catalog is returned for cases in which the user would like to reuse the catalog without generating it again:

[Res, AI] = imProc.astrometry.astrometryCore(AI,'CatName',AstrometricCat);

By default (see 'UpdateHeader' argument), the function add to the header the following keywords:

  • AST_NSRC - Number of sources used in the astrometric solution.
  • AST_ARMS - Asymtotic rms of the astrometric solution (i.e., the rms at the bright end).
  • AST_ERRM - Error on the astrometric system (rms/sqrt(N)) - Note this is not the astrometric uncertainty of stars, but the uncertainty on the fiducial point of the astrometric grid.

By default, this program will also add the RA/Dec to the catalog. This is controlled via the 'OutCatCooUnits', 'OutCatColRA', 'OutCatColDec', and 'OutCatColPos' arguments.

Matching the sources with external catalogs

You can match sources in the catalog with sources in the various catsHTM catalogs.

In the following example we match the catalog in each element in AI with the WISE catalog with search radius of 3 arcsec.

[AI, SelObj, ResInd, CatH] = match_catsHTM(AI, 'WISE', 'Radius',3, 'RadiusUnits','arcsec');

The function will add two columns to each catalog in the AI object, including the angular distance to the closest match (if any), and the number of matches within the search radius (see the 'AddColDist', 'ColDistPos', 'ColDistName', 'ColDistUnits', 'AddColNmatch', 'ColNmatchPos', and 'ColNmatchName' argumnets).

Matching the sources with known Solar System objects

You can use the imProc.match.match2solarSystem function to match sources in the catalogs in AI to known Solar System objects.

Image Processing

Background

Image processing classes

High-level image processing tools

Spectra processing

Pipelines

Start-to-end examples

Celestial coordinates and mechanics

Astrophysics

Time series analysis

  • [timeSeries - Time series analysis tools]
    • [arma]
    • [bin]
    • [detrend]
    • [fit]
    • [fold]
    • [interp]
    • [period]
    • [rand]
    • [stat]
    • [time]
    • [xcorr]
    • [timeDelay]

Telescopes

Virtual observatory and catalogs

General tools

For developers

  • [Developers]
Clone this wiki locally