differt 0.0.35__tar.gz → 0.0.37__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.
- {differt-0.0.35 → differt-0.0.37}/PKG-INFO +2 -2
- {differt-0.0.35 → differt-0.0.37}/pyproject.toml +1 -1
- {differt-0.0.35 → differt-0.0.37}/src/differt/em/_fresnel.py +2 -2
- {differt-0.0.35 → differt-0.0.37}/src/differt/geometry/_utils.py +10 -6
- {differt-0.0.35 → differt-0.0.37}/src/differt/plotting/_core.py +4 -1
- {differt-0.0.35 → differt-0.0.37}/src/differt/rt/_image_method.py +26 -2
- {differt-0.0.35 → differt-0.0.37}/src/differt/rt/_utils.py +3 -2
- {differt-0.0.35 → differt-0.0.37}/src/differt/scene/_triangle_scene.py +6 -3
- {differt-0.0.35 → differt-0.0.37}/src/differt/utils.py +5 -1
- {differt-0.0.35 → differt-0.0.37}/.gitignore +0 -0
- {differt-0.0.35 → differt-0.0.37}/LICENSE.md +0 -0
- {differt-0.0.35 → differt-0.0.37}/README.md +0 -0
- {differt-0.0.35 → differt-0.0.37}/src/differt/__init__.py +0 -0
- {differt-0.0.35 → differt-0.0.37}/src/differt/_version.py +0 -0
- {differt-0.0.35 → differt-0.0.37}/src/differt/em/__init__.py +0 -0
- {differt-0.0.35 → differt-0.0.37}/src/differt/em/_antenna.py +0 -0
- {differt-0.0.35 → differt-0.0.37}/src/differt/em/_constants.py +0 -0
- {differt-0.0.35 → differt-0.0.37}/src/differt/em/_interaction_type.py +0 -0
- {differt-0.0.35 → differt-0.0.37}/src/differt/em/_material.py +0 -0
- {differt-0.0.35 → differt-0.0.37}/src/differt/em/_utd.py +0 -0
- {differt-0.0.35 → differt-0.0.37}/src/differt/em/_utils.py +0 -0
- {differt-0.0.35 → differt-0.0.37}/src/differt/geometry/__init__.py +0 -0
- {differt-0.0.35 → differt-0.0.37}/src/differt/geometry/_paths.py +0 -0
- {differt-0.0.35 → differt-0.0.37}/src/differt/geometry/_triangle_mesh.py +0 -0
- {differt-0.0.35 → differt-0.0.37}/src/differt/plotting/__init__.py +0 -0
- {differt-0.0.35 → differt-0.0.37}/src/differt/plotting/_utils.py +0 -0
- {differt-0.0.35 → differt-0.0.37}/src/differt/py.typed +0 -0
- {differt-0.0.35 → differt-0.0.37}/src/differt/rt/__init__.py +0 -0
- {differt-0.0.35 → differt-0.0.37}/src/differt/rt/_fermat.py +0 -0
- {differt-0.0.35 → differt-0.0.37}/src/differt/scene/__init__.py +0 -0
- {differt-0.0.35 → differt-0.0.37}/src/differt/scene/_sionna.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: DiffeRT
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.37
|
|
4
4
|
Summary: Differentiable Ray Tracing Toolbox for Radio Propagation Simulations
|
|
5
5
|
Project-URL: Changelog, https://github.com/jeertmans/DiffeRT/releases
|
|
6
6
|
Project-URL: Documentation, https://eertmans.be/DiffeRT
|
|
@@ -21,7 +21,7 @@ Classifier: Programming Language :: Python :: 3.13
|
|
|
21
21
|
Classifier: Topic :: Scientific/Engineering
|
|
22
22
|
Requires-Python: >=3.10
|
|
23
23
|
Requires-Dist: chex>=0.1.86
|
|
24
|
-
Requires-Dist: differt-core==0.0.
|
|
24
|
+
Requires-Dist: differt-core==0.0.37
|
|
25
25
|
Requires-Dist: equinox>=0.11.5
|
|
26
26
|
Requires-Dist: filelock>=3.15.4
|
|
27
27
|
Requires-Dist: jax>=0.4.32
|
|
@@ -128,7 +128,7 @@ def fresnel_coefficients(
|
|
|
128
128
|
|
|
129
129
|
>>> from differt.em import fresnel_coefficients
|
|
130
130
|
>>>
|
|
131
|
-
>>> n = 1.5 # Air to glass
|
|
131
|
+
>>> n = 1.5 + 0j # Air to glass
|
|
132
132
|
>>> theta = jnp.linspace(0, jnp.pi / 2)
|
|
133
133
|
>>> cos_theta = jnp.cos(theta)
|
|
134
134
|
>>> (r_s, r_p), (t_s, t_p) = fresnel_coefficients(n, cos_theta)
|
|
@@ -155,7 +155,7 @@ def fresnel_coefficients(
|
|
|
155
155
|
|
|
156
156
|
>>> from differt.em import fresnel_coefficients
|
|
157
157
|
>>>
|
|
158
|
-
>>> n = 1/ 1.5 # Glass to air
|
|
158
|
+
>>> n = 1 / 1.5 + 0j # Glass to air
|
|
159
159
|
>>> theta = jnp.linspace(0, jnp.pi / 2, 300)
|
|
160
160
|
>>> cos_theta = jnp.cos(theta)
|
|
161
161
|
>>> (r_s, r_p), (t_s, t_p) = fresnel_coefficients(n, cos_theta)
|
|
@@ -90,10 +90,10 @@ def normalize(
|
|
|
90
90
|
(Array([0., 0., 0.], dtype=float32), Array(0., dtype=float32))
|
|
91
91
|
"""
|
|
92
92
|
vectors = jnp.asarray(vectors)
|
|
93
|
-
|
|
93
|
+
lengths = jnp.linalg.norm(vectors, axis=-1, keepdims=True)
|
|
94
94
|
|
|
95
|
-
return vectors / jnp.where(
|
|
96
|
-
|
|
95
|
+
return vectors / jnp.where(lengths == 0.0, jnp.ones_like(lengths), lengths), (
|
|
96
|
+
lengths if keepdims else jnp.squeeze(lengths, axis=-1)
|
|
97
97
|
)
|
|
98
98
|
|
|
99
99
|
|
|
@@ -130,7 +130,7 @@ def perpendicular_vectors(u: Float[ArrayLike, "*batch 3"]) -> Float[Array, "*bat
|
|
|
130
130
|
jnp.stack((z, -u[..., 2], u[..., 1]), axis=-1),
|
|
131
131
|
)
|
|
132
132
|
w = jnp.cross(u, v)
|
|
133
|
-
return
|
|
133
|
+
return normalize(w)[0]
|
|
134
134
|
|
|
135
135
|
|
|
136
136
|
@partial(jax.jit, inline=True)
|
|
@@ -166,7 +166,7 @@ def orthogonal_basis(
|
|
|
166
166
|
u = jnp.asarray(u)
|
|
167
167
|
w = perpendicular_vectors(u)
|
|
168
168
|
v = jnp.cross(w, u)
|
|
169
|
-
v =
|
|
169
|
+
v = normalize(v)[0]
|
|
170
170
|
|
|
171
171
|
return v, w
|
|
172
172
|
|
|
@@ -426,7 +426,7 @@ def fibonacci_lattice(
|
|
|
426
426
|
The array of vertices.
|
|
427
427
|
|
|
428
428
|
Raises:
|
|
429
|
-
ValueError: If the provided dtype is not a floating dtype.
|
|
429
|
+
ValueError: If the provided dtype is not a floating dtype, or if ``n`` is not strictly positive.
|
|
430
430
|
|
|
431
431
|
Examples:
|
|
432
432
|
The following example shows how to generate and plot
|
|
@@ -443,6 +443,9 @@ def fibonacci_lattice(
|
|
|
443
443
|
>>> fig = draw_markers(xyz, marker={"color": xyz[:, 0]}, backend="plotly")
|
|
444
444
|
>>> fig # doctest: +SKIP
|
|
445
445
|
"""
|
|
446
|
+
if n <= 0:
|
|
447
|
+
msg = f"Invalid size {n!r}, must be strictly positive."
|
|
448
|
+
raise ValueError(msg)
|
|
446
449
|
if frustum is not None:
|
|
447
450
|
frustum = jnp.asarray(frustum)
|
|
448
451
|
dtype = frustum.dtype
|
|
@@ -797,6 +800,7 @@ def cartesian_to_spherical(
|
|
|
797
800
|
"""
|
|
798
801
|
xyz = jnp.asarray(xyz)
|
|
799
802
|
r = jnp.linalg.norm(xyz, axis=-1)
|
|
803
|
+
r: Array = jnp.where(r == 0.0, jnp.ones_like(r), r)
|
|
800
804
|
p = jnp.arccos(xyz[..., -1] / r)
|
|
801
805
|
a = jnp.arctan2(xyz[..., 1], xyz[..., 0])
|
|
802
806
|
|
|
@@ -621,6 +621,9 @@ def draw_image(
|
|
|
621
621
|
>>> y = np.linspace(-4.0, +4.0, 200)
|
|
622
622
|
>>> X, Y = np.meshgrid(x, y)
|
|
623
623
|
>>> Z = np.sin(X) * np.cos(Y)
|
|
624
|
+
>>> # Let's mask some values to draw a ring
|
|
625
|
+
>>> R = np.sqrt(16 * X * X + Y * Y)
|
|
626
|
+
>>> Z = np.where((R > 0.5) & (R < 1.5), np.nan, Z)
|
|
624
627
|
>>> fig1 = draw_image(Z, backend="plotly")
|
|
625
628
|
>>> fig1 # doctest: +SKIP
|
|
626
629
|
>>>
|
|
@@ -721,7 +724,7 @@ def _(
|
|
|
721
724
|
return fig.add_surface(
|
|
722
725
|
x=x,
|
|
723
726
|
y=y,
|
|
724
|
-
z=np.full_like(data, z0),
|
|
727
|
+
z=np.where(np.isfinite(data), np.full_like(data, z0), np.nan),
|
|
725
728
|
surfacecolor=data,
|
|
726
729
|
**kwargs,
|
|
727
730
|
)
|
|
@@ -119,8 +119,19 @@ def intersection_of_rays_with_planes(
|
|
|
119
119
|
# [*batch 1]
|
|
120
120
|
vn = dot(v, plane_normals, keepdims=True)
|
|
121
121
|
|
|
122
|
-
|
|
123
|
-
|
|
122
|
+
parallel = un == 0.0
|
|
123
|
+
un = jnp.where(parallel, jnp.ones_like(un), un)
|
|
124
|
+
|
|
125
|
+
t = vn / un
|
|
126
|
+
|
|
127
|
+
shape = jnp.broadcast_shapes(ray_origins.shape, ray_directions.shape, t.shape)
|
|
128
|
+
dtype = jnp.result_type(ray_origins, ray_directions, t)
|
|
129
|
+
|
|
130
|
+
return jnp.where(
|
|
131
|
+
parallel & (vn != 0.0),
|
|
132
|
+
jnp.full(shape, jnp.inf, dtype=dtype),
|
|
133
|
+
ray_origins + ray_directions * t,
|
|
134
|
+
)
|
|
124
135
|
|
|
125
136
|
|
|
126
137
|
@jax.jit
|
|
@@ -307,12 +318,25 @@ def image_method(
|
|
|
307
318
|
"""Perform backward pass on images by computing the intersection with mirrors."""
|
|
308
319
|
mirror_vertices, mirror_normals, images = mirror_vertices_normals_and_images
|
|
309
320
|
|
|
321
|
+
# We avoids NaNs (caused by subtraction of two infinities) by replacing
|
|
322
|
+
# previous_intersections with zeros when they are infinite.
|
|
323
|
+
no_previous_intersections = jnp.isinf(previous_intersections)
|
|
324
|
+
previous_intersections = jnp.where(
|
|
325
|
+
no_previous_intersections,
|
|
326
|
+
jnp.zeros_like(previous_intersections),
|
|
327
|
+
previous_intersections,
|
|
328
|
+
)
|
|
310
329
|
intersections = intersection_of_rays_with_planes(
|
|
311
330
|
previous_intersections,
|
|
312
331
|
images - previous_intersections,
|
|
313
332
|
mirror_vertices,
|
|
314
333
|
mirror_normals,
|
|
315
334
|
)
|
|
335
|
+
intersections: Array = jnp.where(
|
|
336
|
+
no_previous_intersections,
|
|
337
|
+
jnp.full_like(intersections, jnp.inf),
|
|
338
|
+
intersections,
|
|
339
|
+
)
|
|
316
340
|
return intersections, intersections
|
|
317
341
|
|
|
318
342
|
_, images = jax.lax.scan(
|
|
@@ -268,10 +268,11 @@ def rays_intersect_triangles(
|
|
|
268
268
|
|
|
269
269
|
# [*batch]
|
|
270
270
|
a = dot(h, edge_1)
|
|
271
|
+
a = jnp.where(a == 0.0, jnp.inf, a) # Avoid division by zero
|
|
271
272
|
|
|
272
273
|
hit = jnp.abs(a) > epsilon
|
|
273
274
|
|
|
274
|
-
f =
|
|
275
|
+
f = 1.0 / a
|
|
275
276
|
s = ray_origins - vertex_0
|
|
276
277
|
u = f * dot(s, h)
|
|
277
278
|
|
|
@@ -531,7 +532,7 @@ def first_triangles_hit_by_rays(
|
|
|
531
532
|
triangle_vertices,
|
|
532
533
|
**kwargs,
|
|
533
534
|
)
|
|
534
|
-
t = jnp.where(hit, t, jnp.inf)
|
|
535
|
+
t = jnp.where(hit, t, jnp.full_like(t, jnp.inf))
|
|
535
536
|
indices = jnp.where(t < t_hit, index, indices)
|
|
536
537
|
t_hit = jnp.minimum(t, t_hit)
|
|
537
538
|
return (indices, t_hit, index + 1), None
|
|
@@ -359,15 +359,18 @@ def _compute_paths_sbr(
|
|
|
359
359
|
# [num_tx_vertices num_rays 3]
|
|
360
360
|
mirror_normals = jnp.take(mesh.normals, triangles, axis=0)
|
|
361
361
|
|
|
362
|
+
# Mark rays leaving the scene as invalid
|
|
363
|
+
inside_scene = jnp.isfinite(t_hit)
|
|
364
|
+
valid_rays &= inside_scene
|
|
365
|
+
# And avoid creating NaNs
|
|
366
|
+
t_hit = jnp.where(inside_scene, t_hit, jnp.zeros_like(t_hit))
|
|
367
|
+
|
|
362
368
|
ray_origins += t_hit[..., None] * ray_directions
|
|
363
369
|
ray_directions = (
|
|
364
370
|
ray_directions
|
|
365
371
|
- 2.0 * dot(ray_directions, mirror_normals, keepdims=True) * mirror_normals
|
|
366
372
|
)
|
|
367
373
|
|
|
368
|
-
# Mark rays leaving the scene as invalid
|
|
369
|
-
valid_rays &= jnp.isfinite(t_hit)
|
|
370
|
-
|
|
371
374
|
return (ray_origins, ray_directions, valid_rays), (
|
|
372
375
|
triangles,
|
|
373
376
|
ray_origins,
|
|
@@ -327,4 +327,8 @@ def safe_divide(
|
|
|
327
327
|
# TODO: add :python: rst role for x / y in docs
|
|
328
328
|
num = jnp.asarray(num)
|
|
329
329
|
den = jnp.asarray(den)
|
|
330
|
-
|
|
330
|
+
shape = jnp.broadcast_shapes(num.shape, den.shape)
|
|
331
|
+
dtype = jnp.result_type(num, den)
|
|
332
|
+
zero_div = den == 0.0
|
|
333
|
+
den = jnp.where(zero_div, jnp.ones_like(den), den)
|
|
334
|
+
return jnp.where(zero_div, jnp.zeros(shape, dtype=dtype), num / den)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|