Welcome to bashes’s documentation!¶
Contents:
bashes package¶
bashes.config module¶
Standardized handling of config info
- class bashes.config.Config(args=None)¶
Bases: dict
Represents a dictionary of serializable configuration data.
- save(name, noclobber=False)¶
Serializes this config to a YAML file using the specified base name. Will not overwrite an existing file if noclobber is True. The .yaml extension is added to name unless it already has an extension.
- bashes.config.githash(what='HEAD')¶
Returns the hash for the HEAD of the git repo containing this file or a helpful error message string if this cannot be determined
- bashes.config.load(name)¶
Loads and returns a dictionary for the named config. The .yaml extension is added to name unless it already has an extension. Note that the return value is a plain dict and not a Config object.
bashes.display module¶
Supports interactive display to a separate DS9 process via XPA. For documentation of XPA see http://hea-www.harvard.edu/saord/ds9/ref/xpa.html
- class bashes.display.Display(config=None)¶
Bases: object
Represents a connection with a running DS9 process.
- config(cmds)¶
Sends commands separated by semicolons
- get(cmd)¶
- set(cmd)¶
- show(image, min=None, max=None, config=None, reuseLimits=False)¶
Displays the specified image in a new frame. The image can be provided as a numpy array or a galsim Image type. Scale limits will be set automatically from the data unless min or max are specified. If reuseLimits is True and this is not the first frame, then min/max are ignored and the limits of the current frame are reused for this image. Any config commands provided in the optional cmds string will be sent. Separate multiple commands with semicolons. By default the frame is zoomed to fit, but this can be overridden in cmds.
bashes.estimator module¶
- class bashes.estimator.Estimator(data, psfs, ivar, stampSize, pixelScale, ntheta, nxy, xymax, xy_oversampling, theta_oversampling, ng, gmax, g1_center, g2_center, featureCalculator=None)¶
Bases: object
Top-level class for performing a Bayesian shear estimation.
- static addArgs(parser)¶
Add arguments to the provided command-line parser that support the fromArgs() method.
- static fromArgs(args)¶
Returns a dictionary of constructor parameter values based on the parsed args provided.
- getNllFine(ig, idata)¶
Returns a (theta) array of NLL values marginalized over flux,x,y for the specified shear and data stamp index. Values are interpolated onto the fine oversampled grid self.thetaFine used for (theta) marginalization.
- getNllXYFine(ith, ig, idata)¶
Returns an (x,y) array of NLL values marginalized over flux for the specified theta, shear, and data stamp index. Values are interpolated onto the fine oversampled grid self.xyFine used for (x,y) marginalization.
- static marginalize(nll)¶
Returns an estimate of the -log of the integral of exp(-nll) using the provided values of nll tabulated on a uniform grid over the integration domain.
- usePrior(sourceModel, fluxSigmaFraction, weight=1.0, traceMsg=None)¶
bashes.features module¶
- class bashes.features.AbsFeatureCalculator(nfeatures)¶
Bases: object
Feature calculator abstract base class.
- nfeatures¶
int
The number of features to calculate.
Parameters: nfeatures (int) – The number of features to calculate. - getFeatureTransform(psf)¶
Returns a matrix that transforms pixel values to features.
Parameters: psf (galsim.GSObject) – The psf model for the corresponding image.
- class bashes.features.FourierMoments(stampSize, pixelScale, sigma)¶
Bases: bashes.features.AbsFeatureCalculator
Calculates fourier domain moment features.
Parameters: - getFeatureTransform(psf)¶
Returns a matrix that transforms pixel values to features.
Parameters: psf (galsim.GSObject) – The psf model for the corresponding image.
- class bashes.features.PixelFeatures(stampSize)¶
Bases: bashes.features.AbsFeatureCalculator
Simple pixel feature calculator.
- nfeatures¶
int
The total number of pixels.
Parameters: stampSize (int) – The postage stamp size in pixels. - getFeatureTransform(psf)¶
Returns a matrix that transforms pixel values to features.
Parameters: psf (galsim.GSObject) – The psf model for the corresponding image.
- bashes.features.circularize(image)¶
Returns the azimuthally averaged 2d image about the center.
Parameters: image (np.ndarray) – Square 2D image.
- bashes.features.fourierMatrix(n)¶
Returns the fourier transform matrix for a square 2d matrix of size n. The following are equivalent:
fourierMatrix(self.stampSize).dot(image.flatten()) np.fft.fft2(image).flatten()Parameters: n (int) – Square image size.
- bashes.features.main()¶
bashes.great3 module¶
- class bashes.great3.Observation(branch, index, epoch)¶
Bases: object
Represents a GREAT3 observation specified by a branch, index (0-199) and epoch.
- static addArgs(parser)¶
Add arguments to the provided command-line parser that support the fromArgs() method.
- createObject(galaxyIndex, shifted=True, lensed=True)¶
Returns a GalSim model of the object corresponding to the specified galaxy index, consisting of the source model with lensing distortion and centroid shift applied, and convolved with the appropriate PSF.
- createPSF(galaxyIndex)¶
Returns a GalSim model of the PSF for the specified galaxy index.
- createSource(galaxyIndex, shifted=False, lensed=False)¶
Returns a GalSim model of the source for the specified galaxy index with optional centroid shifts and weak lensing distortion.
- static fromArgs(args)¶
Returns a dictionary of constructor parameter values based on the parsed args provided.
- classmethod getGSParams()¶
- getImage()¶
Returns the array of postage stamp image data for this observation and initializes our stampSize data member.
- getStars()¶
Returns the array of postage stamp starfield data for this observation.
- getTruthCatalog()¶
Returns the truth catalog for this observation.
- getTruthParams()¶
Returns a dictionary of truth parameter values for this observation.
- renderObject(galaxyIndex, shifted=True, lensed=True, addNoise=True)¶
Renders a postage stamp of the truth model for the specified galaxy index with optional noise (that will exactly match the noise used for GREAT3).
- bashes.great3.main()¶
bashes.tiled module¶
Support for working with tiled images of postage stamps
- bashes.tiled.create(stampSize, nx, ny, scale=None)¶
Creates a new Tiled image with the specified dimensions and pixels initialized to zero.
bashes.utility module¶
- bashes.utility.getBinEdges(*binCenters, **options)¶
Returns a numpy array of bin edges corresponding to the input array of bin centers, which will have a length one greater than the input length. The outer edges will be the same as the outer bin centers unless expand=True is passed as a keyword option. This function is normally used with the matplotlib pcolormesh function, e.g.
ex,ey = getBinEdges(x,y) plt.pcolormesh(ex,ey,z,cmap=’rainbow’) levels = np.min(z) + getDeltaChiSq(dof=2) plt.contour(x,y,z,levels=levels,colors=’w’,linestyles=(‘-‘,’–’,’:’))
- bashes.utility.getDeltaChiSq(CL=(0.6827, 0.9543, 0.9973), dof=2)¶
Returns a numpy array of delta(chisq) values corresponding to the specified list of confidence levels. The default CL values correspond to the enclosed probabilities of 1,2,3-sigmas for a 1D Gaussian pdf.
- bashes.utility.padPeriodic(x, n, offset=0.0)¶
Extend the array x[i] with 0 <= i < N to cover -n <= i < N+n+1 assuming periodicity x[n+N] = x[n]+offset to duplicate existing entries. Returns a new array that contains a copy of the original array. Note that an additional copy is needed on the high side to cover the interval x[N-1] - x[N].
- bashes.utility.render(model, scale, size=None, stamp=None)¶
Returns a rendering of the specified GalSim model into a square postage stamp with the specified pixel scale (arcsecs). Either a stamp pixel size or an existing stamp (with its scale attribute set) must be provided. Note that the model will be convolved with the pixel response, so should not already be convolved with the pixel response.