gns.geom_sampler module

gns.geom_sampler.checkCircleBounds(x, y, rBound)[source]

Check if point given by cartesian coordinates is within rBound of centre of circle

gns.geom_sampler.checkSphereBounds(x, y, z, rBound)[source]

Check if point given by cartesian coordinates is within rBound of centre of sphere

gns.geom_sampler.checkTorusBounds(x, y, z, R, rBound)[source]

Check if point given in cartesian coordinates is within rBound from centre of tube of torus. First calculates azimuthal angle of point to get coordinate of centre of tube which will be closest to the point in question. Then calculates the distance from the centre of the tube to this point, and checks this is within rBound

gns.geom_sampler.getCartesianCoords(circleArr, torusArr, sphereArr, circleLowerLimits, circleUpperLimits, torusLowerLimits, torusUpperLimits, sphereLowerLimits, sphereUpperLimits)[source]

Takes in arrays of geometrically sampled parameters and returns corresponding points in relevant spaces in cartesian coordinates.

gns.geom_sampler.getCartesianSigma(circleArr, torusArr, sphereArr, circleSigma, torusSigma, sphereSigma, circleLowerLimits, circleUpperLimits, torusLowerLimits, torusUpperLimits, sphereLowerLimits, sphereUpperLimits)[source]

Takes in sigma arrays (1-d, not 2-d diagonal) of geometrically sampled parameters (assumes they’re diagonal, off-diagonal elements are missed) and returns corresponding sigmas in relevant spaces in cartesian coordinates.

gns.geom_sampler.getCircleCartSigma(phi, sigmaPhi, r)[source]

Calculate error on x and y based on error propagation formulae coupled with coordinate transformation equations

gns.geom_sampler.getCircleSigma(p, sigmaP, l, u, method='propagation')[source]

If method == ‘constant’ sets sigmaX = sigmaY = 0.5 (n.b. proposal space is disc radius 2, sampling space is unit circle) If method == ‘propagation’ first calls getTwoPiSigma to get error on phi and then uses this to get error on Cartesian components. Has to calculate phi from p which is a little inefficient as this is already done when transforming point to Cartesian, but should add a massive overhead. TODO: rearrange functions so p is converted to phi only once

gns.geom_sampler.getCircleTrial(mean, cov, l, u)[source]

Takes mean and covariance of Cartesian coordinates and samples 2-d Gaussian parameterised by these. If rBound doesn’t evaluate to zero, checks if trial point is within radius rBound of origin in x-y plane (in circle radius rBound)

gns.geom_sampler.getGeomParams(params, geomList)[source]

Return geometric dimensions of params based on geomList. Same as above function

gns.geom_sampler.getGeomSigma(sigma, geomList)[source]

gets diagonal elements of sigma for geometric parameters based on geomList. Array it returns is diagonal As above function

gns.geom_sampler.getGeomTrialPoint(numCirc, numTorus, numSphere, circCartArr, torusCartArr, sphereCartArr, circCartSigArr, torusCartSigArr, sphereCartSigArr, circleLowerLimits, circleUpperLimits, torusLowerLimits, torusUpperLimits, sphereLowerLimits, sphereUpperLimits)[source]

Takes arrays of Cartesian coords of geometrically sampled parameters and gets trial point for each parameter in case of circle, or for each pair in case of torus and sphere. Returns arrays of physical points (one array for each shape)

gns.geom_sampler.getNonGeomLimits(targetSupport, nonGeomList)[source]

get upper and lower limits of non-geom dimensions from targetSupport upper and lower limits.

gns.geom_sampler.getNonGeomParams(params, nonGeomList)[source]

Return non-geom dimensions of params based on vanillaList

gns.geom_sampler.getNonGeomSigma(sigma, nonGeomList)[source]

gets diagonal elements of sigma for non-geom parameters based on nonGeomList. Array it returns is diagonal As above function

gns.geom_sampler.getPiSigma(sigmaP, l, u)[source]

Calculates error on phi isin [0, pi] based on error of p isin [l, u], assuming bounds have no errors

gns.geom_sampler.getShapeLimits(targetSupport, circleList, torusList, sphereList)[source]

get upper and lower limits and save in separate arrays based on geometric shape to be sampled from, from targetSupport upper and lower limits.

gns.geom_sampler.getShapeParams(params, circleList, torusList, sphereList)[source]

Return different geometric shape dimensions of params based on circleList, torusList and sphereList. Same as above function

gns.geom_sampler.getShapeSigma(sigma, circleList, torusList, sphereList)[source]

gets diagonal elements of sigma for geometric shape parameters based on the three lists. Assumes sigma is diagonal or it will miss off-diagonal elements Array it returns is not diagonal, as only need diagonal after converting to Cartesian coordinates

gns.geom_sampler.getSphereCartSigma(phi, theta, sigmaPhi, sigmaTheta, r, sigmaPhiTheta=0.0)[source]

Calculate error on x and y based on error propagation formulae coupled with coordinate transformation equations

gns.geom_sampler.getSphereSigma(p1, p2, sigmaP1, sigmaP2, l1, l2, u1, u2, method='constant')[source]

If method == ‘constant’ sets sigmaX = sigmaY = sigmaZ = 0.01 (n.b. proposal space is sphere radius = 2, sampling space is surface of sphere radius 1) If method == ‘propagation’ first calls getTwoPiSigma and getPiSigma to get errors on phi & theta and then uses this to get error on Cartesian components. Has to calculate phi and theta from p1, p2 which is a little inefficient as this is already done when transforming point to Cartesian, but should add a massive overhead. TODO: rearrange functions so p1, p2 are converted to phi and theta only once

gns.geom_sampler.getSphereTrial(mean, cov, l1, l2, u1, u2)[source]

Takes mean and covariance of Cartesian coordinates and samples 3-d Gaussian parameterised by these. If rBound doesn’t evaluate to zero, checks if trial point is within sphere with radius = rBound

gns.geom_sampler.getTorusCartSigma(phi, theta, sigmaPhi, sigmaTheta, r, R, sigmaPhiTheta=0.0)[source]

Calculate error on x and y based on error propagation formulae coupled with coordinate transformation equations

gns.geom_sampler.getTorusSigma(p1, p2, sigmaP1, sigmaP2, l1, l2, u1, u2, method='propagation')[source]

If method == ‘constant’ sets sigmaX = sigmaY = sigmaZ = 0.5 (n.b. proposal space is solid torus greater radius = lesser radius 2, sampling space is surface of torus with greater radius = 2 and lesser radius = 1) If method == ‘propagation’ first calls getTwoPiSigma to get errors on phi & theta and then uses this to get error on Cartesian components. Has to calculate phi and theta from p1, p2 which is a little inefficient as this is already done when transforming point to Cartesian, but should add a massive overhead. TODO: rearrange functions so p1, p2 are converted to phi and theta only once

gns.geom_sampler.getTorusTrial(mean, cov, l1, l2, u1, u2)[source]

Takes mean and covariance of Cartesian coordinates and samples 3-d Gaussian parameterised by these. If rBound doesn’t evaluate to zero, checks if trial point is within torus with inner radius = rBound and greater radius = R. If rBound != R (for R isin positive real numbers)

gns.geom_sampler.getTwoPiSigma(sigmaP, l, u)[source]

Calculates error on phi isin [0, 2pi] based on error of p isin [l, u], assuming bounds have no errors

gns.geom_sampler.recombineTrialPoint(nonGeomPrimeArr, circlePrimeArr, torusPrimeArr, spherePrimeArr, nonGeomList, circleList, torusList, sphereList)[source]

recombine non-geom and geometric dimensions of trial point in same order as input parameter

gns.geom_sampler.splitGeomParams(paramGeomList)[source]

Get indexes of parameters from paramList based on whether parameter should be sampled in physical (non-geometric) or geometric space, and add these to two lists which can be used to index parameter array

gns.geom_sampler.splitGeomShapes(geomList, shapeList)[source]

Splits geomList into three separate lists by shape. Assumes that if shape in shapeList is torus or sphere, and an element of shapeList is one of these shapes, then the next parameter in geomList corresponds to second parameter of that pair. Hence for this to work, parameters in geomList corresponding to 3-d shapes should be paired in order