prtools 1.2.0__tar.gz → 1.3.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.3.0/PKG-INFO ADDED
@@ -0,0 +1,80 @@
1
+ Metadata-Version: 2.4
2
+ Name: prtools
3
+ Version: 1.3.0
4
+ Summary: Utility functions for image-based phase retrieval
5
+ Author: Andy Kee
6
+ License: MIT License
7
+
8
+ Copyright (c) 2023 Andy Kee
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+ Project-URL: Homepage, https://github.com/andykee/prtools
28
+ Project-URL: Documentation, https://andykee.github.io/prtools/
29
+ Project-URL: Bug Tracker, https://github.com/andykee/prtools/issues
30
+ Classifier: Development Status :: 5 - Production/Stable
31
+ Classifier: Intended Audience :: Science/Research
32
+ Classifier: License :: OSI Approved :: MIT License
33
+ Classifier: Programming Language :: Python :: 3
34
+ Classifier: Topic :: Scientific/Engineering
35
+ Classifier: Topic :: Scientific/Engineering :: Astronomy
36
+ Classifier: Topic :: Scientific/Engineering :: Image Processing
37
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
38
+ Classifier: Topic :: Scientific/Engineering :: Physics
39
+ Requires-Python: >=3.8
40
+ Description-Content-Type: text/x-rst
41
+ License-File: LICENSE
42
+ License-File: NOTICE
43
+ Requires-Dist: numpy
44
+ Requires-Dist: scipy
45
+ Provides-Extra: jax
46
+ Requires-Dist: jax; extra == "jax"
47
+ Requires-Dist: optax; extra == "jax"
48
+ Dynamic: license-file
49
+
50
+ prtools
51
+ =======
52
+ |pypi version|
53
+
54
+ The prtools package implements functionality and tools that may be helpful
55
+ when performing image-based phase retrieval including:
56
+
57
+ * Image processing, reduction, and analysis
58
+ * Creating, fitting, and removing Zernike polynomials
59
+ * Drawing various shapes in arrays
60
+ * Computing statistics and optical simulation parameters
61
+
62
+ Installation
63
+ ------------
64
+ Install and update prtools using `pip`_:
65
+
66
+ .. code-block:: text
67
+
68
+ pip install prtools
69
+
70
+ Links
71
+ -----
72
+ * **Docs:** https://andykee.github.io/prtools/
73
+ * **Releases:** https://pypi.org/project/prtools/
74
+ * **Source:** https://github.com/andykee/prtools/
75
+ * **Issues:** https://github.com/andykee/prtools/issues/
76
+
77
+ .. _pip: https://pip.pypa.io/en/stable/getting-started/
78
+
79
+ .. |pypi version| image:: https://img.shields.io/pypi/v/prtools.svg
80
+ :target: https://pypi.python.org/pypi/prtools
@@ -20,7 +20,7 @@ Install and update prtools using `pip`_:
20
20
 
21
21
  Links
22
22
  -----
23
- * **Docs:** https://prtools.readthedocs.io/
23
+ * **Docs:** https://andykee.github.io/prtools/
24
24
  * **Releases:** https://pypi.org/project/prtools/
25
25
  * **Source:** https://github.com/andykee/prtools/
26
26
  * **Issues:** https://github.com/andykee/prtools/issues/
@@ -0,0 +1,66 @@
1
+ __version__ = '1.3.0'
2
+
3
+ from prtools._backend import __backend__, use
4
+
5
+ from prtools.array import (
6
+ centroid,
7
+ pad,
8
+ subarray,
9
+ boundary,
10
+ rebin,
11
+ rescale,
12
+ normpow,
13
+ shift,
14
+ register,
15
+ medfix
16
+ )
17
+
18
+ from prtools.cost import sserror
19
+
20
+ from prtools.fourier import dft2, idft2
21
+
22
+ from prtools.misc import (
23
+ calcpsf,
24
+ translation_defocus,
25
+ fft_shape,
26
+ min_sampling,
27
+ pixelscale_nyquist,
28
+ find_wrapped
29
+ )
30
+
31
+ from prtools.segmented import hex_segments
32
+
33
+ from prtools.shape import (
34
+ mesh,
35
+ circle,
36
+ hexagon,
37
+ rectangle,
38
+ spider,
39
+ gauss,
40
+ sin,
41
+ waffle
42
+ )
43
+
44
+ from prtools.sparse import (
45
+ index,
46
+ dense,
47
+ sparse,
48
+ index_from_mask,
49
+ mask_from_index
50
+ )
51
+
52
+ from prtools.stats import (
53
+ ee,
54
+ pv,
55
+ rms,
56
+ radial_avg
57
+ )
58
+
59
+ from prtools.zernike import (
60
+ zernike,
61
+ zernike_compose,
62
+ zernike_basis,
63
+ zernike_fit,
64
+ zernike_remove,
65
+ zernike_coordinates
66
+ )
@@ -0,0 +1,73 @@
1
+ import sys
2
+ import types
3
+
4
+ from prtools.backend import registry
5
+ from prtools.backend._base import _BackendLibrary
6
+
7
+
8
+ class _BackendName:
9
+ """Helper class for storing the backend name - needed since strings are
10
+ immutable.
11
+ """
12
+
13
+ def __init__(self, name):
14
+ self.name = name
15
+
16
+ def __repr__(self):
17
+ return self.name
18
+
19
+ def __str__(self):
20
+ return self.name
21
+
22
+ def __eq__(self, other):
23
+ return self.name == other
24
+
25
+
26
+ class _Backend(types.ModuleType):
27
+ __backend__ = _BackendName(None)
28
+ numpy = _BackendLibrary(None)
29
+ scipy = _BackendLibrary(None)
30
+
31
+ @classmethod
32
+ def use(cls, backend):
33
+ """Select the backend used for N-dimensional array operations.
34
+
35
+ Parameters
36
+ ----------
37
+ backend : str
38
+ The backend to use. This can be any of the following backends,
39
+ which are case-insensitive:
40
+
41
+ * NumPy
42
+ * JAX
43
+ """
44
+ #if name in registry:
45
+ backend = backend.lower()
46
+ cls.__backend__.name = backend
47
+ cls.numpy.module = registry.load_numpy(backend)
48
+ cls.scipy.module = registry.load_scipy(backend)
49
+
50
+
51
+ @classmethod
52
+ def set_backend(cls, name, numpy_module, scipy_module):
53
+ """Change the backend
54
+
55
+ Parameters
56
+ ----------
57
+ name : str
58
+ Name of the backend.
59
+ numpy_module : module
60
+ Library providing numpy-like functionality
61
+ scipy_module : module
62
+ Library providing scipy-like functionality
63
+ """
64
+ cls.__backend__.name = name
65
+ cls.numpy.module = numpy_module
66
+ cls.scipy.module = scipy_module
67
+
68
+
69
+ # use NumPy by default
70
+ _Backend.use('numpy')
71
+
72
+ # https://stackoverflow.com/a/72911884
73
+ sys.modules[__name__].__class__ = _Backend