Analysis (Shared)¶
ellipse.py¶
Auxiliary module with functions to generate generalized ellipse masks.
- author
Ruyman Azzollini
-
class
vison.analysis.ellipse.TestEllipse(methodName='runTest')¶ Unit tests for the ellipse module.
-
setUp()¶ Hook method for setting up the test fixture before exercising it.
-
-
vison.analysis.ellipse.area_superellip(r, q, c=0)¶ Returns area of superellipse, given the semi-major axis length
-
vison.analysis.ellipse.dist_superellipse(n, center, q=1.0, pos_ang=0.0, c=0.0)¶ Form an array in which the value of each element is equal to the semi-major axis of the superellipse of specified center, axial ratio, position angle, and c parameter which passes through that element. Useful for super-elliptical aperture photometry.
Inspired on dist_ellipse.pro from AstroLib (IDL).
Note: this program doesn’t take into account the change in the order of axes from IDL to Python. That means, that in ‘n’ and in ‘center’, the order of the coordinates must be reversed with respect to the case for dist_ellipse.pro, in order to get expected results. Nonetheless, the polar angle means the counter-clock wise angle with respect to the ‘y’ axis.
- Parameters
n – shape of array (N1,N2), it can be an integer (squared shape NxN)
center – center of superellipse radii: (c1,c2)
q – axis ratio r2/r1
pos_ang – position angle of isophotes, in degrees, CCW from axis 1
c – boxyness (c>0) /diskyness (c<0)
-
vison.analysis.ellipse.effective_radius(area, q=1.0, c=0.0)¶ Returns semi-major axis length of superellipse, given the area
Guyonnet15.py¶
Library with functions that implement the algorithms described in Guyonnet+15. “Evidence for self-interaction of charge distribution in CCDs” Guyonnet, Astier, Antilogus, Regnault and Doherty 2015
Notes:
I renamed “x” (pixel boundary index) to “b”, to avoid confusion with cartesian “x”.
In paper, X belongsto [(0,1),(1,0),(0,-1),(-1,0)]. Here b is referred to as cardinal points “N”,”E”,”S”,”W”. It is linked to matrix index ib, running between 0 and 3.
Created on Thu Sep 22 11:38:24 2016
- author
Ruyman Azzollini
-
vison.analysis.Guyonnet15.correct_estatic(img, aijb)¶ Corrects an image from pixel-boundaries deformation due to electrostatic forces. Subtracts delta-Q.
- Parameters
img – image, 2D array
aijb – Aijb matrix, 3D array
- Returns
array, img - delta-Q
-
vison.analysis.Guyonnet15.degrade_estatic(img, aijb)¶ Degrades an image according to matrix of pixel-boundaries deformations. Follows on Eq. 11 of G15. Adds delta-Q.
- Parameters
img – image, 2D array
aijb – Aijb matrix, 3D array
- Returns
array, img + delta-Q
-
vison.analysis.Guyonnet15.fpred_aijb(p, i, j, ib)¶ ‘The smoothing model assumes that a_{ij}^x coefficients are the product of a function of distance from the source charge to the considered boundary (r_{ij}) and that it also trivially depends on the angle between the source-boundary vector and the normal to the boundary (theta_{i,j}^x)’
Eq. 18
- Parameters
p – parameters of the radial function (list of 2)
i – pixel coordinate i
j – pixel coordinate j
ib – boundary index [0, 1, 2, 3]
- Returns
f(rij)cos(theta_ij^x)
-
vison.analysis.Guyonnet15.frdist(i, j, ib)¶ Distance from the source charge to considered boundary “b”
- Parameters
i – pixel coordinate i
j – pixel coordinate j
ib – boundary index [0, 1, 2, 3]
- Returns
distance r(ijb)
-
vison.analysis.Guyonnet15.ftheta_bound(i, j, ib)¶ “[theta_i,j^X is] the angle between the source-boundary vector and the normal to the boundary”.
- Parameters
i – pixel coordinate i
j – pixel coordinate j
ib – boundary index [0, 1, 2, 3]
- Returns
theta_i,j^x
-
vison.analysis.Guyonnet15.fun_p(x, *p)¶ auxiliary function to ‘solve_for_psmooth’
-
vison.analysis.Guyonnet15.generate_GaussPSF(N, sigma)¶ Create a circular symmetric Gaussian centered on the centre of a NxN matrix/image.
-
vison.analysis.Guyonnet15.get_Rdisp(img, aijb)¶ Retrieves map of relative displacements of pixel boundaries, for input img and Aijb matrix.
See G15 - Eq. 6
- Parameters
img – image, 2D array
aijb – aijb matrix, 3D array NxNx4
- Returns
array, relative displacements all boundaries of pixels in img
-
vison.analysis.Guyonnet15.get_cross_shape_rough(cross, pitch=12.0)¶
-
vison.analysis.Guyonnet15.get_deltaQ(img, aijb)¶ Retrieves deltaQ map for input image and aijb matrix.
See G15 - Eq. 11
- Parameters
img – image, 2D array
aijb – Aijb matrix, 3D array
- Returns
array, matrix with delta-Q for each pixel in img, given aijb
-
vison.analysis.Guyonnet15.get_kernel(aijb)¶ ‘kernel’ is an array (2N-1)x(2N-1)x4. Each plane kernel[:,:,b] is a 2D array with the displacement coefficients aijb, in all directions around a pixel at (0,0).
- Parameters
aijb – array, matrix with displacements in 1st quadrant
- Returns
kernel matrix, (2N-1)x(2N-1)x4
-
vison.analysis.Guyonnet15.plot_map(z, ii, jj, title='')¶
-
vison.analysis.Guyonnet15.plot_maps_ftheta(f, ii, jj, suptitle='')¶
-
vison.analysis.Guyonnet15.show_disps_CCD273(aijb, stretch=5.0, peak=28571.428571428572, N=25, sigma=1.6, title='', figname='')¶
-
vison.analysis.Guyonnet15.solve_for_A_linalg(covij, var=1.0, mu=1.0, doplot=False, psmooth=None, returnAll=False, verbose=False)¶ Function to retrieve the A matrix of pixel boundaries displacements, given a matrix of pixel covariances, variance, and mu.
if var==1 and mu==1, it is understood that covij is the correlation matrix.
See section 6.1 of G15.
- Parameters
covij – array, squared matrix with pixel covariances.
var – float, variance of the flat-field.
mu – float, mean value of the flat-field.
doplot – if True, plot the fit of the fpred(ijb) function
psmooth – coefficients of the fpred(aijb) function (Eq. 18)
returnAll – bool, controls return values
verbose – bool, be verbose or not.
- Returns
if returnAll == True, return (aijb, psmooth), otherwise return aijb only
-
vison.analysis.Guyonnet15.solve_for_psmooth(covij, var, mu, doplot=False)¶ Solving (p0,p1) parameters in Eq. 18 using covariance matrix and measured covariance matrix.
- Parameters
covij – array, covariance matrix
var – float, variance
mu – float, expected value of pixel values (“mean” of flat-field)
doplot – bool, if True, plot data and best fit model
- Returns
best-fit parameters, and errors: 2 tuples of 2 elements each
-
vison.analysis.Guyonnet15.test0()¶
-
vison.analysis.Guyonnet15.test_getkernel()¶
-
vison.analysis.Guyonnet15.test_selfconsist()¶
-
vison.analysis.Guyonnet15.test_solve()¶