AegeanTools classes

SourceFinder

class AegeanTools.source_finder.SourceFinder(**kwargs)[source]

The Aegean source finding algorithm

Attributes:
global_data : AegeanTools.models.GlobalFittingData

State holder for properties.

sources : list

List of sources that have been found/measured.

log : logging.log

Logger to use. Default = None

estimate_lmfit_parinfo(data, rmsimg, curve, beam, innerclip, outerclip=None, offsets=(0, 0), max_summits=None)[source]

Estimates the number of sources in an island and returns initial parameters for the fit as well as limits on those parameters.

Parameters:
data : 2d-array

(sub) image of flux values. Background should be subtracted.

rmsimg : 2d-array

Image of 1sigma values

curve : 2d-array

Image of curvature values [-1,0,+1]

beam : AegeanTools.fits_image.Beam

The beam information for the image.

innerclip, outerclip : float

Inerr and outer level for clipping (sigmas).

offsets : (int, int)

The (x,y) offset of data within it’s parent image

max_summits : int

If not None, only this many summits/components will be fit. More components may be present in the island, but subsequent components will not have free parameters.

Returns:
model : lmfit.Parameters

The initial estimate of parameters for the components within this island.

find_sources_in_image(filename, hdu_index=0, outfile=None, rms=None, bkg=None, max_summits=None, innerclip=5, outerclip=4, cores=None, rmsin=None, bkgin=None, beam=None, doislandflux=False, nopositive=False, nonegative=False, mask=None, lat=None, imgpsf=None, blank=False, docov=True, cube_index=None)[source]

Run the Aegean source finder.

Parameters:
filename : str or HDUList

Image filename or HDUList.

hdu_index : int

The index of the FITS HDU (extension).

outfile : str

file for printing catalog (NOT a table, just a text file of my own design)

rms : float

Use this rms for the entire image (will also assume that background is 0)

max_summits : int

Fit up to this many components to each island (extras are included but not fit)

innerclip, outerclip : float

The seed (inner) and flood (outer) clipping level (sigmas).

cores : int

Number of CPU cores to use. None means all cores.

rmsin, bkgin : str or HDUList

Filename or HDUList for the noise and background images. If either are None, then it will be calculated internally.

beam : (major, minor, pa)

Floats representing the synthesised beam (degrees). Replaces whatever is given in the FITS header. If the FITS header has no BMAJ/BMIN then this is required.

doislandflux : bool

If True then each island will also be characterized.

nopositive, nonegative : bool

Whether to return positive or negative sources. Default nopositive=False, nonegative=True.

mask : str

The filename of a region file created by MIMAS. Islands outside of this region will be ignored.

lat : float

The latitude of the telescope (declination of zenith).

imgpsf : str or HDUList

Filename or HDUList for a psf image.

blank : bool

Cause the output image to be blanked where islands are found.

docov : bool

If True then include covariance matrix in the fitting process. (default=True)

cube_index : int

For image cubes, cube_index determines which slice is used.

Returns:
sources : list

List of sources found.

load_globals(filename, hdu_index=0, bkgin=None, rmsin=None, beam=None, verb=False, rms=None, bkg=None, cores=1, do_curve=True, mask=None, lat=None, psf=None, blank=False, docov=True, cube_index=None)[source]

Populate the global_data object by loading or calculating the various components

Parameters:
filename : str or HDUList

Main image which source finding is run on

hdu_index : int

HDU index of the image within the fits file, default is 0 (first)

bkgin, rmsin : str or HDUList

background and noise image filename or HDUList

beam : AegeanTools.fits_image.Beam

Beam object representing the synthsized beam. Will replace what is in the FITS header.

verb : bool

Verbose. Write extra lines to INFO level log.

rms, bkg : float

A float that represents a constant rms/bkg levels for the entire image. Default = None, which causes the rms/bkg to be loaded or calculated.

cores : int

Number of cores to use if different from what is autodetected.

do_curve : bool

If True a curvature map will be created, default=True.

mask : str or AegeanTools.regions.Region

filename or Region object

lat : float

Latitude of the observing telescope (declination of zenith)

psf : str or HDUList

Filename or HDUList of a psf image

blank : bool

True = blank output image where islands are found. Default = False.

docov : bool

True = use covariance matrix in fitting. Default = True.

cube_index : int

For an image cube, which slice to use.

priorized_fit_islands(filename, catalogue, hdu_index=0, outfile=None, bkgin=None, rmsin=None, cores=1, rms=None, bkg=None, beam=None, lat=None, imgpsf=None, catpsf=None, stage=3, ratio=None, outerclip=3, doregroup=True, docov=True, cube_index=None)[source]

Take an input catalog, and image, and optional background/noise images fit the flux and ra/dec for each of the given sources, keeping the morphology fixed

if doregroup is true the groups will be recreated based on a matching radius/probability. if doregroup is false then the islands of the input catalog will be preserved.

Multiple cores can be specified, and will be used.

Parameters:
filename : str or HDUList

Image filename or HDUList.

catalogue : str or list

Input catalogue file name or list of OutputSource objects.

hdu_index : int

The index of the FITS HDU (extension).

outfile : str

file for printing catalog (NOT a table, just a text file of my own design)

rmsin, bkgin : str or HDUList

Filename or HDUList for the noise and background images. If either are None, then it will be calculated internally.

cores : int

Number of CPU cores to use. None means all cores.

rms : float

Use this rms for the entire image (will also assume that background is 0)

beam : (major, minor, pa)

Floats representing the synthesised beam (degrees). Replaces whatever is given in the FITS header. If the FITS header has no BMAJ/BMIN then this is required.

lat : float

The latitude of the telescope (declination of zenith).

imgpsf : str or HDUList

Filename or HDUList for a psf image.

catpsf : str or HDUList

Filename or HDUList for the catalogue psf image.

stage : int

Refitting stage

ratio : float

If not None - ratio of image psf to catalog psf, otherwise interpret from catalogue or image if possible

innerclip, outerclip : float

The seed (inner) and flood (outer) clipping level (sigmas).

docov : bool

If True then include covariance matrix in the fitting process. (default=True)

cube_index : int

For image cubes, slice determines which slice is used.

Returns:
sources : list

List of sources measured.

result_to_components(result, model, island_data, isflags)[source]

Convert fitting results into a set of components

Parameters:
result : lmfit.MinimizerResult

The fitting results.

model : lmfit.Parameters

The model that was fit.

island_data : AegeanTools.models.IslandFittingData

Data about the island that was fit.

isflags : int

Flags that should be added to this island (in addition to those within the model)

Returns:
sources : list

A list of components, and islands if requested.

save_background_files(image_filename, hdu_index=0, bkgin=None, rmsin=None, beam=None, rms=None, bkg=None, cores=1, outbase=None)[source]

Generate and save the background and RMS maps as FITS files. They are saved in the current directly as aegean-background.fits and aegean-rms.fits.

Parameters:
image_filename : str or HDUList

Input image.

hdu_index : int

If fits file has more than one hdu, it can be specified here. Default = 0.

bkgin, rmsin : str or HDUList

Background and noise image filename or HDUList

beam : AegeanTools.fits_image.Beam

Beam object representing the synthsized beam. Will replace what is in the FITS header.

rms, bkg : float

A float that represents a constant rms/bkg level for the entire image. Default = None, which causes the rms/bkg to be loaded or calculated.

cores : int

Number of cores to use if different from what is autodetected.

outbase : str

Basename for output files.

save_image(outname)[source]

Save the image data. This is probably only useful if the image data has been blanked.

Parameters:
outname : str

Name for the output file.