1- import math
21from typing import List , Tuple
32
43import numpy as np
1211)
1312from .ray_tracing import ray_tracing
1413from .trafo import correct_brown_affine , pixel_to_metric
15- from .vec_utils import norm , vec_set
14+ from .vec_utils import vec_norm
1615
1716
1817def multimed_nlay (
@@ -64,9 +63,9 @@ def fast_multimed_r_nlay(
6463 n2 : np .ndarray ,
6564 n3 : float ,
6665 d : np .ndarray ,
67- x0 ,
68- y0 ,
69- z0 ,
66+ x0 : float ,
67+ y0 : float ,
68+ z0 : float ,
7069 pos : np .ndarray
7170) -> float :
7271 """Calculate the radial shift for the multimedia model.
@@ -87,22 +86,23 @@ def fast_multimed_r_nlay(
8786 for i in range (1 , nlay ):
8887 zout += d [i ]
8988
90- r = norm (X - x0 , Y - y0 , 0 )
89+
90+ r = vec_norm (np .array ([X - x0 , Y - y0 , 0 ]))
9191 rq = r
9292
9393 it = 0
9494 while (rdiff > 0.001 or rdiff < - 0.001 ) and it < n_iter :
9595 zdiff = z0 - Z
9696 if zdiff == 0 :
9797 zdiff = 1.0
98- beta1 = math . atan (rq / zdiff )
98+ beta1 = np . arctan (rq / zdiff )
9999 for i in range (nlay ):
100- beta2 [i ] = math . asin ( math .sin (beta1 ) * n1 / n2 [i ])
101- beta3 = math . asin ( math .sin (beta1 ) * n1 / n3 )
100+ beta2 [i ] = np . arcsin ( np .sin (beta1 ) * n1 / n2 [i ])
101+ beta3 = np . arcsin ( np .sin (beta1 ) * n1 / n3 )
102102
103- rbeta = (z0 - d [0 ]) * math .tan (beta1 ) - zout * math .tan (beta3 )
103+ rbeta = (z0 - d [0 ]) * np .tan (beta1 ) - zout * np .tan (beta3 )
104104 for i in range (nlay ):
105- rbeta += d [i ] * math .tan (beta2 [i ])
105+ rbeta += d [i ] * np .tan (beta2 [i ])
106106
107107 rdiff = r - rbeta
108108 rq += rdiff
@@ -127,14 +127,14 @@ def trans_cam_point(
127127
128128 pos_t, cross_p, cross_c = trans_cam_point(ex, mm, glass, pos, ex_t)
129129 """
130- origin = np .r_ [ex .x0 , ex .y0 , ex .z0 ]
130+ origin = np .r_ [ex .x0 , ex .y0 , ex .z0 ] # type: ignore
131131 pos = pos .astype (np .float64 )
132132
133133 return fast_trans_cam_point (
134134 origin , mm .d [0 ], glass_dir , pos )
135135
136136
137- # @njit(fastmath=True)
137+ @njit (fastmath = True )
138138def fast_trans_cam_point (
139139 primary_point : np .ndarray ,
140140 d : float ,
@@ -266,8 +266,8 @@ def init_mmlut(vpar: VolumePar, cpar: ControlPar, cal: Calibration) -> Calibrati
266266 z_min = min (vpar .z_min_lay )
267267 z_max = max (vpar .z_max_lay )
268268
269- z_min -= math .fmod (z_min , rw )
270- z_max += rw - math .fmod (z_max , rw )
269+ z_min -= np .fmod (z_min , rw )
270+ z_max += rw - np .fmod (z_max , rw )
271271
272272 z_min_t = z_min
273273 z_max_t = z_max
@@ -292,8 +292,11 @@ def init_mmlut(vpar: VolumePar, cpar: ControlPar, cal: Calibration) -> Calibrati
292292 if xyz_t [2 ] > z_max_t :
293293 z_max_t = xyz_t [2 ]
294294
295- R = norm (xyz_t [0 ] - cal_t .ext_par .x0 ,
296- xyz_t [1 ] - cal_t .ext_par .y0 , 0 )
295+ R = vec_norm (
296+ np .r_ [xyz_t [0 ] - cal_t .ext_par .x0 ,
297+ xyz_t [1 ] - cal_t .ext_par .y0 ,
298+ 0 ]
299+ )
297300
298301 if R > Rmax :
299302 Rmax = R
@@ -308,14 +311,14 @@ def init_mmlut(vpar: VolumePar, cpar: ControlPar, cal: Calibration) -> Calibrati
308311 if xyz_t [2 ] > z_max_t :
309312 z_max_t = xyz_t [2 ]
310313
311- R = norm ( xyz_t [0 ] - cal_t .ext_par .x0 ,
312- xyz_t [1 ] - cal_t .ext_par .y0 , 0 )
314+ R = vec_norm ( np . r_ [ xyz_t [0 ] - cal_t .ext_par .x0 ,
315+ xyz_t [1 ] - cal_t .ext_par .y0 , 0 ] )
313316
314317 if R > Rmax :
315318 Rmax = R
316319
317320 # round values (-> enlarge)
318- Rmax += rw - math .fmod (Rmax , rw )
321+ Rmax += rw - np .fmod (Rmax , rw )
319322
320323 # get # of rasterlines in r, z
321324 nr = int (Rmax / rw + 1 )
@@ -334,11 +337,11 @@ def init_mmlut(vpar: VolumePar, cpar: ControlPar, cal: Calibration) -> Calibrati
334337
335338 for i in range (nr ):
336339 for j in range (nz ):
337- xyz = vec_set ( Ri [i ] + cal_t .ext_par .x0 ,
338- cal_t .ext_par .y0 , Zi [j ])
340+ xyz = np . r_ [ Ri [i ] + cal_t .ext_par .x0 ,
341+ cal_t .ext_par .y0 , Zi [j ]]
339342 data .flat [i * nz + j ] = multimed_r_nlay (cal_t , cpar .mm , xyz )
340343
341- print ("filled mmlut data with {data}" )
344+ # print(f "filled mmlut data with {data}")
342345 cal .mmlut .data = data
343346
344347 return cal
0 commit comments