microeye 2.3.2__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.
Files changed (190) hide show
  1. microEye/__init__.py +47 -0
  2. microEye/_version.py +2 -0
  3. microEye/analysis/__init__.py +1 -0
  4. microEye/analysis/checklist_dialog.py +143 -0
  5. microEye/analysis/cmosMaps.py +228 -0
  6. microEye/analysis/filters/__init__.py +9 -0
  7. microEye/analysis/filters/base.py +21 -0
  8. microEye/analysis/filters/spatial.py +338 -0
  9. microEye/analysis/filters/temporal.py +76 -0
  10. microEye/analysis/fitting/__init__.py +0 -0
  11. microEye/analysis/fitting/fit.py +680 -0
  12. microEye/analysis/fitting/nena.py +375 -0
  13. microEye/analysis/fitting/phasor_fit.py +90 -0
  14. microEye/analysis/fitting/processing.py +317 -0
  15. microEye/analysis/fitting/psf/__init__.py +6 -0
  16. microEye/analysis/fitting/psf/extract.py +1129 -0
  17. microEye/analysis/fitting/psf/rubost_mean.py +150 -0
  18. microEye/analysis/fitting/psf/spline.py +167 -0
  19. microEye/analysis/fitting/psf/stats/__init__.py +12 -0
  20. microEye/analysis/fitting/psf/stats/core.py +295 -0
  21. microEye/analysis/fitting/psf/stats/curve_fit.py +708 -0
  22. microEye/analysis/fitting/psf/stats/io.py +104 -0
  23. microEye/analysis/fitting/psf/stats/slope_fit.py +171 -0
  24. microEye/analysis/fitting/psf/temp.py +147 -0
  25. microEye/analysis/fitting/psf/test.py +47 -0
  26. microEye/analysis/fitting/pyfit3Dcspline/CPU/CPUfunctions.py +657 -0
  27. microEye/analysis/fitting/pyfit3Dcspline/CPU/CPUmleFit_LM.py +1336 -0
  28. microEye/analysis/fitting/pyfit3Dcspline/CPU/CPUsplineLib.py +270 -0
  29. microEye/analysis/fitting/pyfit3Dcspline/CPU/__init__.py +1 -0
  30. microEye/analysis/fitting/pyfit3Dcspline/GPU/GPUfunctions.py +609 -0
  31. microEye/analysis/fitting/pyfit3Dcspline/GPU/GPUmleFit_LM_EMCCD.py +1396 -0
  32. microEye/analysis/fitting/pyfit3Dcspline/GPU/GPUmleFit_LM_sCMOS.py +1426 -0
  33. microEye/analysis/fitting/pyfit3Dcspline/GPU/GPUsplineLib.py +231 -0
  34. microEye/analysis/fitting/pyfit3Dcspline/GPU/__init__.py +2 -0
  35. microEye/analysis/fitting/pyfit3Dcspline/__init__.py +10 -0
  36. microEye/analysis/fitting/pyfit3Dcspline/constants.py +27 -0
  37. microEye/analysis/fitting/pyfit3Dcspline/mainfunctions.py +903 -0
  38. microEye/analysis/fitting/results.py +917 -0
  39. microEye/analysis/fitting/results_stats.py +251 -0
  40. microEye/analysis/fitting/tardis.py +209 -0
  41. microEye/analysis/multi_viewer.py +568 -0
  42. microEye/analysis/processing/__init__.py +1 -0
  43. microEye/analysis/processing/frc.py +120 -0
  44. microEye/analysis/rendering/__init__.py +3 -0
  45. microEye/analysis/rendering/base.py +452 -0
  46. microEye/analysis/rendering/cloud.py +215 -0
  47. microEye/analysis/rendering/core.py +47 -0
  48. microEye/analysis/rendering/volumetric.py +198 -0
  49. microEye/analysis/tools/__init__.py +0 -0
  50. microEye/analysis/tools/kymograms.py +1079 -0
  51. microEye/analysis/tools/roi_selectors.py +556 -0
  52. microEye/analysis/utils/__init__.py +3 -0
  53. microEye/analysis/utils/coordinates.py +18 -0
  54. microEye/analysis/utils/images.py +68 -0
  55. microEye/analysis/utils/windows.py +19 -0
  56. microEye/analysis/viewer/__init__.py +3 -0
  57. microEye/analysis/viewer/image_options_widget.py +615 -0
  58. microEye/analysis/viewer/images.py +1225 -0
  59. microEye/analysis/viewer/layers_widget.py +415 -0
  60. microEye/analysis/viewer/localizations.py +1304 -0
  61. microEye/analysis/viewer/psf.py +1003 -0
  62. microEye/analysis/viewer/volume.py +456 -0
  63. microEye/hardware/__init__.py +3 -0
  64. microEye/hardware/cams/__init__.py +29 -0
  65. microEye/hardware/cams/camera_calibration.py +99 -0
  66. microEye/hardware/cams/camera_list.py +528 -0
  67. microEye/hardware/cams/camera_options.py +694 -0
  68. microEye/hardware/cams/camera_panel.py +941 -0
  69. microEye/hardware/cams/dummy/__init__.py +1 -0
  70. microEye/hardware/cams/dummy/dummy_panel.py +759 -0
  71. microEye/hardware/cams/jobs.py +497 -0
  72. microEye/hardware/cams/line_profiler.py +99 -0
  73. microEye/hardware/cams/linescan/IR_Cam.py +474 -0
  74. microEye/hardware/cams/linescan/__init__.py +1 -0
  75. microEye/hardware/cams/micam.py +524 -0
  76. microEye/hardware/cams/pco/__init__.py +58 -0
  77. microEye/hardware/cams/pco/enums.py +382 -0
  78. microEye/hardware/cams/pco/pco_cam.py +761 -0
  79. microEye/hardware/cams/pco/pco_panel.py +477 -0
  80. microEye/hardware/cams/shortcuts.py +312 -0
  81. microEye/hardware/cams/thorlabs/__init__.py +1 -0
  82. microEye/hardware/cams/thorlabs/thorlabs.py +1508 -0
  83. microEye/hardware/cams/thorlabs/thorlabs_panel.py +850 -0
  84. microEye/hardware/cams/ueye/__init__.py +1 -0
  85. microEye/hardware/cams/ueye/ueye_camera.py +1023 -0
  86. microEye/hardware/cams/ueye/ueye_panel.py +861 -0
  87. microEye/hardware/cams/vimba/__init__.py +1 -0
  88. microEye/hardware/cams/vimba/vimba_cam.py +1000 -0
  89. microEye/hardware/cams/vimba/vimba_panel.py +813 -0
  90. microEye/hardware/device.py +60 -0
  91. microEye/hardware/lasers/__init__.py +13 -0
  92. microEye/hardware/lasers/io_matchbox.py +791 -0
  93. microEye/hardware/lasers/io_params.py +85 -0
  94. microEye/hardware/lasers/io_single_laser.py +742 -0
  95. microEye/hardware/lasers/laser_relay.py +594 -0
  96. microEye/hardware/mieye/__init__.py +1 -0
  97. microEye/hardware/mieye/acquisition_manager.py +467 -0
  98. microEye/hardware/mieye/devices_manager.py +533 -0
  99. microEye/hardware/mieye/miEye.py +659 -0
  100. microEye/hardware/misc/__init__.py +0 -0
  101. microEye/hardware/misc/acquisition_view.py +71 -0
  102. microEye/hardware/misc/reglo.py +761 -0
  103. microEye/hardware/misc/temp.py +188 -0
  104. microEye/hardware/port_config.py +59 -0
  105. microEye/hardware/protocols/__init__.py +2 -0
  106. microEye/hardware/protocols/actions.py +402 -0
  107. microEye/hardware/protocols/actions_items.py +703 -0
  108. microEye/hardware/protocols/designer.py +244 -0
  109. microEye/hardware/protocols/scene_manager.py +191 -0
  110. microEye/hardware/protocols/serialization.py +97 -0
  111. microEye/hardware/pycromanager/__init__.py +16 -0
  112. microEye/hardware/pycromanager/core.py +1433 -0
  113. microEye/hardware/pycromanager/devices.py +461 -0
  114. microEye/hardware/pycromanager/enums.py +107 -0
  115. microEye/hardware/pycromanager/headless.py +153 -0
  116. microEye/hardware/pycromanager/utils.py +34 -0
  117. microEye/hardware/pycromanager/widgets/__init__.py +5 -0
  118. microEye/hardware/pycromanager/widgets/bridges.py +407 -0
  119. microEye/hardware/pycromanager/widgets/headless_manager.py +258 -0
  120. microEye/hardware/pycromanager/widgets/headless_options.py +224 -0
  121. microEye/hardware/pycromanager/widgets/pycro_panel.py +455 -0
  122. microEye/hardware/stages/__init__.py +18 -0
  123. microEye/hardware/stages/elliptec/__init__.py +5 -0
  124. microEye/hardware/stages/elliptec/baseDevice.py +314 -0
  125. microEye/hardware/stages/elliptec/device.py +384 -0
  126. microEye/hardware/stages/elliptec/deviceID.py +212 -0
  127. microEye/hardware/stages/elliptec/devicePort.py +379 -0
  128. microEye/hardware/stages/elliptec/deviceStatus.py +65 -0
  129. microEye/hardware/stages/elliptec/devicesView.py +706 -0
  130. microEye/hardware/stages/elliptec/ellDevices.py +134 -0
  131. microEye/hardware/stages/elliptec/messageUpdater.py +34 -0
  132. microEye/hardware/stages/elliptec/motorInfo.py +153 -0
  133. microEye/hardware/stages/elliptec/stage.py +62 -0
  134. microEye/hardware/stages/elliptec/test.py +139 -0
  135. microEye/hardware/stages/kinesis/__init__.py +1 -0
  136. microEye/hardware/stages/kinesis/kdc101/__init__.py +1 -0
  137. microEye/hardware/stages/kinesis/kdc101/enums.py +1002 -0
  138. microEye/hardware/stages/kinesis/kdc101/factory.py +171 -0
  139. microEye/hardware/stages/kinesis/kdc101/kdc101.py +718 -0
  140. microEye/hardware/stages/kinesis/kinesis.py +776 -0
  141. microEye/hardware/stages/piezo_concept.py +607 -0
  142. microEye/hardware/stages/stabilizer.py +785 -0
  143. microEye/hardware/stages/stage.py +89 -0
  144. microEye/hardware/widgets/__init__.py +10 -0
  145. microEye/hardware/widgets/controller.py +246 -0
  146. microEye/hardware/widgets/devices.py +133 -0
  147. microEye/hardware/widgets/focusWidget.py +264 -0
  148. microEye/hardware/widgets/qlist_slider.py +113 -0
  149. microEye/hardware/widgets/scan_acquisition.py +424 -0
  150. microEye/icons/1024.png +0 -0
  151. microEye/icons/128.png +0 -0
  152. microEye/icons/16.png +0 -0
  153. microEye/icons/24.png +0 -0
  154. microEye/icons/256.png +0 -0
  155. microEye/icons/32.png +0 -0
  156. microEye/icons/48.png +0 -0
  157. microEye/icons/512.png +0 -0
  158. microEye/icons/64.png +0 -0
  159. microEye/icons/__init__.py +0 -0
  160. microEye/icons/close.svg +88 -0
  161. microEye/icons/mieye.png +0 -0
  162. microEye/icons/min.svg +83 -0
  163. microEye/icons/viewer.png +0 -0
  164. microEye/launcher.py +42 -0
  165. microEye/qt.py +181 -0
  166. microEye/utils/__init__.py +2 -0
  167. microEye/utils/enum_encoder.py +10 -0
  168. microEye/utils/expandable_groupbox.py +93 -0
  169. microEye/utils/gui_helper.py +457 -0
  170. microEye/utils/hid/__init__.py +8 -0
  171. microEye/utils/hid/controller.py +153 -0
  172. microEye/utils/hid/device.py +63 -0
  173. microEye/utils/hid/enums.py +140 -0
  174. microEye/utils/hid/utils.py +58 -0
  175. microEye/utils/labelled_slider.py +134 -0
  176. microEye/utils/metadata.py +599 -0
  177. microEye/utils/metadata_tree.py +718 -0
  178. microEye/utils/micro_launcher.py +245 -0
  179. microEye/utils/parameter_tree.py +325 -0
  180. microEye/utils/pyscripting.py +444 -0
  181. microEye/utils/retry_exec.py +35 -0
  182. microEye/utils/start_gui.py +112 -0
  183. microEye/utils/thread_worker.py +115 -0
  184. microEye/utils/uImage.py +1512 -0
  185. microeye-2.3.2.dist-info/METADATA +401 -0
  186. microeye-2.3.2.dist-info/RECORD +190 -0
  187. microeye-2.3.2.dist-info/WHEEL +5 -0
  188. microeye-2.3.2.dist-info/entry_points.txt +2 -0
  189. microeye-2.3.2.dist-info/licenses/LICENSE +674 -0
  190. microeye-2.3.2.dist-info/top_level.txt +1 -0
@@ -0,0 +1,609 @@
1
+ import math
2
+
3
+ import numba as nb
4
+ import numpy as np
5
+ from numba import cuda
6
+
7
+
8
+ @cuda.jit(device=True)
9
+ def kernel_IntGauss1D(ii, x, sigma) -> float:
10
+ '''_summary_
11
+
12
+ Parameters
13
+ ----------
14
+ ii : int
15
+ ???
16
+ x : float
17
+ ???
18
+ sigma : float
19
+ sigma value of the PSF
20
+ '''
21
+ norm = 1.0 / (2.0*sigma*sigma)
22
+
23
+ return 0.5 * (
24
+ math.erf((ii-x+0.5) * math.sqrt(norm))
25
+ - math.erf((ii-x-0.5) * math.sqrt(norm)))
26
+
27
+
28
+ @cuda.jit(
29
+ nb.float32(nb.float32, nb.float32, nb.float32, nb.float32),
30
+ device=True)
31
+ def kernel_alpha(z, Ax, Bx, d):
32
+ '''compute coefficient for alpha
33
+
34
+ Parameters
35
+ ----------
36
+ z : float
37
+ ???
38
+ Ax : float
39
+ ???
40
+ Bx : float
41
+ ???
42
+ d : float
43
+ ???
44
+
45
+ Returns
46
+ -------
47
+ float
48
+ alpha value
49
+ '''
50
+
51
+ return 1.0 + math.pow(z/d, 2) + Ax*math.pow(z/d, 3) + Bx*math.pow(z/d, 4)
52
+
53
+
54
+ @cuda.jit(
55
+ nb.float32(nb.float32, nb.float32, nb.float32, nb.float32),
56
+ device=True)
57
+ def kernel_dalphadz(z, Ax, Bx, d) -> float:
58
+ '''compute first derivative for alpha in relation to z
59
+
60
+ Parameters
61
+ ----------
62
+ z : float
63
+ ???
64
+ Ax : float
65
+ ???
66
+ Bx : float
67
+ ???
68
+ d : float
69
+ ???
70
+
71
+ Returns
72
+ -------
73
+ float
74
+ first derivative for alpha value
75
+ '''
76
+
77
+ return (
78
+ 2.0 * z/(d*d) +
79
+ 3.0*Ax*math.pow(z, 2)/(d*d*d) +
80
+ 4.0*Bx*math.pow(z, 3)/math.pow(d, 4))
81
+
82
+
83
+ @cuda.jit(
84
+ nb.float32(nb.float32, nb.float32, nb.float32, nb.float32),
85
+ device=True)
86
+ def kernel_d2alphadz2(z, Ax, Bx, d):
87
+ '''compute second derivative for alpha in relation to z
88
+
89
+ Parameters
90
+ ----------
91
+ z : float
92
+ ???
93
+ Ax : float
94
+ ???
95
+ Bx : float
96
+ ???
97
+ d : float
98
+ ???
99
+
100
+ Returns
101
+ -------
102
+ float
103
+ second derivative for alpha value
104
+ '''
105
+
106
+ return (
107
+ 2.0/(d*d) +
108
+ 6.0*Ax*z/(d*d*d) +
109
+ 12.0*Bx*math.pow(z, 2)/math.pow(d, 4))
110
+
111
+
112
+ @cuda.jit(
113
+ nb.types.Tuple((nb.float32, nb.float32))(
114
+ nb.int32, nb.float32, nb.float32,
115
+ nb.float32, nb.float32, nb.boolean),
116
+ device=True)
117
+ def kernel_DerivativeIntGauss1D(ii, x, sigma, N, PSFy, calc_d2):
118
+ '''compute the derivative of the 1D gaussian
119
+
120
+ Parameters
121
+ ----------
122
+ ii : int
123
+ ???
124
+ x : float
125
+ ???
126
+ sigma : float
127
+ ???
128
+ N : float
129
+ ???
130
+ PSFy : float
131
+ ???
132
+ calc_d2 : bool
133
+ calculate d2udt2
134
+
135
+ Returns
136
+ -------
137
+ (float, float)
138
+ dudt, d2udt2 values
139
+ '''
140
+ a = math.exp(-0.5*math.pow(((ii+0.5-x)/sigma), 2))
141
+ b = math.exp(-0.5*math.pow((ii-0.5-x)/sigma, 2))
142
+
143
+ dudt = - (N / (math.sqrt(2.0 * np.pi) * sigma)) * (a-b) * PSFy
144
+ d2udt2 = 0.0
145
+
146
+ if (calc_d2):
147
+ d2udt2 = - (N / (math.sqrt(2.0 * np.pi) * math.pow(sigma, 3))) * \
148
+ ((ii+0.5-x)*a-(ii-0.5-x)*b)*PSFy
149
+
150
+ return dudt, d2udt2
151
+
152
+
153
+ @cuda.jit(
154
+ nb.types.Tuple((nb.float32, nb.float32))(
155
+ nb.int32, nb.float32, nb.float32,
156
+ nb.float32, nb.float32, nb.boolean),
157
+ device=True)
158
+ def kernel_DerivativeIntGauss1DSigma(ii, x, Sx, N, PSFy, calc_d2):
159
+ '''compute the derivative of the 1D gaussian
160
+
161
+ Parameters
162
+ ----------
163
+ ii : int
164
+ ???
165
+ x : float
166
+ ???
167
+ sigma : float
168
+ ???
169
+ N : float
170
+ ???
171
+ PSFy : float
172
+ ???
173
+ calc_d2 : bool
174
+ calculate d2udt2
175
+
176
+ Returns
177
+ -------
178
+ (float, float)
179
+ dudt, d2udt2 values
180
+ '''
181
+ ax = math.exp(-0.5*math.pow(((ii+0.5-x)/Sx), 2))
182
+ bx = math.exp(-0.5*math.pow((ii-0.5-x)/Sx, 2))
183
+
184
+ dudt = - (N/(math.sqrt(2*np.pi)*Sx*Sx)) * \
185
+ (ax * (ii - x + 0.5) - bx*(ii - x - 0.5)) * PSFy
186
+ d2udt2 = 0.0
187
+
188
+ if (calc_d2):
189
+ d2udt2 = (
190
+ - (2 / Sx)*dudt
191
+ - (N/(math.sqrt(2*np.pi)*math.pow(Sx, 5)))*(
192
+ ax*math.pow((ii-x+0.5), 3)
193
+ - bx*math.pow((ii-x-0.5), 3)) * PSFy)
194
+
195
+ return dudt, d2udt2
196
+
197
+
198
+ @cuda.jit(
199
+ nb.types.Tuple((nb.float32, nb.float32))(
200
+ nb.int32, nb.int32, nb.float32, nb.float32,
201
+ nb.float32, nb.float32, nb.float32, nb.float32, nb.boolean),
202
+ device=True)
203
+ def kernel_DerivativeIntGauss2DSigma(ii, jj, x, y, S, N, PSFx, PSFy, calc_d2):
204
+ '''compute the derivative of the 2D gaussian
205
+
206
+ Parameters
207
+ ----------
208
+ ii : int
209
+ ???
210
+ jj : int
211
+ ???
212
+ x : float
213
+ ???
214
+ y : float
215
+ ???
216
+ S : float
217
+ ???
218
+ N : float
219
+ ???
220
+ PSFx : float
221
+ ???
222
+ PSFy : float
223
+ ???
224
+ calc_d2 : bool
225
+ calculate d2udt2
226
+
227
+ Returns
228
+ -------
229
+ (float, float)
230
+ dudt, d2udt2 values
231
+ '''
232
+
233
+ dSx, ddSx = kernel_DerivativeIntGauss1DSigma(
234
+ ii, x, S, N, PSFy, calc_d2)
235
+ dSy, ddSy = kernel_DerivativeIntGauss1DSigma(
236
+ jj, y, S, N, PSFx, calc_d2)
237
+
238
+ dudt = dSx + dSy
239
+ d2udt2 = 0.0
240
+ if (calc_d2):
241
+ d2udt2 = ddSx + ddSy
242
+
243
+ return dudt, d2udt2
244
+
245
+
246
+ @cuda.jit(
247
+ nb.types.Tuple((nb.float32, nb.float32))(
248
+ nb.int64, nb.float32[:]),
249
+ device=True)
250
+ def kernel_CenterofMass2D(sz, data):
251
+ '''compute the 2D center of mass of a subregion
252
+
253
+ Parameters
254
+ ----------
255
+ sz : _type_
256
+ nxn size of the subregion
257
+ data : _type_
258
+ subregion to search
259
+
260
+ Returns
261
+ -------
262
+ tuple[float, float]
263
+ (x, y) coordinate to return
264
+ '''
265
+ tmpx = tmpy = tmpsum = 0.0
266
+
267
+ for ii in range(sz):
268
+ for jj in range(sz):
269
+ tmpx += data[sz*jj+ii]*ii
270
+ tmpy += data[sz*jj+ii]*jj
271
+ tmpsum += data[sz*jj+ii]
272
+
273
+ x = tmpx / tmpsum
274
+ y = tmpy / tmpsum
275
+
276
+ return x, y
277
+
278
+
279
+ @cuda.jit(
280
+ nb.types.Tuple((nb.float32, nb.float32))(
281
+ nb.int32, nb.float32, nb.float32[:]),
282
+ device=True)
283
+ def kernel_GaussFMaxMin2D(sz, sigma, data) -> tuple[float, float]:
284
+ '''returns filtered min and pixels of a given subregion
285
+
286
+ Parameters
287
+ ----------
288
+ sz : int
289
+ nxn size of the subregion
290
+ sigma : float
291
+ used in filter calculation
292
+ data : float[]
293
+ the subregion to search
294
+
295
+ Returns
296
+ -------
297
+ tuple[float, float]
298
+ (MaxN, MinBG) maximum pixel value, minimum background value.
299
+ '''
300
+ # int ii, jj, kk, ll;
301
+ MaxN = 0.0
302
+ MinBG = 10e10 # big
303
+
304
+ norm = 1.0 / (2.0 * sigma * sigma)
305
+ # loop over all pixels
306
+ for kk in range(sz):
307
+ for ll in range(sz):
308
+ MaxN = max(MaxN, data[kk*sz+ll])
309
+ MinBG = min(MinBG, data[kk*sz+ll])
310
+
311
+ return MaxN, MinBG
312
+
313
+
314
+ @cuda.jit(
315
+ nb.types.Tuple((nb.float32[:], nb.float32))(
316
+ nb.int32, nb.int32, nb.float32,
317
+ nb.float32[:], nb.float32[:]),
318
+ device=True)
319
+ def kernel_DerivativeGauss2D(ii, jj, PSFSigma, theta, dudt):
320
+ '''compute DerivativeGauss2D
321
+
322
+ Parameters
323
+ ----------
324
+ ii : int
325
+ _description_
326
+ jj : int
327
+ _description_
328
+ PSFSigma : float
329
+ _description_
330
+ theta : float[]
331
+ _description_
332
+ dudt : float[]
333
+ _description_
334
+
335
+ Returns
336
+ -------
337
+ tuple[ndarray, float]
338
+ (dudt, model)
339
+ '''
340
+ PSFx = kernel_IntGauss1D(ii, theta[0], PSFSigma)
341
+ PSFy = kernel_IntGauss1D(jj, theta[1], PSFSigma)
342
+
343
+ model = theta[3] + theta[2] * PSFx * PSFy
344
+
345
+ # calculating derivatives
346
+ dudt[0], _ = kernel_DerivativeIntGauss1D(
347
+ ii, theta[0], PSFSigma, theta[2], PSFy, False)
348
+ dudt[1], _ = kernel_DerivativeIntGauss1D(
349
+ jj, theta[1], PSFSigma, theta[2], PSFx, False)
350
+ dudt[2] = PSFx * PSFy
351
+ dudt[3] = 1.0
352
+
353
+ return dudt, model
354
+
355
+
356
+ @cuda.jit(
357
+ nb.types.Tuple((nb.float32[:], nb.float32))(
358
+ nb.int32, nb.int32,
359
+ nb.float32[:], nb.float32[:]),
360
+ device=True)
361
+ def kernel_DerivativeGauss2D_sigma(ii, jj, theta, dudt):
362
+ '''compute DerivativeGauss2D_sigma
363
+
364
+ Parameters
365
+ ----------
366
+ ii : int
367
+ _description_
368
+ jj : int
369
+ _description_
370
+ PSFSigma : float
371
+ _description_
372
+ theta : float[]
373
+ _description_
374
+ dudt : float[]
375
+ _description_
376
+
377
+ Returns
378
+ -------
379
+ tuple[ndarray, float]
380
+ (dudt, model)
381
+ '''
382
+ PSFx = kernel_IntGauss1D(ii, theta[0], theta[4])
383
+ PSFy = kernel_IntGauss1D(jj, theta[1], theta[4])
384
+
385
+ model = theta[3] + theta[2] * PSFx * PSFy
386
+
387
+ dudt[0], _ = kernel_DerivativeIntGauss1D(
388
+ ii, theta[0], theta[4], theta[2], PSFy, False)
389
+ dudt[1], _ = kernel_DerivativeIntGauss1D(
390
+ jj, theta[1], theta[4], theta[2], PSFx, False)
391
+ dudt[4], _ = kernel_DerivativeIntGauss2DSigma(
392
+ ii, jj, theta[0], theta[1], theta[4], theta[2], PSFx, PSFy, False)
393
+ dudt[2] = PSFx * PSFy
394
+ dudt[3] = 1.0
395
+
396
+ return dudt, model
397
+
398
+
399
+ @cuda.jit(device=True)
400
+ def kernel_DerivativeIntGauss2Dz(
401
+ ii, jj, theta, PSFSigma_x, PSFSigma_y, Ax, Ay, Bx, By, gamma, d,
402
+ dudt, d2udt2, calc_d2):
403
+ '''compute the derivative of the 2D gaussian
404
+
405
+ Parameters
406
+ ----------
407
+ ii : int
408
+ _description_
409
+ jj : int
410
+ _description_
411
+ theta : float
412
+ _description_
413
+ PSFSigma_x : float
414
+ _description_
415
+ PSFSigma_y : float
416
+ _description_
417
+ Ax : float
418
+ _description_
419
+ Ay : float
420
+ _description_
421
+ Bx : float
422
+ _description_
423
+ By : float
424
+ _description_
425
+ gamma : float
426
+ _description_
427
+ d : float
428
+ _description_
429
+ pPSFx : float
430
+ _description_
431
+ pPSFy : float
432
+ _description_
433
+ dudt : float
434
+ _description_
435
+ d2udt2 : float
436
+ _description_
437
+ calc_d2 : bool
438
+ calculate d2udt2
439
+
440
+ Returns
441
+ -------
442
+ tuple[...]
443
+ (PSFx, PSFy, dudt, d2udt2, model)
444
+ '''
445
+
446
+ z = theta[4]
447
+
448
+ alphax = kernel_alpha(z-gamma, Ax, Bx, d)
449
+ alphay = kernel_alpha(z+gamma, Ay, By, d)
450
+
451
+ Sx = PSFSigma_x*math.sqrt(alphax)
452
+ Sy = PSFSigma_y*math.sqrt(alphay)
453
+
454
+ PSFx = kernel_IntGauss1D(ii, theta[0], Sx)
455
+ PSFy = kernel_IntGauss1D(jj, theta[1], Sy)
456
+ # pPSFx = PSFx
457
+ # pPSFy = PSFy
458
+
459
+ dudt[0], ddx = kernel_DerivativeIntGauss1D(
460
+ ii, theta[0], Sx, theta[2], PSFy, True)
461
+ dudt[1], ddy = kernel_DerivativeIntGauss1D(
462
+ jj, theta[1], Sy, theta[2], PSFx, True)
463
+ dSx, ddSx = kernel_DerivativeIntGauss1DSigma(
464
+ ii, theta[0], Sx, theta[2], PSFy, True)
465
+ dSy, ddSy = kernel_DerivativeIntGauss1DSigma(
466
+ jj, theta[1], Sy, theta[2], PSFx, True)
467
+
468
+ dSdalpha_x = PSFSigma_x/(2.0*math.sqrt(alphax))
469
+ dSdalpha_y = PSFSigma_y/(2.0*math.sqrt(alphay))
470
+
471
+ dSdzx = dSdalpha_x * kernel_dalphadz(z-gamma, Ax, Bx, d)
472
+ dSdzy = dSdalpha_y * kernel_dalphadz(z+gamma, Ay, By, d)
473
+ dudt[4] = dSx * dSdzx + dSy * dSdzy
474
+
475
+ dudt[2] = PSFx * PSFy
476
+ dudt[3] = 1.0
477
+
478
+ model = theta[3] + theta[2] * PSFx * PSFy
479
+
480
+ if (calc_d2):
481
+ d2udt2[0] = ddx
482
+ d2udt2[1] = ddy
483
+
484
+ d2Sdalpha2_x = -PSFSigma_x/(4.0*math.pow(alphax, 1.5))
485
+ d2Sdalpha2_y = -PSFSigma_y/(4.0*math.pow(alphay, 1.5))
486
+
487
+ ddSddzx = (
488
+ d2Sdalpha2_x * math.pow(kernel_dalphadz(z-gamma, Ax, Bx, d), 2) +
489
+ dSdalpha_x * kernel_d2alphadz2(z-gamma, Ax, Bx, d))
490
+ ddSddzy = (
491
+ d2Sdalpha2_y*math.pow(kernel_dalphadz(z+gamma, Ay, By, d), 2) +
492
+ dSdalpha_y*kernel_d2alphadz2(z+gamma, Ay, By, d))
493
+
494
+ d2udt2[4] = (
495
+ ddSx * (dSdzx * dSdzx) +
496
+ dSx * ddSddzx +
497
+ ddSy * (dSdzy * dSdzy) +
498
+ dSy * ddSddzy)
499
+ d2udt2[2] = 0.0
500
+ d2udt2[3] = 0.0
501
+
502
+ return PSFx, PSFy, dudt, d2udt2, model
503
+
504
+
505
+ @cuda.jit(device=True)
506
+ def kernel_DerivativeGauss2D_sigmaxy(ii, jj, theta, dudt):
507
+ '''
508
+ Parameters
509
+ ----------
510
+ ii : int
511
+ _description_
512
+ jj : int
513
+ _description_
514
+ theta : float[]
515
+ _description_
516
+ dudt : float[]
517
+ _description_
518
+
519
+ Returns
520
+ -------
521
+ tuple[ndarray, float]
522
+ (dudt, model)
523
+ '''
524
+ PSFx = kernel_IntGauss1D(ii, theta[0], theta[4])
525
+ PSFy = kernel_IntGauss1D(jj, theta[1], theta[5])
526
+
527
+ dudt[0], _ = kernel_DerivativeIntGauss1D(
528
+ ii, theta[0], theta[4], theta[2], PSFy, False)
529
+ dudt[1], _ = kernel_DerivativeIntGauss1D(
530
+ jj, theta[1], theta[5], theta[2], PSFx, False)
531
+ dudt[4], _ = kernel_DerivativeIntGauss1DSigma(
532
+ ii, theta[0], theta[4], theta[2], PSFy, False)
533
+ dudt[5], _ = kernel_DerivativeIntGauss1DSigma(
534
+ jj, theta[1], theta[5], theta[2], PSFx, False)
535
+ dudt[2] = PSFx * PSFy
536
+ dudt[3] = 1.0
537
+
538
+ model = theta[3] + theta[2] * PSFx * PSFy
539
+
540
+ return dudt, model
541
+
542
+
543
+ @cuda.jit(device=True)
544
+ def kernel_MatInvN(M, Minv, DiagMinv, sz):
545
+ '''nxn partial matrix inversion
546
+
547
+ Parameters
548
+ ----------
549
+ M : _type_
550
+ matrix to inverted
551
+ Minv : _type_
552
+ Minv inverted matrix result
553
+ DiagMinv : _type_
554
+ DiagMinv just the inverted diagonal
555
+ sz : _type_
556
+ sz size of the matrix
557
+ '''
558
+ tmp1 = 0.0
559
+ yy = cuda.local.array(shape=30, dtype=np.float32)
560
+
561
+ for jj in range(sz):
562
+ # calculate upper matrix
563
+ for ii in range(jj+1):
564
+ # deal with ii-1 in the sum, set sum(kk=0->ii-1) when ii=0 to zero
565
+ if (ii > 0):
566
+ for kk in range(ii):
567
+ tmp1 += M[ii+kk*sz]*M[kk+jj*sz]
568
+ M[ii+jj*sz] -= tmp1
569
+ tmp1 = 0
570
+
571
+ for ii in range(jj+1, sz, 1):
572
+ if (jj > 0):
573
+ for kk in range(jj):
574
+ tmp1 += M[ii+kk*sz] * M[kk+jj*sz]
575
+ M[ii+jj*sz] = (1/M[jj+jj*sz])*(M[ii+jj*sz]-tmp1)
576
+ tmp1 = 0
577
+ else:
578
+ M[ii+jj*sz] = (1/M[jj+jj*sz])*M[ii+jj*sz]
579
+
580
+ tmp1 = 0
581
+
582
+ for num in range(sz):
583
+ # calculate yy
584
+ if (num == 0):
585
+ yy[0] = 1
586
+ else:
587
+ yy[0] = 0
588
+
589
+ for ii in range(1, sz, 1):
590
+ b = 1 if ii == num else 0
591
+ for jj in range(ii):
592
+ tmp1 += M[ii+jj*sz]*yy[jj]
593
+ yy[ii] = b-tmp1
594
+ tmp1 = 0
595
+
596
+ # calculate Minv
597
+ Minv[sz-1+num*sz] = yy[sz-1] / M[(sz-1)+(sz-1)*sz]
598
+
599
+ for ii in range(sz-2, -1, -1):
600
+ for jj in range(ii+1, sz, 1):
601
+ tmp1 += M[ii+jj*sz]*Minv[jj+num*sz]
602
+ Minv[ii+num*sz] = (1/M[ii+ii*sz])*(yy[ii]-tmp1)
603
+ tmp1 = 0
604
+
605
+ # if DiagMinv:
606
+ for ii in range(sz):
607
+ DiagMinv[ii] = Minv[ii * sz + ii]
608
+
609
+ return Minv, DiagMinv