galfitools.galout package¶
Submodules¶
galfitools.galout.PhotDs9 module¶
- galfitools.galout.PhotDs9.FluxBox(Image, xpos, ypos, rx, ry, angle, ncol, nrow)[source]¶
Gets the flux from a DS9 region box in an image
- galfitools.galout.PhotDs9.FluxEllip(Image, xpos, ypos, rx, ry, angle, ncol, nrow)[source]¶
Gets the flux from an DS9 region ellipse in an image
- galfitools.galout.PhotDs9.FluxKron(imagemat, x, y, R, theta, ell, xmin, xmax, ymin, ymax)[source]¶
This subroutine obtain the flux from a Kron ellipse delimited by box defined by: xmin, xmax, ymin, ymax
- galfitools.galout.PhotDs9.FluxPolygon(Image, tupVerts, ncol, nrow)[source]¶
Gets the flux from a DS9 region polygon in an image
- galfitools.galout.PhotDs9.photDs9(ImageFile, RegFile, maskfile, zeropoint, plate, sky)[source]¶
computes the magnitude inside a DS9 region file
Computes the magnitude inside the region defined by ellipse, box or polygon in DS9 region format.
- Parameters:
- Returns:
mag (float) – magnitude measured from DS9 region
sb (float) – surface brightness measured from DS9 region
exptime (float) – exposition time from image
galfitools.galout.fitlog2csv module¶
galfitools.galout.galfit_stats_to_csv module¶
Read a list of GALFIT parameter files, extract model parameters, compute statistics across files, and save the results to a CSV file.
Assumptions¶
All GALFIT files correspond to the same model.
Components appear in the same order in all files.
The uncertainty of each parameter is estimated from the scatter among the different GALFIT solutions.
Usage¶
galfit_stats_to_csv.py galfit_list.txt output.csv
- galfitools.galout.galfit_stats_to_csv.build_statistics(all_data: Dict[Tuple[int, str, str, str, int], List[float]]) List[Dict[str, Any]][source]¶
Compute statistics for each grouped parameter.
- galfitools.galout.galfit_stats_to_csv.clean_line(line: str) str[source]¶
Remove comments and surrounding blanks.
- galfitools.galout.galfit_stats_to_csv.extract_numeric_values(rest: str) List[float][source]¶
Extract numeric values from the right-hand side of a GALFIT line.
This ignores fit flags such as trailing ‘1 1’ or ‘0’. It only keeps tokens that can be converted to float.
- galfitools.galout.galfit_stats_to_csv.is_float(token: str) bool[source]¶
Return True if token can be interpreted as a float.
- galfitools.galout.galfit_stats_to_csv.parse_galfit_file(filepath: Path) List[Dict[str, Any]][source]¶
Parse one GALFIT parameter file.
galfitools.galout.galfit_table_corrector module¶
galfit_table_corrector.py
Usage example¶
fitlogTableCorrector input.txt out.txt –A 0.12 –K 0.04 –pixscale 0.396 –kpc-per-arcsec 0.48 –re-units arcsec
galfitools.galout.getBT module¶
- galfitools.galout.getBT.bulge_to_total(mag_bulge, mag_disk, mag_bar=99)[source]¶
Compute the bulge-to-total luminosity ratio (B/T) from bulge and disk magnitudes.
- galfitools.galout.getBT.getBT(galfitFile: str, dis: float, num_comp: int) float[source]¶
gets the Bulge to Total luminosity ratio
Computes the Bulge to Total luminosity ratio from a a GALFIT file which contains a surface brightness model of two (or three) surface brightness components.
It assumes that the first component in the GALFIT file is the bulge and the second the disk. If the model is composed of bulge, bar and disk, it takes the bulge as the first component, bar as second and the disk as the third component. Therefore sort the surface brightness components accordingly.
If a bar is modeled it takes its luminosity as part of the bulge for the computation of the bulge/Total ratio
If more than three component is found for the galaxy the programs ends and it does not compute the B/T.
galfitools.galout.getBarSize module¶
- class galfitools.galout.getBarSize.GetIr[source]¶
Bases:
objectClass called by getDiff, getDiffx, getIs to obtain the surface brightness from a set of Sersic functions at different radii
the main method is Ir
- Ir : obtains the surface brightness at R
- Itotser : method called by Ir to obtain the
total surface brightness of the set components at R
- Iser : method called by Itotser to obtain
the surface brightnness per component at R
- Itotfer : method called by Ir to obtain the
total surface brightness of ferrer model set components at R
- Ifer : method called by Itotfer to obtain
the surface brightnness of ferrer moodel per component at R
- Ifer(R: float, Io: list, Re: list, n: list, n2: list, q: list, pa: list, theta: float) float[source]¶
ferrers flux to a determined R
- galfitools.galout.getBarSize.findDisk(galfitFile, dis, num_comp, angle, plot, ranx)[source]¶
Determines the barlength using the disk method.
Computes the barlength when the difference between the galaxy surface brightness and disk is minimal. It is computed along the angle direction of the bar. It is assumed the bar is second component.
- Parameters:
galfitFile (str) – name of the GALFIT file
dis (float) – maximum distance among components
num_comp (int) – Number of component from which the center of all components will be determined.
angle (float) – Position angle of the major axis of the galaxy. If None it will take the angle of the second component. Bar is assumed to be the second component.
plot (bool) – if True, it will makes plot of the second derivative
ranx (list) – Specify the range for the plot’s x-axis: xmin to xmax for plotting and searching. If set to None, the default range is [0.1, 100].
- Returns:
rbar – radius of the barlength in pixels
- Return type:
- galfitools.galout.getBarSize.getBarSize(galfitFile: str, dis: int, num_comp: int, plot: bool, ranx: list, out: str, red: bool, scale=1.0, method='break_kappa') tuple[float, int, float][source]¶
gets the bar size of the spiral galaxies
It takes the average of Kappa radius (maximum curvature) and Break radius (maximum of double derivative) to estimate the bar size of the three composed model of bulge, bar, and disk.
It assumes the bar model is the second component of the GALFIT file. Bar model can be a Sersic or Ferrer function. The rest of components must be Sersic (or related) models.
- Parameters:
galfitFile (str)
dis (int)
num_comp (int) – Number of component where it’ll obtain center of all components. in other words it selects the galaxy that contains the bar if simultaneous fitting of galaxies was used.
plot (bool) – If True, it draws plots of the break and kappa radius
ranx (list) – range of search (xmin to xmax) for the kappa radius and break radius. If None, it will search in a range of r=1 to 2.5*Re of effetive radius of the bar model.
out (str) – Name of the output file for the DS9 ellipse region marking the bar.
red (bool) – If True, draws DS9 region ellipse as red color
scale (float) – constant to multiply the bar length. Default =1
method (str) – indicates which method is used to measure the bar length. Options include ‘break_kappa’, ‘break’ ‘kappa’, ‘re’, ‘disk’, ‘all’. Default=’break_kappa’
- Returns:
rbar (float) – bar size in pixels
N (int) – number of components of the galaxy
theta (float) – angular position of the galactic’s bar
See also
getBreak2get the break radius
getKappa2get the kappa radius
- galfitools.galout.getBarSize.getDiff(head1, comps1, comps2, R, theta)[source]¶
Calculates the surface brightness difference between two models at various radii I1 - I2.
galfitools.galout.getCOW module¶
- class galfitools.galout.getCOW.GetCOW[source]¶
Bases:
objectObtains the Curve-of-Growth at a given radius
The main method is GetCOWrad which calls to the other methods This is the one to be used. See the parameters of this method below:
- Parameters:
head (GalHead data class defined in galin/galfit.py)
comps (GalComps data class defined in galin/galfit.py)
theta (float) – Angular position indicating the direction of the galaxy’s curve of growth.
R (array) – Array indicating the radius at each point where the curve of growth will be computed.
- GetCOWrad : given a array of R, obtains the curve of growth
- GetCOWFluxR : selects the components of the galaxy and gets the
total flux of the COW at a given R
- funCOWSer : obtains the function of the COW
- COWtotser : obtains the total Sersic flux of all components
to a determined R
- COWser : obtains the Sersic flux of one component to a determined R
- galfitools.galout.getCOW.getCOW(galfitFile: str, dis: int, angle: float, frac: float, num_comp: int, plotname: str, dpival: int, galfitF2: str, maxdiff: bool) float[source]¶
plots the curve-of-growth
Makes a plot of the Curver-of-Growth from the galfit.XX file. The curve model is made from the Sersic functions.
- Parameters:
galfitFile (str) – name of the GALFIT file
dis (int) – maximum distance among components
angle (float) – angular position of the major axis galaxy. by default (if it is set to None) it will take the last component of the model in the GALFIT file.
frac (float) – fraction of light radius. This is the upper limit of X-Axis.
num_comp (int,) – Number of component where it’ll obtain the center (X,Y)
plotname (str) – name of the output plot fileh
dpival (int) – value of the dpi (dots per inch) for the plot
galfitF2 (str) – Second GALFIT file to add to the plot (optional).
maxdiff (bool) – plot the maximum difference as a vertical line between model 1 and 2 (galfitF2)
- Returns:
totmag (float) – total magnitude
N (int) – total number of components of the galaxy
theta (float) – Angular position indicating the direction of the galaxy’s curve of growth.
Warning
use dis parameter with precaution. The equations assume that the components of the same galaxy share the same center. greater values of dis will produce wrong computations of COW
galfitools.galout.getCOWds9 module¶
- galfitools.galout.getCOWds9.FluxBox(Image, xpos, ypos, rx, ry, angle, ncol, nrow)[source]¶
Gets the flux from a DS9 region box in an image
- galfitools.galout.getCOWds9.FluxEllipStep(Image, xpos, ypos, rx, ry, angle, ncol, nrow, step=1)[source]¶
Gets the flux from an DS9 region ellipse at diffent radius in an image
- galfitools.galout.getCOWds9.FluxKron(imagemat, x, y, R, theta, ell, xmin, xmax, ymin, ymax)[source]¶
This subroutine obtain the flux from a Kron ellipse delimited by box defined by: xmin, xmax, ymin, ymax
- galfitools.galout.getCOWds9.FluxPolygon(Image, tupVerts, ncol, nrow)[source]¶
Gets the flux from a DS9 region polygon in an image
- galfitools.galout.getCOWds9.getCOWDs9(ImageFile, RegFile, maskfile, zeropoint, plate, sky, cmap='inferno', step=1, output='cowds9.png', dpival=200)[source]¶
- computes the magnitude inside a DS9 region file to contruct
the Curve of Growth
Computes the magnitude inside the region defined by ellipse at different radius to compute the Curve of Growth. The ellipse radius is used as a limit for the curve of growth.
- Parameters:
ImageFile (str) – name of the image file
RegFile (str) – name of the DS9 region file
maskfile (str) – name of the mask image
zeropoint (float) – magnitude zero point
plate (float) – plate scale
sky (float) – sky background in counts
step (float) – increase in radius for the magnitude integration
dpival (int) – dots per inch for the plot default = 200
output (str) – plot output file name
- Returns:
mag (float) – magnitude measured from DS9 region
exptime (float) – exposition time from image
galfitools.galout.getChiNu module¶
- galfitools.galout.getChiNu.getChiNu(galfile, numcomp, fracrad=0.99, ds9reg=None)[source]¶
getChiNu computes the Chinu square
computes the Chinu square inside a ellipse with the fraction of total light given by fracrad.
returns Chinu, Akaike information Criterion, Bayesian information criterion and total of free parameters
galfitools.galout.getMeRad module¶
- galfitools.galout.getMeRad.Fser(R: float, Flux: list, Re: list, n: list, q: list, pa: list) float[source]¶
partial sersic flux computed from zero up to R for a single sersic
- galfitools.galout.getMeRad.GetFtotser(R: float, flux: list, rad: list, n: list, q: list, pa: list) float[source]¶
partial sersic flux computed from zero up to R for a set of sersics
- galfitools.galout.getMeRad.getMeRad(galfitFile: str, dis: int, rad: float, angle: float, num_comp: int, mecorr=0) float[source]¶
Obtains the surface brightness at a given radius from a set of Sersic functions.
Given a model composed of multiple Sersic functions, it returns the surface brightness at given radius
- Parameters:
galfitFile (str) – name of the GALFIT file
dis (float) – maximum distance among components
rad (float) – Radius at which the surface brightness is computed
angle (float) – Position angle of the major axis of the galaxy. If None it will take the angle of the last components
num_comp (int) – Number of component from which the center of all components will be determined.
mecorr (float) – Surface brightness correction for universe expansion
- Returns:
totmag (float) – total magnitude
meanmerad (float) – mean of surface brightness at rad in mag/arcsec**2
merad (float) – surface brightness at rad in mag/arcsec**2
N (int) – total number of components
theta (float) – Angular position indicating the direction along which break radius is computed. In degrees
galfitools.galout.getMissingLight module¶
- class galfitools.galout.getMissingLight.GetMag[source]¶
Bases:
objectObtains the total flux and magnitude up to a given radius, applicable only for Sersic functions.
- galfitools.galout.getMissingLight.getMiss(head, mag1, mag2)[source]¶
obtains the magnitude difference
- Parameters:
head (GalHead data class defined in galfit.py)
mag1 (Magnitude 1)
mag2 (Magnitude 2)
- Returns:
magMiss – magnitude difference
- Return type:
- galfitools.galout.getMissingLight.getMissLight(galfitFile1, galfitFile2, dis, num_comp, rad)[source]¶
gets the missing light from the difference between two GALFIT models
From two surface brightness models of the same galaxy, this function computes the magnitude of the difference between the two models. The calculation extends from the center to the radius provided by the user
- Parameters:
galfitFile1 (str) – Galfit File containing the coreless surface brightness model
galfitFile2 (str) – Galfit File containing the core surface brightness model
dis (float) – Maximum distance among components
num_comp (int) – number of component to select center of galaxy. It will apply for both GALFIT files
rad (float) – upper limit of radius to integrate the missing light in pixels
- Returns:
magmiss (float) – magnitude of the missing light
N1 (number of components of model 1)
N2 (number of components of model 2)
Warning
It only works for Sersic functions and their derivations such as de Vaucouleurs, exponential, gaussian.
galfitools.galout.getN module¶
- class galfitools.galout.getN.GetN[source]¶
Bases:
objectComputes the Sersic index from photometric parameters
- GalNs : computes the Sersic index from effective radius and
other fraction of light radius.
- MeMeanMe : computes the Sersic index from surface brightness
at Re and mean surface brightness at Re.
- MeM0(me: float, m0: float) float[source]¶
Uses me and m0 to compute n. It is not very realiable and takes longer than the other two methods
- solveKm0(a: float, b: float, me: float, m0: float) float[source]¶
return the sersic index. It uses Bisection
- galfitools.galout.getN.getN(galfitFile: str, dis: float, frac: float, angle: float, num_comp: int, plot: bool, const=0) float[source]¶
gets the Sersic index
Assuming the galaxy is physically composed of a single Sersic profile, this function computes the Sersic index using two methods: (1) by comparing the mean surface brightness at the effective radius to the surface brightness at the effective radius, and (2) by using two light fraction radii (effective radius and any other radius). Both methods employ bisection.
Although it may seem contradictory to derive the Sersic index from a fit involving multiple Sersic components, this approach is useful when the galaxy is modeled using MGE (Multi-Gaussian Expansion) and the Sersic index needs to be estimated.
- Parameters:
galfitFile (str) – name of the GALFIT file
dis (float) – maximum distance among components
frac (float,) – fraction of light.
angle (float,) – Angle of the major axis of the galaxy. If None, it uses the angle of the last component
num_comp (int,) – number of component where the center will be take the center
plot (bool,) – If True, makes a plot of Sersic index vs. fraction of light radius used for computation.
const (float, optional) – Substract constant from plot (for visualization purposes only)
- Returns:
sersic (float)
float – Sersic index mean of the fraction of light radius
float – Sersic index standard deviation mean of the fraction of light radius method
totmag (float) – total magnitude
N (int) – total number of components
theta (Angular position indicating the direction along) – which the effective radius and surface brightness at the effective radius are computed. In degrees
Warning
The computation of the Sersic index assumes that all Sersic functions share the same center. Therefore, use the dis tolerance variable with caution. If the distance between components is significant, the result will be less accurate.
Notes
The fraction light method, gets the Sersic index using two fraction of light radius, for example it uses the Re and R90 (50% of light radius and 90% of light radius) Hence this method uses different fraction of light radius and Re, and it returns the mean and standard deviation of all the estimations of the Sersic index.
The fraction light method calculates the Sersic index using two light fraction radii, such as the effective radius (Re) and another radius enclosing some fraction of the light. This method uses various light fraction radii and Re, and returns the mean and standard deviation of all Sersic index estimates.
galfitools.galout.getNds9 module¶
- galfitools.galout.getNds9.FluxBox(Image, xpos, ypos, rx, ry, angle, ncol, nrow)[source]¶
Gets the flux from a DS9 region box in an image
- galfitools.galout.getNds9.FluxEllipStep(Image, xpos, ypos, rx, ry, angle, ncol, nrow, step=1)[source]¶
Gets the flux from an DS9 region ellipse at diffent radius in an image
- galfitools.galout.getNds9.FluxKron(imagemat, x, y, R, theta, ell, xmin, xmax, ymin, ymax)[source]¶
This subroutine obtain the flux from a Kron ellipse delimited by box defined by: xmin, xmax, ymin, ymax
- galfitools.galout.getNds9.FluxPolygon(Image, tupVerts, ncol, nrow)[source]¶
Gets the flux from a DS9 region polygon in an image
- galfitools.galout.getNds9.getNDs9(ImageFile, RegFile, maskfile, zeropoint, plate, sky, step=1, output='cowds9.png', dpival=200, plot=False)[source]¶
- computes the magnitude inside a DS9 region file to contruct
the Curve of Growth
Computes the magnitude inside the region defined by ellipse at different radius to compute the Curve of Growth. The ellipse radius is used as a limit for the curve of growth.
- Parameters:
output: plot output
- Returns:
mag (float) – magnitude measured from DS9 region
sb (float) – surface brightness measured from DS9 region
exptime (float) – exposition time from image
galfitools.galout.getPeak module¶
- galfitools.galout.getPeak.getPeak(image: str, regfile: str, center: bool, maskfile: str) None[source]¶
- Returns the coordinates of the pixel with the
highest value of counts from a DS9 ellipse region file
- Parameters:
- Returns:
float, float – X,Y coordinates of the pixel with the highest count value
axratio (float) – axis ratio of the DS9 ellipse region file
theta (float)
galfitools.galout.getRads module¶
- class galfitools.galout.getRads.GetBreak[source]¶
Bases:
object- Class to obtain the break radius from a set of Sersic functions.
Class called by getBreak function.
- GalBreak : Evaluates the Break function
- FindBreak : Return the break radii of a set of Sersic functions
- MulFindBreak : Returns the break radius by evaluating it at various
initial parameters derived from a list of effective radii.
- funGalBreakSer : evaluates the break function at a given radius
- BreakSer : Break function to a determined R
- class galfitools.galout.getRads.GetFWHM[source]¶
Bases:
object- Class to obtain the FWHM for the whole model
Class called by getFWHM function.
- FindFWHM : return the fwhm of a set of Sersic functions.
It uses Bisection
- FullFWHMSer : Surface brightness I(R) from sersic function evaluated at R
- GalFWHM : Evaluates the surface britghtness from a list of R
- funGalFWHMSer : Evaluates Surface brightness at R
- FWHMSer : Surface brightness I(R) from sersic function evaluated at R
- FWHMSer(R: float, Ie: list, Re: list, n: list, q: list, pa: list, theta: float) float[source]¶
I(R) from sersic function to a determined R
- class galfitools.galout.getRads.GetIr[source]¶
Bases:
objectClass called by getDiff, getDiffx, getIs to obtain the surface brightness from a set of Sersic functions at different radii
the main method is Ir
- Ir : obtains the surface brightness at R
- Itotser : method called by Ir to obtain the
total surface brightness of the set components at R
- Iser : method called by Itotser to obtain
the surface brightnness per component at R
- class galfitools.galout.getRads.GetKappa[source]¶
Bases:
object- Class to obtain the kappa radius from a set of Sersic functions.
Class called by getKappa function.
- GalKappa : Evaluates the kappa function
- FindKappa : Return the kappa radii of a set of Sersic functions
- MulFindKappa: Returns the kappa radius by evaluating it at various
initial parameters derived from a list of effective radii.
- funGalKappaSer : evaluates the kappa function at a given radius
- BetaSer : kappa function to a determined R
- BetaSer(R: float, Ie: list, Re: list, n: list, q: list, pa: list, theta: float) float[source]¶
Kappa from sersic function to a determined R
- FindKappa(comps: GalComps, theta: float, initial_comp: int) float[source]¶
return the break radius of a set of Sersic functions
- MulFindKappa(comps: GalComps, theta: float, radius: list) float[source]¶
return the kappa radius evaluated at different effective radius
- SlopeSer(R: float, Ie: list, Re: list, n: list, q: list, pa: list, theta: float) float[source]¶
slope from sersic function to a determined R
- class galfitools.galout.getRads.GetMe[source]¶
Bases:
object- Class to obtain the surface brightness at effective radius
and the mean surface brightness at effective radius in units of mag/’’
- MeanMe : Mean Surface brightness I(R) at effective radius
- Me : Surface brightness I(R) at R
- Itotser : Evaluates the Sersic surface brightness flux
from a list of R
- Iser : Sersic surface brightness flux at R
- class galfitools.galout.getRads.GetReff[source]¶
Bases:
object- Class to obtain the effective radius of the composed
surface brightness model
class is called by GetReComp function. Main method is GetReSer.
- Attributes of the main method GetReser.
- galhead¶
data class that stores header information of Galfit file.
- Type:
GalHead data class defined in galin/galfit.py
- comps¶
data class that stores the components parameters of galfit file.
- Type:
GalComps data class defined in galin/galfit.py
- eff¶
fraction of total light. The method will find the radius at this value. eff must be between 0 and 1
- Type:
- theta¶
Angular position indicating the direction along which break radius is computed. In degrees
- Type:
- GetReSer : computes the effective radius from the
composed Sersic model using the bisection method
- Ffer(R: float, Flux: list, Re: list, n: list, n2: list, q: list, pa: list, theta: float) float[source]¶
Luminosity inside radius R for a Ferrer-like profile.
- Parameters:
- Returns:
L – Luminosity inside radius R.
- Return type:
- Fser(R: float, Flux: list, Re: list, n: list, q: list, pa: list, theta: float) float[source]¶
partial sersic flux computed from zero up to R for a single sersic
- Ftotserfer(R: float, NameComp: str, flux: list, rad: list, n: list, n2: list, q: list, pa: list, theta: float) float[source]¶
partial sersic flux computed from zero up to R for a set of sersics
- class galfitools.galout.getRads.GetSlope[source]¶
Bases:
objectClass to obtain the slope radius from a set of Sersic (and Ferrer) functions.
This class is called by GetSlope Function to compute the radius at the given slope value. The main method is FindSlope. GalSlope accepts Ferrer model
- GalSlope: Evaluates the first derivative at the specified radius (R).
- FindSlope: Return the slope radius of a set of Sersic functions.
It uses bisection to find the radius at the specified slope
- FindSlope(comps: GalComps, theta: float, slope: float) float[source]¶
return the Re of a set of Sersic functions. It uses Bisection
- FullSlopeSer(R: float, Ie: float, Re: list, n: list, q: list, pa: list, theta: float) float[source]¶
- SlopeFerrer(R: float, Ie: list, Re: list, n: list, q: list, pa: list, theta: float) float[source]¶
slope from Ferrer function to a determined R
=> d log Σ / d log r = - α * n * x / (1-x)
- Note: parameters here are not Sersic anymore, but
these use the same positional arguments in sersic file. For instance Re here really means Outer truncation radius. Ie does not have an equivalent, but it is used as beta here. Sersic index is alpha here.
- SlopeSer(R: float, Ie: list, Re: list, n: list, q: list, pa: list, theta: float) float[source]¶
slope from sersic function to a determined R
- galfitools.galout.getRads.MulFindBreak(comps: GalComps, theta: float, radius: list)[source]¶
Given a list of radii, it finds the break radius by evaluating each radius in the list as an initial parameter.
- galfitools.galout.getRads.MultiFindKappa(comps, theta, radius)[source]¶
Given a list of radii, it finds the kappa radius by evaluating each radius in the list as an initial parameter.
- galfitools.galout.getRads.getBreak(galfitFile: str, dis: float, inicomp: int, quick: bool, random: int, num_comp: int, angle: float, plot: bool, ranx: list) float[source]¶
Obtains the break radius from a set of Sersic functions.
Given a model composed of multiple Sersic functions, it returns the radius corresponding to the maximum of the second derivative.
- Parameters:
galfitFile (str) – name of the GALFIT file
dis (float) – maximum distance among components
inicomp (int) – Number of component where it’ll obtain the initial parameter to search break radius or to generated random initial radius
quick (bool) – If True, it chooses inicomp as a initial parameter
random (int) – Number of random radii to use as initial parameters for the global maximum search. Random radii will be generated within the range from 0 to the effective radius of the component specified by the inicomp parameter.
num_comp (int) – Number of component from which the center of all components will be determined.
angle (float) – Position angle of the major axis of the galaxy. If None it will take the angle of the last components
plot (bool) – if True, it will makes plot of the second derivative
ranx (list) – Specify the range for the plot’s x-axis: xmin to xmax for plotting and searching. If set to None, the default range is [0.1, 100].
- Returns:
rbreak (float) – break radius in pixels
N (int) – total number of components
theta (float) – Angular position indicating the direction along which break radius is computed. In degrees
See also
getBreak2a more efficient way to compute Break radius
Notes
The maximum of the second derivative involves to find the global maximum among many local maximums. Hence the choose of the initial parameters is fundamental.
- galfitools.galout.getRads.getBreak2(galfitFile: str, dis: float, angle: float, num_comp: int, plot: bool, ranx: list) float[source]¶
- Obtains the break radius from a set of Sersic functions.
This is an alternative method to getBreak
Given a model composed of multiple Sersic functions, it returns the radius corresponding to the maximum of the second derivative. This method is more efficient to find the global maximum than getBreak
- Parameters:
galfitFile (str) – name of the GALFIT file
dis (float) – maximum distance among components
num_comp (int) – Number of component from which the center of all components will be determined.
angle (float) – Position angle of the major axis of the galaxy. If None it will take the angle of the last components
plot (bool) – if True, it will makes plot of the second derivative
ranx (list) – Specify the range for the plot’s x-axis: xmin to xmax for plotting and searching. If set to None, the default range is [0.1, 100].
- Returns:
rbreak (float) – break radius in pixels
N (int) – total number of components
theta (float) – Angular position indicating the direction along which break radius is computed. In degrees
See also
getBreakan alternative to find Break radius
Notes
The maximum of the second derivative involves to find the global maximum among many local maximums. Hence the choose of the appropiate range with the ranx variable
- galfitools.galout.getRads.getBulgeRad(galfitFile1, galfitFile2, dis, num_comp, angle, plot, ranx)[source]¶
Determines the radius at which the surface brightness of two models are equal.
Given two surface brightness models, this function identifies the radius where their surface brightness values are equal. This is useful for determining the radius where the surface brightness of the bulge and disk are equal, or for finding the radius between the core and coreless regions in elliptical galaxies.
- Parameters:
galfitFile1 (str) – name of the GALFIT file with model 1
galfitFile2 (str) – name of the GALFIT file with model 2
dis (float) – maximum distance among components
num_comp (int) – Number of component from which the center of all components will be determined.
angle (float) – Position angle of the major axis of the galaxy. If None it will take the angle of the last components
plot (bool) – if True, it will makes plot of the second derivative
ranx (list) – Specify the range for the plot’s x-axis: xmin to xmax for plotting and searching. If set to None, the default range is [0.1, 100].
- Returns:
rbulge (float) – radius where the I1 and I2 are equal in pixels
N1 (int) – total number of components for model 1
N2 (int) – total number of components for model 2
theta (float) – Angular position indicating the direction along which this radius is computed. In degrees
- galfitools.galout.getRads.getDiff(head1, comps1, comps2, R, theta)[source]¶
Calculates the surface brightness difference between two models at various radii I1 - I2.
- galfitools.galout.getRads.getDiffx(r, head1, comps1, comps2, theta)[source]¶
Calculates the surface brightness difference between two models at a specified radii I1 - I2.
- galfitools.galout.getRads.getFWHM(galfitFile: str, dis: int, angle: float, num_comp: int)[source]¶
Obtains gets the FWHM from a set of Sersics functions.
Given a model composed of multiple Sersic functions, it returns the radius with Full Width Half Maximum (FWHM)
- Parameters:
galfitFile (str) – name of the GALFIT file
dis (float) – maximum distance among components
angle (float) – Position angle of the major axis of the galaxy. If None it will take the angle of the last components
num_comp (int) – Number of component from which the center of all components will be determined.
- Returns:
fwhm (float) – FWHM radius in pixels
N (int) – total number of components
theta (float) – Angular position indicating the direction along which break radius is computed. In degrees
- galfitools.galout.getRads.getIs(head1, comps1, comps2, R, theta)[source]¶
Calculates the surface brightness of two models at various radii.
- galfitools.galout.getRads.getKappa(galfitFile: str, dis: int, inicomp: int, quick: bool, random: int, angle: float, num_comp: int, plot: bool, ranx: list) float[source]¶
Obtains the Kappa radius from a set of Sersic functions.
Given a model composed of multiple Sersic functions, it returns the radius corresponding to the maximum curvature.
- Parameters:
galfitFile (str) – name of the GALFIT file
dis (float) – maximum distance among components
inicomp (int) – Number of component where it’ll obtain the initial parameter to search kappa radius or to generated random initial radius
quick (bool) – If True, it chooses inicomp as a initial parameter
random (int) – Number of random radii to use as initial parameters for the global maximum search. Random radii will be generated within the range from 0 to the effective radius of the component specified by the inicomp parameter.
num_comp (int) – Number of component from which the center of all components will be determined.
angle (float) – Position angle of the major axis of the galaxy. If None it will take the angle of the last components
plot (bool) – if True, it will makes plot of the second derivative
ranx (list) – Specify the range for the plot’s x-axis: xmin to xmax for plotting and searching. If set to None, the default range is [0.1, 100].
- Returns:
rkappa (float) – kappa radius in pixels
N (int) – total number of components
theta (float) – Angular position indicating the direction along which break radius is computed. In degrees
See also
getKappa2a more efficient way to compute Kappa radius
Notes
The maximum of the curvature involves to find the global maximum among many local maximums. Hence the choose of the initial parameters is fundamental.
- galfitools.galout.getRads.getKappa2(galfitFile: str, dis: int, angle: float, num_comp: int, plot: bool, ranx: list) float[source]¶
- Obtains the kappa radius from a set of Sersic functions.
This is an alternative method to getKappa function.
Given a model composed of multiple Sersic functions, it returns the radius corresponding to the maximum curvature. This method is more efficient to find the global maximum than getKappa
- Parameters:
galfitFile (str) – name of the GALFIT file
dis (float) – maximum distance among components
num_comp (int) – Number of component from which the center of all components will be determined.
angle (float) – Position angle of the major axis of the galaxy. If None it will take the angle of the last components
plot (bool) – if True, it will makes plot of the second derivative
ranx (list) – Specify the range for the plot’s x-axis: xmin to xmax for plotting and searching. If set to None, the default range is [0.1, 100].
- Returns:
rbreak (float) – break radius in pixels
N (int) – total number of components
theta (float) – Angular position indicating the direction along which break radius is computed. In degrees
See also
getKappaan alternative to find Kappa radius
Notes
The maximum of the curvature involves to find the global maximum among many local maximums. Hence the choose of the appropiate range with the ranx variable
- galfitools.galout.getRads.getReComp(galfitFile: str, dis: int, eff: float, angle: float, num_comp: int, mecorr=0) float[source]¶
Obtains the effective radius from a set of Sersic functions.
Given a model composed of multiple Sersic functions, it returns the effective radius or any other radius that represents a percent of total light.
- Parameters:
galfitFile (str) – name of the GALFIT file
dis (float) – maximum distance among components
eff (float) – fraction of total light. The function will find the radius at this value. eff must be between 0 and 1
angle (float) – Position angle of the major axis of the galaxy. If None it will take the angle of the last components
num_comp (int) – Number of component from which the center of all components will be determined. If different than 1, Effective radius will be computed in the angular position of this component.
mecorr (float) – surface brightness correction for universe expansion
- Returns:
EffRad (float) – radius found at eff of total light in pixels
totmag (float) – total magnitude
meanme (float) – mean of surface brightness at effective radius in mag/arcsec**2
me (float) – surface brightness at EffRad in mag/arcsec**2
N (int) – total number of components
theta (float) – Angular position indicating the direction along which break radius is computed. In degrees
Notes
The function call a class to find EffRad using the Bisection method.
- galfitools.galout.getRads.getSlope(galfitFile: str, dis: int, slope: float, angle: float, num_comp: int, plot: bool, ranx: list) float[source]¶
Obtains the slope radius from a set of Sersic functions.
Given a model composed of multiple Sersic functions, this function returns the radius corresponding to the derivative value specified by the slope variable. It calls to class GetSlope to computed using the bisection method
- Parameters:
galfitFile (str) – name of the GALFIT file
dis (float) – maximum distance among components
slope (float) – Value of the slope at which the radius will be determined.
angle (float) – Position angle of the major axis of the galaxy. If None it will take the angle of the last components
num_comp (int) – Number of component from which the center of all components will be determined.
plot (bool) – if True, it will makes plot of the second derivative
ranx (list) – Specify the range for the plot’s x-axis: xmin to xmax for plotting and searching. If set to None, the default range is [0.1, 100].
- Returns:
rgam (float) – the slope radius in pixels
N (int) – total number of components
theta (float) – Angular position indicating the direction along which break radius is computed. In degrees
galfitools.galout.magcorr module¶
- galfitools.galout.magcorr.magCorr(galfitFile: str, fileout: str, A=0.0, K=0.0) GalComps[source]¶
Corrects magnitudes for Extinction and K correction.
It reads a galfit file and corrects all the magnitudes for Extinction and K correction
- Parameters:
- Returns:
galcomps – data class defined in galfitools.galin.galfit
- Return type:
Note
user must provide the corrections and applies to all components in the GALFIT file.
See also
conver2Sersicconverts gaussian, exponential de Vaucoulers to Sersic models
conver2Ferrerconvert gaussian bar to a Ferrer bar
conver2Edgeconvert to edgedisk
galfitools.galout.magedgedisk module¶
- galfitools.galout.magedgedisk.edgedisk_total_magnitude(mu0_mag_arcsec2: float, hs_pix: float, rs_pix: float, pixscale: float) float[source]¶
Compute the total magnitude of a GALFIT edgedisk model.
- Parameters:
- Returns:
Total magnitude of the edgedisk model.
- Return type:
- Raises:
ValueError – If any geometric parameter is non-positive.
- galfitools.galout.magedgedisk.magEdge(galfile, numedge=2)[source]¶
Computes the magnitude of the EdgeDisk function.
It converts a exponential function (or Sersic with n = 1) to a edgedisk function
- Parameters:
- Returns:
magedge
- Return type:
magnitude of the EdgeDisk function
See also
exp2edgeConvert a Exponential function to EdgeDisk function.
galfitools.galout.magferrer module¶
- galfitools.galout.magferrer.ferrer_luminosity(R, Sigma0, r_out, alpha, beta_par)[source]¶
Luminosity inside radius R for a Ferrer-like profile.
- Parameters:
- Returns:
L – Luminosity inside radius R.
- Return type:
- galfitools.galout.magferrer.ferrer_total_luminosity(Sigma0, r_out, alpha, beta_par)[source]¶
Total luminosity integrated from 0 to r_out.
- galfitools.galout.magferrer.ferrers_magnitude(R: float, mu0_mag_arcsec2: float, r_out: float, alpha: float, beta_par: float, pixscale: float) float[source]¶
Compute the magnitude of the GALFIT ferrers model inside radius R.
- Parameters:
- Returns:
magnitude inside radius R
- Return type:
- galfitools.galout.magferrer.ferrers_total_magnitude(mu0_mag_arcsec2: float, r_out: float, alpha: float, beta_par: float, pixscale: float) float[source]¶
Compute the total magnitude of the GALFIT ferrers model.
- Parameters:
- Returns:
Total magnitude of the ferrers model.
- Return type:
- galfitools.galout.magferrer.magFerrers(galfile, numferrer=2)[source]¶
Computes the magnitude of the Ferrers function.
It computes magnitude :param galfitFile: name of the GALFIT file :type galfitFile: str :param numferrer: component number (position in input file) of the ferrer function
default = 2
- Returns:
magedge
- Return type:
magnitude of the EdgeDisk function
See also
magEdgeComputes the Ferrers function.
galfitools.galout.showcube module¶
- galfitools.galout.showcube.Comp2Ellip(galhead, galcomps, N, lw=1)[source]¶
converts galfit component parameter into an Ellipse object
- class galfitools.galout.showcube.ShowCube(cubeimg: str, namepng='cubeout.png', dpival=100, bri=0, con=1, cmap='viridis', ellipse=[], plate=1)[source]¶
Bases:
object
- galfitools.galout.showcube.displayCube(cubeimage: str, namecube: str, dpival: int, brightness: float, contrast: float, cmap: str, scale: float, noplot: bool) None[source]¶
makes an image of the GALFIT cube image output
- Parameters:
cubeimage (str) – name of the GALFIT FITS cube image
namecube (str) – name of the output png image
dpival (int) – dots per inch value
brightness (float) – brightness
contrast (float) – contrast
cmap (str) – name of the matplotlib color map
scale (float) – plate scale of the image
noplot (bool) – if True avoids plotting and write the output image
- Return type:
None
galfitools.galout.split_components module¶
Split a GALFIT file into one file per non-sky component.
- galfitools.galout.split_components.get_component_type(component_block: list[str]) str[source]¶
Return the GALFIT function name for a component block.
- galfitools.galout.split_components.split_galfit_file(galfit_file: Path, output_dir: Path | None = None) list[Path][source]¶
Split a GALFIT file into several files, one per non-sky component.
- Parameters:
galfit_file (pathlib.Path) – Input GALFIT file.
output_dir (pathlib.Path or None, optional) – Directory where the output files are written. If None, the files are written in the same directory as galfit_file.
- Returns:
Paths of the generated files.
- Return type:
list of pathlib.Path
Notes
The script keeps the original GALFIT header, defined as all lines before the first
# Component number:block. The sky component is ignored.