autoprof.autoprofutils package

Submodules

autoprof.autoprofutils.Diagnostic_Plots module

autoprof.autoprofutils.Diagnostic_Plots.Plot_Axial_Profiles(dat, R, sb, sbE, pa, results, options)[source]
autoprof.autoprofutils.Diagnostic_Plots.Plot_Background(values, bkgrnd, noise, results, options)[source]
autoprof.autoprofutils.Diagnostic_Plots.Plot_EllipseModel(IMG, Model, R, modeltype, results, options)[source]
autoprof.autoprofutils.Diagnostic_Plots.Plot_I_Profile(dat, R, I, I_e, parameters, results, options)[source]
autoprof.autoprofutils.Diagnostic_Plots.Plot_Isophote_Fit(dat, sample_radii, parameters, results, options)[source]
autoprof.autoprofutils.Diagnostic_Plots.Plot_Isophote_Init_Ellipse(dat, circ_ellipse_radii, ellip, phase, results, options)[source]
autoprof.autoprofutils.Diagnostic_Plots.Plot_Isophote_Init_Optimize(circ_ellipse_radii, allphase, phase, pa_err, test_ellip, test_f2, ellip, ellip_err, results, options)[source]
autoprof.autoprofutils.Diagnostic_Plots.Plot_Meas_Fmodes(R, parameters, results, options)[source]
autoprof.autoprofutils.Diagnostic_Plots.Plot_PSF_Stars(IMG, stars_x, stars_y, stars_fwhm, psf, results, options, flagstars=None)[source]
autoprof.autoprofutils.Diagnostic_Plots.Plot_Phase_Profile(R, parameters, results, options)[source]
autoprof.autoprofutils.Diagnostic_Plots.Plot_Radial_Profiles(dat, R, sb, sbE, pa, nwedges, wedgeangles, wedgewidth, results, options)[source]
autoprof.autoprofutils.Diagnostic_Plots.Plot_SB_Profile(dat, R, SB, SB_e, parameters, results, options)[source]

autoprof.autoprofutils.ImageTransform module

autoprof.autoprofutils.ImageTransform.Crop(IMG, results, options)[source]

Crop the edges of an image about a center point.

If a ‘Center’ method has been applied before in the pipeline we use that to define the galaxy center, otherwise we define the center as half the image.

ap_cropto states the new size of the image after cropping. We default to 512*512.

autoprof.autoprofutils.ImageTransform.Resolution(IMG, results, options)[source]

Change the resolution of an image

Can be used to resample an image at a new pixel scale. The new image can have finer sampling (smaller pixels) or coarser sampling (larger pixels) and this can be accomplished with a variety of methods. First, there are pooling methods which can only reduce the resolution, these methods take a certain block as defined by ap_resolution_shape and perform a mean, median, or max operation on those pixels. That value then becomes the pixel value for a downsampled image. Alternatively, one can use either bicubic or Lanczos interpolation, which can upsample or downsample the image. The parameter ap_resolution_shape is then the desired new shape of the image, which will be fit to represent the same area on the sky. To match the same area on the sky, each pixel is assumed to have a width of 1, thus representing a 1x1 square on the sky.

Parameters:
  • ap_resolution_method (string, default 'lanczos') – Method which is used to perform resolution resampling. Options are: ‘max pool’, ‘mean pool’, ‘median pool’, ‘bicubic’, and ‘lanczos’. Lanczos is very slow, but represents the best interpolation method according to information theory.

  • ap_resolution_shape (tuple, default None) – Shape used for resampling. For pooling methods, this represents the size of the pool/box in which a calcualtion is done. For other methods this is the size of the final desired image. This parameter is required.

  • ap_resolution_dtype (object, default None) – Optional parameter to set a new dtype for the image after resampling. This can be used to reduce precision if it is unnecessary, limiting the size of the final image if it is very finely resampled.

  • ap_iso_interpolate_window (int, default 5) – Only used by Lanczos interpolation, this will set the area of pixels used to calculate the Lanczos interpolated values. Larger values are more accurate, but require quadratically more computation time.

Note

The inputted pixel scale will be incorrect after this operation if it is set for the original image.

Returns:

  • IMG (ndarray) – Resampled galaxy image according to user specified sampling method.

  • results (dict) –

    {}
    

autoprof.autoprofutils.SharedFunctions module

autoprof.autoprofutils.SharedFunctions.AddScale(ax, img_width, loc='lower right')[source]

ax: figure axis object img_width: image width in arcseconds loc: location to put hte scale bar

autoprof.autoprofutils.SharedFunctions.Angle_Average(a)[source]

Compute the average for a list of angles, which may wrap around a cyclic boundary.

a: list of angles in the range [0,2pi]

autoprof.autoprofutils.SharedFunctions.Angle_Median(a)[source]

Compute the median for a list of angles, which may wrap around a cyclic boundary.

a: list of angles in the range [0,2pi]

autoprof.autoprofutils.SharedFunctions.Angle_Scatter(a)[source]

Compute the scatter for a list of angles, which may wrap around a cyclic boundary.

a: list of angles in the range [0,2pi]

autoprof.autoprofutils.SharedFunctions.Angle_TwoAngles_cos(a1, a2)[source]

Compute the angle between two vectors at angles a1 and a2

autoprof.autoprofutils.SharedFunctions.Angle_TwoAngles_sin(a1, a2)[source]

Compute the angle between two vectors at angles a1 and a2

autoprof.autoprofutils.SharedFunctions.Fmode_Areas(R, parameters)[source]
autoprof.autoprofutils.SharedFunctions.Fmode_fluxdens_to_fluxsum(R, I, parameters, A=None)[source]

Integrate a flux density profile, with isophotes including Fourier perturbations.

Parameters:
  • R (arcsec) – semi-major axis length

  • I (flux/arcsec^2) – flux density

  • parameters (list of dictionaries) –

    list of dictionary of isophote shape parameters for each radius. formatted as

    {'ellip': ellipticity,
     'm': list of modes used,
     'Am': list of mode powers,
     'Phim': list of mode phases
    

    }

    entries for each radius.

autoprof.autoprofutils.SharedFunctions.Fmode_fluxdens_to_fluxsum_errorprop(R, I, IE, parameters, N=100, symmetric_error=True)[source]

Integrate a flux density profile, with isophotes including Fourier perturbations.

Parameters:
  • R (arcsec) – semi-major axis length

  • I (flux/arcsec^2) – flux density

  • parameters (list of dictionaries) –

    list of dictionary of isophote shape parameters for each radius. formatted as

    {'ellip': ellipticity,
     'm': list of modes used,
     'Am': list of mode powers,
     'Phim': list of mode phases
    

    }

    entries for each radius.

autoprof.autoprofutils.SharedFunctions.GetOptions(c)[source]

Extract all of the AutoProf user optionional parameters form the config file. User options are identified as any python object that starts with “ap_” in the variable name.

autoprof.autoprofutils.SharedFunctions.ISB_to_muSB(I, band, IE=None)[source]

Converts surface brightness in Lsolar pc^-2 into mag arcsec^-2

I: surface brightness, (L/Lsun) pc^-2 band: Photometric band in which measurements were taken returns: surface brightness in mag arcsec^-2

autoprof.autoprofutils.SharedFunctions.LSBImage(dat, noise)[source]
autoprof.autoprofutils.SharedFunctions.L_to_mag(L, band, Le=None, zeropoint=None)[source]

Returns the Absolute magnitude of a star given its luminosity and distance L: Luminosity in solar luminosities band: Photometric band in which measurements were taken Le: Uncertainty in luminosity zeropoint: user defined zero point

returns: Absolute magnitude

autoprof.autoprofutils.SharedFunctions.PA_shift_convention(pa, deg=False)[source]

Alternates between standard mathematical convention for angles, and astronomical position angle convention. The standard convention is to measure angles counter-clockwise relative to the positive x-axis The astronomical convention is to measure angles counter-clockwise relative to the positive y-axis

autoprof.autoprofutils.SharedFunctions.Read_Image(filename, options)[source]

Reads a galaxy image given a file name. In a fits image the data is assumed to exist in the primary HDU unless given ‘hdulelement’. In a numpy file, it is assumed that only one image is in the file.

filename: A string containing the full path to an image file

returns: Extracted image data as numpy 2D array

autoprof.autoprofutils.SharedFunctions.Rotate_Cartesian(theta, X, Y)[source]
autoprof.autoprofutils.SharedFunctions.Rscale_Fmodes(theta, modes, Am, Phim)[source]
autoprof.autoprofutils.SharedFunctions.Rscale_SuperEllipse(theta, ellip, C=2)[source]
autoprof.autoprofutils.SharedFunctions.SBprof_to_COG(R, SB, parameters)[source]

Converts a surface brightness profile to a curve of growth by integrating the SB profile in flux units then converting back to mag units. Two methods are implemented, one using the trapezoid method and one assuming constant SB between isophotes. Trapezoid method is in principle more accurate, but may become unstable with erratic data.

R: Radius in arcsec SB: surface brightness in mag arcsec^-2 axisratio: b/a indicating degree of isophote ellipticity method: 0 for trapezoid, 1 for constant

returns: magnitude values at each radius of the profile in mag

autoprof.autoprofutils.SharedFunctions.SBprof_to_COG_errorprop(R, SB, SBE, parameters, N=100, symmetric_error=True)[source]

Converts a surface brightness profile to a curve of growth by integrating the SB profile in flux units then converting back to mag units. Two methods are implemented, one using the trapezoid method and one assuming constant SB between isophotes. Trapezoid method is in principle more accurate, but may become unstable with erratic data. An uncertainty profile is also computed, from a given SB uncertainty profile and optional axisratio uncertainty profile.

R: Radius in arcsec SB: surface brightness in mag arcsec^-2 SBE: surface brightness uncertainty relative mag arcsec^-2 axisratio: b/a indicating degree of isophote ellipticity axisratioE: uncertainty in b/a N: number of iterations for computing uncertainty method: 0 for trapezoid, 1 for constant

returns: magnitude and uncertainty profile in mag

autoprof.autoprofutils.SharedFunctions.Sigma_Clip_Upper(v, iterations=10, nsigma=5)[source]

Perform sigma clipping on the “v” array. Each iteration involves computing the median and 16-84 range, these are used to clip beyond “nsigma” number of sigma above the median. This is repeated for “iterations” number of iterations, or until convergence if None.

autoprof.autoprofutils.SharedFunctions.Smooth_Mode(v)[source]
autoprof.autoprofutils.SharedFunctions.StarFind(IMG, fwhm_guess, background_noise, mask=None, peakmax=None, detect_threshold=20.0, minsep=10.0, reject_size=10.0, maxstars=inf)[source]

Find stars in an image, determine their fwhm and peak flux values.

IMG: image data as numpy 2D array fwhm_guess: A guess at the PSF fwhm, can be within a factor of 2 and everything should work background_noise: image background flux noise mask: masked pixels as numpy 2D array with same dimensions as IMG peakmax: maximum allowed peak flux value for a star, used to remove saturated pixels detect_threshold: threshold (in units of sigma) value for convolved image to consider a pixel as a star candidate. minsep: minimum allowed separation between stars, in units of fwhm_guess reject_size: reject stars with fitted FWHM greater than this times the fwhm_guess maxstars: stop once this number of stars have been found, this is for speed purposes

autoprof.autoprofutils.SharedFunctions.abs_mag_to_app_mag(M, D, Me=0.0, De=0.0)[source]

Converts an absolute magnitude to an apparent magnitude M: Absolute magnitude at 10 parcecs D: Distance to object in parsecs returns: Apparent magnitude

autoprof.autoprofutils.SharedFunctions.app_mag_to_abs_mag(m, D, me=0.0, De=0.0)[source]

Converts an apparent magnitude to an absolute magnitude m: Apparent magnitude D: Distance to object in parsecs returns: Absolute magnitude at 10 parcecs

autoprof.autoprofutils.SharedFunctions.arcsec_to_pc(theta, D, thetae=0.0, De=0.0)[source]

Converts a size in arcseconds to parsec

theta: angle in arcsec D: distance in pc

autoprof.autoprofutils.SharedFunctions.flux_to_mag(flux, zeropoint, fluxe=None)[source]
autoprof.autoprofutils.SharedFunctions.flux_to_sb(flux, pixscale, zeropoint)[source]
autoprof.autoprofutils.SharedFunctions.fluxdens_to_fluxsum(R, I, axisratio)[source]

Integrate a flux density profile

R: semi-major axis length (arcsec) I: flux density (flux/arcsec^2) axisratio: b/a profile

autoprof.autoprofutils.SharedFunctions.fluxdens_to_fluxsum_errorprop(R, I, IE, axisratio, axisratioE=None, N=100, symmetric_error=True)[source]

Integrate a flux density profile

R: semi-major axis length (arcsec) I: flux density (flux/arcsec^2) axisratio: b/a profile

autoprof.autoprofutils.SharedFunctions.halfmag(mag)[source]

Computes the magnitude corresponding to half in log space. Effectively, converts to luminosity, divides by 2, then converts back to magnitude. Distance is not needed as it cancels out. Here is a basic walk through:

m_1 - m_ref = -2.5log10(I_1/I_ref)
m_2 - m_ref = -2.5log10(I_1/2I_ref)
            = -2.5log10(I_1/I_ref) + 2.5log10(2)
m_2 = m_1 + 2.5log10(2)
autoprof.autoprofutils.SharedFunctions.interpolate_Lanczos(dat, X, Y, scale)[source]

Perform Lanczos interpolation on an image. https://pixinsight.com/doc/docs/InterpolationAlgorithms/InterpolationAlgorithms.html

autoprof.autoprofutils.SharedFunctions.interpolate_bicubic(dat, X, Y)[source]
autoprof.autoprofutils.SharedFunctions.mag_to_L(mag, band, mage=None, zeropoint=None)[source]

Returns the luminosity (in solar luminosities) given the absolute magnitude and reference point. mag: Absolute magnitude band: Photometric band in which measurements were taken mage: uncertainty in absolute magnitude zeropoint: user defined zero point returns: Luminosity in solar luminosities

autoprof.autoprofutils.SharedFunctions.mag_to_flux(mag, zeropoint, mage=None)[source]
autoprof.autoprofutils.SharedFunctions.mag_to_magperarcsec2(m, a=None, b=None, R=None, A=None)[source]

Converts mag to mag/arcsec^2 m: mag a: semi major axis radius (arcsec) b: semi minor axis radius (arcsec) A: pre-calculated area (arcsec^2) returns: mag/arcsec^2

autoprof.autoprofutils.SharedFunctions.magperarcsec2_to_mag(mu, a=None, b=None, A=None)[source]

Converts mag/arcsec^2 to mag mu: mag/arcsec^2 a: semi major axis radius (arcsec) b: semi minor axis radius (arcsec) A: pre-calculated area (arcsec^2) returns: mag

autoprof.autoprofutils.SharedFunctions.muSB_to_ISB(mu, band, muE=None)[source]

Converts surface brightness in mag arcsec^-2 into Lsolar pc^-2

mu: surface brightness, mag arcsec^-2 band: Photometric band in which measurements were taken returns: surface brightness in (L/Lsun) pc^-2

autoprof.autoprofutils.SharedFunctions.parametric_Fmodes(theta, modes, Am, Phim)[source]
autoprof.autoprofutils.SharedFunctions.parametric_SuperEllipse(theta, ellip, C=2)[source]
autoprof.autoprofutils.SharedFunctions.pc_to_arcsec(R, D, Re=0.0, De=0.0)[source]

Converts a size in parsec to arcseconds

R: length in pc D: distance in pc

autoprof.autoprofutils.SharedFunctions.sb_to_flux(sb, pixscale, zeropoint)[source]

Module contents