Animating Trajectories

[5]:
import numpy as np
import os, time
import scipy
import matplotlib.pyplot as plt
import matplotlib
from IPython.display import HTML

from neoradium import DeepMimoData, TrjChannel, Carrier, Grid, Modem, AntennaPanel, random
from neoradium.utils import getNmse
[6]:
# Replace this with the folder on your computer where you store DeepMIMO scenarios
dataFolder = "/data/RayTracing/DeepMIMO/Scenarios/V4/"
DeepMimoData.setScenariosPath(dataFolder)

# Create a DeepMimoData object
deepMimoData = DeepMimoData("asu_campus_3p5")
deepMimoData.print()

DeepMimoData Properties:
  Scenario:                   asu_campus_3p5
  Version:                    4.0.0a3
  UE Grid:                    rx_grid
  Grid Size:                  411 x 321
  Base Station:               BS (at [166. 104.  22.])
  Total Grid Points:          131,931
  UE Spacing:                 [1. 1.]
  UE bounds (xyMin, xyMax)    [-225.55 -160.17], [184.45 159.83]
  UE Height:                  1.50
  Carrier Frequency:          3.5 GHz
  Num. paths (Min, Avg, Max): 0, 6.21, 10
  Num. total blockage:        46774
  LOS percentage:             19.71%

[7]:
random.setSeed(123)                                 # Make results reproducible

# Create the carrier:
carrier = Carrier(startRb=0, numRbs=25, spacing=15) # Carrier with 25 Resource Blocks, 15KHz subcarrier spacing
bwp = carrier.curBwp                                # The only bandwidth part in the carrier

# Create a random trajectory at waking speed.
trajectory = deepMimoData.getRandomTrajectory(xyBounds=np.array([[-210, 40], [-120, 100]]),   # Traj. bounds
                                              segLen=5,               # Num grid points on shortest segment
                                              bwp=bwp,                # The bandwidth part
                                              trajLen=100,            # Number of grid points on trajectory
                                              speedMps=15)            # Speed in mps

trajectory.print()                                  # Print the trajectory information
deepMimoData.drawMap("LOS-NLOS", trajectory)        # Draw the Map with the trajectory

Trajectory Properties:
  start (x,y,z):         (-164.55, 39.83, 1.50)
  No. of points:         8227
  curIdx:                0 (0.00%)
  curSpeed:              [10.64 10.64  0.  ]
  Total distance:        123.44 meters
  Total time:            8.226 seconds
  Average Speed:         15.006 mps
  Carrier Frequency:     3.5 GHz
  Paths (Min, Avg, Max): 6, 8.99, 10
  Totally blocked:       0
  LOS percentage:        26.43%

[7]:
(<Figure size 742.518x471.734 with 1 Axes>,
 <Axes: title={'center': 'Map of LOS/NLOS paths'}, xlabel='X', ylabel='Y'>)
../../../../_images/source_Playground_Notebooks_RayTracing_TrajChannelAnim_3_2.png
[8]:
# A call back function that is called to draw up to three graphs below the animated trajectory
def handleGraph(request, ax, trajectory, points=None):
    if request=="Config":
        # Configure all graphs
        if len(ax)>0:
            ax[0].set_xlim(0,trajectory.numPoints)
            ax[0].set_ylim(0,1.2)
            ax[0].set_title("Line of Sight Flag")
        if len(ax)>1:
            ax[1].set_xlim(0,trajectory.numPoints)
            ax[1].set_ylim(900,1300)
            ax[1].set_title("Delay of first path (ns)")
        if len(ax)>2:
            ax[2].set_xlim(0,trajectory.numPoints)
            ax[2].set_ylim(-130,-80)
            ax[2].set_title("Power of first path (db)")

    elif request=="Draw":
        # For Draw: ax is an array of `numGraphs` elements
        p0, p1 = points
        if len(ax)>0: ax[0].plot([p0,p1], [trajectory.points[p0].hasLos,    trajectory.points[p1].hasLos],    'green', markersize=1)
        if len(ax)>1: ax[1].plot([p0,p1], [trajectory.points[p0].delays[0], trajectory.points[p1].delays[0]], 'blue',  markersize=1)
        if len(ax)>2: ax[2].plot([p0,p1], [trajectory.points[p0].powers[0], trajectory.points[p1].powers[0]], 'red',   markersize=1)

# Increase the animation memory limit to 100 MB
matplotlib.rcParams['animation.embed_limit'] = 100000000

# Now create the animation and display it in the following cell. This can take a while...
anim = deepMimoData.animateTrajectory(trajectory, numGraphs=3, graphCallback=handleGraph)
HTML(anim.to_jshtml())

[8]:
[ ]: