cbasspy.groundpy package

Submodules

cbasspy.groundpy.loadAndSubtractGroundTemplates module

cbasspy.groundpy.makeGroundTemplates module

cbasspy.groundpy.newGtCode module

createAzBins(azBinWidth, numOfChannels, justNumOfAzBins=False)

Create empty azimuth bins to fill

Parameters:

azBinWidth : float

Width of the azimuth bins in degrees

numOfChannels : float

Number of channels, default should be 6

justNumOfAzBins : bool, True

If True, only return numOfAzBins

Returns:

azBinLower : array_like, [,numOfAzBins]

Lower limits of azimuth bins (degrees)

azBinMiddle : array_like, [,numOfAzBins]

Centres of azimuth bins (degrees)

azBinUpper : array_like, [,numOfAzBins]

Upper limits of azimuth bins (degrees)

numOfAzBins : float

Number of azimuth bins

ground : array_like

Empty array to be filled with ground templates for I1, I2, Q1, Q2, U1 and U2

hits : array_like

Emptyu array to be filled with the hit count in each azimuth bin for I1, I2, Q1, Q2, U1 and U2.

createGroundFromTodFits(fitsFileName, cutName='NIGHT', maskMap=None, azBinWidth=1.0, refAzMin=-2.0, refAzMax=2.0, modelSky=None, doElTest=False, targetEl=37.0, targetElTol=2.0)

Create a ground template from a single fits file. Note, the returned ground signal needs to be divided by the hits.

The ground template construction routine is as follows: * Detrend * Bin detrended and masked data

Parameters:

fitsFileName : str

Name of fits file to load in

cutName : str, ‘NIGHT’

Which cut extension to use

maskMap : array_like, None

If not None, the masks to use. Shape must be [3,:] Celestial coordinates

azBinWidth : float, 1.0

Width of the azimuth bins in degrees

refAzMin : float, -2.0

Lower bound of reference data for detredning, in degrees

refAzMaz : float

Upper bound of reference data for detrending, in degrees

modelSky : array_like, None

If not None, the model sky map to subtract from th I reference data. Celestial coordiantes

doElTest : boolean, False

Whether to test that the elevation in the fits file matches the target

targetEl : float, 37.

Target elevation, in degrees

targetElTol : float, 2.0

Tolerance of the target elevation, in degrees

Returns:

ground : array_like

Ground templates for I1, I2, Q1, Q2, U1 and U2

hits : array_like

Hit count in each azimuth bin for I1, I2, Q1, Q2, U1 and U2. The hit count can be different for each channel due to differing choices of mask.

subtractGroundFromTodFits(fitsFileName, ground, azBinWidth, outString, outFitsDir, doElTest=False, targetEl=37.0, targetElTol=2.0)

Subtracts a ground template from TOD FITS file and then saves the output to a new FITS file. The new FITS file has name ‘{0}{1}_gs_{2}.fits’.format(outFitsDir,fitsFileName.split(‘/’)[-1][0:-5],outString)

Parameters:

fitsFileName : str

FITS file to subtract the ground signal from

ground : array_like

Ground profile, shape [6,numOfAzBins]

azBinWidth : float

Width of azimuth bins in degrees

outString : str

Suffix to include in output fits files names

outFitsDir : str

Where to save the ground subtracted fits files

doElTest : bool, False

Whether to test that the elevation in the fits file matches the target

targetEl : float, 37.

Target elevation, in degrees

targetElTol : float, 2.0

Tolerance of the target elevation, in degrees

cbasspy.groundpy.oldPlotting module

Module useful for plotting the C-BASS Ground profiles

lombScarPowerSpec(groundDates, groundTemplates, chanNo, angleNo, nyquist_factor=1, samples_per_peak=10, norm='standard')

Estimates the Lomb-Scargle power spectrum for a given anglenumber and channel number. nyquist_factor and samples_per_peak are used by the lombscargle algorithm to decide the frequencies to sample. norm is the normalization, ‘standard’ by default, if ‘psd’ then no weighting is applied.

Parameters:

groundDates : array_like

Date of ground template

groundTemplates : array_like

Ground template for each day

chanNo : int

Which ground template to plot

angleNo : int

Which angle to estimate power spectrum for

nyquist_factor : int, optional {1}

Lomb-scargle options

samples_per_peak : int, otional {10}

Lomb-scargle options

norm : str, optional {‘standard’}

Lomb-scargle options

Returns:

Frequency : array_like

Frequency

Power : array_like

Lomb-scargle power

See also

readDir
read in groundDates and groundTemplates from a directory.
lombScarPowerSpec_plot(groundDates, groundTemplates, chanNo, angleNo, ax, norm='standard')

Plots the Lomb-Scargle power spectrum for a given angleNo and chanNo.

Parameters:

groundDates : array_like

Date of ground template

groundTemplates : array_like

Ground template for each day

chanNo : int

Which channel to plot

angleNo : int

Which angle to plot

ax : matplotlib axis

where to plot

norm : str, optional {‘standard’}

Lomb-scargle option

See also

lombScarPowerSpec
Estimates lomb-scargle power spectra
readDir
read in groundDates and groundTemplates from a directory.
lombScarglePowerSpec_wf(groundDates, groundTemplates, chanNo, ax)

Plots a waterfall plot of the Lomb-Scargle power spectrum across all angles.

Parameters:

groundDates : array_like

Date of ground template

groundTemplates : array_like

Ground template for each day

chanNo : int

Which channel to plot

ax : matplotlib axis

where to plot

See also

readDir
read in groundDates and groundTemplates from a directory.
lombScarPowerSpec_plot
plots lomb-scargle power spectrum for single angle
lombScarPowerSpec
Estimates lomb-scargle power spectra
plotAll(dirName, outSuffix, outDir='./')

Generates lots of plots of the ground profiles in a given directory

Parameters:

dirName : str

Name of directory containing ground templates, eg ‘/elephant/Reductions/v19/ground_templates_v19’

outSuffix : str

String to include in image file names, eg ‘v19’

outDir : str, optional {‘./’}

Where to save figures.

plotAllComparisons(dirs=['/stegodon/Reductions/v19/ground_templates_v19', '/stegodon/Reductions/v20/ground_templates_v20', '/stegodon/Reductions/v21/ground_templates_v21', '/stegodon/Reductions/v25/ground_templates_v25'], dirDescrs=['v19', 'v20', 'v21', 'v25'], outDir='./')

Plots the average ground templates for several reductions

Parameters:

dirs : array_like, optional {[dirNameV19,dirNameV20,dirNameV21,dirNameV25]}

Array of strings listing the directories of the ground templates from different reductions.

dirDescrs : array_like, optional, {[‘v19’,’v20’,’v21’,’v25’]}

Array of strings describing each reduction.

outDir : str, optional {‘./’}

Where to save the outputs

plotComparisons(ax1, ax2, dirs, dirDescrs, chanNo, chanName)

Generates plots to compare ground templates from different runs of the pipeline.

The code plots the average ground templates in the first ax. The code plots the difference between the average templates and the super-average in the second ax. (super-average is the average of the two averages.)

Parameters:

ax1 : matplotlib ax

ax2 : matplotlib ax

dirs : array_like

Array of strings listing the directories of the ground templates from different reductions. e.g. [dirNameV19,dirNameV20,dirNameV21,dirNameV25].

dirDescrs : array_like

Array of strings describing each reduction. e.g. [‘v19’,’v20’,’v21’,’v25’]

chanNo : int

Which channel to compare

chanName : str

Description for chanNo, e.g. ‘I1’

readDir(dirName)

Reads in all of the txt files in a directory and outputs the dates and ground templates as numpy arrays.

Parameters:

dirName : str

Location of ground templates

Returns:

groundDates : array_like, datetime objects

Date of ground template

groundTemplates : array_like

Ground template for each day

waterfallPlot(groundDates, groundTemplates, chanNo, ax, VMAX=0.07, VMIN=-0.07, subtractMean=False)

Plots a prety waterfall plot of the ground templates for a given chanNo.

Parameters:

groundDates : array_like

Date of ground template

groundTemplates : array_like

Ground template for each day

chanNo : int

Which channel to plot

ax : matplotlib axis

where to plot

VMAX : float, optional {0.07}

Ceiling

VMIN : float, optional {-0.07}

Floor

subtractMean : optional, {True, False}

Whether to subtract the means from the ground templates.

See also

readDir
read in groundDates and groundTemplates from a directory.
waterfallPlot_crude(groundDates, groundTemplates, chanNo)

Creates a new figure and plots a crude waterfall.

Parameters:

groundDates : array_like, datetime objects

Date of ground template

groundTemplates : array_like

Ground template for each day

chanNo : int {0,1,2,3,4,5,6}

Which template t plot

See also

readDir
read in groundDates and groundTemplates from a directory.