galfitools.mge package¶
Submodules¶
galfitools.mge.SbProf module¶
- class galfitools.mge.SbProf.Config[source]¶
Bases:
objectData class for configuration parameters of SbProf
- Aext = 0¶
- center = False¶
- dpival = 150¶
- dplot = True¶
- ds9reg = 'none.reg'¶
- exptime = 1¶
- grid = False¶
- image = 'none.fits'¶
- logx = False¶
- mask = 'mask.fits'¶
- mgzpt = 25¶
- minlevel = 0¶
- namesec = 'gal.png'¶
- output = 'out.png'¶
- parg = 0¶
- pix = False¶
- qarg = 1¶
- rad = 0¶
- rad2 = 0¶
- ranx = [0, 0]¶
- rany = [0, 0]¶
- scale = 1¶
- sectors = 19¶
- skylevel = 0¶
- xc = 1¶
- yc = 1¶
- class galfitools.mge.SbProf.DataImg[source]¶
Bases:
objectData class to save the galaxy image and mask image
- img = array([[2., 6.], [3., 2.]])¶
- mask = array([[2., 6.], [3., 2.]])¶
- galfitools.mge.SbProf.EllipSectors(conf, sectgalax, n_sectors=19, minlevel=0)[source]¶
Creates the plot from data obtained by sectors_photometry
- galfitools.mge.SbProf.FindSB(xarcq, ymgeq, numsectors)[source]¶
obtains the surface brightness from the divided sectors by angle
# the xarcq array must be ordered # use mag instead of counts
- galfitools.mge.SbProf.PlotSB(xradq, ysbq, ysberrq, conf, scale)[source]¶
Produces final best-fitting plot
- galfitools.mge.SbProf.SectPhot(conf, dataimg, n_sectors=19, minlevel=0)[source]¶
Calls to function sectors_photometry for galaxy and model
- galfitools.mge.SbProf.readDataImg(conf)[source]¶
reads the galaxy image and mask image
- Parameters:
conf (Data class Config defined below)
- Returns:
dataimg – contains the images.
- Return type:
Data class DataImg defined above which
- galfitools.mge.SbProf.sbProf(args)[source]¶
Creates a surface brightness profile
- Parameters:
args (argument parser data class) – from library argparser
are (The parameters of the args class)
below (explained)
args.Image (str) – the FITS image
args.Ds9Region (str) – DS9 ellipse region file, which must enclose the galaxy to be fitted.
args.mgzpt (float) – magnitude zeropoint
args.mask (str) – name of the mask image
args.axrat (float) – axis ratio
args.angle (float) – position angle
args.sky (float) – value of the sky background
args.plate (float) – plate scale of the image
args.output (str) – name of the output plot
args.center (bool) – If True, it uses the center of the DS9 ellipse. otherwise will use the pixel position of the peak
args.ranx (list) – range of the x-axis in the plot.
args.rany (list) – range of the y-axis in the plot.
args.logx (bool) – if True x axis is logarithmic
args.pix (bool) – If true top axis indicates pixels
args.grid (bool) – if True enables grid in plot
args.rad (float) – if it is different than None it plots and vertical line at the indicated value
args.rad2 (float) – A second vertical line. If it is different than None it plots and vertical line at the indicated value
galfitools.mge.mge2galfit module¶
- galfitools.mge.mge2galfit.PrintGauss(hdl, ncomp, xpos, ypos, magass, fwhm, axratgass, anglegass, Z, fit)[source]¶
Print the GALFIT Gauss function parameters to a file specified by the filehandle.
- Parameters:
hdl (str) – filehandler
ncomp (int) – number of component
magass (float) – magnitud of Gaussian component
fwhm (float) – Full Width Half Maximum in pixels
axratgass (axis ratio of Gauss component)
anglegass (angular position of component measured from Y-axis) – in degrees
Z (int) – skip object. Z GALFIT component parameter
fit (int) – leave parameter free/fixed during fit
- Return type:
# repeated
- galfitools.mge.mge2galfit.PrintHeader(hdl, A, B, C, D, E, F, G, xlo, xhi, ylo, yhi, convx, convy, J, platedx, platedy, Op, P, S)[source]¶
Print the GALFIT header parameters to a file specified by the filehandle.
- galfitools.mge.mge2galfit.PrintSersic(hdl, ncomp, xpos, ypos, magser, reser, nser, axratser, angleser, Z, fit, serfit)[source]¶
Print the GALFIT Sersic function parameters to a file specified by the filehandle.
- Parameters:
hdl (str) – filehandler
ncomp (int) – number of component
magser (float) – magnitud of Sersic component
reser (float) – effective radius in pixels
nser (float) – Sersic index
axratser (axis ratio of Sersic component)
angleser (angular position of component measured from Y-axis) – in degrees
Z (int) – skip object. Z GALFIT component parameter
fit (int) – leave parameter free/fixed during fit
- Return type:
- galfitools.mge.mge2galfit.PrintSky(hdl, ncomp, sky, Z, fit)[source]¶
Print the GALFIT sky function parameters to a file specified by the filehandle.
- galfitools.mge.mge2galfit.ReadMgePsf(psfile)[source]¶
Reads the file created by mge2gal returns the normalized psf.
Notes
Not used in GALFITools and will be removed in the future
- galfitools.mge.mge2galfit.makeConstraints(consfile: str, numcomp: int) True[source]¶
Creates a contraints file for GALFIT with the number of components
- galfitools.mge.mge2galfit.mge2gal(galfitFile, regfile, center, psf, twist, gauss, freeser, freesky, numgauss, sky=0, xypos=None, ellip=None, posang=None) str[source]¶
Creates MGE initial parameters for GALFIT
Creates a Multi-Gaussian Expansion (MGE) model and formats it into an initial parameter file for fitting by GALFIT.
- galfitFilestr
GALFIT file from which the header information will be extracted to create the MGE model.
- regfilestr
DS9 ellipse region file, which must enclose the galaxy to be fitted.
- centerBool
if True it will take the geometric’s center of the DS9 ellipse as the center, otherwise it will take the pixel with the peak’s value
- psffloat
value of the PSF sigma
- twistbool
If True, the twist option for MGE is enabled, allowing the angular positions of the Gaussians to differ from one another.
- gaussbool
if True, it uses the gaussian model instead of the Sersic model with n = 0.5
- freeserbool
leaves the sersic index as a free parameter to fit
- freeskybool
leaves the sky parameter as a free parameter to fit
- numgaussint
maximum number of gaussians allowed to fit
- skyfloat
value of the sky background. Default = 0
- xyposlist, optional
provides the (x y) position center of the object to fit
- ellipfloat
ellipticity of the object.
- posangfloat
position angle of object. Measured from Y-axis
- Returns:
T2 – name of the output FITS
- Return type:
Notes
The creation of initial parameters for MGE are created through the routine of Cappellari, MNRAS 333,400-410 (2002)
galfitools.mge.sersic2mge module¶
- class galfitools.mge.sersic2mge.GalfitGaussianComponent(x0: float, y0: float, magnitude: float, fwhm_pix: float, axis_ratio: float, pa_deg: float)[source]¶
Bases:
objectGaussian component in GALFIT format.
- Parameters:
- class galfitools.mge.sersic2mge.GaussianFluxComponent(flux: float, sigma_pix: float, axis_ratio: float)[source]¶
Bases:
objectGaussian component represented by total flux.
- Parameters:
- class galfitools.mge.sersic2mge.SersicParameters(x0: float, y0: float, magnitude: float, re_pix: float, n: float, axis_ratio: float, pa_deg: float, zeropoint: float)[source]¶
Bases:
objectParameters of a Sérsic component.
- Parameters:
x0 (float) – X position in pixels.
y0 (float) – Y position in pixels.
magnitude (float) – Integrated magnitude.
re_pix (float) – Effective radius in pixels.
n (float) – Sérsic index.
axis_ratio (float) – Axis ratio q = b/a.
pa_deg (float) – Position angle in degrees using the GALFIT convention.
zeropoint (float) – Photometric zeropoint.
- galfitools.mge.sersic2mge.choose_sigma_grid(re_pix: float, n_gaussians: int, min_sigma_factor: float = 0.02, max_sigma_factor: float = 8.0) ndarray[source]¶
Create a logarithmic sigma grid.
- galfitools.mge.sersic2mge.combined_gaussian_profile(r: ndarray, components: List[GaussianFluxComponent]) ndarray[source]¶
Evaluate the summed Gaussian profile.
- Parameters:
r (np.ndarray) – Radius array in pixels.
components (list of GaussianFluxComponent) – Gaussian components.
- Returns:
Summed intensity profile.
- Return type:
np.ndarray
- galfitools.mge.sersic2mge.conver2mge(galcomps, numgauss, rmax, nsamples, minsigma, maxsigma, zp, index, fout, numbercomp) None[source]¶
converts sersic components to mge components
It converts a Sersic function to a Multi Gaussian expansion
- Parameters:
galcomps (GalComps) – data class containing the galfit components
numgauss (int) – number of gaussian used
rmax (float) – radius max factor
nsamples (int) – number of samples
minsigma (float) – minimum sigma factor
maxsigma (float) – maximum sigma factor
zp (float) – magnitude zero point
index (int) – index position of the components in galcomps
fout (filehandler) – file handler of the output file
numbercomp (int) – number of component
- Returns:
ng – total number of gaussian used in fit
- Return type:
See also
conver2Sersicconverts gaussian, exponential de Vaucoulers to Sersic models
conver2Ferrerconvert gaussian bar to a Ferrer bar
exp2edgeconverts exponential function ot edgedisk function
- galfitools.mge.sersic2mge.convert_to_galfit_gaussians(params: SersicParameters, components: List[GaussianFluxComponent]) List[GalfitGaussianComponent][source]¶
Convert Gaussian flux components to GALFIT Gaussian parameters.
- Parameters:
params (SersicParameters) – Original Sérsic parameters.
components (list of GaussianFluxComponent) – Gaussian components.
- Returns:
Components in GALFIT format.
- Return type:
- galfitools.mge.sersic2mge.fit_sersic_with_flux_conservation(params: SersicParameters, n_gaussians: int = 6, r_max_factor: float = 10.0, n_samples: int = 800, min_sigma_factor: float = 0.02, max_sigma_factor: float = 8.0) List[GaussianFluxComponent][source]¶
Approximate a Sérsic profile with Gaussian components conserving total flux.
The fit is done in terms of total Gaussian fluxes F_j. After the fit, the solution is renormalized so that the sum of all Gaussian fluxes matches exactly the total Sérsic flux.
- Parameters:
params (SersicParameters) – Sérsic parameters.
n_gaussians (int, optional) – Number of Gaussian components.
r_max_factor (float, optional) – Maximum radius in units of R_e.
n_samples (int, optional) – Number of radial samples.
min_sigma_factor (float, optional) – Minimum sigma relative to R_e.
max_sigma_factor (float, optional) – Maximum sigma relative to R_e.
- Returns:
Gaussian components with flux-conserving normalization.
- Return type:
- galfitools.mge.sersic2mge.format_galfit_gaussian_block(components: List[GalfitGaussianComponent], start_index: int = 1, fit_position: bool = False, fit_magnitude: bool = True, fit_fwhm: bool = True, fit_axis_ratio: bool = False, fit_pa: bool = False) str[source]¶
Format Gaussian components as GALFIT text blocks.
- Parameters:
components (list of GalfitGaussianComponent) – Components in GALFIT format.
start_index (int, optional) – Starting component number.
fit_position (bool, optional) – Whether x and y are free.
fit_magnitude (bool, optional) – Whether magnitude is free.
fit_fwhm (bool, optional) – Whether FWHM is free.
fit_axis_ratio (bool, optional) – Whether axis ratio is free.
fit_pa (bool, optional) – Whether PA is free.
- Returns:
GALFIT block text.
- Return type:
- galfitools.mge.sersic2mge.gaussian_profile_from_flux(r: ndarray, component: GaussianFluxComponent) ndarray[source]¶
Evaluate one Gaussian profile from total flux.
- Parameters:
r (np.ndarray) – Radius array in pixels.
component (GaussianFluxComponent) – Gaussian component.
- Returns:
Intensity profile.
- Return type:
np.ndarray
- galfitools.mge.sersic2mge.gaussian_unit_flux_profile(r: ndarray, sigma_pix: float, axis_ratio: float) ndarray[source]¶
Evaluate a Gaussian profile normalized to unit total flux.
- galfitools.mge.sersic2mge.magnitude_from_flux(flux: float, zeropoint: float) float[source]¶
Convert total flux into magnitude.
- galfitools.mge.sersic2mge.print_summary(params: SersicParameters, components: List[GaussianFluxComponent]) None[source]¶
Print a summary of the flux consistency.
- Parameters:
params (SersicParameters) – Original Sérsic parameters.
components (list of GaussianFluxComponent) – Gaussian components.
- galfitools.mge.sersic2mge.sersic_ie_from_total_flux(params: SersicParameters) float[source]¶
Compute I_e from the total flux of an elliptical Sérsic model.
- Parameters:
params (SersicParameters) – Sérsic parameters.
- Returns:
Intensity at the effective radius.
- Return type:
- galfitools.mge.sersic2mge.sersic_profile(r: ndarray, params: SersicParameters) ndarray[source]¶
Evaluate the Sérsic profile.
- Parameters:
r (np.ndarray) – Radius array in pixels.
params (SersicParameters) – Sérsic parameters.
- Returns:
Intensity profile.
- Return type:
np.ndarray
- galfitools.mge.sersic2mge.total_flux_from_magnitude(magnitude: float, zeropoint: float) float[source]¶
Convert integrated magnitude into total flux.
- galfitools.mge.sersic2mge.total_magnitude_of_gaussians(components: List[GaussianFluxComponent], zeropoint: float) float[source]¶
Compute the total integrated magnitude of all Gaussian components.
- Parameters:
components (list of GaussianFluxComponent) – Gaussian components.
zeropoint (float) – Photometric zeropoint.
- Returns:
Total magnitude.
- Return type: