cbasspy.jackknives package¶
Submodules¶
cbasspy.jackknives.jkexamples module¶
Module to generate example dictionary file and options file for use with jackknife code. You will likely want to call these each time you are starting a new set of jackknives.
-
generateDict
(dstName='./jkdict_eg.py')¶ Script to generate an example dictionary file.
Parameters: dstName : str, optional {‘./jkdict_eg.py’}
Name to save example file as
-
generateOptions
(dstName='./jkoptions_eg.ini')¶ Script to generate an example ini file.
Parameters: dstName : str, optional {‘./jkoptions_eg.ini’}
Name to save example file as
cbasspy.jackknives.jkgeneral module¶
This module does most of the work when running jackknife tests.
Typically you will call cbasspy.jackknives.jkgeneral.jackknife()
or cbasspy.jackknives.jkgeneral.run_jackknife_glam()
.
-
calc_chisq
(cov1, cov2, map1, map2, extraMask=None, lotsOfOutputs=False)¶ Given two covariance matrices and two maps return the reduced chi squared value and dof.
Parameters: cov1 : array_like
cov2 : array_like
map1 : array_like
map2 : array_like
extraMask : array_like, optional {None}
Extra mask of points to ignore. Pixels set to 1 in mask will be used.
lotsOfOutputs : optional {False,True}
if True outputs chi^2_red(I) and chi^2_red(P) separately
Returns: reduced_chisq : float
dof : float
-
chisqGainFactor
(whichPol, map1, map2, cov1, cov2, reverse=False, brightFrac=0.01)¶
-
jackknife
(maps, JKtitle, whichJK, jk_options, jkrun)¶ Do a set of jackknives
This is the main jackknife function.
Parameters: maps : array_like
list of jkm.CBASSmap objects
JKtitle : str
name of jackknife
whichJK : array_like
list of pairs of maps to compare, eg [(0,1),(0,2),(1,2)]
jk_options : ‘str’
.ini file with jackknife options. This determines the outputs
See also
run_jackknife_glam
- Run on Glamdring queue.
-
map_stats
(map_masked)¶ Calculate mean and rms of IQU masked map
Parameters: map_masked : array_like
Input I,Q,U map
Returns: meanI : float
meanQ : float
meanU : float
rmsI : float
rmsQ : float
rmsU : float
-
plotAlmTriangle
(wdiff, fig, ax, doJustNoise=False, doCbar=False)¶ Plot a triangle of alms.
Parameters: wdiff : array_like
HealPix weighted difference map
fig : matplotlib figure
ax : matplotlib ax
doJustNoise : bool, False
Whether to do a noise simulation
doCbar : bool, False
Whether to plot a colorbar
Returns: image : array_like
Image of alms
-
plotAlmZoom
(image_wdiff, titleStr='')¶ Plot a zoom in on ell,m=0,0
Parameters: image_wdiff : array_like
Image of weighted difference alms
titleStr : str
Title for plot
-
plotDataAndSimNoise
(wdiff, titleStr='')¶ Generate a figure containing a pair of traingle plots of alms. The left hand plot is the data. The right hand plot is a realisation of noise with the same std.
Parameters: wdiff : array_like
HealPix weighted difference map
titleStr : str
Title of plot
-
plotPowerSpec
(maskName, skyClName, weightName, sigma_0, numWhiteSims, outDir, diffMapName, fig_title, outName, spiceParams, ubin=20, pngDpi=300)¶
-
plotPowerSpecFactorOf2
(maskName, numWhiteSims, outDir, diff2MapName, sum2MapName, noiseOver2, outName, spiceParams, ubin=20, pngDpi=300)¶ Parameters: maskName: name of sky mask file
nuWhiteSims: Number of realization of white noise to create
outDir: Output directory
diff2MapName: Name of difference map
sum2MapName: Name of sum map
outName: Name of output figure
spiceParams: Spice param file
ubin: width of ell bins
noiseOver2: Noise map
-
plotPowerSpecFactorOf2PlaneMask
(maskNames, numWhiteSims, outDir, diff2MapName, sum2MapName, noiseOver2, outName, spiceParams, ubin=20, pngDpi=300)¶ Parameters: maskNames: namea of sky mask files, [mask10,mask20,mask30,mask40,mask50,mask60]]
nuWhiteSims: Number of realization of white noise to create
outDir: Output directory
diff2MapName: Name of difference map
sum2MapName: Name of sum map
outName: Name of output figure
spiceParams: Spice param file
ubin: width of ell bins
noiseOver2: Noise map
-
plotPte
(wdiff, mMin=5, ellMin=50, titleStr='')¶ Plot histograms of the PTE values for the a weighted difference map alms. The PTE values are calcualted by comaring the distribution to the equivalent Gaussian.
They are also plotted excluding the region below mMin and ellMin
Parameters: wdiff : array_like
Weighted difference map
mMin : int
Minimum m value for restricted region
ellMin : int
Minimum ell value for restricted region
titleStr : str
Title of figure
-
powerSpecResids
(jkParams, PS_jk, PS_sky, PS_noise)¶ jkParams[0] = multiplicative factor for sky jkParams[1] = multiplicative factor for noise
-
powerSpecResids2
(jkParams, PS_diff2, PS_whiteNoise_mu, ell)¶ jkParams[0] : intercept jkParams[1] : slope
-
produce_plane_masks
(NSIDE, outDir, rotTo, cutOff)¶ Produce a mask of the galactic plane
eg, NSIDE=512, outDir=outDir, rotTo=’c’, cutOff=10. i.e. cutOff in degrees from galactic plane.
-
returnPowerSpecFactorOf2
(maskName, numWhiteSims, outDir, diff2MapName, sum2MapName, noiseOver2, outName, spiceParams, ubin=20, pngDpi=300, apodizesigma=90, thetamax=90)¶
-
run_jackknife_glam
(maps, JKtitle, whichJK, jk_options, jkrun)¶ Do a set of jackknives on glamdring.
Inputs are strings, eg:
- maps = ‘[allGood_EL37_S30,allGood_EL47_S30,allGood_EL67_S30,allGood_EL77_S30]’
- JKtitle = ‘elevation’
- whichJK = ‘list(itertools.combinations(range(0,len(maps)), 2)) # Every combination’
- jk_options = ‘jk_options.ini’
- jk_run = ‘jk_run23.py’ (for example)
The example above has set whichJK to every combination of maps Could instead specify just the few you want to compare, eg: > whichJK = ‘([0,1],[2,3])’
See also
jackknife
- If you don’t want to run on Glamdring
-
save_diff_map
(map, mapTitle, mapName, doGnomic=False, doCart=False, unitFontSize=15, kwargs={}, pngDpi=300)¶ Save a map as either gnomic or mollview image
Parameters: map : array_like
map to save
mapTitle : str
Title in image
mapName : str
File name and extension
doGnomic : optional, {False,True}
Whether to do a gnomic projection
doCart : optional, {False,True}
Whether to do a cartesian projection
kwargs : *
Dictionary to pass to moll/gnom view
-
subtract_masked_maps
(map1_masked, map2_masked, weights=[], divide_by_two=False)¶ Subtracts two maps from each other.
If weights are provided then calculate weighted diff
Parameters: map1_masked : masked array_like
I,Q,U map
map2_masked : masked array_like
I,Q,U map
weights : array_like, optional
weights map
divide_by_two : boolean, optional {False}
If True, divide the difference map by two
Returns: diffMap : array_like
(weighted) difference map
-
sum_masked_maps
(map1_masked, map2_masked, divide_by_two=False)¶ Sums two maps
Parameters: map1_masked : masked array_like
I,Q,U map
map2_masked : masked array_like
I,Q,U map
divide_by_two : boolean, optional {False}
If True, divide the sum map by two
cbasspy.jackknives.jkmaps module¶
Map objects, used by jackknife codes.
-
class
CBASSmap
(cutName, fileListName, paramName, dir, coord, jkd)¶ Bases:
object
Maps objects, used by the jackknife code
When creating a CBASSmap object, you need to define the following attributes,
- cutName
- fileListName
- paramName
- dir
- coord
- jkd
The rest are calculated by various methods.
Attributes
Name (str) map name has format [cutName]_[fileListName]_[paramName]_[coord] cutName (str) name of cut on the data cut (str) cbass.split_data command to obtain the cut fileListName (str) short name of .txt file list fileList (str) full file name fileListDir (str) directory to find .txt file paramName (str) short name of .ini parameter file param (str) full parameter file name paramDir (str) directory to find .ini file coord (str) coordinate system of map, eg ‘c’, ‘g’ jkd (dictionary) dictionary containing all the information, see cbasspy.jackknives.jkexamples.generateDict()
and how to run jackknives doc.mapDir (str) where to find the map and cov .fits files todDir (str) where to find the tod .fits files Methods
-
make_map
()¶ Tell glamdring to make the map
-
mv_map
()¶ Tell glamdring to move the map to mapDir
-
read_cov
()¶ Read in covariance matrix
Returns: cov : array_like
II,QQ,UU,IQ,IU,QU covariance maps.
-
read_hits
()¶ Read in the hits map
Returns: map : array_like
H map
-
read_map
()¶ Read in a map
Returns: map : array_like
I, Q, U map.
-
split_data
()¶ Tell Glamdring to perform the cut on the data on files in fileList.
-
DESCART
= '~/CBASS/cbass_analysis/descart/map_making/descart_cbass'¶ str: Descart function