prtools 1.1.0__tar.gz → 1.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {prtools-1.1.0/prtools.egg-info → prtools-1.2.0}/PKG-INFO +1 -1
- {prtools-1.1.0 → prtools-1.2.0}/prtools/__init__.py +3 -3
- {prtools-1.1.0 → prtools-1.2.0}/prtools/fourier.py +4 -4
- {prtools-1.1.0 → prtools-1.2.0}/prtools/shape.py +0 -1
- {prtools-1.1.0 → prtools-1.2.0}/prtools/sparse.py +57 -30
- {prtools-1.1.0 → prtools-1.2.0}/prtools/zernike.py +16 -11
- {prtools-1.1.0 → prtools-1.2.0/prtools.egg-info}/PKG-INFO +1 -1
- {prtools-1.1.0 → prtools-1.2.0}/LICENSE +0 -0
- {prtools-1.1.0 → prtools-1.2.0}/NOTICE +0 -0
- {prtools-1.1.0 → prtools-1.2.0}/README.rst +0 -0
- {prtools-1.1.0 → prtools-1.2.0}/prtools/array.py +0 -0
- {prtools-1.1.0 → prtools-1.2.0}/prtools/misc.py +0 -0
- {prtools-1.1.0 → prtools-1.2.0}/prtools/segmented.py +0 -0
- {prtools-1.1.0 → prtools-1.2.0}/prtools/stats.py +0 -0
- {prtools-1.1.0 → prtools-1.2.0}/prtools.egg-info/SOURCES.txt +0 -0
- {prtools-1.1.0 → prtools-1.2.0}/prtools.egg-info/dependency_links.txt +0 -0
- {prtools-1.1.0 → prtools-1.2.0}/prtools.egg-info/requires.txt +0 -0
- {prtools-1.1.0 → prtools-1.2.0}/prtools.egg-info/top_level.txt +0 -0
- {prtools-1.1.0 → prtools-1.2.0}/setup.cfg +0 -0
- {prtools-1.1.0 → prtools-1.2.0}/setup.py +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
__version__ = '1.
|
|
2
|
+
__version__ = '1.2.0'
|
|
3
3
|
|
|
4
4
|
from prtools.array import (
|
|
5
5
|
centroid, pad, boundary, rebin, rescale, normpow,
|
|
@@ -20,12 +20,12 @@ from prtools.shape import (
|
|
|
20
20
|
)
|
|
21
21
|
|
|
22
22
|
from prtools.sparse import (
|
|
23
|
-
spindex, sparray, spmatrix,
|
|
23
|
+
spindex, sparray, spmatrix, spindex_from_mask, mask_from_spindex
|
|
24
24
|
)
|
|
25
25
|
|
|
26
26
|
from prtools.stats import ee, rms, pv
|
|
27
27
|
|
|
28
28
|
from prtools.zernike import (
|
|
29
29
|
zernike, zernike_compose, zernike_basis, zernike_fit,
|
|
30
|
-
zernike_remove
|
|
30
|
+
zernike_remove, zernike_coordinates
|
|
31
31
|
)
|
|
@@ -119,15 +119,15 @@ def _dft2_matrices(m, n, M, N, alphar, alphac, shiftr, shiftc, offsetr, offsetc,
|
|
|
119
119
|
else:
|
|
120
120
|
sign = 1
|
|
121
121
|
R, S, U, V = _dft2_coords(m, n, M, N)
|
|
122
|
-
E1 = np.exp(sign*2.0 * 1j * np.pi * alphar * np.outer(R
|
|
123
|
-
E2 = np.exp(sign*2.0 * 1j * np.pi * alphac * np.outer(S
|
|
122
|
+
E1 = np.exp(sign*2.0 * 1j * np.pi * alphar * np.outer(R+offsetr, U-shiftr)).T
|
|
123
|
+
E2 = np.exp(sign*2.0 * 1j * np.pi * alphac * np.outer(S+offsetc, V-shiftc))
|
|
124
124
|
return E1, E2
|
|
125
125
|
|
|
126
126
|
|
|
127
127
|
def _idft2_matrices(m, n, M, N, alphar, alphac, shiftr, shiftc, offsetr, offsetc):
|
|
128
128
|
R, S, U, V = _dft2_coords(m, n, M, N)
|
|
129
|
-
E1 = np.exp(2.0 * 1j * np.pi * alphar * np.outer(R
|
|
130
|
-
E2 = np.exp(2.0 * 1j * np.pi * alphac * np.outer(S
|
|
129
|
+
E1 = np.exp(2.0 * 1j * np.pi * alphar * np.outer(R+offsetr, U-shiftr)).T
|
|
130
|
+
E2 = np.exp(2.0 * 1j * np.pi * alphac * np.outer(S+offsetc, V-shiftc))
|
|
131
131
|
return E1, E2
|
|
132
132
|
|
|
133
133
|
|
|
@@ -47,7 +47,6 @@ def _meshij(shape, shift, angle):
|
|
|
47
47
|
rr, cc = np.meshgrid(np.arange(nr) - np.floor(nr/2.0) - shift[0],
|
|
48
48
|
np.arange(nc) - np.floor(nc/2.0) - shift[1],
|
|
49
49
|
indexing='ij')
|
|
50
|
-
angle = np.deg2rad(angle)
|
|
51
50
|
r = rr * np.cos(angle) + cc * np.sin(angle)
|
|
52
51
|
c = rr * -np.sin(angle) + cc * np.cos(angle)
|
|
53
52
|
return r, c
|
|
@@ -1,45 +1,35 @@
|
|
|
1
|
-
from collections import namedtuple
|
|
2
|
-
|
|
3
1
|
import numpy as np
|
|
4
2
|
|
|
5
3
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
def spindex(m):
|
|
10
|
-
"""Create a sparse coordinate list (COO) index object.
|
|
4
|
+
class spindex:
|
|
5
|
+
"""Sparse coordinate list (COO) index
|
|
11
6
|
|
|
12
7
|
Parameters
|
|
13
8
|
----------
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
9
|
+
row : array_like
|
|
10
|
+
List of row indices which contain nonzero data
|
|
11
|
+
col : array_like
|
|
12
|
+
List of column indices which contain nonzero data
|
|
13
|
+
shape : (2,) array_like
|
|
14
|
+
Dimensions of dense matrix
|
|
15
|
+
nnz : int, optional
|
|
16
|
+
Number of nonzero entries in dense matrix. If not
|
|
17
|
+
specified,
|
|
17
18
|
Returns
|
|
18
19
|
-------
|
|
19
|
-
|
|
20
|
-
namedtuple with the following attributes:
|
|
21
|
-
|
|
22
|
-
* ``row`` List of row indices which contain nonzero data
|
|
23
|
-
* ``col`` List of column indices which contain nonzero data
|
|
24
|
-
* ``shape`` Tuple of dimensions of ``m``
|
|
25
|
-
* ``nnz`` Number of nonzero entries in ``m``
|
|
20
|
+
spindex
|
|
26
21
|
|
|
27
22
|
See Also
|
|
28
23
|
--------
|
|
29
|
-
* :func:`~prtools.spmatrix` Create a dense matrix from a sparse array
|
|
30
24
|
* :func:`~prtools.sparray` Create a sparse array from a dense matrix
|
|
25
|
+
* :func:`~prtools.spmatrix` Create a dense matrix from a sparse array
|
|
31
26
|
"""
|
|
32
27
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
def spmask(index):
|
|
41
|
-
"""Create a mask from a sparse coordinate list (COO) index."""
|
|
42
|
-
return spmatrix(np.ones(index.row.shape), index)
|
|
28
|
+
def __init__(self, row, col, shape, nnz=None):
|
|
29
|
+
self.row = row
|
|
30
|
+
self.col = col
|
|
31
|
+
self.shape = shape
|
|
32
|
+
self.nnz = nnz if nnz is not None else len(self.row)
|
|
43
33
|
|
|
44
34
|
|
|
45
35
|
def spmatrix(a, index):
|
|
@@ -49,7 +39,7 @@ def spmatrix(a, index):
|
|
|
49
39
|
----------
|
|
50
40
|
a : array_like
|
|
51
41
|
Sparse array to be reformed as a dense matrix
|
|
52
|
-
index :
|
|
42
|
+
index : :class:`~prtools.spindex`
|
|
53
43
|
Corresponding index object
|
|
54
44
|
|
|
55
45
|
Returns
|
|
@@ -78,7 +68,7 @@ def sparray(m, index=None):
|
|
|
78
68
|
----------
|
|
79
69
|
m : array_like
|
|
80
70
|
Dense matrix to be reformed as a sparse vector
|
|
81
|
-
index :
|
|
71
|
+
index : :class:`~prtools.spindex`
|
|
82
72
|
Corresponding index object
|
|
83
73
|
|
|
84
74
|
Returns
|
|
@@ -101,3 +91,40 @@ def sparray(m, index=None):
|
|
|
101
91
|
a = m.ravel()
|
|
102
92
|
return a[rmi]
|
|
103
93
|
|
|
94
|
+
|
|
95
|
+
def spindex_from_mask(m):
|
|
96
|
+
"""Create a sparse coordinate list (COO) index object from a
|
|
97
|
+
mask.
|
|
98
|
+
|
|
99
|
+
Parameters
|
|
100
|
+
----------
|
|
101
|
+
m : array_like
|
|
102
|
+
Dense matrix to be vectorized
|
|
103
|
+
|
|
104
|
+
Returns
|
|
105
|
+
-------
|
|
106
|
+
:class:`~prtools.spindex`
|
|
107
|
+
"""
|
|
108
|
+
|
|
109
|
+
m = np.asarray(m)
|
|
110
|
+
r, c = m.nonzero()
|
|
111
|
+
shape = m.shape
|
|
112
|
+
nnz = len(r)
|
|
113
|
+
return spindex(row=r, col=c, shape=shape, nnz=nnz)
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
def mask_from_spindex(index):
|
|
117
|
+
"""Create a mask from a sparse coordinate list (COO) index.
|
|
118
|
+
|
|
119
|
+
Parameters
|
|
120
|
+
----------
|
|
121
|
+
index : :class:`~prtools.spindex`
|
|
122
|
+
Index object
|
|
123
|
+
|
|
124
|
+
Returns
|
|
125
|
+
-------
|
|
126
|
+
ndarray
|
|
127
|
+
Dense matrix
|
|
128
|
+
"""
|
|
129
|
+
|
|
130
|
+
return spmatrix(np.ones(index.row.shape), index)
|
|
@@ -366,30 +366,35 @@ def zernike_coordinates(mask, shift=None, angle=0, indexing='ij'):
|
|
|
366
366
|
mask : array_like
|
|
367
367
|
Binary mask defining the extent to compute the Zernike polynomial
|
|
368
368
|
over.
|
|
369
|
-
shift : (2,) array_like
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
369
|
+
shift : (2,) array_like, optional
|
|
370
|
+
How far to shift center in float (rows, cols). If None (default),
|
|
371
|
+
shift is computed automatically to locate the origin at the mask
|
|
372
|
+
centroid.
|
|
373
373
|
angle: float, optional
|
|
374
374
|
Angle to rotate coordinate system by in degrees. rotate is specified
|
|
375
375
|
relative to the x-axis. Default is 0.
|
|
376
|
-
|
|
376
|
+
indexing : {'ij', 'xy'}, optional
|
|
377
|
+
Matrix ('ij', default) or cartesian ('xy') indexing of output.
|
|
378
|
+
|
|
379
|
+
Returns
|
|
380
|
+
-------
|
|
381
|
+
rho, theta : ndarrays
|
|
382
|
+
|
|
377
383
|
"""
|
|
378
384
|
mask = np.asarray(mask)
|
|
379
385
|
|
|
380
386
|
if shift is None:
|
|
381
387
|
center = np.asarray(mask.shape)/2
|
|
382
388
|
centroid = prtools.centroid(mask)
|
|
383
|
-
shift = (centroid[
|
|
384
|
-
|
|
389
|
+
shift = (centroid[0]-center[0], centroid[1]-center[1])
|
|
385
390
|
|
|
386
|
-
yy, xx = prtools.mesh(shape=mask.shape, shift=shift, indexing=indexing)
|
|
391
|
+
yy, xx = prtools.mesh(shape=mask.shape, shift=shift, angle=angle, indexing=indexing)
|
|
387
392
|
|
|
388
393
|
r = np.abs(xx+1j*yy)
|
|
389
394
|
rho = r/np.max(r*mask) # rho is defined to be 1 on the edge of the aperture
|
|
395
|
+
rho[np.where(rho==0)] = 1e-99
|
|
390
396
|
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
theta = np.angle(xx*np.exp(1j*angle) + 1j*yy*np.exp(1j*angle))
|
|
397
|
+
theta = np.angle(xx + 1j*yy)
|
|
398
|
+
theta[np.where(theta==0)] = 1e-99
|
|
394
399
|
|
|
395
400
|
return rho, theta
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|