Visualization
In [ ]:
Copied!
"""# Visualization and Scene.
[](https://colab.research.google.com/github/DeepMIMO/DeepMIMO/blob/main/docs/tutorials/2_visualization.py)
[](https://github.com/DeepMIMO/DeepMIMO/blob/main/docs/tutorials/2_visualization.py)
---
**Tutorial Overview:**
- Coverage Maps - Visualizing signal coverage
- Rays - Ray propagation visualization
- Path Plots - Visualization of different path components
- Scene & Materials - 3D scene and material visualization
- Plot Overlays - Combining different visualizations
**Related Video:** [Visualization Video](https://youtu.be/MO7h2shBhsc)
---
"""
"""# Visualization and Scene.
[](https://colab.research.google.com/github/DeepMIMO/DeepMIMO/blob/main/docs/tutorials/2_visualization.py)
[](https://github.com/DeepMIMO/DeepMIMO/blob/main/docs/tutorials/2_visualization.py)
---
**Tutorial Overview:**
- Coverage Maps - Visualizing signal coverage
- Rays - Ray propagation visualization
- Path Plots - Visualization of different path components
- Scene & Materials - 3D scene and material visualization
- Plot Overlays - Combining different visualizations
**Related Video:** [Visualization Video](https://youtu.be/MO7h2shBhsc)
---
"""
In [ ]:
Copied!
# Import libraries
import matplotlib.pyplot as plt
import numpy as np
import deepmimo as dm
# Import libraries
import matplotlib.pyplot as plt
import numpy as np
import deepmimo as dm
In [ ]:
Copied!
# Load dataset
scen_name = "asu_campus_3p5"
dm.download(scen_name)
dataset = dm.load(scen_name)
# Load dataset
scen_name = "asu_campus_3p5"
dm.download(scen_name)
dataset = dm.load(scen_name)
Coverage Maps¶
Visualize signal coverage across the scenario.
In [ ]:
Copied!
# Plot power coverage
dataset.power.plot()
plt.title("Power Coverage Map")
plt.show()
# Plot power coverage
dataset.power.plot()
plt.title("Power Coverage Map")
plt.show()
In [ ]:
Copied!
# Plot pathloss coverage
dataset.pathloss.plot()
plt.title("Pathloss Coverage Map")
plt.show()
# Plot pathloss coverage
dataset.pathloss.plot()
plt.title("Pathloss Coverage Map")
plt.show()
Rays¶
Visualize ray propagation paths.
In [ ]:
Copied!
# Plot rays for a user with line-of-sight
u_idx = np.where(dataset.los == 1)[0][100]
dataset.plot_rays(u_idx, proj_3D=False, dpi=100)
plt.title("Ray Propagation Paths")
plt.show()
# Plot rays for a user with line-of-sight
u_idx = np.where(dataset.los == 1)[0][100]
dataset.plot_rays(u_idx, proj_3D=False, dpi=100)
plt.title("Ray Propagation Paths")
plt.show()
Path Plots¶
Visualize different path components and characteristics.
Percentage of Power¶
In [ ]:
Copied!
# Plot power percentage per path
if hasattr(dataset, "power"):
# Calculate power percentage
linear_power = 10 ** (dataset.power / 10)
total_power = np.sum(linear_power, axis=1, keepdims=True)
power_pct = (linear_power / (total_power + 1e-20)) * 100
plt.figure(figsize=(10, 6))
plt.hist(power_pct[power_pct > 0].flatten(), bins=50)
plt.xlabel("Power Percentage (%)")
plt.ylabel("Count")
plt.title("Distribution of Power Percentage per Path")
plt.show()
# Plot power percentage per path
if hasattr(dataset, "power"):
# Calculate power percentage
linear_power = 10 ** (dataset.power / 10)
total_power = np.sum(linear_power, axis=1, keepdims=True)
power_pct = (linear_power / (total_power + 1e-20)) * 100
plt.figure(figsize=(10, 6))
plt.hist(power_pct[power_pct > 0].flatten(), bins=50)
plt.xlabel("Power Percentage (%)")
plt.ylabel("Count")
plt.title("Distribution of Power Percentage per Path")
plt.show()
Number of Interactions¶
In [ ]:
Copied!
# Visualize number of interactions per path
if hasattr(dataset, "interactions"):
interactions = dataset.interactions
# Count digits in interaction codes
num_interactions = np.array(
[[len(str(int(x))) if x > 0 else 0 for x in row] for row in interactions]
)
plt.figure(figsize=(10, 6))
plt.hist(num_interactions.flatten(), bins=range(10))
plt.xlabel("Number of Interactions")
plt.ylabel("Count")
plt.title("Distribution of Interaction Counts")
plt.show()
# Visualize number of interactions per path
if hasattr(dataset, "interactions"):
interactions = dataset.interactions
# Count digits in interaction codes
num_interactions = np.array(
[[len(str(int(x))) if x > 0 else 0 for x in row] for row in interactions]
)
plt.figure(figsize=(10, 6))
plt.hist(num_interactions.flatten(), bins=range(10))
plt.xlabel("Number of Interactions")
plt.ylabel("Count")
plt.title("Distribution of Interaction Counts")
plt.show()
Scene & Materials¶
Explore the 3D scene and materials.
Scene Visualization¶
In [ ]:
Copied!
# Plot the 3D scene
if hasattr(dataset, "scene"):
dataset.scene.plot()
plt.title("3D Scene")
plt.show()
else:
print("Scene data not available for this scenario")
# Plot the 3D scene
if hasattr(dataset, "scene"):
dataset.scene.plot()
plt.title("3D Scene")
plt.show()
else:
print("Scene data not available for this scenario")
Materials¶
In [ ]:
Copied!
# Display material properties
if hasattr(dataset, "materials"):
print("Available Materials:")
print(dataset.materials)
else:
print("Material data not available for this scenario")
# Display material properties
if hasattr(dataset, "materials"):
print("Available Materials:")
print(dataset.materials)
else:
print("Material data not available for this scenario")
Plot Overlays¶
Combine different visualizations for comprehensive analysis.
2D Scene, Coverage & Rays Overlay¶
In [ ]:
Copied!
# Overlay coverage map with rays
fig, ax = plt.subplots(figsize=(12, 8))
# Plot coverage as background
dataset.power.plot(ax=ax)
# Overlay rays for a selected user
los_users = np.where(dataset.los == 1)[0]
if len(los_users) > 0:
dataset.plot_rays(los_users[50], ax=ax, proj_3D=False)
plt.title("Coverage Map with Ray Overlay")
plt.show()
# Overlay coverage map with rays
fig, ax = plt.subplots(figsize=(12, 8))
# Plot coverage as background
dataset.power.plot(ax=ax)
# Overlay rays for a selected user
los_users = np.where(dataset.los == 1)[0]
if len(los_users) > 0:
dataset.plot_rays(los_users[50], ax=ax, proj_3D=False)
plt.title("Coverage Map with Ray Overlay")
plt.show()
3D Scene & Rays Overlay¶
In [ ]:
Copied!
# 3D visualization with scene and rays
if hasattr(dataset, "scene"):
# Plot rays first, then overlay the scene
ax = dataset.plot_rays(los_users[50])
dataset.scene.plot(ax=ax)
ax.legend().set_visible(False)
plt.title("3D Scene with Rays")
plt.show()
else:
print("3D scene not available for this scenario")
# 3D visualization with scene and rays
if hasattr(dataset, "scene"):
# Plot rays first, then overlay the scene
ax = dataset.plot_rays(los_users[50])
dataset.scene.plot(ax=ax)
ax.legend().set_visible(False)
plt.title("3D Scene with Rays")
plt.show()
else:
print("3D scene not available for this scenario")
Next Steps¶
Continue with:
- Tutorial 3: Detailed Channel Generation - Deep dive into channel generation parameters
- Tutorial 4: User Selection and Dataset Manipulation - Learn how to filter and sample users