rms-psiops 1.0.0__py3-none-any.whl
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.
- psiops/__init__.py +174 -0
- psiops/__init__.pyi +494 -0
- psiops/_filter.py +334 -0
- psiops/_utils.py +251 -0
- psiops/_validation.py +318 -0
- psiops/_version.py +24 -0
- psiops/circle.py +27 -0
- psiops/fft.py +203 -0
- psiops/fitting.py +474 -0
- psiops/gaussian_filter.py +181 -0
- psiops/imagemodel/__init__.py +54 -0
- psiops/imagemodel/arraymodel.py +101 -0
- psiops/imagemodel/gaussian.py +115 -0
- psiops/imagemodel/smearedmodel.py +76 -0
- psiops/imagemodel/summedmodel.py +61 -0
- psiops/ishift.py +257 -0
- psiops/maximum.py +233 -0
- psiops/mean.py +209 -0
- psiops/median.py +270 -0
- psiops/minimum.py +233 -0
- psiops/outliers.py +103 -0
- psiops/patch.py +156 -0
- psiops/resample.py +366 -0
- psiops/reshape.py +75 -0
- psiops/rotate.py +592 -0
- psiops/shift.py +201 -0
- psiops/stdev.py +180 -0
- psiops/stretch.py +480 -0
- psiops/unzoom.py +115 -0
- psiops/variance.py +288 -0
- psiops/zoom.py +102 -0
- rms_psiops-1.0.0.dist-info/METADATA +154 -0
- rms_psiops-1.0.0.dist-info/RECORD +36 -0
- rms_psiops-1.0.0.dist-info/WHEEL +5 -0
- rms_psiops-1.0.0.dist-info/licenses/LICENSE +201 -0
- rms_psiops-1.0.0.dist-info/top_level.txt +1 -0
psiops/__init__.py
ADDED
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
##########################################################################################
|
|
2
|
+
# psiops/__init__.py
|
|
3
|
+
##########################################################################################
|
|
4
|
+
"""\
|
|
5
|
+
psiops: Photometrically accurate Science Image Operations on 2-D images.
|
|
6
|
+
|
|
7
|
+
* Spatial transforms: zoom, unzoom, shift, ishift, resample, reshape, rotate.
|
|
8
|
+
* Spatial filters: gaussian, mean, median, minimum, maximum, variance, standard deviation,
|
|
9
|
+
plus a ``circle`` helper for building circular filter footprints.
|
|
10
|
+
* Stack operations: mean, median, minimum, maximum, variance, standard deviation.
|
|
11
|
+
* Other operations: FFT, inverse FFT, correlation, autocorrelation, image alignment,
|
|
12
|
+
least-squares fitting, PSF modeling and fitting, outlier detection, and patching of
|
|
13
|
+
masked pixels.
|
|
14
|
+
|
|
15
|
+
General properties:
|
|
16
|
+
|
|
17
|
+
- Relative to similar functions such as those provided by SciPy, these spatial transforms
|
|
18
|
+
preserve photometric integrity. In other words, the sum of the pixels in a given region
|
|
19
|
+
of an image will be preserved almost exactly under all shift and rotate operations. As
|
|
20
|
+
one would expect under "zoom" operations, pixel sums change in proportion to the product
|
|
21
|
+
of the zoom factors being applied along the two image axes. SciPy functions do not have
|
|
22
|
+
these properties, making them unreliable for many scientific purposes.
|
|
23
|
+
|
|
24
|
+
At the boundary, a pixel beyond the image edge is assumed to equal the nearest in-image
|
|
25
|
+
pixel (edge replication), so edge pixels retain their intensity rather than darkening
|
|
26
|
+
toward zero. Pixel sums are therefore preserved for content surrounded by the image; a
|
|
27
|
+
compact source whose own edge values are nonzero can have its integral grow slightly as
|
|
28
|
+
those edges replicate outward, so pad such a source with a zero border if exact integral
|
|
29
|
+
conservation is required.
|
|
30
|
+
|
|
31
|
+
All of the underlying algorithms are designed for numerical efficiency and should
|
|
32
|
+
generally operate quickly. Unnecessary loops are rigorously avoided.
|
|
33
|
+
|
|
34
|
+
- Most operations support boolean masks of invalid pixels. Wherever the mask is True, the
|
|
35
|
+
array value is excluded from scientific analysis. Masked pixels remain masked under
|
|
36
|
+
spatial transforms and do not participate in "filter" and "stack" operations.
|
|
37
|
+
|
|
38
|
+
- Most operations can be performed on an arbitrarily-shaped array of images all at once.
|
|
39
|
+
The last two axes of the array are assumed to be the spatial axes of the image.
|
|
40
|
+
|
|
41
|
+
- The operations are safe to call concurrently from multiple threads as long as each call
|
|
42
|
+
works on its own arrays: every function computes on the inputs it is given, shares no
|
|
43
|
+
mutable per-call state, and NumPy releases the GIL for the heavy array work. A few
|
|
44
|
+
module-level settings (the shortcut optimizations, the working-memory limit used to tile
|
|
45
|
+
large arrays, and some internal diagnostic counters) are process-global; they are not
|
|
46
|
+
meant to be changed from several threads at once. For heavy parallel workloads, prefer
|
|
47
|
+
multiple processes, the usual approach for NumPy/SciPy code.
|
|
48
|
+
|
|
49
|
+
Important note: There are many places in this library where one can specify a fractional
|
|
50
|
+
location within the pixel grid of an image. Throughout, we follow the convention that
|
|
51
|
+
integer coordinates refer to the corners between pixels and half-integers refer to pixel
|
|
52
|
+
centers. In other words, (0,0) is the lower corner of the image array and (0.5,0.5) is the
|
|
53
|
+
center of the first pixel.
|
|
54
|
+
"""
|
|
55
|
+
|
|
56
|
+
import functools
|
|
57
|
+
|
|
58
|
+
import numpy as np
|
|
59
|
+
|
|
60
|
+
__all__ = [
|
|
61
|
+
# Spatial transforms
|
|
62
|
+
'ishift',
|
|
63
|
+
'resample',
|
|
64
|
+
'reshape',
|
|
65
|
+
'rotate',
|
|
66
|
+
'shift',
|
|
67
|
+
'unzoom',
|
|
68
|
+
'zoom',
|
|
69
|
+
# Stack operations and spatial filters
|
|
70
|
+
'circle',
|
|
71
|
+
'gaussian_filter',
|
|
72
|
+
'maximum',
|
|
73
|
+
'maximum_filter',
|
|
74
|
+
'mean',
|
|
75
|
+
'mean_filter',
|
|
76
|
+
'median',
|
|
77
|
+
'median_filter',
|
|
78
|
+
'minimum',
|
|
79
|
+
'minimum_filter',
|
|
80
|
+
'stdev',
|
|
81
|
+
'stdev_filter',
|
|
82
|
+
'variance',
|
|
83
|
+
'variance_filter',
|
|
84
|
+
# Modeling
|
|
85
|
+
'ArrayModel',
|
|
86
|
+
'Fitting',
|
|
87
|
+
'Gaussian',
|
|
88
|
+
'ImageModel',
|
|
89
|
+
'SmearedModel',
|
|
90
|
+
'Stretch',
|
|
91
|
+
'SummedModel',
|
|
92
|
+
# Other operations
|
|
93
|
+
'autocorrelate',
|
|
94
|
+
'correlate',
|
|
95
|
+
'fft',
|
|
96
|
+
'fft_power',
|
|
97
|
+
'ialign',
|
|
98
|
+
'ifft',
|
|
99
|
+
'outliers',
|
|
100
|
+
'patch',
|
|
101
|
+
]
|
|
102
|
+
|
|
103
|
+
# Spatial transforms
|
|
104
|
+
# Stack operations and spatial filters
|
|
105
|
+
from psiops.circle import circle
|
|
106
|
+
from psiops.gaussian_filter import gaussian_filter
|
|
107
|
+
from psiops.ishift import ishift
|
|
108
|
+
from psiops.maximum import maximum, maximum_filter
|
|
109
|
+
from psiops.mean import mean, mean_filter
|
|
110
|
+
from psiops.median import median, median_filter
|
|
111
|
+
from psiops.minimum import minimum, minimum_filter
|
|
112
|
+
from psiops.resample import resample
|
|
113
|
+
from psiops.reshape import reshape
|
|
114
|
+
from psiops.rotate import rotate
|
|
115
|
+
from psiops.shift import shift
|
|
116
|
+
from psiops.stdev import stdev, stdev_filter
|
|
117
|
+
from psiops.unzoom import unzoom
|
|
118
|
+
from psiops.variance import variance, variance_filter
|
|
119
|
+
from psiops.zoom import zoom
|
|
120
|
+
|
|
121
|
+
# Modeling
|
|
122
|
+
from psiops.fitting import Fitting
|
|
123
|
+
from psiops.imagemodel import ImageModel
|
|
124
|
+
from psiops.imagemodel.arraymodel import ArrayModel
|
|
125
|
+
from psiops.imagemodel.gaussian import Gaussian
|
|
126
|
+
from psiops.imagemodel.smearedmodel import SmearedModel
|
|
127
|
+
from psiops.imagemodel.summedmodel import SummedModel
|
|
128
|
+
from psiops.stretch import Stretch
|
|
129
|
+
|
|
130
|
+
# Other operations
|
|
131
|
+
from psiops.fft import fft, ifft, fft_power, correlate, autocorrelate, ialign
|
|
132
|
+
from psiops.outliers import outliers
|
|
133
|
+
from psiops.patch import patch
|
|
134
|
+
|
|
135
|
+
##########################################################################################
|
|
136
|
+
# Divide-by-zero warning suppression
|
|
137
|
+
##########################################################################################
|
|
138
|
+
|
|
139
|
+
# Wherever fully masked or zero-weight pixels appear, this library intentionally produces
|
|
140
|
+
# 0/0 or x/0, yielding NaN or inf as documented. NumPy reports these as a "divide by zero
|
|
141
|
+
# encountered" or "invalid value encountered in divide" RuntimeWarning. We suppress them
|
|
142
|
+
# at the NumPy error-state source -- which holds even when warnings are turned into errors
|
|
143
|
+
# (e.g. `-W error` or pytest's `filterwarnings = ["error"]`) -- by wrapping each public
|
|
144
|
+
# entry point in `np.errstate(...)`, rather than scattering the same guard at every
|
|
145
|
+
# division. Only `divide`/`invalid` are affected; all other RuntimeWarnings, and the
|
|
146
|
+
# user's own code, are left untouched.
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
def _suppress_divide_warnings(func):
|
|
150
|
+
@functools.wraps(func)
|
|
151
|
+
def wrapper(*args, **kwargs):
|
|
152
|
+
with np.errstate(divide='ignore', invalid='ignore'):
|
|
153
|
+
return func(*args, **kwargs)
|
|
154
|
+
return wrapper
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
_globals = globals()
|
|
158
|
+
for _name in __all__:
|
|
159
|
+
_obj = _globals[_name]
|
|
160
|
+
if not isinstance(_obj, type): # a module-level function
|
|
161
|
+
_globals[_name] = _suppress_divide_warnings(_obj)
|
|
162
|
+
|
|
163
|
+
for _cls, _methods in ( # the model/fit classes that divide
|
|
164
|
+
(ArrayModel, ('transform',)),
|
|
165
|
+
(Gaussian, ('transform',)),
|
|
166
|
+
(SmearedModel, ('transform',)),
|
|
167
|
+
(SummedModel, ('transform',)),
|
|
168
|
+
(Stretch, ('set_image', 'set_target', 'fit')),
|
|
169
|
+
(Fitting, ('set_target', 'fit')),
|
|
170
|
+
):
|
|
171
|
+
for _method in _methods:
|
|
172
|
+
setattr(_cls, _method, _suppress_divide_warnings(getattr(_cls, _method)))
|
|
173
|
+
|
|
174
|
+
##########################################################################################
|
psiops/__init__.pyi
ADDED
|
@@ -0,0 +1,494 @@
|
|
|
1
|
+
##########################################################################################
|
|
2
|
+
# psiops/__init__.pyi
|
|
3
|
+
#
|
|
4
|
+
# Type stub for the public API of the psiops package, i.e. the names exported from
|
|
5
|
+
# psiops/__init__.py. Signatures mirror the implementation modules.
|
|
6
|
+
##########################################################################################
|
|
7
|
+
|
|
8
|
+
from collections.abc import Sequence
|
|
9
|
+
|
|
10
|
+
import numpy as np
|
|
11
|
+
import numpy.typing as npt
|
|
12
|
+
|
|
13
|
+
##########################################################################################
|
|
14
|
+
# Spatial transforms
|
|
15
|
+
##########################################################################################
|
|
16
|
+
|
|
17
|
+
def ishift(
|
|
18
|
+
image: np.ndarray,
|
|
19
|
+
offset: int | tuple[int, int],
|
|
20
|
+
mask: np.ndarray | None = ...,
|
|
21
|
+
*,
|
|
22
|
+
maskval: float | None = ...,
|
|
23
|
+
weights: np.ndarray | None = ...,
|
|
24
|
+
nans: bool = ...,
|
|
25
|
+
mode: str = ...,
|
|
26
|
+
cval: float | None = ...,
|
|
27
|
+
returns: str | None = ...,
|
|
28
|
+
) -> np.ndarray | list[np.ndarray]: ...
|
|
29
|
+
def resample(
|
|
30
|
+
image: np.ndarray,
|
|
31
|
+
zoom_: float | tuple[float, float],
|
|
32
|
+
mask: np.ndarray | None = ...,
|
|
33
|
+
*,
|
|
34
|
+
maskval: float | None = ...,
|
|
35
|
+
weights: np.ndarray | None = ...,
|
|
36
|
+
nans: bool = ...,
|
|
37
|
+
origin: tuple[float, float] | None = ...,
|
|
38
|
+
center: tuple[float, float] | None = ...,
|
|
39
|
+
shape: tuple[int, int] | None = ...,
|
|
40
|
+
minweight: float = ...,
|
|
41
|
+
returns: str | None = ...,
|
|
42
|
+
) -> np.ndarray | list[np.ndarray | tuple[float, float]]: ...
|
|
43
|
+
def reshape(
|
|
44
|
+
image: np.ndarray,
|
|
45
|
+
shape: int | tuple[int, int],
|
|
46
|
+
mask: np.ndarray | None = ...,
|
|
47
|
+
*,
|
|
48
|
+
maskval: float | None = ...,
|
|
49
|
+
weights: np.ndarray | None = ...,
|
|
50
|
+
nans: bool = ...,
|
|
51
|
+
returns: str | None = ...,
|
|
52
|
+
) -> np.ndarray | list[np.ndarray]: ...
|
|
53
|
+
def rotate(
|
|
54
|
+
image: np.ndarray,
|
|
55
|
+
angle: float,
|
|
56
|
+
mask: np.ndarray | None = ...,
|
|
57
|
+
*,
|
|
58
|
+
maskval: float | None = ...,
|
|
59
|
+
weights: np.ndarray | None = ...,
|
|
60
|
+
nans: bool = ...,
|
|
61
|
+
origin: tuple[float, float] | None = ...,
|
|
62
|
+
center: tuple[float, float] | None = ...,
|
|
63
|
+
shape: tuple[int, int] | None = ...,
|
|
64
|
+
minweight: float = ...,
|
|
65
|
+
eps: float = ...,
|
|
66
|
+
returns: str | None = ...,
|
|
67
|
+
_debug: dict | None = ...,
|
|
68
|
+
) -> np.ndarray | list[np.ndarray | tuple[float, float]]: ...
|
|
69
|
+
def shift(
|
|
70
|
+
image: np.ndarray,
|
|
71
|
+
offset: float | tuple[float, float],
|
|
72
|
+
mask: np.ndarray | None = ...,
|
|
73
|
+
*,
|
|
74
|
+
maskval: float | None = ...,
|
|
75
|
+
weights: np.ndarray | None = ...,
|
|
76
|
+
nans: bool = ...,
|
|
77
|
+
mode: str = ...,
|
|
78
|
+
cval: float | None = ...,
|
|
79
|
+
returns: str | None = ...,
|
|
80
|
+
) -> np.ndarray | list[np.ndarray]: ...
|
|
81
|
+
def unzoom(
|
|
82
|
+
image: np.ndarray,
|
|
83
|
+
unzoom_: int | tuple[int, int],
|
|
84
|
+
mask: np.ndarray | None = ...,
|
|
85
|
+
*,
|
|
86
|
+
maskval: float | None = ...,
|
|
87
|
+
weights: np.ndarray | None = ...,
|
|
88
|
+
nans: bool = ...,
|
|
89
|
+
returns: str | None = ...,
|
|
90
|
+
) -> np.ndarray | list[np.ndarray]: ...
|
|
91
|
+
def zoom(
|
|
92
|
+
image: np.ndarray,
|
|
93
|
+
zoom_: int | tuple[int, int],
|
|
94
|
+
mask: np.ndarray | None = ...,
|
|
95
|
+
*,
|
|
96
|
+
maskval: float | None = ...,
|
|
97
|
+
weights: np.ndarray | None = ...,
|
|
98
|
+
nans: bool = ...,
|
|
99
|
+
returns: str | None = ...,
|
|
100
|
+
) -> np.ndarray | list[np.ndarray]: ...
|
|
101
|
+
|
|
102
|
+
##########################################################################################
|
|
103
|
+
# Stack operations and spatial filters
|
|
104
|
+
##########################################################################################
|
|
105
|
+
|
|
106
|
+
def circle(radius: float) -> np.ndarray: ...
|
|
107
|
+
def gaussian_filter(
|
|
108
|
+
image: np.ndarray,
|
|
109
|
+
sigma: float | tuple[float, float],
|
|
110
|
+
mask: np.ndarray | None = ...,
|
|
111
|
+
*,
|
|
112
|
+
maskval: float | None = ...,
|
|
113
|
+
weights: np.ndarray | None = ...,
|
|
114
|
+
nans: bool = ...,
|
|
115
|
+
mode: str = ...,
|
|
116
|
+
cval: float = ...,
|
|
117
|
+
order: int | tuple[int, int] = ...,
|
|
118
|
+
returns: str | None = ...,
|
|
119
|
+
) -> np.ndarray | list[np.ndarray]: ...
|
|
120
|
+
def maximum(
|
|
121
|
+
image: np.ndarray,
|
|
122
|
+
mask: np.ndarray | None = ...,
|
|
123
|
+
*,
|
|
124
|
+
maskval: float | None = ...,
|
|
125
|
+
weights: np.ndarray | None = ...,
|
|
126
|
+
nans: bool = ...,
|
|
127
|
+
axis: int | tuple[int, ...] | None = ...,
|
|
128
|
+
keepdims: bool = ...,
|
|
129
|
+
returns: str | None = ...,
|
|
130
|
+
) -> np.ndarray | list[np.ndarray]: ...
|
|
131
|
+
def maximum_filter(
|
|
132
|
+
image: np.ndarray,
|
|
133
|
+
footprint: npt.ArrayLike | int | tuple[int, int],
|
|
134
|
+
*,
|
|
135
|
+
mask: np.ndarray | None = ...,
|
|
136
|
+
maskval: float | None = ...,
|
|
137
|
+
weights: np.ndarray | None = ...,
|
|
138
|
+
nans: bool = ...,
|
|
139
|
+
returns: str | None = ...,
|
|
140
|
+
) -> np.ndarray | list[np.ndarray]: ...
|
|
141
|
+
def mean(
|
|
142
|
+
image: np.ndarray,
|
|
143
|
+
mask: np.ndarray | None = ...,
|
|
144
|
+
*,
|
|
145
|
+
maskval: float | None = ...,
|
|
146
|
+
weights: np.ndarray | None = ...,
|
|
147
|
+
nans: bool = ...,
|
|
148
|
+
axis: int | tuple[int, ...] | None = ...,
|
|
149
|
+
keepdims: bool = ...,
|
|
150
|
+
factors: npt.ArrayLike | None = ...,
|
|
151
|
+
returns: str | None = ...,
|
|
152
|
+
) -> np.ndarray | list[np.ndarray]: ...
|
|
153
|
+
def mean_filter(
|
|
154
|
+
image: np.ndarray,
|
|
155
|
+
footprint: npt.ArrayLike | int | tuple[int, int],
|
|
156
|
+
*,
|
|
157
|
+
mask: np.ndarray | None = ...,
|
|
158
|
+
maskval: float | None = ...,
|
|
159
|
+
weights: np.ndarray | None = ...,
|
|
160
|
+
nans: bool = ...,
|
|
161
|
+
returns: str | None = ...,
|
|
162
|
+
) -> np.ndarray | list[np.ndarray]: ...
|
|
163
|
+
def median(
|
|
164
|
+
image: np.ndarray,
|
|
165
|
+
mask: np.ndarray | None = ...,
|
|
166
|
+
*,
|
|
167
|
+
maskval: float | None = ...,
|
|
168
|
+
weights: np.ndarray | None = ...,
|
|
169
|
+
nans: bool = ...,
|
|
170
|
+
axis: int | tuple[int, ...] | None = ...,
|
|
171
|
+
keepdims: bool = ...,
|
|
172
|
+
factors: npt.ArrayLike | None = ...,
|
|
173
|
+
omit: int = ...,
|
|
174
|
+
returns: str | None = ...,
|
|
175
|
+
) -> np.ndarray | list[np.ndarray]: ...
|
|
176
|
+
def median_filter(
|
|
177
|
+
image: np.ndarray,
|
|
178
|
+
footprint: npt.ArrayLike | int | tuple[int, int],
|
|
179
|
+
*,
|
|
180
|
+
mask: np.ndarray | None = ...,
|
|
181
|
+
maskval: float | None = ...,
|
|
182
|
+
weights: np.ndarray | None = ...,
|
|
183
|
+
nans: bool = ...,
|
|
184
|
+
omit: int = ...,
|
|
185
|
+
returns: str | None = ...,
|
|
186
|
+
) -> np.ndarray | list[np.ndarray]: ...
|
|
187
|
+
def minimum(
|
|
188
|
+
image: np.ndarray,
|
|
189
|
+
mask: np.ndarray | None = ...,
|
|
190
|
+
*,
|
|
191
|
+
maskval: float | None = ...,
|
|
192
|
+
weights: np.ndarray | None = ...,
|
|
193
|
+
nans: bool = ...,
|
|
194
|
+
axis: int | tuple[int, ...] | None = ...,
|
|
195
|
+
keepdims: bool = ...,
|
|
196
|
+
returns: str | None = ...,
|
|
197
|
+
) -> np.ndarray | list[np.ndarray]: ...
|
|
198
|
+
def minimum_filter(
|
|
199
|
+
image: np.ndarray,
|
|
200
|
+
footprint: npt.ArrayLike | int | tuple[int, int],
|
|
201
|
+
*,
|
|
202
|
+
mask: np.ndarray | None = ...,
|
|
203
|
+
maskval: float | None = ...,
|
|
204
|
+
weights: np.ndarray | None = ...,
|
|
205
|
+
nans: bool = ...,
|
|
206
|
+
returns: str | None = ...,
|
|
207
|
+
) -> np.ndarray | list[np.ndarray]: ...
|
|
208
|
+
def stdev(
|
|
209
|
+
image: np.ndarray,
|
|
210
|
+
mask: np.ndarray | None = ...,
|
|
211
|
+
*,
|
|
212
|
+
maskval: float | None = ...,
|
|
213
|
+
weights: np.ndarray | None = ...,
|
|
214
|
+
nans: bool = ...,
|
|
215
|
+
axis: int | tuple[int, ...] | None = ...,
|
|
216
|
+
keepdims: bool = ...,
|
|
217
|
+
factors: npt.ArrayLike | None = ...,
|
|
218
|
+
stdtype: str = ...,
|
|
219
|
+
returns: str | None = ...,
|
|
220
|
+
) -> np.ndarray | list[np.ndarray]: ...
|
|
221
|
+
def stdev_filter(
|
|
222
|
+
image: np.ndarray,
|
|
223
|
+
footprint: npt.ArrayLike | int | tuple[int, int],
|
|
224
|
+
*,
|
|
225
|
+
mask: np.ndarray | None = ...,
|
|
226
|
+
maskval: float | None = ...,
|
|
227
|
+
weights: np.ndarray | None = ...,
|
|
228
|
+
nans: bool = ...,
|
|
229
|
+
stdtype: str = ...,
|
|
230
|
+
returns: str | None = ...,
|
|
231
|
+
) -> np.ndarray | list[np.ndarray]: ...
|
|
232
|
+
def variance(
|
|
233
|
+
image: np.ndarray,
|
|
234
|
+
mask: np.ndarray | None = ...,
|
|
235
|
+
*,
|
|
236
|
+
maskval: float | None = ...,
|
|
237
|
+
weights: np.ndarray | None = ...,
|
|
238
|
+
nans: bool = ...,
|
|
239
|
+
axis: int | tuple[int, ...] | None = ...,
|
|
240
|
+
keepdims: bool = ...,
|
|
241
|
+
factors: npt.ArrayLike | None = ...,
|
|
242
|
+
vartype: str = ...,
|
|
243
|
+
returns: str | None = ...,
|
|
244
|
+
) -> np.ndarray | list[np.ndarray]: ...
|
|
245
|
+
def variance_filter(
|
|
246
|
+
image: np.ndarray,
|
|
247
|
+
footprint: npt.ArrayLike | int | tuple[int, int],
|
|
248
|
+
*,
|
|
249
|
+
mask: np.ndarray | None = ...,
|
|
250
|
+
maskval: float | None = ...,
|
|
251
|
+
weights: np.ndarray | None = ...,
|
|
252
|
+
nans: bool = ...,
|
|
253
|
+
vartype: str = ...,
|
|
254
|
+
returns: str | None = ...,
|
|
255
|
+
) -> np.ndarray | list[np.ndarray]: ...
|
|
256
|
+
|
|
257
|
+
##########################################################################################
|
|
258
|
+
# Modeling
|
|
259
|
+
##########################################################################################
|
|
260
|
+
|
|
261
|
+
class ImageModel:
|
|
262
|
+
def transform(
|
|
263
|
+
self,
|
|
264
|
+
shape: tuple[int, int],
|
|
265
|
+
center: tuple[float, float],
|
|
266
|
+
expand: float = ...,
|
|
267
|
+
rotate: float = ...,
|
|
268
|
+
) -> np.ndarray: ...
|
|
269
|
+
|
|
270
|
+
class ArrayModel(ImageModel):
|
|
271
|
+
def __init__(
|
|
272
|
+
self,
|
|
273
|
+
array: np.ndarray,
|
|
274
|
+
origin: tuple[float, float] | None = ...,
|
|
275
|
+
outside: float = ...,
|
|
276
|
+
) -> None: ...
|
|
277
|
+
def transform(
|
|
278
|
+
self,
|
|
279
|
+
shape: tuple[int, int],
|
|
280
|
+
center: tuple[float, float],
|
|
281
|
+
expand: float = ...,
|
|
282
|
+
rotate: float = ...,
|
|
283
|
+
) -> np.ndarray: ...
|
|
284
|
+
|
|
285
|
+
class Gaussian(ImageModel):
|
|
286
|
+
def __init__(self, sigma: float = ..., integral: float = ...) -> None: ...
|
|
287
|
+
def transform(
|
|
288
|
+
self,
|
|
289
|
+
shape: tuple[int, int],
|
|
290
|
+
center: tuple[float, float],
|
|
291
|
+
expand: float = ...,
|
|
292
|
+
rotate: float = ...,
|
|
293
|
+
) -> np.ndarray: ...
|
|
294
|
+
|
|
295
|
+
class SmearedModel(ImageModel):
|
|
296
|
+
def __init__(
|
|
297
|
+
self,
|
|
298
|
+
model: ImageModel,
|
|
299
|
+
smear: npt.ArrayLike,
|
|
300
|
+
maxstep: float = ...,
|
|
301
|
+
) -> None: ...
|
|
302
|
+
def transform(
|
|
303
|
+
self,
|
|
304
|
+
shape: tuple[int, int],
|
|
305
|
+
center: tuple[float, float],
|
|
306
|
+
expand: float = ...,
|
|
307
|
+
rotate: float = ...,
|
|
308
|
+
) -> np.ndarray: ...
|
|
309
|
+
|
|
310
|
+
class SummedModel(ImageModel):
|
|
311
|
+
def __init__(
|
|
312
|
+
self,
|
|
313
|
+
models: Sequence[ImageModel],
|
|
314
|
+
factors: npt.ArrayLike,
|
|
315
|
+
) -> None: ...
|
|
316
|
+
def transform(
|
|
317
|
+
self,
|
|
318
|
+
shape: tuple[int, int],
|
|
319
|
+
center: tuple[float, float],
|
|
320
|
+
expand: float = ...,
|
|
321
|
+
rotate: float = ...,
|
|
322
|
+
) -> np.ndarray: ...
|
|
323
|
+
|
|
324
|
+
class Stretch:
|
|
325
|
+
orders: tuple[int, ...]
|
|
326
|
+
ranks: tuple[int, ...]
|
|
327
|
+
ncoeffs: int
|
|
328
|
+
coeffs: np.ndarray | None
|
|
329
|
+
image: np.ndarray | None
|
|
330
|
+
image_mask: np.ndarray | None
|
|
331
|
+
shape: tuple[int, int] | None
|
|
332
|
+
target: np.ndarray | None
|
|
333
|
+
target_mask: np.ndarray | None
|
|
334
|
+
target_weights: np.ndarray | None
|
|
335
|
+
mask: np.ndarray | None
|
|
336
|
+
dof: int | None
|
|
337
|
+
weight_sum: float | None
|
|
338
|
+
chi_sq: float | None
|
|
339
|
+
rms: float | None
|
|
340
|
+
covar: np.ndarray | None
|
|
341
|
+
def __init__(
|
|
342
|
+
self,
|
|
343
|
+
orders: Sequence[int],
|
|
344
|
+
coeffs: npt.ArrayLike | None = ...,
|
|
345
|
+
*,
|
|
346
|
+
image: np.ndarray | None = ...,
|
|
347
|
+
mask: np.ndarray | None = ...,
|
|
348
|
+
maskval: float | None = ...,
|
|
349
|
+
weights: np.ndarray | None = ...,
|
|
350
|
+
nans: bool = ...,
|
|
351
|
+
) -> None: ...
|
|
352
|
+
def set_coeffs(self, coeffs: npt.ArrayLike) -> None: ...
|
|
353
|
+
def set_image(
|
|
354
|
+
self,
|
|
355
|
+
image: np.ndarray,
|
|
356
|
+
mask: np.ndarray | None = ...,
|
|
357
|
+
maskval: float | None = ...,
|
|
358
|
+
nans: bool = ...,
|
|
359
|
+
) -> None: ...
|
|
360
|
+
def set_target(
|
|
361
|
+
self,
|
|
362
|
+
target: np.ndarray,
|
|
363
|
+
*,
|
|
364
|
+
mask: np.ndarray | None = ...,
|
|
365
|
+
maskval: float | None = ...,
|
|
366
|
+
weights: np.ndarray | None = ...,
|
|
367
|
+
nans: bool = ...,
|
|
368
|
+
) -> None: ...
|
|
369
|
+
def fit(self) -> None: ...
|
|
370
|
+
@property
|
|
371
|
+
def model(self) -> np.ndarray: ...
|
|
372
|
+
@property
|
|
373
|
+
def background(self) -> np.ndarray: ...
|
|
374
|
+
@property
|
|
375
|
+
def scaling(self) -> np.ndarray: ...
|
|
376
|
+
@property
|
|
377
|
+
def residuals(self) -> np.ndarray: ...
|
|
378
|
+
@property
|
|
379
|
+
def residuals_1d(self) -> np.ndarray: ...
|
|
380
|
+
@property
|
|
381
|
+
def m_sigma(self) -> np.ndarray: ...
|
|
382
|
+
@property
|
|
383
|
+
def b_sigma(self) -> np.ndarray: ...
|
|
384
|
+
@property
|
|
385
|
+
def s_sigma(self) -> np.ndarray: ...
|
|
386
|
+
|
|
387
|
+
class Fitting:
|
|
388
|
+
imagemodel: ImageModel
|
|
389
|
+
stretch: Stretch
|
|
390
|
+
target: np.ndarray
|
|
391
|
+
mask: np.ndarray | None
|
|
392
|
+
weights: np.ndarray | None
|
|
393
|
+
corner: tuple[int, int]
|
|
394
|
+
shape: tuple[int, int]
|
|
395
|
+
params: np.ndarray
|
|
396
|
+
transformed: np.ndarray
|
|
397
|
+
x: float
|
|
398
|
+
y: float
|
|
399
|
+
zoom: float
|
|
400
|
+
rotate: float
|
|
401
|
+
guesses: np.ndarray
|
|
402
|
+
flags: np.ndarray
|
|
403
|
+
limits: np.ndarray
|
|
404
|
+
nparams: int
|
|
405
|
+
lsq_dict: dict
|
|
406
|
+
dof: int
|
|
407
|
+
weight_sum: float
|
|
408
|
+
chi_sq: float
|
|
409
|
+
rms: float
|
|
410
|
+
covar: np.ndarray
|
|
411
|
+
dx: float
|
|
412
|
+
dy: float
|
|
413
|
+
corr: float
|
|
414
|
+
def __init__(self, model: ImageModel, stretch: Stretch) -> None: ...
|
|
415
|
+
def set_target(
|
|
416
|
+
self,
|
|
417
|
+
target: np.ndarray,
|
|
418
|
+
*,
|
|
419
|
+
mask: np.ndarray | None = ...,
|
|
420
|
+
maskval: float | None = ...,
|
|
421
|
+
weights: np.ndarray | None = ...,
|
|
422
|
+
nans: bool = ...,
|
|
423
|
+
corner: tuple[int, int] = ...,
|
|
424
|
+
shape: tuple[int, int] | None = ...,
|
|
425
|
+
) -> None: ...
|
|
426
|
+
def remask(self, mask: np.ndarray) -> None: ...
|
|
427
|
+
def fit(
|
|
428
|
+
self,
|
|
429
|
+
guesses: Sequence[float | Sequence[float]],
|
|
430
|
+
flags: Sequence[bool] = ...,
|
|
431
|
+
limits: Sequence[float] = ...,
|
|
432
|
+
lsq_dict: dict | None = ...,
|
|
433
|
+
) -> None: ...
|
|
434
|
+
@property
|
|
435
|
+
def model(self) -> np.ndarray: ...
|
|
436
|
+
@property
|
|
437
|
+
def background(self) -> np.ndarray: ...
|
|
438
|
+
@property
|
|
439
|
+
def scaling(self) -> np.ndarray: ...
|
|
440
|
+
@property
|
|
441
|
+
def residuals(self) -> np.ndarray: ...
|
|
442
|
+
@property
|
|
443
|
+
def median_abs_deviation(self) -> float: ...
|
|
444
|
+
@property
|
|
445
|
+
def m_sigma(self) -> np.ndarray: ...
|
|
446
|
+
@property
|
|
447
|
+
def b_sigma(self) -> np.ndarray: ...
|
|
448
|
+
@property
|
|
449
|
+
def s_sigma(self) -> np.ndarray: ...
|
|
450
|
+
|
|
451
|
+
##########################################################################################
|
|
452
|
+
# Other operations
|
|
453
|
+
##########################################################################################
|
|
454
|
+
|
|
455
|
+
def fft(image: np.ndarray, *, retile: bool = ..., real: bool = ...) -> np.ndarray: ...
|
|
456
|
+
def ifft(image: np.ndarray, *, retile: bool = ..., real: bool = ...) -> np.ndarray: ...
|
|
457
|
+
def fft_power(image: np.ndarray, retile: bool = ...) -> np.ndarray: ...
|
|
458
|
+
def correlate(
|
|
459
|
+
image: np.ndarray,
|
|
460
|
+
reference: np.ndarray,
|
|
461
|
+
*,
|
|
462
|
+
normalize: bool = ...,
|
|
463
|
+
retile: bool = ...,
|
|
464
|
+
) -> np.ndarray: ...
|
|
465
|
+
def autocorrelate(image: np.ndarray, retile: bool = ...) -> np.ndarray: ...
|
|
466
|
+
def ialign(
|
|
467
|
+
image: np.ndarray,
|
|
468
|
+
reference: np.ndarray,
|
|
469
|
+
sigma: float,
|
|
470
|
+
) -> tuple[int, int]: ...
|
|
471
|
+
def outliers(
|
|
472
|
+
image: np.ndarray,
|
|
473
|
+
footprint: float = ...,
|
|
474
|
+
*,
|
|
475
|
+
cutoff: float = ...,
|
|
476
|
+
quantile: float = ...,
|
|
477
|
+
axis: int | tuple[int, ...] | None = ...,
|
|
478
|
+
mask: np.ndarray | None = ...,
|
|
479
|
+
maskval: float | None = ...,
|
|
480
|
+
weights: np.ndarray | None = ...,
|
|
481
|
+
nans: bool = ...,
|
|
482
|
+
) -> np.ndarray: ...
|
|
483
|
+
def patch(
|
|
484
|
+
image: np.ndarray,
|
|
485
|
+
mask: np.ndarray | None = ...,
|
|
486
|
+
*,
|
|
487
|
+
maskval: float | None = ...,
|
|
488
|
+
weights: np.ndarray | None = ...,
|
|
489
|
+
nans: bool = ...,
|
|
490
|
+
size: float = ...,
|
|
491
|
+
returns: str = ...,
|
|
492
|
+
) -> np.ndarray | list[np.ndarray]: ...
|
|
493
|
+
|
|
494
|
+
##########################################################################################
|