API Reference
You can find automatically generated documentation for each module in the M2_ProposalTools package below.
M2_ProposalTools.analytic_integrations module
- M2_ProposalTools.analytic_integrations.analytic_shells(r_bins, vals, theta, alphas=[], shockxi=0.0, fixalpha=False, finite=False, narm=False, strad=False, negvals=None, tmax=0)[source]
Returns an integrated map of some signal along the line of sight. This routine assumes that the pressure within a shell has a power law distribution.
- Parameters:
r_bins (class:numpy.ndarray) – The radial bins (in radians)
vals (class:numpy.ndarray) – Pressure for each bin used
theta (class:numpy.ndarray) – An array of radii (in radian) in the map, which will be used for gridding the model
alphas (array-like) – An array of power laws (indices) for 3d pressure distribution
shockxi (float) – Polar tapering, if used in a shock model.
finite (bool) – Set this keyword if you do NOT want to integrate to infinity.
narm (bool) – Normalize at R_min (within a bin)
strad (bool, optional) – STrict RADii. When using a shock model (e.g. Abell 2146), where specific radii, especially inner radii are defined, this keyword should be set! Note that if the finite keyword is set, then this does not need to be set.
negvals (class:numpy.ndarray, optional) – None by default. Otherwise, set as boolean array, same length as r_bins
- Returns:
out – Map convolved with the beam.
- Return type:
class:numpy.ndarray
- M2_ProposalTools.analytic_integrations.binsky(args, r_bins, theta_range, theta, inalphas=[])[source]
Returns a surface brightness map for a binned profile, slopes, and radial integrals.
- Parameters:
args (class:numpy.ndarray) – Pressure for each bin used
- r_bins: class:numpy.ndarray
bin edges
- theta_rangeclass:numpy.ndarray
Highly sampled array of radii.
- thetaclass:numpy.ndarray
A map of azimuthal angles.
- inalphaslist
Generally best to leave as an empty list.
- Returns:
outmap (class:numpy.ndarray)
alphas (class:numpy.ndarray)
integrals (class:numpy.ndarray)
- M2_ProposalTools.analytic_integrations.binsky_SZ_general(epressure, geoparams, r_bins, theta_range, xymap, inalphas=[], beta=0.0, betaz=None, finite=False, narm=False, fixalpha=False, strad=False, array='2', instrument='MUSTANG2', taper='normal')[source]
Returns a surface brightness map for a binned profile fit, with far more generality than previously done.
- Parameters:
epressure (array-like) – The electron pressure (no units in Python, but otherwise should be in cm**-3 keV**-1)
geoparams (array-like) – [X_shift, Y_shift, Rotation, Ella*, Ellb*, Ellc*, Xi*, Opening Angle]
r_bins (array-like) – The (elliptical) bins for the profile.
theta_range (class:numpy.ndarray) – Array of radii for the corresponding Int_Pres
xymap (tuple of class:numpy.ndarray) – A tuple (x,y) where x and y are grids of their respective coordinates in << arceconds >>
inalphas (array-like) – Nothing to see here. Move along.
beta (float) – Fraction of the speed of light of the cluster bulk (peculiar) motion.
betaz (float) – Fraction of the speed of light of the cluster along the line of sight.
finite (bool) – Integrate out to last finite (defined) bin.
narm (bool) – Normalized at R_Min. This is important for integrating shells.
strad (bool) – STrict RADii; if the pressure model has to obey strict placements of radii, use this!
Notes
Ella should be set to 1. Therefore, define Ellb relative to Ella (and likewise with Ellc)
- Returns:
mymap – A 2D map from input radial surface brightness profile
- Return type:
class:numpy.ndarray
- M2_ProposalTools.analytic_integrations.binsky_general(vals, geoparams, r_bins, theta_range, xymap, inalphas=[], finite=False, narm=False, taper='normal', fixalpha=False, strad=False)[source]
Returns a surface brightness map for a binned profile fit
- Parameters:
vals (array-like) – The electron pressure (no units in Python, but otherwise should be in cm**-3 keV**-1)
geoparams (array-like) – [X_shift, Y_shift, Rotation, Ella*, Ellb*, Ellc*, Xi*, Opening Angle]
r_bins (array-like) – The (elliptical) bins for the profile.
theta_range (array-like) – The range of angles for which to create a 1D profile (which can then be interpolated)
xymap (tuple) – A tuple (x,y) where x and y are grids of their respective coordinates in << arceconds >>
inalphas (array-like) – Nothing to see here. Move along.
beta (float) – Fraction of the speed of light of the cluster bulk (peculiar) motion.
betaz (float) – Fraction of the speed of light of the cluster along the line of sight.
finite (bool) – Integrate out to last finite (defined) bin.
narm (bool) – Normalized at R_Min. This is important for integrating shells.
strad (bool) – STrict RADii; if the pressure model has to obey strict placements of radii, use this!
Notes –
__________ –
is (--> We should consider Ella to be RESTRICTED to 1. That) –
calculated (Ellb and Ellc should always be) –
parameter. (relative to the x-axis) –
- Returns:
mymap – A map that accounts for a range of geometrical restrictions. The integrals may not be applicable.
- Return type:
class:numpy.ndarray
- M2_ProposalTools.analytic_integrations.general_gridding(xymap, theta_range, r_bins, geoparams, finite=False, taper='normal', integrals=0, Int_Pres=0, ell_int=0, tap_int=0, oldvs=False, xyinas=True)[source]
Returns a surface brightness map for a binned los-integrated profile (Int_Pres).
- Parameters:
xymap (tuple of class:numpy.ndarray) – A tuple (x,y) where x and y are grids of their respective coordinates in << arceconds >>
theta_range (class:numpy.ndarray) – Array of radii for the corresponding Int_Pres
geoparams (array-like) – [X_shift, Y_shift, Rotation, Ella*, Ellb*, Ellc*, Xi*, Opening Angle]
Notes
Ella should be set to 1. Therefore, define Ellb relative to Ella (and likewise with Ellc)
- Returns:
mymap – A 2D map from input radial surface brightness profile
- Return type:
class:numpy.ndarray
- M2_ProposalTools.analytic_integrations.get_ell_rads(x, y, ella, ellb)[source]
Get ellipsoidal radii from x,y standard
:param : :type : param x: coordinate along major axis (a) :param : :type : type x: class:numpy.ndarray :param : :type : param y: coordinate along minor axis (b) :param : :type : type y: class:numpy.ndarray :param : :type : param ella: scaling along major axis (should stay 1) :param : :type : type ella: float :param : :type : param ellb: scaling along minor axis :param : :type : type ella: float
- M2_ProposalTools.analytic_integrations.grid_profile(theta_range, profile, xymap, geoparams=[0, 0, 0, 1, 1, 1, 0, 0], myscale=1.0, axis='z', xyinas=True)[source]
Grids a sufficiently fine-resolution profile.
- Parameters:
theta_range (class:numpy.ndarray) – Abscisca (radii, in radians) for profile
profile (class:numpy.ndarray) – Ordinate profile values
xymap (tuple) – A tuple (x,y) where x and y are grids of their respective coordinates in << arceconds >>
geoparams (array-like) – [X_shift, Y_shift, Rotation, Ella*, Ellb*, Ellc*, Xi*, Opening Angle]
myscale (float) – Rescale the profile (e.g. to account for elongation along the line of sight)
axis (str) – scale about x, y, or z
xyinas (bool) – xymap is in arcseconds (yes)
- Returns:
mymap – A map that accounts for a range of geometrical restrictions.
- Return type:
class:numpy.ndarray
- M2_ProposalTools.analytic_integrations.integrate_profiles(epressure, geoparams, r_bins, theta_range, inalphas=[], beta=0.0, betaz=None, finint=False, narm=False, fixalpha=False, strad=False, array='2', fullSZcorr=False, SZtot=False, columnDen=False, Comptony=True, instrument='MUSTANG2', negvals=None, tmax=0)[source]
Returns a Compton y profile for an input pressure profile.
- Parameters:
epressure (class:numpy.ndarray) – Electron pressure in units such that its integral over theta_range (itself in radians), results in the unitless Compton y parameter.
geoparams (array-like) – [X_shift, Y_shift, Rotation, Ella*, Ellb*, Ellc*, Xi*, Opening Angle]
r_bins (array-like) – The (elliptical) bins, in radians, for the profile.
theta_range (class:numpy.ndarray) – The range of angles for which to create a 1D profile (which can then be interpolated)
inalphas (array-like, optional) – This should generally be an empty list, unless modelling shocks.
beta (float) – Fraction of the speed of light of the cluster bulk (peculiar) motion.
betaz (float) – Fraction of the speed of light of the cluster along the line of sight.
finint (bool) – Integrate out to last finite (defined) bin. Defaults to False
narm (bool) – Normalized at R_Min. Defaults to False
fixalpha (bool) – Fix alpha (to whatever inalpha is); useful for shocks.
strad (bool) – STrict RADii; if the pressure model has to obey strict placements of radii, use this!
array (str) – only used with NIKA2 data; which detector array is being used?
fullSZcorr (bool) – integrate relativistic corrections along line of sight?
SZtot (bool) – total SZ signal… not really useful
columnDen (bool) – Set to true if you want to return the column density…?
Comptony (bool) – When set (by default), returns Comptony profile
instrument (str) – MUSTANG-2 by default. Used in relativistic calculations.
negvals (class:`numpy.ndarray`(dtype=bool)) – Boolean array, the length of density_proxy.
- Returns:
Int_Pres (class:numpy.ndarray) – The combined los integrals over theta_range
alphas (class:numpy.ndarray) – The power-law indices between bins (e.g. pressures)
integrals (class:numpy.ndarray) – The los integral per bin (e.g. per shell), each across theta_range
Notes
Ella should be set to 1. Therefore, define Ellb relative to Ella (and likewise with Ellc)
Xi is a sneaky gem.
integrals allows for sneakiness.
- M2_ProposalTools.analytic_integrations.iter_grid_profile(integrals, myrs, theta_range, xymap, geoparams=[0, 0, 0, 1, 1, 1, 0, 0], axis='z')[source]
This largely copies the functionality of grid_profile, but is designed to be much faster for iterative applications (same geoparams)
- Parameters:
integrals (class:numpy.ndarray) – array of los-integrated values (i.e. SB profiles)
myrs (array-like) – array of bin radii
theta_range (class:numpy.ndarray) – profile of radii
xymap (tuple) – tuple of arrays of x and y coordinates
:param geoparams : [X_shift, Y_shift, Rotation, Ella*, Ellb*, Ellc*, Xi*, Opening Angle] :type geoparams : array-like :param axis : scale about x, y, or z :type axis : str
- M2_ProposalTools.analytic_integrations.iter_grid_profile_v2(integrals, myrs, theta_range, xymap, geoparams=[0, 0, 0, 1, 1, 1, 0, 0], axis='z', xyinas=True)[source]
This largely copies the functionality of grid_profile, but is designed to be much faster for iterative applications (same geoparams)
- Parameters:
integrals (class:numpy.ndarray) – array of los-integrated values (i.e. SB profiles)
myrs (array-like) – array of bin radii
theta_range (class:numpy.ndarray) – profile of radii
xymap (tuple) – tuple of arrays of x and y coordinates
:param geoparams : [X_shift, Y_shift, Rotation, Ella*, Ellb*, Ellc*, Xi*, Opening Angle] :type geoparams : array-like :param axis : scale about x, y, or z :type axis : str :param xinas : xymap is in arcseconds? :type xinas : bool
- M2_ProposalTools.analytic_integrations.log_profile(args, r_bins, radii, alphas=[], rintmax=[], finite=False)[source]
Performs logarithmic interpolation and extrapolation. This can easily be improved, but hasn’t been the bottleneck.
r_bins and radii must be in the same units. :param args: binned values (assumed to be pressure) :type args: class:numpy.ndarray :param r_bins: bin edges :type r_bins: class:numpy.ndarray :param radii: radial points onto which you will interpolate or extrapolate :type radii: class:numpy.ndarray :param alphas: If zeros or an empty list, this function will calculate power law index between bins. :type alphas: array-like, optional :param rintmax: If zeros or an empty list, integration extends to infinity. Default is []. :type rintmax: array-like, optional :param finite: Do not integrate to infinity; stop at last value in r_bins. :type finite: bool
- Returns:
presprof (Interpolated (pressure) profile)
alphas (The power-law indices between bins (e.g. pressures))
- M2_ProposalTools.analytic_integrations.myredcosine(tmax, n)[source]
computes .. math:
\int_0^tmax cos^n(x) dx
- M2_ProposalTools.analytic_integrations.myrincbeta(x, a, b)[source]
compute the regularized incomplete beta function. .. math:
B(x;a,b) \equiv \int_0^x u^{a-1} (1-u)^{b-1} du
- M2_ProposalTools.analytic_integrations.plinfty(p, rmin, rmax, radarr, tmax=None)[source]
Analytic los integral for infinity. It doesn’t work. Returns 0.
- Parameters:
p (float) – “Spectral Index”. That is, the power law (without the minus sign) that the “emissivity” follows within your bin. If you want to integrate to infinity, you must have SINDEX > 1. All other cases can handle any SINDEX value.
rmin (float) – Minimum radius for your bin. This is 0 for the sphere.
rmax (float) – Maximum radius for your bin. If you wish to set this to infinity, then set it to a negative value.
radarr (class:numpy.ndarray) – A radial array of projected radii (same units as RMIN and RMAX) for which projected values will be calculated. If the innermost value is zero, its value, in the scaled radius array will be set to FF.
tmax (float) – Maximum theta (from the nose - of, say, a shock).
- M2_ProposalTools.analytic_integrations.plshell(p, rmin, rmax, radarr, tmax=0)[source]
Analytic los integral for a spherical shell.
- Parameters:
p (float) – “Spectral Index”. That is, the power law (without the minus sign) that the “emissivity” follows within your bin. If you want to integrate to infinity, you must have SINDEX > 1. All other cases can handle any SINDEX value.
rmin (float) – Minimum radius for your bin. This is 0 for the sphere.
rmax (float) – Maximum radius for your bin. If you wish to set this to infinity, then set it to a negative value.
radarr (class:numpy.ndarray) – A radial array of projected radii (same units as RMIN and RMAX) for which projected values will be calculated. If the innermost value is zero, its value, in the scaled radius array will be set to FF.
tmax (float) – Maximum theta (from the nose - of, say, a shock).
- M2_ProposalTools.analytic_integrations.plsphere(p, rmin, rmax, radarr, tmax=0)[source]
Analytic los integral for a full sphere.
- Parameters:
p (float) – “Spectral Index”. That is, the power law (without the minus sign) that the “emissivity” follows within your bin. If you want to integrate to infinity, you must have SINDEX > 1. All other cases can handle any SINDEX value.
rmin (float) – Minimum radius for your bin. This is 0 for the sphere.
rmax (float) – Maximum radius for your bin. If you wish to set this to infinity, then set it to a negative value.
radarr (class:numpy.ndarray) – A radial array of projected radii (same units as RMIN and RMAX) for which projected values will be calculated. If the innermost value is zero, its value, in the scaled radius array will be set to FF.
tmax (float) – Maximum theta (from the nose - of, say, a shock).
- M2_ProposalTools.analytic_integrations.plsphole(p, rmin, rmax, radarr, tmax=0)[source]
Analytic los integral for out to infinity, but missing a spherical core.
- Parameters:
p (float) – “Spectral Index”. That is, the power law (without the minus sign) that the “emissivity” follows within your bin. If you want to integrate to infinity, you must have SINDEX > 1. All other cases can handle any SINDEX value.
rmin (float) – Minimum radius for your bin. This is 0 for the sphere.
rmax (float) – Maximum radius for your bin. If you wish to set this to infinity, then set it to a negative value.
radarr (class:numpy.ndarray) – A radial array of projected radii (same units as RMIN and RMAX) for which projected values will be calculated. If the innermost value is zero, its value, in the scaled radius array will be set to FF.
tmax (float) – Maximum theta (from the nose - of, say, a shock).
- M2_ProposalTools.analytic_integrations.prep_SZ_binsky(pressure, temp_iso, geoparams=None)[source]
Small function, intended to do more (for relativistic corrections), but currently only allows for one ICM temperature.
- Parameters:
pressure (array-like) – array of electron pressures
temp_iso (float) – isothermal temperature
geoparams (array-like) – [X_shift, Y_shift, Rotation, Ella*, Ellb*, Ellc*, Xi*, Opening Angle]
- Returns:
edensity (class:numpy.ndarray) – Proxy for electron density (per cubic cm)
etemperature (class:numpy.ndarray) – Proxy for electron temperature (times Bolzmann Constant; keV)
geoparams (array-like) – [X_shift, Y_shift, Rotation, Ella*, Ellb*, Ellc*, Xi*, Opening Angle]
- M2_ProposalTools.analytic_integrations.rot_trans_grid(x, y, xs, ys, rot_rad)[source]
Shift and rotate coordinates
- Parameters:
x (class:numpy.ndarray) – coordinate along major axis (a)
:param : :type : param y: coordinate along minor axis (b) :param : :type : type y: class:numpy.ndarray :param : :type : param xs: translation along x-axis :param : :type : type xs: float :param : :type : param ys: translation along y-axis :param : :type : type ys: float :param : :type : param rot_rad: rotation angle, in radians :param : :type : type rot_rad: float
- M2_ProposalTools.analytic_integrations.shell_pl(epsnot, sindex, rmin, rmax, radarr, c=1.0, ff=0.001, epsatrmin=0, narm=False, tmax=0)[source]
The heart of this code. This routine calculates analytic los integrals depending on the case.
- Parameters:
epsnot (float) – The normalization factor. The default behavior is for this to be defined at RMAX, the outer edge of a sphere or shell. If you integrate to infinity, then this should be defined at RMIN. And of course, RMIN=0, and RMAX as infinity provides no scale on which to define EPSNOT. See the optional variable EPSATRMIN.
sindex (float) – “Spectral Index”. That is, the power law (without the minus sign) that the “emissivity” follows within your bin. If you want to integrate to infinity, you must have SINDEX > 1. All other cases can handle any SINDEX value.
rmin (float) – Minimum radius for your bin. Can be 0.
rmax (float) – Maximum radius for your bin. If you wish to set this to infinity, then set it to a negative value.
radarr (class:numpy.ndarray) – A radial array of projected radii (same units as RMIN and RMAX) for which projected values will be calculated. If the innermost value is zero, its value, in the scaled radius array will be set to FF.
c (float) – The scaling axis for an ellipse along the line of sight. Default is 1.0
ff (float) – Fudge Factor, but more of a thresholding factor. Default is 1e-3.
epsatrmin – Set this to a value greater than 0 if you want EPSNOT to be defined at RMIN. This automatically happens if RMAX<0
narm (bool) – Normalized At R_Min. This option specifies that you have already normalized the bins at R_Min (for a shell case). The other two cases are strictly imposed where the normalization is set. The default is False, because that is just how I started using this.
tmax (float) – Maximum theta (from the nose - of, say, a shock).
NOTE: If RMIN = 0 and RMAX < 0, then this program will return 0.
- M2_ProposalTools.analytic_integrations.ycyl_prep(Int_Pres, theta_range)[source]
Just preparing some numbers.
- Parameters:
Int_Pres (class:numpy.ndarray) – integrated pressures
theta_range (class:numpy.ndarray) – radii
- M2_ProposalTools.analytic_integrations.ycylfromprof(Int_Pres, theta_range, theta_max)[source]
Integrate Int_Pres over area to get y_cyl
:param : :type : param Int_Pres: array of Compton y values :param : :type : type Int_Pres: class:numpy.ndarray :param : :type : param theta_range: array of radii, in radians :param : :type : type theta_range: class:numpy.ndarray :param : :type : param theta_max: perform integral within this radius. :param : :type : type theta_max: float
M2_ProposalTools.numerical_integration module
- M2_ProposalTools.numerical_integration.Ycyl_from_yProf(yprof, rads, r500, nrads=10000)[source]
Calculate y_cylindrival from profile
- M2_ProposalTools.numerical_integration.int_profile(profrad, profile, radProjected, zmax=0)[source]
This currently only integrates out to the max of profrad. If you want to give a fixed z, you should be sure it is LESS THAN the max of profrad, and then adjust the code below.
You likely want profrad to be in kpc. In this way, you will integrate units of pressure over kpc, and the resultant units are comprehensible.
- Parameters:
profrad (np.ndarray) – radial nodes
profile (np.ndarray) – normalizations at said nodes
radProjected (np.ndarray) – is an array of z-coordinates along the line of sight.
zmax (float, optional.) – impose a maximum los depth? Default is 0 (no max imposed).
- M2_ProposalTools.numerical_integration.int_tapered_profile_per_theta(profrad, profile, radProjected, mytheta, thetamin=0.4, thetamax=0.6, zmax=0)[source]
This currently only integrates out to the max of profrad. If you want to give a fixed z, you should be sure it is LESS THAN the max of profrad, and then adjust the code below.
NEW EDIT. profrad and radProjected should be in RADIANS!!! This will make integrating the taper function easier.
YOU MUST THEREFORE HAVE profile CONVERTED TO THE APPROPRIATE UNITS TO MAKE THIS INTEGRATION CORRECT (scaling/unit-wise).
- Parameters:
profrad (np.ndarray) – radial nodes
profile (np.ndarray) – normalizations at said nodes
radProjected (np.ndarray) – is an array of z-coordinates along the line of sight.
mytheta (float) – a given polar angle off of some “nose”
thetamin (float) – minimum nose angle, wherein a taper begins
thetamax (float) – maximum nose angle, wherein a taper ends
zmax (float, optional.) – impose a maximum los depth? Default is 0 (no max imposed).
- M2_ProposalTools.numerical_integration.interp_plaws(nodes, norms, alphas, radii)[source]
Assumes you’ll want values extrapolated to min of outradii and max of outradii
- Parameters:
nodes (np.ndarray) – radial nodes
norms (np.ndarray) – normalizations at said nodes
alphas (np.ndarray) – the logarithmic slope (power law index) for corresponding nodes.
radii (np.ndarray) – Radii; same units as nodes
- M2_ProposalTools.numerical_integration.loop_int_tppt(thetas, profrad, profile, radProjected, thetamin=0.4, thetamax=0.6, zmax=0)[source]
Loop over int_tapered_profile_per_theta
- Parameters:
thetas (np.ndarray) – is an array of polar angle off of some “nose”
profrad (np.ndarray) – radial nodes
profile (np.ndarray) – normalizations at said nodes
radProjected (np.ndarray) – is an array of z-coordinates along the line of sight.
thetamin (float) – minimum nose angle, wherein a taper begins
thetamax (float) – maximum nose angle, wherein a taper ends
zmax (float, optional.) – impose a maximum los depth? Default is 0 (no max imposed).
M2_ProposalTools.ModelFitting module
- M2_ProposalTools.ModelFitting.Y_SZ_v2(yProf, efv, retcurvs=False)[source]
- Parameters:
I’m adopting equations 25-27 in Arnaud+ 2010, which makes use of Y_SZ, or Y_cyl and the Universal Pressure Profile (UPP). I tried to find just a straight empirical Y_cyl(R500)-M_500, but that doesn’t seem to exist?!?
- M2_ProposalTools.ModelFitting.bin_two2Ds(independent, dependent, binsize=1, witherr=False, withcnt=False)[source]
Bins two 2D arrays based on the independent array (e.g. one of radii).
- Parameters:
independent (class:numpy.ndarray) – An array of independent variables (e.g. radii)
dependent (class:numpy.ndarray) – An array of dependent variables (e.g. RMS or surface brightness)
binsize (float) – Binsize, relative to independent array.
witherr (bool) – Calculate the corresponding uncertainties (of the mean)
withcnt (bool) – Calculate the number of elements (e.g. pixels) within each bin.
- Returns:
abin (class:numpy.ndarray) – Binned absisca values
obin (class:numpy.ndarray) – Binned ordinate values
oerr (class:numpy.ndarray) – Binned uncertainties of the mean
cnts (class:numpy.ndarray) – Binned counts
- M2_ProposalTools.ModelFitting.circ_Gauss(xdata, xc, yc, norm, sig, mnlvl)[source]
Calculate a 2D (circular) Gaussian
- M2_ProposalTools.ModelFitting.ellipsoidal_ICM(cosmo_pars, efv, pos, xymap, alphas, posind=0, fixalpha=False)[source]
Run the actual fitting procedure.
- Parameters:
cosmo_pars (dict) – Dictionary of cosmological parameters
efv (dict) – Dictionary of emcee fitting variables
pos (array-like) – emcee fitting parameters
xymap (tuple) – tuple of arrays of x- and y-coordinates.
alphas (np.ndarray) – power-law indices
posind (int) – index for emcee parameters
fixalpha (bool) – Fix the power-law indices to input values? Default is False.
- M2_ProposalTools.ModelFitting.extract_radial_profile(hdul, arcmin=True)[source]
Extract a radial profile using the CRPIX value in a HDU.
- M2_ProposalTools.ModelFitting.fit_Gaussian_toSNR(SNRmap, pixsize, maxRad=2.0)[source]
close to fitmap as was used in IDL :param SNRmap: a 2D numpy array :type SNRmap: nump.ndarray :param pixsize: pixel size, in arcseconds :type pixsize: float :param maxRad: Maximum search radius, arcminutes :type maxRad: float
- M2_ProposalTools.ModelFitting.fit_spherical_model(z, M500, hdul, model='NP', pink=True, alpha=2, knee=0.008333333333333333, nkbin=100, fwhm=9.0, nsteps=1000, y2k=-3.4, uKinput=True, ySph=True, YMrel='A10', outdir='/tmp/', outbase='NP_fit_corner.png', size=3.5, Dist=False, plotPin=True, adPhys=True, WIKID=False, fit_cen=True, addNoise=True)[source]
- Parameters:
z (float) – Redshift
M500 (quantity (mass units)) – \(M\_{500}\)
hdul (list of HDU class objects) – Astropy/fits HDU list (Make sure wtmap and img have appropriate units)
model (str) – Type of model. Can be “NP” (for non-parametric), “GNFW” for generalized NFW, or “BETA” for a beta model.
pink (bool) – noise realization is pink noise
alpha (float) – power-law index for red-noise part of pink noise. Default is 2.
knee (float) – where, in inverse arcseconds, does the knee occur.
nkbin (int) – number of k-bins used to generate spectrum for pink noise.
fwhm (float) – Smoothing kernel for filtered map.
nsteps (int) – Number of steps to use in MCMC.
y2k (float) – Conversion factor between Compton y and Kelvin_RJ (for MUSTANG-2). Default is -3.4.
uKinput (bool) – The input map is taken to be in units of microKelvin_RJ if set.
ySph (bool) – Calculate \(y_{Sph}\) if set; otherwise calculate \(y_{cyl}\). Default is True.
YMrel (str) – Which Y-M relation to use? Default is “A10”.
outdir (str) – A string indicating the output directory, including trailing “/”.
outbase (str) – filename, without the directory path.
size (float.) – size of Lissajous daisy scan used (for transfer function). Options are 2.5, 3.0, 3.5, 4.0, 4.5, or 5.0
fit_cen (bool) – Fit for a center? Default is True
- M2_ProposalTools.ModelFitting.get_emcee_fit_vars(cosmo_pars, M500, SNRint, xc, yc, pixsize, outdir, MinRes=1.0, model='NP', ySph=True, YMrel='A10', nb_theta_range=150, SNRperbin=4.0, n_at_rmin=False, fit_mnlvl=True, fit_cen=True, fit_geo=False, size=3.5, Dist=False, WIKID=False)[source]
- Parameters:
cosmo_pars (dict) – a dictionary of cosmological parameters
M500 (quantity (mass units)) – \(M\_{500}\)
SNRint (float) – Integrated SNR (how many sigma detection).
xc (float) – x-centroid, in pixels
yc (float) – y-centroid, in pixels
pixsize (float) – pixel size, in arcseconds
outdir (str) – A string indicating the output directory, including trailing “/”.
MinRes (float) – minimum resolution (in defining radial profile). Default is 1 arcsecond.
model (str) – Type of model. Can be “NP” (for non-parametric), “GNFW” for generalized NFW, or “BETA” for a beta model.
ySph (bool) – Calculate \(y_{Sph}\) if set; otherwise calculate \(y_{cyl}\). Default is True.
YMrel (str) – Which Y-M relation to use? Default is “A10”.
nb_theta_range (int) – number of points in theta_range array.
SNRperbin (float) – minimum desired SNR per bin. Default is 4.0.
n_at_rmin (bool) – Normalize at r_min. Default is False. (Unless you know what you are doing, leave this.)
fit_mnlvl (bool) – Fit for a mean level? Default is True
fit_cen (bool) – Fit for a center? Default is True
fit_geo (bool) – Fit for a an elliptical geometry? Default is False
size (float.) – size of Lissajous daisy scan used (for transfer function). Options are 2.5, 3.0, 3.5, 4.0, 4.5, or 5.0
- M2_ProposalTools.ModelFitting.get_int_SNR(SNRmap, pixsize, maxRad=2.0, bv=120.0, SNRthresh=1.0)[source]
Get the integrated detection significance.
- M2_ProposalTools.ModelFitting.improved_bin_spacing(radminmax, nbins, mway=False)[source]
Calculate the bin spacing for MUSTANG-2 based on the number of bins.
- M2_ProposalTools.ModelFitting.make_skymodel_map(hdul, pos, cosmo_pars, efv, xymap)[source]
Run the actual fitting procedure.
- Parameters:
hdul (list) – an input fits HDUList with extension=0 being the data and extension=1 being the weights.
pos (array-like) – parameters fit with mcmc
cosmo_pars (dict) – Dictionary of cosmological parameters
efv (dict) – Dictionary of emcee fitting variables
xymap (tuple) – tuple of arrays of x- and y-coordinates.
- M2_ProposalTools.ModelFitting.plot_SB_profiles(SimObs, SimSky, outdir, filename, prntPk=True, isUK=True, xmin=0, xmax=2.0, addHDU=None, addLabel=None)[source]
A routine to plot a simulated sky versus simulated observation, radial profiles.
- Parameters:
SimObs (list) – an HDUList object for simulated observations
SimSky (list) – an HDUList object for simulated sky (beam-convolved; not filtered)
outdir (str) – Output director, with the trailing “/”
filename (str) – Output filename, without path.
prntPk (bool) – Print the peaks of profiles and maps? Default is True.
isUK (bool) – Are the arrays in the HDULists in units of uK? Default is True
- M2_ProposalTools.ModelFitting.plot_pressure_profiles(solns, efv, cosmo_pars, m500, myfs=10, plotPin=True, adPhys=True)[source]
For now, assuming model == “NP”… need to add others
- M2_ProposalTools.ModelFitting.pos_neg_formatter(med, high_err, low_err, sys=None, cal=None)[source]
Input the median (or mode), and the error bars (not percentile values, but the distance between the +/-1 sigma percentiles and the 0 sigma percentile).
- M2_ProposalTools.ModelFitting.post_mcmc_products(hdul, sampler, cosmo_pars, efv, xymap, outfile, plotPin=True, adPhys=True)[source]
After the fitting, make plots and stuff
- Parameters:
hdul (list) – an input fits HDUList with extension=0 being the data and extension=1 being the weights.
sampler (class) – sampler from emcee
cosmo_pars (dict) – Dictionary of cosmological parameters
efv (dict) – Dictionary of emcee fitting variables
xymap (tuple) – tuple of arrays of x- and y-coordinates.
outfile (str) – output file (full path)
- M2_ProposalTools.ModelFitting.prntPeak(yProf, inHDU, isUK=True, Tag='SimObs-- ')[source]
Print the peak of a profile and map to STDOUT.
- M2_ProposalTools.ModelFitting.run_emcee(hdul, cosmo_pars, efv, xymap, outfile, BSerr=False, nsteps=1000, plotPin=True, adPhys=True)[source]
Run the actual fitting procedure.
- Parameters:
hdul (list) – an input fits HDUList with extension=0 being the data and extension=1 being the weights.
cosmo_pars (dict) – Dictionary of cosmological parameters
efv (dict) – Dictionary of emcee fitting variables
xymap (tuple) – tuple of arrays of x- and y-coordinates.
outfile (str) – output file (full path)
BSerr – Bootstrap error?
:type BSerrL bool :param nsteps: Number of fitting steps. Default is 1000. :type nsteps: int
- M2_ProposalTools.ModelFitting.ycyl_simul_v2(rads, yProf, alpha, maxrad, ylist, geom, r_thresh=0.03, retcurvs=False)[source]
- Parameters:
rads (numpy.ndarray) – Radius in radians
yProf (numpy.ndarray) – Compton y profile
alpha (array-like) – list of power-law indices
maxrad (float) – maximum radius
ylist (numpy.ndarray) – array of expected y values.
geom (array-like) – [X_shift, Y_shift, Rotation, Ella*, Ellb*, Ellc*, Xi*, Opening Angle]
r_thresh (float) – Threshold value. Default is 3e-2.
retcurvs (bool) – Return curves? Default is False.
- M2_ProposalTools.ModelFitting.ysph_simul(ylist, rads, pProf, alpha, geom, ythresh=3e-08, retcurvs=False)[source]
- Parameters:
ylist (numpy.ndarray) – array of expected y values.
rads (numpy.ndarray) – Radius in radians
pProf (numpy.ndarray) – pressure profile
alpha (array-like) – list of power-law indices
geom (array-like) – [X_shift, Y_shift, Rotation, Ella*, Ellb*, Ellc*, Xi*, Opening Angle]
y_thresh (float) – Threshold value. Default is 3e-8.
retcurvs (bool) – Return curves? Default is False.
M2_ProposalTools.WorkHorse module
- M2_ProposalTools.WorkHorse.M500_from_R500_z(R500, z)[source]
- Parameters:
R500 (Quantity) – A cluster’s R500, in physical length units (e.g. kpc)
z (float) – The cluster’s redshift
- Returns:
M500 – M500, in solar masses.
- Return type:
quantity
- M2_ProposalTools.WorkHorse.R500_P500_from_M500_z(M500, z)[source]
- Parameters:
m500 (Quantity) – A cluster’s mass: M500
z (float) – The cluster’s redshift
- Returns:
R500 (quantity) – R500 in physical units (e.g. kpc)
P500 (quantity) – P500 in units of pressure
- M2_ProposalTools.WorkHorse.a10_from_m500_z(m500, z, rads, Dist=True, c500=None, p=None, a=None, b=None, c=None)[source]
- Parameters:
M500 (quantity) – \(M\_{500}\) with units of mass.
z (float) – Redshift
xymap (tuple(class:numpy.ndarray)) – A tuple of x- and y-coordinates
rads (quantity,array) – Array of radii (with units of length)
Dist (bool) – Assume a disturbed A10 profile? Default is False
c500 (float, none-type) – If None, adopts the radius scaling value for A10 (full or disturbed) sample
p (float, none-type) – If None, adopts the normalization value for A10 (full or disturbed) sample
a (float, none-type) – If None, adopts the alpha value for A10 (full or disturbed) sample
b (float, none-type) – If None, adopts the beta value for A10 (full or disturbed) sample
c (float, none-type) – If None, adopts the gamma value for A10 (full or disturbed) sample
- Returns:
gnfw_prof – A radial profile with units of pressure
- Return type:
quantity,array
- M2_ProposalTools.WorkHorse.get_AAA_BBB(YMrel, delta, ycyl=False, h70=1.0)[source]
Basically just a repository of Y-M relations. YMrel must be either:
‘A10’ (Arnaud 2010)
‘A11’ (Anderson 2011)
‘M12’ (Marrone 2012)
‘P14’ (Planck 2014), or
‘P17’ (Planelles 2017)
All are converted to Y = 10^BBB * M^AAA; mass (M) is in units of solar masses; Y is in Mpc^2 (i.e. with D_A^2 * E(z)^-2/3)
- M2_ProposalTools.WorkHorse.get_SNR_map(hdul)[source]
- Parameters:
hdul (list of HDU class objects) – First extension is the image; second extension is the weightmap
- Returns:
SNRmap – A signal-to-noise (ratio) map.
- Return type:
2D numpy array
- M2_ProposalTools.WorkHorse.get_YM_sys_err(logy, YMrel, delta=500, ySph=True, h70=1.0)[source]
An attempt to propagate errors based on uncertainties reported in the literature.
- Parameters:
- Returns:
xer – Inferred systematic error, fractional
- Return type:
quantity
- M2_ProposalTools.WorkHorse.get_cosmo()[source]
- Returns:
cosmo – Returns a cosmo object from astropy.cosmology
- Return type:
class
- M2_ProposalTools.WorkHorse.get_d_ang(z)[source]
- Parameters:
z (float) – The redshift.
- Returns:
d_ang – The angular distance (with units of length)
- Return type:
quantity
- M2_ProposalTools.WorkHorse.get_ell_rads(x, y, ella, ellb)[source]
Get ellipsoidal radii from x,y standard
- Parameters:
x (class:numpy.ndarray) – coordinate along major axis (a)
y (class:numpy.ndarray) – coordinate along minor axis (b)
ella (float) – scaling along major axis (should stay 1)
ellb – scaling along minor axis
- M2_ProposalTools.WorkHorse.get_freqarr_2d(nx, ny, psx, psy)[source]
Compute frequency array for 2D FFT transform
- Parameters:
nx (integer) – number of samples in the x direction
ny (integer) – number of samples in the y direction
psx (integer) – map pixel size in the x direction
psy (integer) – map pixel size in the y direction
- Returns:
k – frequency vector
- Return type:
float 2D numpy array
- M2_ProposalTools.WorkHorse.get_noise_realization(hdul, pink=True, alpha=2, knee=0.016666666666666666, nkbin=100, fwhm=9.0)[source]
- Parameters:
hdul (list of HDU class objects) – First extension is the image; second extension is the weightmap
pink (bool) – Make the noise pink (more realistic)
alpha (float) – The power-law index of the red noise component.
knee (float) – Where is the knee in the power spectrum, in inverse arcseconds.
nkbin (int) – Number of bins in making an array of k-values.
fwhm (float) – FWHM of the smoothing kernel, in arcseconds. Used to determine k_max.
- Returns:
noise – A (very approximate) noise realization.
- Return type:
2D numpy array
- M2_ProposalTools.WorkHorse.get_sz_values()[source]
- Returns:
szcv (dict) – A dictionary of constant values.
szcu (dict) – A dictionary of constants with units.
- M2_ProposalTools.WorkHorse.get_xfertab(size, WIKID=False)[source]
- Parameters:
size (float) – size of scan (radially, in arcminutes)
- Returns:
tab – An array containing frequency and transfer function values
- Return type:
float 2D numpy array
- M2_ProposalTools.WorkHorse.get_xymap(map, pixsize, xcentre=[], ycentre=[], oned=True, cpix=0)[source]
Returns a map of X and Y offsets (from the center) in arcseconds.
INPUTS:
- mapa 2D array
for which you want to construct the xymap
- pixsizea quantity
(with units of an angle)
- xcentrefloat
The number of the pixel that marks the X-centre of the map
- ycentrefloat
The number of the pixel that marks the Y-centre of the map
- onedbool
Specify 1D for most cases pertaining to fitting models.
- cpixfloat
Specify if pixel indexing has an offset (e.g. 0 or 1)
- M2_ProposalTools.WorkHorse.get_yProf(radii, pprof, z)[source]
- Parameters:
radii (quantity,array) – Array of radii (with units of length)
pprof (quantity,array) – A radial profile with units of pressure
z (float) – The redshift
- Returns:
thetas (array) – A radial profile in units of radians
yProf_clust (array) – A radial profile of Compton y values
- M2_ProposalTools.WorkHorse.gnfw(R500, P500, radii, c500=1.177, p=8.403, a=1.051, b=5.4905, c=0.3081)[source]
- \[P(r) = \frac{P_{500} p}{(r* c_{500} / R_{500})^{\gamma} \left(1 + (r* c_{500} / R_{500})^{\alpha} \right)^{(\beta - \gamma)/\alpha}}\]
- Parameters:
R500 (quantity) – \(R\_{500}\) with units of length.
P500 (quantity) – \(P\_{500}\) with units of pressure.
radii (quantity,array) – An array of radii, with units of length
c500 (float) – The concentration parameter
p (float) – The pressure normalization parameter
a (float) – The rollover parameter; the \(\alpha\) parameter
b (float) – The slope at outer radii; the \(\beta\) parameter
c (float) – The slope at inner radii; the \(\gamma\) parameter
- Returns:
result – A radial profile with units of pressure
- Return type:
quantity,array
- M2_ProposalTools.WorkHorse.grid_profile(rads, profile, xymap, geoparams=[0, 0, 0, 1, 1, 1, 0, 0], myscale=1.0, axis='z')[source]
Return a tuple of x- and y-coordinates.
- Parameters:
rads (class:numpy.ndarray) – An array of radii (same units as xymap)
profile (class:numpy.ndarray) – A radial profile of surface brightness.
xymap (tuple(class:numpy.ndarray)) – A tuple of x- and y-coordinates
geoparams (array-like) – [X_shift, Y_shift, Rotation, Ella*, Ellb*, Ellc*, Xi*, Opening Angle]
myscale (float) – Generally best to leave as unity.
axis (str) – Which axis are you projecting along.
- Returns:
mymap – An output map
- Return type:
class:numpy.ndarray
- M2_ProposalTools.WorkHorse.inst_params(instrument)[source]
Returns a Compton y profile for an input pressure profile.
- M2_ProposalTools.WorkHorse.lightweight_simobs_A10(z, M500, ptgs=[[180, 45.0]], sizes=[3.5], times=[10.0], offsets=[1.5], center=[180, 45.0], xsize=12.0, ysize=12.0, pixsize=2.0, Dist=True, fwhm=9.0, conv2uK=False, verbose=False, y2k=-3.4, c500=None, p=None, a=None, b=None, c=None)[source]
A lightweight mock observation tool. To be lightweight, everything is approximate – but it’s fast!
- Parameters:
z (float) – The redshift
M500 (quantity) – \(M\_{500}\) with units of mass
ptgs (list(list)) – A list of 2-element pairs (of RA and Dec, in degrees)
sizes (list(float)) – A list of scan sizes, in arcminutes. Only 2.5, 3.0, 3.5, 4.0, 4.5, and 5.0 are valid.
times (list(float)) – A list of integration times for corresponding pointings and scan sizes, in hours.
offsets (list(float)) – A list of pointing offsets, in arcminutes.
center (list) – A two-element list corresponding to the RA and Dec of the center of the map
xsize (float) – The length of the map, in arcminutes, along the RA direction.
ysize (float) – The length of the map, in arcminutes, along the Dec direction.
pixsize (float) – The pixel size, in arcseconds
Dist (bool) – Adopt a disturbed A10 model?
fwhm (float) – The smoothing kernal for a resultant MIDAS map, in arcseconds. 9” is the default.
conv2uK (bool) – Convert the resultant images from Compton y to microK_RJ (the standard units for MUSTANG-2 maps).
verbose (bool) – Have the function print extraneous information?
c500 (float, none-type) – If None, adopts the radius scaling value for A10 (full or disturbed) sample
p (float, none-type) – If None, adopts the normalization value for A10 (full or disturbed) sample
a (float, none-type) – If None, adopts the alpha value for A10 (full or disturbed) sample
b (float, none-type) – If None, adopts the beta value for A10 (full or disturbed) sample
c (float, none-type) – If None, adopts the gamma value for A10 (full or disturbed) sample
- M2_ProposalTools.WorkHorse.lightweight_simobs_hdu(SkyHDU, ptgs=[[180, 45.0]], sizes=[3.5], times=[10.0], offsets=[1.5], center=None, xsize=12.0, ysize=12.0, pixsize=2.0, fwhm=9.0, verbose=False, WIKID=False)[source]
A lightweight mock observation tool. To be lightweight, everything is approximate – but it’s fast!
- Parameters:
SkyHDU (HDUList) – An HDUList, for which only the first extension (ext=0) is accessed. That extension should contain a beam-convolved image of the target.
ptgs (list(list)) – A list of 2-element pairs (of RA and Dec, in degrees)
sizes (list(float)) – A list of scan sizes, in arcminutes. Only 2.5, 3.0, 3.5, 4.0, 4.5, and 5.0 are valid.
times (list(float)) – A list of integration times for corresponding pointings and scan sizes, in hours.
offsets (list(float)) – A list of pointing offsets, in arcminutes.
fwhm (float) – The smoothing kernal for a resultant MIDAS map, in arcseconds. 9” is the default.
verbose (bool) – Have the function print extraneous information?
center (list or None-type) – If supplied, a two-element list corresponding to the RA and Dec of the center of the weight map. Set this if wish to adopt a new astrometry for your weight map, relative to the astrometry of the input SkyHDU. The default is None and as such the weight map will adopt the astrometry of the SkyHDU.
xsize (float) – The length of the map, in arcminutes, along the RA direction.
ysize (float) – The length of the map, in arcminutes, along the Dec direction.
pixsize (float) – The pixel size, in arcseconds
- M2_ProposalTools.WorkHorse.m_delta_from_ydelta(y_delta, cosmo_pars, delta=500, ycyl=False, YMrel='A10', h70=1.0)[source]
- Parameters:
y_delta (float) – A particular integrated Y
cosmo_pars (dict) – A dictionary of cosmological parameters for a given redshift.
delta (float) – Which density contrast, 500 or 2500?
ycyl (bool) – Is your integrated Y a cylindrical integration?
YMrel (str) – Which scaling relation are you using?
h70 (float) – Hubble parameter normalization
- Returns:
Mdelta – Inferred M_delta, without units
- Return type:
quantity
- M2_ProposalTools.WorkHorse.make_A10Map(M500, z, pixsize=2, h70=1, nb_theta_range=150, Dist=True, nR500=3.0, c500=None, p=None, a=None, b=None, c=None)[source]
Makes an A10 map with automated mapsize.
- Parameters:
M500 (quantity) – \(M\_{500}\) with units of mass.
z (float) – Redshift
pixsize (float) – Pixel size, in arcseconds
h70 (float) – Normalization of the Hubble parameter.
nb_theta_range (int) – Number of elements in an array of radii.
Dist (bool) – Assume a disturbed A10 profile? Default is False
c500 (float, none-type) – If None, adopts the radius scaling value for A10 (full or disturbed) sample
p (float, none-type) – If None, adopts the normalization value for A10 (full or disturbed) sample
a (float, none-type) – If None, adopts the alpha value for A10 (full or disturbed) sample
b (float, none-type) – If None, adopts the beta value for A10 (full or disturbed) sample
c (float, none-type) – If None, adopts the gamma value for A10 (full or disturbed) sample
- Returns:
ymap – An output Compton y map
- Return type:
class:numpy.ndarray
- M2_ProposalTools.WorkHorse.make_A10_hdu(z, M500, pixsize, center=[180, 45.0], nR500=3.0, Dist=True, beamConvolve=True, conv2uK=True, y2k=-3.4, c500=None, p=None, a=None, b=None, c=None)[source]
Compute and grid an A10 Compton y profile and put it into an HDUList
- Parameters:
z (float) – The redshift
M500 (quantity) – \(M\_{500}\) with units of mass
pixsize (float) – The pixel size, in arcseconds
center (list) – A two-element list corresponding to the RA and Dec of the center of the map
Dist (bool) – Adopt a disturbed A10 model?
conv2uK (bool) – Convert the resultant images from Compton y to microK_RJ (the standard units for MUSTANG-2 maps).
y2k (float) – What is the conversion factor between Compton y and K_RJ (for MUSTANG-2)? The default is -3.4, which corresponds to the conversion with relativistic corrections for kT_e ~ 7 keV. This factor is -3.5 at kT_e = 2 keV and -3.3 at kT_e = 12 keV.
verbose (bool) – Have the function print extraneous information?
c500 (float, none-type) – If None, adopts the radius scaling value for A10 (full or disturbed) sample
p (float, none-type) – If None, adopts the normalization value for A10 (full or disturbed) sample
a (float, none-type) – If None, adopts the alpha value for A10 (full or disturbed) sample
b (float, none-type) – If None, adopts the beta value for A10 (full or disturbed) sample
c (float, none-type) – If None, adopts the gamma value for A10 (full or disturbed) sample
- M2_ProposalTools.WorkHorse.make_a10_map(M500, z, xymap, Theta500, nx, ny, nb_theta_range=150, Dist=False, c500=None, p=None, a=None, b=None, c=None)[source]
Return a tuple of x- and y-coordinates.
- Parameters:
M500 (quantity) – \(M\_{500}\) with units of mass.
z (float) – Redshift
xymap (tuple(class:numpy.ndarray)) – A tuple of x- and y-coordinates
Theta500 (float) – \(R\_{500}\) in radians
nx (int) – Number of pixels along axis 0
ny (int) – Number of pixels along axis 1
nb_theta_range (int) – Number of elements in an array of radii.
Dist (bool) – Assume a disturbed A10 profile? Default is False
c500 (float, none-type) – If None, adopts the radius scaling value for A10 (full or disturbed) sample
p (float, none-type) – If None, adopts the normalization value for A10 (full or disturbed) sample
a (float, none-type) – If None, adopts the alpha value for A10 (full or disturbed) sample
b (float, none-type) – If None, adopts the beta value for A10 (full or disturbed) sample
c (float, none-type) – If None, adopts the gamma value for A10 (full or disturbed) sample
- Returns:
ymap – An output Compton y map
- Return type:
class:numpy.ndarray
- M2_ProposalTools.WorkHorse.make_image(kbin, psbin, nx=1024, ny=1024, pixsize=1.0, verbose=False)[source]
- Parameters:
- Returns:
noise – A (very approximate) noise realization.
- Return type:
2D numpy array
- M2_ProposalTools.WorkHorse.make_pinknoise_real(rmsmap, pixsize, alpha=2, knee=0.008333333333333333, nkbin=100, fwhm=9.0, kmin=0.0011111111111111111)[source]
- Parameters:
rmsmap (2D numpy array) – A map of (white noise) RMS.
pixsize (float) – Pixel size, in arcseconds
alpha (float) – The power-law index of the red noise component.
knee (float) – Where is the knee in the power spectrum, in inverse arcseconds.
nkbin (int) – Number of bins in making an array of k-values.
fwhm (float) – FWHM of the smoothing kernel, in arcseconds. Used to determine k_max.
kmin (float) – The minimum k-value accessed (roughly).
- Returns:
noise – A (very approximate) noise realization.
- Return type:
2D numpy array
- M2_ProposalTools.WorkHorse.make_rmap(xymap)[source]
Return a map of radii
- Parameters:
xymap (tuple(class:numpy.ndarray)) – A tuple of x- and y-coordinates
- Returns:
rmap – A map of radii
- Return type:
class:numpy.ndarray
- M2_ProposalTools.WorkHorse.rMP500_from_y500(yinteg, cosmo_pars, ySZ=True, ySph=True, YMrel='A10')[source]
- Parameters:
- Returns:
r500 (float) – Inferred R500, in radians
M500_i (quantity) – Inferred M500, with units
P500 (quantity) – Inferred P500, with units
msys (float) – Inferred systematic error (value) in units of 1e14 solMass
- M2_ProposalTools.WorkHorse.rot_trans_grid(x, y, xs, ys, rot_rad)[source]
Shift and rotate coordinates
- M2_ProposalTools.WorkHorse.smooth_by_M2_beam(image, pixsize=2.0)[source]
Smooths an image by a double Gaussian that is representative for MUSTANG-2.
- Parameters:
image (float 2D numpy array) – 2D array for which we compute the power spectrum
pixsize (float) – Pixel size, in arcseconds
- Returns:
bcmap – beam-convolved map
- Return type:
float 2D numpy array
- M2_ProposalTools.WorkHorse.y_delta_from_mdelta(m_delta, z, delta=500, ycyl=False, YMrel='A10', h70=1.0)[source]
Finds A,B (scaling law terms, in get_AAA_BBB()) and applies them.
- Parameters:
m_delta (float) – A cluster’s mass at some delta (e.g. M500 or M2500) in solar masses, as a value.
z (float) – The cluster’s redshift
delta (float) – Specify the delta (500 or 2500)
ycyl (bool) – Do you want y_cyl or y_Sph?
YMrel (str) – Which Y-M relation to use. The default is “A10” other options include “M12”, “P17”.
h70 (float) – Confirm the Hubble parameter at z=0, relative to 70 km/s/Mpc.
- Returns:
y_delta – The corresponding integrated Y value
- Return type:
M2_ProposalTools.FilterImages module
- M2_ProposalTools.FilterImages.apply_xfer(mymap, tab, pixsize, tabdims='1D', BSerr=False)[source]
Applies a transfer function based on the instrument for which you want to simulate an observation for. This is namely dependent on the format of the transfer function. It would be great if the format were standardized…but for now, we’ll stick with this.
Caution
The transfer function for MUSTANG2 and NIKA2 are not accurate as of June 2017. (They use the old transfer function…just to have something defined.)
- Parameters:
mymap (float 2D numpy array) –
tab (A tabulated (or 2D array) of the transfer function) –
pixsize (Pixel size (arcseconds)) –
tabdims (A string ("1D" or "2D") for the dimensions of the tabulated) – transfer function
pixsize –
BSerr (Attempt to fold in transfer function error; generally not used.) –
- Returns:
mapfilt
- Return type:
The filtered mymap (2D array)
- M2_ProposalTools.FilterImages.bpcos_filter_2d(k, par)[source]
From JMP; perform parametric Fourier filtering
- Parameters:
k (float 2D numpy array) – input image
par (four-element array or list) – par[0:2] is used for the high pass filter; par[2:4] is used for the low pass filter.
- Returns:
output – The filter, in Fourier space
- Return type:
float 2D numpy array
- M2_ProposalTools.FilterImages.cross_power_spectrum_2d(arr, arr1, nbins=10, psx=1.0, psy=1.0, logbins=False)[source]
Compute 2D cross-power spectrum of arr and arr1
- Parameters:
arr (float 2D numpy array) – 2D array for which we compute the power spectrum
arr1 (float 2D numpy array) – 2D array for which we compute the power spectrum
nbins (integer, optional) – number of frequency k bins (10)
psx (integer, optional (1)) –
psy (integer, optional (1)) –
logbins (bool, optional (False)) –
- Returns:
kbin (float 1D numpy array) – bins in k-space
pkbin (float 1D numpy array) – 2D power spectrum for kbin
- M2_ProposalTools.FilterImages.fourier_conv_2d(arr, kernel)[source]
From JMP; perform convolution, i.e. (arr * kernel)
- Parameters:
arr (float 2D numpy array) – input image
kernel (float 2D numpy array) – input convolution kernel (real-space)
- Returns:
output – convolved image
- Return type:
float 2D numpy array
- M2_ProposalTools.FilterImages.fourier_filtering_2d(arr, filt_type, par)[source]
From JMP; perform parametric Fourier filtering
- Parameters:
arr (float 2D numpy array) – input image
filt_type (str) – One of “gauss”, “hpcos”, “lpcos”, “bpcos”, or “tab”. The options refer to a 2D Gaussian kernel, a high-pass cosine filter, a low-pass cosine filter, a windowed (both hp and lp) cosine filter, or a tabulated filter.
par (float, array-like, or tuple of arrays, depending on the filt_type.) –
- Returns:
output – filtered image
- Return type:
float 2D numpy array
- M2_ProposalTools.FilterImages.gauss_2d(sigma, nx, ny)[source]
From JMP; perform parametric Fourier filtering
- Parameters:
k (float 2D numpy array) – input image
par (four-element array or list) – par[0:2] is used for the high pass filter; par[2:4] is used for the low pass filter.
- Returns:
output – The filter, in Fourier space
- Return type:
float 2D numpy array
- M2_ProposalTools.FilterImages.gauss_filter_2d(k, par)[source]
From JMP; perform parametric Fourier filtering
- Parameters:
k (float 2D numpy array) – input image
par (float) – The fwhm of a 2D Gaussian.
- Returns:
output – The filter, in Fourier space
- Return type:
float 2D numpy array
- M2_ProposalTools.FilterImages.get_freqarr_2d(nx, ny, psx, psy)[source]
Compute frequency array for 2 D FFT transform
- Parameters:
nx (integer) – number of samples in the x direction
ny (integer) – number of samples in the y direction
psx (integer) – map pixel size in the x direction
psy (integer) – map pixel size in the y direction
- Returns:
k – frequency vector
- Return type:
float 2D numpy array
- M2_ProposalTools.FilterImages.get_xfer(tabfile, tabformat='ascii', tabdims='1D', tabcomments='#', instrument='MUSTANG2', tabextend=True)[source]
Retrieves transfer function information from a relevant file.
Caution
The transfer functions for MUSTANG2 are only approximate
- Parameters:
tabfile (str) – A filename containing transfer function information
tabformat (str) – Either “ascii’ or ‘fits’
tabdims (str) –
function (A string ("1D" or "2D") for the dimensions of the tabulated transfer) –
tabcomments (str) – If the file is ascii, what are the comment characters?
instrument (str) – For now, only “MUSTANG2” and “MUSTANG” are explicitly supported
tabextend (bool) – Extrapolate to lower frequencies? Default is True
- Returns:
tab
- Return type:
a 2-D array for which entries [0,:] correspond to the wavenumber (k) and entries [1,:] correspond to the transfer function values.
- M2_ProposalTools.FilterImages.hpcos_filter_2d(k, par)[source]
From JMP; perform parametric Fourier filtering
- Parameters:
k (float 2D numpy array) – input image
par (two-element array or list) – par[0] corresponds to the where the filter is zero. par[1] corresponds to where the filter is unity. (par[1] > par[0])
- Returns:
output – The filter, in Fourier space
- Return type:
float 2D numpy array
- M2_ProposalTools.FilterImages.lpcos_filter_2d(k, par)[source]
From JMP; perform parametric Fourier filtering
- Parameters:
k (float 2D numpy array) – input image
par (two-element array or list) – par[0] corresponds to the where the filter is still unity. par[1] corresponds to where the filter is zero. (par[1] > par[0])
- Returns:
output – The filter, in Fourier space
- Return type:
float 2D numpy array
- M2_ProposalTools.FilterImages.power_spectrum_2d(arr, nbins=10, psx=1, psy=1, logbins=False)[source]
Compute 2D power spectrum of arr
- Parameters:
arr (float 2D numpy array) – 2D array for which we compute the power spectrum
nbins (integer, optional) – number of frequency k bins (10)
psx (integer, optional (1)) –
- Returns:
kbin (float 1D numpy array) – bins in k-space
pkbin (float 1D numpy array) – 2D power spectrum for kbin
- M2_ProposalTools.FilterImages.table_filter_2d(k, par)[source]
From JMP; perform parametric Fourier filtering
- Parameters:
k (float 2D numpy array) – input image
par (four-element array or list) – par[0:2] is used for the high pass filter; par[2:4] is used for the low pass filter.
- Returns:
output – The filter, in Fourier space
- Return type:
float 2D numpy array
M2_ProposalTools.MakeRMSmap module
- M2_ProposalTools.MakeRMSmap.Make_ImgWtmap_HDU(HDUTemplate, Img, Wtmap)[source]
Return a map of RMS sensitivites based on input set of scans.
- Parameters:
HDUTemplate (class:astropy.io.fits.HDUList) – A list of HDUs
Img (class:numpy.ndarray) – An image
Wtmap (class:numpy.ndarray) – A corresponding weightmap
- Returns:
ImgWtsHDUs – A list of HDUs; first extension is the image; second extension is the weight map.
- Return type:
class:astropy.io.fits.HDUList
- M2_ProposalTools.MakeRMSmap.add_to_wtmap(wtmap, hdr, p, s, t, offset=1.5, WIKID=False)[source]
For a given scan set, add weights to a given weightmap.
- Parameters:
wtmap (class:numpy.ndarray) – A weight map.
hdr (list(str)) – A header with associated astrometric information
p (array_like) – A list of 2-elements containing the RA and Dec of pointings to be used.
s (float) – Scan size. Options are 2.5, 3.0, 3.5, 4.0, 4.5, or 5.0
t (float) – The time to be spent with corresponding pointing and scan size
offset (float) – If 0 then just a central pointing is used. If anything greater than zero, the a 4-scan offset pattern is assumed, using the given offset, in arcminutes.
- Returns:
wtmap – A map of the resultant weights
- Return type:
class:numpy.ndarray
- M2_ProposalTools.MakeRMSmap.ax_zoom(zoom, ax)[source]
For a given axes object (with an image), zoom in.
- Parameters:
zoom (float) – A factor by which you wish to zoom in (zoom > 1).
ax (class:matplotlib.pyplot.axes) – The axes object with the image.
- M2_ProposalTools.MakeRMSmap.bin_log2Ds(independent, dependent, nbins=10, witherr=False, withcnt=False)[source]
Bins two 2D arrays based on the independent array (e.g. one of radii). Do this if both arrays are better distributed in log-space.
- Parameters:
independent (class:numpy.ndarray) – An array of independent variables (e.g. radii)
dependent (class:numpy.ndarray) – An array of dependent variables (e.g. RMS or surface brightness)
nbins (float) – Number of bins
witherr (bool) – Calculate the corresponding uncertainties (of the mean)
withcnt (bool) – Calculate the number of elements (e.g. pixels) within each bin.
- Returns:
abin (class:numpy.ndarray) – Binned absisca values
obin (class:numpy.ndarray) – Binned ordinate values
oerr (class:numpy.ndarray) – Binned uncertainties of the mean
cnts (class:numpy.ndarray) – Binned counts
- M2_ProposalTools.MakeRMSmap.bin_two2Ds(independent, dependent, binsize=1, witherr=False, withcnt=False)[source]
Bins two 2D arrays based on the independent array (e.g. one of radii).
- Parameters:
independent (class:numpy.ndarray) – An array of independent variables (e.g. radii)
dependent (class:numpy.ndarray) – An array of dependent variables (e.g. RMS or surface brightness)
binsize (float) – Binsize, relative to independent array.
witherr (bool) – Calculate the corresponding uncertainties (of the mean)
withcnt (bool) – Calculate the number of elements (e.g. pixels) within each bin.
- Returns:
abin (class:numpy.ndarray) – Binned absisca values
obin (class:numpy.ndarray) – Binned ordinate values
oerr (class:numpy.ndarray) – Binned uncertainties of the mean
cnts (class:numpy.ndarray) – Binned counts
- M2_ProposalTools.MakeRMSmap.calc_RMS_profile(hdul, rmsmap, Cntr, rmax=None)[source]
Return a map of RMS sensitivites based on input set of scans.
- hdulclass:astropy.io.fits.HDUList
A list of HDUs
- Cntrarray_like
Two-element object specifying the RA and Dec of the center.
- rmsmapclass:numpy.ndarray
A map of achieved RMS.
- rmaxfloat
Maximum radius out to which a profile is calculated.
- rbinclass:numpy.ndarray
Binned radii
- ybinclass:numpy.ndarray
Binned RMS values
- M2_ProposalTools.MakeRMSmap.calculate_RMS_within(Rads, RMSprof, Rmaxes=[2, 3, 4])[source]
Bins two 2D arrays based on the independent array (e.g. one of radii). Do this if both arrays are better distributed in log-space.
- M2_ProposalTools.MakeRMSmap.coaddimg_noRP(hdu1, hdu2)[source]
This version assumes no reprojection. That is, you had better have the same astrometry between the two! A more general version to be written…
- Parameters:
hdu1 (class:astropy.io.fits.HDUList) – A list of HDUs
hdu2 (class:astropy.io.fits.HDUList) – A list of HDUs
- Returns:
hdu1 – A list of HDUs, with the coadded image.
- Return type:
class:astropy.io.fits.HDUList
- M2_ProposalTools.MakeRMSmap.conv_wtmap_torms(wtmap)[source]
Converts a weightmap to an rms map.
- Parameters:
wtmap (numpy.ndarray) – a weightmap
- Returns:
rmsmap
- Return type:
numpy.ndarray
- M2_ProposalTools.MakeRMSmap.get_mapspd_pars(size, WIKID=False)[source]
Return parameters describing the RMS profile by scan size.
- M2_ProposalTools.MakeRMSmap.get_mapwts(radii, pars, s)[source]
Return the RMS (mapping speed) profile as a function of scan size.
- Parameters:
radii (class:numpy.ndarray) – Radii (can be 1D or 2D) in arcminutes.
pars (list) – A list of 4 parameters that describe the RMS profile.
- Returns:
wts – The resultant weightmap
- Return type:
class:numpy.ndarray
- M2_ProposalTools.MakeRMSmap.get_rms_cmap()[source]
Tiny function to get a colormap with desired indexing, and importantly make values above or below it white.
- Returns:
colormap
- Return type:
- M2_ProposalTools.MakeRMSmap.get_rmsprof_from_s(radii, s, WIKID=False)[source]
Return the RMS (mapping speed) profile as a function of scan size.
- Parameters:
radii (class:numpy.ndarray) – Radii (can be 1D or 2D) in arcminutes.
s (float) – Scan size. Options are 2.5, 3.0, 3.5, 4.0, 4.5, or 5.0
- Returns:
rms – The resultant rms profile
- Return type:
class:numpy.ndarray
- M2_ProposalTools.MakeRMSmap.get_rmsprofile(radii, pars, size, cf=1.4142135623730951)[source]
Return the RMS (mapping speed) profile as a function of scan size.
- Parameters:
- Returns:
rms – The resultant rms profile
- Return type:
class:numpy.ndarray
- M2_ProposalTools.MakeRMSmap.make_rmap(xymap)[source]
Return a map of radii
- Parameters:
xymap (tuple(class:numpy.ndarray)) – A tuple of x- and y-coordinates
- Returns:
rmap – A map of radii
- Return type:
class:numpy.ndarray
- M2_ProposalTools.MakeRMSmap.make_rms_map(hdul, ptgs, szs, time, offsets=[1.5])[source]
Return a map of RMS sensitivites based on input set of scans.
- Parameters:
hdul (class:astropy.io.fits.HDUList) – A Header-Data-Unit list
ptgs (list(list)) – A list of 2-element array-like objects containing the RA and Dec of pointings to be used.
szs (array_like) – A list of scan sizes to be used.
time (array_like) – A list of times to be spent with corresponding pointing and scan size
offsets (array_like) – A corresponding list of scan offsets. If 0 then just a central pointing is used. If anything greater than zero, the a 4-scan offset pattern is assumed, using the given offset, in arcminutes.
- Returns:
imgout (class:numpy.ndarray) – A map of the resultant RMS
ns (class:numpy.ndarray) – An array of the (non-rounded) number of scans required to reach the specified time(s).
- M2_ProposalTools.MakeRMSmap.make_template_hdul(nx, ny, cntr, pixsize, cx=None, cy=None)[source]
Return a map of RMS sensitivites based on input set of scans.
- Parameters:
- Returns:
TempHDU – A Header-Data-Unit list (only one HDU)
- Return type:
class:astropy.io.fits.HDUList
- M2_ProposalTools.MakeRMSmap.make_xymap(img, hdr, ra, dec)[source]
Return a tuple of x- and y-coordinates.
- Parameters:
- Returns:
xymap – A tuple of x- and y-coordinates
- Return type:
tuple(class:numpy.ndarray)
- M2_ProposalTools.MakeRMSmap.mark_radec(ax, hdr, ra, dec)[source]
Make a nice image (via imshow) of the RMS map.
- M2_ProposalTools.MakeRMSmap.plot_circ(ax, hdr, ra, dec, goodrad, color='r', ls='--', lw=2)[source]
Make a nice image (via imshow) of the RMS map.
- M2_ProposalTools.MakeRMSmap.plot_rms(hdul, rmsmap, savefile, vmin=18, vmax=318, myfs=15, nscans=None, prntinfo=True, cmark=True)[source]
Make a nice image (via imshow) of the RMS map.
- hdullist(obj)
Any list of objects obtained from fits.open()
- rmsmapnumpy.ndarray
An 2D array constituting the RMSmap. The assumption is that ext=1 in the input hdul is the weightmap. If this is not the case, then the RMSmap can be supplied here.
- savefilestr
A string with the full path of where to save the output image (assumed to be a png).
- vminfloat
Minimum RMS value (in the colorbar).
- vmaxfloat
Maximum RMS value (in the colorbar).
- myfsfloat
Fontsize for labels and such.
- nscansint
Number of Lissajous Daisy scans to achieve integration time. (optional)
- prntinfobool
Set this to print information on the figure.
- cmarkbool
Set this to make a center mark.
- M2_ProposalTools.MakeRMSmap.plot_rms_general(hdul, savefile, vmin=18, vmax=318, myfs=15, rmsmap=None, nscans=None, prntinfo=False, cmark=True, ggmIsImg=False, tlo=True, wtcut=0.1, cra=0, cdec=0, ggm=False, ggmCut=0.05, cc='k', ncnts=0, title=None, tsource=0, R500=0, r5col='c', zoom=1, noaxes=False, verbose=False, imgext=0, ggmPix=5.0, mask=None)[source]
Make a nice image (via imshow) of the RMS map.
- Parameters:
hdul (list(obj)) – Any list of objects obtained from fits.open()
savefile (str) – A string with the full path of where to save the output image (assumed to be a png).
vmin (float) – Minimum RMS value (in the colorbar).
vmax (float) – Maximum RMS value (in the colorbar).
myfs (float) – Fontsize for labels and such.
rmsmap (numpy.ndarray) – An 2D array constituting the RMSmap. The assumption is that ext=1 in the input hdul is the weightmap. If this is not the case, then the RMSmap can be supplied here.
nscans (int) – Number of Lissajous Daisy scans to achieve integration time. (optional)
prntinfo (bool) – Set this to print information on the figure.
cmark (bool) – Mark the center of the cluster. To be used in tandem with cra and cdec.
ggmIsImg (bool) – If you want to display the GGM image instead of the RMS map, set this
tlo (bool) – Hard-coded application of a tight layout for the figure.
wtcut (float) – A weight cut for selecting regions in the map.
cra (float) – The center RA, in degrees, if marking the center of the target.
cdec (float) – The center Dec, in degrees, if marking the center of the target.
ggm (bool) – Option to perform a GGM filter on the input (ext=imgext) image, from hdul.
ggmCut (float) – Determine a minimum level of the ggm map, with respect to its maximum, for use with contours.
cc (str) – Contour color.
ncnts (int) – Number of contours
title (str) – Provide a title for the figure, if desired.
tsource (float) – Time on source (to be printed on the figure, if prntinfo is set)
R500 (float) – Intended to be \(R_{500}\) for clusters, provided in the same units as pixelsize. Can be used as a circle of interest for any target, with radius \(R_{500}\).
r5col (str) – A string corresponding to the color of the circle to be drawn for \(R_{500}\), if provided.
zoom (float) – If you wish to zoom in, set this to some value greater than 1.
noaxes (bool) – Hide the image axes.
verbose (bool) – Print a few things to stdout.
imgext (int) – Extension of the image (to show, or of which to take the GGM). Default is 0.