astrophot.utils.conversions package

Submodules

astrophot.utils.conversions.coordinates module

astrophot.utils.conversions.coordinates.Axis_Ratio_Cartesian(q, X, Y, theta=0.0, inv_scale=False)[source]

Applies the transformation: R(theta) Q R(-theta) where R is the rotation matrix and Q is the matrix which scales the y component by 1/q. This effectively counter-rotates the coordinates so that the angle theta is along the x-axis then applies the y-axis scaling, then re-rotates everything back to where it was.

astrophot.utils.conversions.coordinates.Axis_Ratio_Cartesian_np(q, X, Y, theta=0.0, inv_scale=False)[source]

Applies the transformation: R(theta) Q R(-theta) where R is the rotation matrix and Q is the matrix which scales the y component by 1/q. This effectively counter-rotates the coordinates so that the angle theta is along the x-axis then applies the y-axis scaling, then re-rotates everything back to where it was.

astrophot.utils.conversions.coordinates.Rotate_Cartesian(theta, X, Y=None)[source]

Applies a rotation matrix to the X,Y coordinates

astrophot.utils.conversions.coordinates.Rotate_Cartesian_np(theta, X, Y)[source]

Applies a rotation matrix to the X,Y coordinates

astrophot.utils.conversions.dict_to_hdf5 module

astrophot.utils.conversions.dict_to_hdf5.dict_to_hdf5(h, D)[source]
astrophot.utils.conversions.dict_to_hdf5.hdf5_to_dict(h)[source]
astrophot.utils.conversions.dict_to_hdf5.to_hdf5_has_None(l)[source]

astrophot.utils.conversions.functions module

astrophot.utils.conversions.functions.general_uncertainty_prop(param_tuple, param_err_tuple, forward)[source]

Simple function to propogate uncertainty using the standard first order error propogation method with autodiff derivatives. The encodes:

\[\sigma_f^2 = \sum_i \left(\frac{df}{dx_i}\sigma_i\right)^2\]

where i indexes over all the parameters of the function f

Parameters:
  • param_tuple (tuple) – A tuple of the inputs to the function as pytorch tensors.

  • param_err_tuple (tuple) – A tuple of uncertainties (sigma) for the input parameters.

  • forward (func) – The function through which to propogate uncertainty, should be of the form: f(*x) -> y where x is the param_tuple as given and y is a scalar.

astrophot.utils.conversions.functions.moffat_I0_to_flux(I0, n, rd, q)[source]

Compute the total flux integrated to infinity for a moffat profile.

Parameters:
  • I0 – central intensity (flux/arcsec^2)

  • n – moffat curvature parameter (unitless)

  • rd – scale radius

  • q – axis ratio

astrophot.utils.conversions.functions.sersic_I0_to_flux_np(I0, n, R, q)[source]

Compute the total flux integrated to infinity for a 2D eliptical sersic given the \(I_0,n,R_s,q\) parameters which uniquely define the profile (\(I_0\) is the central intensity in flux/arcsec^2). Note that \(R_s\) is not the effective radius, but in fact the scale radius in the more straightforward sersic representation:

\[I(R) = I_0e^{-(R/R_s)^{1/n}}\]
Parameters:
  • I0 – central intensity (flux/arcsec^2)

  • n – sersic index

  • R – Scale radius

  • q – axis ratio (b/a)

astrophot.utils.conversions.functions.sersic_I0_to_flux_torch(I0, n, R, q)[source]

Compute the total flux integrated to infinity for a 2D eliptical sersic given the \(I_0,n,R_s,q\) parameters which uniquely define the profile (\(I_0\) is the central intensity in flux/arcsec^2). Note that \(R_s\) is not the effective radius, but in fact the scale radius in the more straightforward sersic representation:

\[I(R) = I_0e^{-(R/R_s)^{1/n}}\]
Parameters:
  • I0 – central intensity (flux/arcsec^2)

  • n – sersic index

  • R – Scale radius

  • q – axis ratio (b/a)

astrophot.utils.conversions.functions.sersic_Ie_to_flux_np(Ie, n, R, q)[source]

Compute the total flux integrated to infinity for a 2D eliptical sersic given the \(I_e,n,R_e,q\) parameters which uniquely define the profile (\(I_e\) is the intensity at \(R_e\) in flux/arcsec^2). Note that \(R_e\) is the effective radius in the sersic representation:

\[I(R) = I_ee^{-b_n[(R/R_e)^{1/n}-1]}\]
Parameters:
  • Ie – intensity at the effective radius (flux/arcsec^2)

  • n – sersic index

  • R – Scale radius

  • q – axis ratio (b/a)

astrophot.utils.conversions.functions.sersic_Ie_to_flux_torch(Ie, n, R, q)[source]

Compute the total flux integrated to infinity for a 2D eliptical sersic given the \(I_e,n,R_e,q\) parameters which uniquely define the profile (\(I_e\) is the intensity at \(R_e\) in flux/arcsec^2). Note that \(R_e\) is the effective radius in the sersic representation:

\[I(R) = I_ee^{-b_n[(R/R_e)^{1/n}-1]}\]
Parameters:
  • Ie – intensity at the effective radius (flux/arcsec^2)

  • n – sersic index

  • R – Scale radius

  • q – axis ratio (b/a)

astrophot.utils.conversions.functions.sersic_flux_to_I0_np(flux, n, R, q)[source]

Compute the central intensity (flux/arcsec^2) for a 2D eliptical sersic given the \(F,n,R_s,q\) parameters which uniquely define the profile (\(F\) is the total flux integrated to infinity). Note that \(R_s\) is not the effective radius, but in fact the scale radius in the more straightforward sersic representation:

\[I(R) = I_0e^{-(R/R_s)^{1/n}}\]
Parameters:
  • flux – total flux integrated to infinity (flux)

  • n – sersic index

  • R – Scale radius

  • q – axis ratio (b/a)

astrophot.utils.conversions.functions.sersic_flux_to_I0_torch(flux, n, R, q)[source]

Compute the central intensity (flux/arcsec^2) for a 2D eliptical sersic given the \(F,n,R_s,q\) parameters which uniquely define the profile (\(F\) is the total flux integrated to infinity). Note that \(R_s\) is not the effective radius, but in fact the scale radius in the more straightforward sersic representation:

\[I(R) = I_0e^{-(R/R_s)^{1/n}}\]
Parameters:
  • flux – total flux integrated to infinity (flux)

  • n – sersic index

  • R – Scale radius

  • q – axis ratio (b/a)

astrophot.utils.conversions.functions.sersic_flux_to_Ie_np(flux, n, R, q)[source]

Compute the intensity at \(R_e\) (flux/arcsec^2) for a 2D eliptical sersic given the \(F,n,R_e,q\) parameters which uniquely define the profile (\(F\) is the total flux integrated to infinity). Note that \(R_e\) is the effective radius in the sersic representation:

\[I(R) = I_ee^{-b_n[(R/R_e)^{1/n}-1]}\]
Parameters:
  • flux – flux integrated to infinity (flux)

  • n – sersic index

  • R – Scale radius

  • q – axis ratio (b/a)

astrophot.utils.conversions.functions.sersic_flux_to_Ie_torch(flux, n, R, q)[source]

Compute the intensity at \(R_e\) (flux/arcsec^2) for a 2D eliptical sersic given the \(F,n,R_e,q\) parameters which uniquely define the profile (\(F\) is the total flux integrated to infinity). Note that \(R_e\) is the effective radius in the sersic representation:

\[I(R) = I_ee^{-b_n[(R/R_e)^{1/n}-1]}\]
Parameters:
  • flux – flux integrated to infinity (flux)

  • n – sersic index

  • R – Scale radius

  • q – axis ratio (b/a)

astrophot.utils.conversions.functions.sersic_inv_np(I, n, Re, Ie)[source]

Invert the sersic profile. Compute the radius coresponding to a given intensity for a pure sersic profile.

astrophot.utils.conversions.functions.sersic_inv_torch(I, n, Re, Ie)[source]

Invert the sersic profile. Compute the radius coresponding to a given intensity for a pure sersic profile.

astrophot.utils.conversions.functions.sersic_n_to_b(n)[source]

Compute the b(n) for a sersic model. This factor ensures that the \(R_e\) and \(I_e\) parameters do in fact correspond to the half light values and not some other scale radius/intensity.

astrophot.utils.conversions.optimization module

astrophot.utils.conversions.optimization.boundaries(val, limits)[source]

val in limits expanded to range -inf to inf

astrophot.utils.conversions.optimization.cyclic_boundaries(val, limits)[source]

Applies cyclic boundary conditions to the input value.

astrophot.utils.conversions.optimization.cyclic_difference_np(val1, val2, period)[source]

Applies the difference operation between two values with cyclic boundary conditions.

astrophot.utils.conversions.optimization.cyclic_difference_torch(val1, val2, period)[source]

Applies the difference operation between two values with cyclic boundary conditions.

astrophot.utils.conversions.optimization.d_boundaries_dval(val, limits)[source]

derivative of: val in limits expanded to range -inf to inf

astrophot.utils.conversions.optimization.d_inv_boundaries_dval(val, limits)[source]

derivative of: val in range -inf to inf compressed to within the limits

astrophot.utils.conversions.optimization.inv_boundaries(val, limits)[source]

val in range -inf to inf compressed to within the limits

astrophot.utils.conversions.units module

astrophot.utils.conversions.units.PA_shift_convention(pa, unit='rad')[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

astrophot.utils.conversions.units.flux_to_mag(flux, zeropoint, fluxe=None)[source]

Converts a flux total into logarithmic magnitude units.

\[m = -2.5\log_{10}(flux) + z.p.\]

where \(z.p.\) is the zeropoint.

astrophot.utils.conversions.units.flux_to_sb(flux, pixel_area, zeropoint)[source]

Conversion from flux units to logarithmic surface brightness units.

\[\mu = -2.5\log_{10}(flux) + z.p. + 2.5\log_{10}(A)\]

where \(z.p.\) is the zeropoint and \(A\) is the area of a pixel.

astrophot.utils.conversions.units.mag_to_flux(mag, zeropoint, mage=None)[source]

converts logarithmic magnitude units into a flux total.

\[flux = 10^{-(m - z.p.)/2.5}\]

where \(z.p.\) is the zeropoint.

astrophot.utils.conversions.units.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

\[\mu = m + 2.5\log_{10}(A)\]

where \(A\) is an area in arcsec^2.

astrophot.utils.conversions.units.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

\[m = \mu -2.5\log_{10}(A)\]

where \(A\) is an area in arcsec^2.

astrophot.utils.conversions.units.sb_to_flux(sb, pixel_area, zeropoint)[source]

Converts logarithmic surface brightness units into flux units.

\[flux = A 10^{-(\mu - z.p.)/2.5}\]

where \(z.p.\) is the zeropoint and \(A\) is the area of a pixel.

Module contents