@@ -67,7 +67,7 @@ def fast_multimed_r_nlay(
6767 y0 : float ,
6868 z0 : float ,
6969 pos : np .ndarray
70- ) -> float :
70+ ) -> float :
7171 """Faster mutlimedia model calculation."""
7272 n_iter = 40
7373 X , Y , Z = pos
@@ -85,7 +85,8 @@ def fast_multimed_r_nlay(
8585 beta2 = np .arcsin (np .sin (beta1 ) * n1 / n2 [0 ])
8686 beta3 = np .arcsin (np .sin (beta1 ) * n1 / n3 )
8787
88- rbeta = (z0 - d [0 ]) * np .tan (beta1 ) - zout * np .tan (beta3 ) + np .sum (d * np .tan (beta2 ))
88+ rbeta = (z0 - d [0 ]) * np .tan (beta1 ) - zout * \
89+ np .tan (beta3 ) + np .sum (d * np .tan (beta2 ))
8990
9091 rdiff = r - rbeta
9192 rq += rdiff
@@ -106,7 +107,7 @@ def trans_cam_point(
106107
107108 pos_t, cross_p, cross_c = trans_cam_point(ex, mm, glass, pos, ex_t)
108109 """
109- origin = np .r_ [ex .x0 , ex .y0 , ex .z0 ] # type: ignore
110+ origin = np .r_ [ex .x0 , ex .y0 , ex .z0 ] # type: ignore
110111 pos = pos .astype (np .float64 )
111112
112113 return fast_trans_cam_point (
@@ -119,7 +120,7 @@ def fast_trans_cam_point(
119120 d : float ,
120121 glass_dir : np .ndarray ,
121122 pos : np .ndarray
122- ) -> Tuple [np .ndarray , np .ndarray , np .ndarray , float ]:
123+ ) -> Tuple [np .ndarray , np .ndarray , np .ndarray , float ]:
123124 """Derive translation of camera point."""
124125 dist_o_glass = float (np .linalg .norm (glass_dir )) # vector length
125126 if dist_o_glass == 0.0 :
@@ -174,8 +175,15 @@ def back_trans_point(
174175 """
175176 return fast_back_trans_point (glass , mm .d [0 ], cross_c , cross_p , pos_t )
176177
178+
177179@njit (fastmath = True , cache = True , nogil = True )
178- def fast_back_trans_point (glass_direction : np .ndarray , d : float , cross_c , cross_p , pos_t ) -> np .ndarray :
180+ def fast_back_trans_point (
181+ glass_direction : np .ndarray ,
182+ d : float ,
183+ cross_c : np .ndarray ,
184+ cross_p : np .ndarray ,
185+ pos_t : np .ndarray
186+ ) -> np .ndarray :
179187 """Run numba faster version of back projection."""
180188 # Calculate the glass direction vector
181189
@@ -199,12 +207,13 @@ def fast_back_trans_point(glass_direction: np.ndarray, d: float, cross_c, cross_
199207
200208 # If the norm of the vector temp is greater than zero, adjust the position
201209 # of the point in the camera coordinate system
202- if norm_temp > 0.0 : # type: ignore
210+ if norm_temp > 0.0 : # type: ignore
203211 renorm_temp = temp * (- pos_t [0 ] / norm_temp )
204212 pos = pos - renorm_temp
205213
206214 return pos
207215
216+
208217@njit (fastmath = True , cache = True , nogil = True )
209218def move_along_ray (glob_z : float , vertex : np .ndarray , direct : np .ndarray ) -> np .ndarray :
210219 """Move along the ray to the global z plane.
@@ -252,7 +261,7 @@ def init_mmlut(vpar: VolumePar, cpar: ControlPar, cal: Calibration) -> Calibrati
252261 z_max_t = z_max
253262
254263 # intersect with image vertices rays
255- cal_t = Calibration (mmlut = cal .mmlut .copy ())
264+ cal_t = Calibration (mmlut = cal .mmlut .copy ())
256265
257266 for i in range (2 ):
258267 for j in range (2 ):
@@ -273,9 +282,9 @@ def init_mmlut(vpar: VolumePar, cpar: ControlPar, cal: Calibration) -> Calibrati
273282
274283 R = vec_norm (
275284 np .r_ [xyz_t [0 ] - cal_t .ext_par .x0 ,
276- xyz_t [1 ] - cal_t .ext_par .y0 ,
277- 0 ]
278- )
285+ xyz_t [1 ] - cal_t .ext_par .y0 ,
286+ 0 ]
287+ )
279288
280289 if R > Rmax :
281290 Rmax = R
@@ -291,7 +300,7 @@ def init_mmlut(vpar: VolumePar, cpar: ControlPar, cal: Calibration) -> Calibrati
291300 z_max_t = xyz_t [2 ]
292301
293302 R = vec_norm (np .r_ [xyz_t [0 ] - cal_t .ext_par .x0 ,
294- xyz_t [1 ] - cal_t .ext_par .y0 , 0 ])
303+ xyz_t [1 ] - cal_t .ext_par .y0 , 0 ])
295304
296305 if R > Rmax :
297306 Rmax = R
@@ -317,8 +326,9 @@ def init_mmlut(vpar: VolumePar, cpar: ControlPar, cal: Calibration) -> Calibrati
317326 for i in range (nr ):
318327 for j in range (nz ):
319328 xyz = np .r_ [Ri [i ] + cal_t .ext_par .x0 ,
320- cal_t .ext_par .y0 , Zi [j ]]
321- cal .mmlut_data .flat [i * nz + j ] = multimed_r_nlay (cal_t , cpar .mm , xyz )
329+ cal_t .ext_par .y0 , Zi [j ]]
330+ cal .mmlut_data .flat [i * nz +
331+ j ] = multimed_r_nlay (cal_t , cpar .mm , xyz )
322332
323333 # print(f"filled mmlut data with {data}")
324334 # cal.mmlut_data = data
@@ -337,6 +347,8 @@ def get_mmf_from_mmlut(cal: Calibration, pos: np.ndarray) -> float:
337347 return fast_get_mmf_from_mmlut (rw , origin , data , nz , nr , pos )
338348
339349# @njit
350+
351+
340352def fast_get_mmf_from_mmlut (
341353 rw : int ,
342354 origin : np .ndarray ,
0 commit comments