NVlabs / sionna

Sionna: An Open-Source Library for Next-Generation Physical Layer Research
https://nvlabs.github.io/sionna
Other
822 stars 235 forks source link

Antenna Arrays Configuration #667

Closed evaristesome closed 3 days ago

evaristesome commented 1 week ago

In Sionna, Beginners, Part 3, Antenna Arrays orientation, there is a problem executing this piece of code:

CARRIER_FREQUENCY = 2.6e9 # Carrier frequency in Hz.
                          # This is needed here to define the antenna element spacing.
UT_ARRAY = sn.channel.tr38901.Antenna(  polarization="single",
                                        polarization_type="V",
                                        antenna_pattern="38.901",
                                        carrier_frequency=CARRIER_FREQUENCY)
UT_ARRAY.show();
BS_ARRAY = sn.channel.tr38901.AntennaArray( num_rows=1,
                                            num_cols=int(NUM_BS_ANT/2),
                                            polarization="dual",
                                            polarization_type="cross",
                                            antenna_pattern="38.901", # Try 'omni'
                                            carrier_frequency=CARRIER_FREQUENCY)
BS_ARRAY.show();

##############################################################################
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[17], line 8
      2                           # This is needed here to define the antenna element spacing.
      4 UT_ARRAY = sn.channel.tr38901.Antenna(  polarization="single",
      5                                         polarization_type="V",
      6                                         antenna_pattern="38.901",
      7                                         carrier_frequency=CARRIER_FREQUENCY)
----> 8 UT_ARRAY.show();
     10 BS_ARRAY = sn.channel.tr38901.AntennaArray( num_rows=1,
     11                                             num_cols=int(NUM_BS_ANT[/2](http://localhost:8888/2)),
     12                                             polarization="dual",
     13                                             polarization_type="cross",
     14                                             antenna_pattern="38.901", # Try 'omni'
     15                                             carrier_frequency=CARRIER_FREQUENCY)
     16 BS_ARRAY.show();

File ~/.local/lib/python3.8/site-packages/sionna/channel/tr38901/antenna.py:631, in PanelArray.show(self)
    629 fig = plt.figure()
    630 pos_pol1 = self._ant_pos_pol1
--> 631 plt.plot(pos_pol1[:,1], pos_pol1[:,2],
    632     marker=marker_p1, markeredgecolor='red',
    633     markersize="20", linestyle="None", markeredgewidth="2")
    634 for i, p in enumerate(pos_pol1):
    635     fig.axes[0].annotate(self._ant_ind_pol1[i].numpy()+1, (p[1], p[2]))

File [/usr/lib/python3/dist-packages/matplotlib/pyplot.py:2787](http://localhost:8888/usr/lib/python3/dist-packages/matplotlib/pyplot.py#line=2786), in plot(scalex, scaley, data, *args, **kwargs)
   2785 @docstring.copy(Axes.plot)
   2786 def plot(*args, scalex=True, scaley=True, data=None, **kwargs):
-> 2787     return gca().plot(
   2788         *args, scalex=scalex, scaley=scaley, **({"data": data} if data
   2789         is not None else {}), **kwargs)

File [/usr/lib/python3/dist-packages/matplotlib/axes/_axes.py:1665](http://localhost:8888/usr/lib/python3/dist-packages/matplotlib/axes/_axes.py#line=1664), in Axes.plot(self, scalex, scaley, data, *args, **kwargs)
   1434 """
   1435 Plot y versus x as lines and[/or](http://localhost:8888/or) markers.
   1436 
   (...)
   1662 (``'green'``) or hex strings (``'#008000'``).
   1663 """
   1664 kwargs = cbook.normalize_kwargs(kwargs, mlines.Line2D._alias_map)
-> 1665 lines = [*self._get_lines(*args, data=data, **kwargs)]
   1666 for line in lines:
   1667     self.add_line(line)

File [/usr/lib/python3/dist-packages/matplotlib/axes/_base.py:225](http://localhost:8888/usr/lib/python3/dist-packages/matplotlib/axes/_base.py#line=224), in _process_plot_var_args.__call__(self, *args, **kwargs)
    223     this += args[0],
    224     args = args[1:]
--> 225 yield from self._plot_args(this, kwargs)

File [/usr/lib/python3/dist-packages/matplotlib/axes/_base.py:405](http://localhost:8888/usr/lib/python3/dist-packages/matplotlib/axes/_base.py#line=404), in _process_plot_var_args._plot_args(self, tup, kwargs)
    401     cbook.warn_deprecated(
    402         "2.2", message="cycling among columns of inputs with "
    403         "non-matching shapes is deprecated.")
    404 for j in range(max(ncx, ncy)):
--> 405     seg = func(x[:, j % ncx], y[:, j % ncy], kw, kwargs)
    406     ret.append(seg)
    407 return ret

File [/usr/lib/python3/dist-packages/matplotlib/axes/_base.py:312](http://localhost:8888/usr/lib/python3/dist-packages/matplotlib/axes/_base.py#line=311), in _process_plot_var_args._makeline(self, x, y, kw, kwargs)
    310 default_dict = self._getdefaults(set(), kw)
    311 self._setdefaults(default_dict, kw)
--> 312 seg = mlines.Line2D(x, y, **kw)
    313 return seg

File [/usr/lib/python3/dist-packages/matplotlib/lines.py:382](http://localhost:8888/usr/lib/python3/dist-packages/matplotlib/lines.py#line=381), in Line2D.__init__(self, xdata, ydata, linewidth, linestyle, color, marker, markersize, markeredgewidth, markeredgecolor, markerfacecolor, markerfacecoloralt, fillstyle, antialiased, dash_capstyle, solid_capstyle, dash_joinstyle, solid_joinstyle, pickradius, drawstyle, markevery, **kwargs)
    380 self._color = None
    381 self.set_color(color)
--> 382 self._marker = MarkerStyle(marker, fillstyle)
    384 self._markevery = None
    385 self._markersize = None

File [/usr/lib/python3/dist-packages/matplotlib/markers.py:243](http://localhost:8888/usr/lib/python3/dist-packages/matplotlib/markers.py#line=242), in MarkerStyle.__init__(self, marker, fillstyle)
    241 self._marker_function = None
    242 self.set_fillstyle(fillstyle)
--> 243 self.set_marker(marker)

File [/usr/lib/python3/dist-packages/matplotlib/markers.py:309](http://localhost:8888/usr/lib/python3/dist-packages/matplotlib/markers.py#line=308), in MarkerStyle.set_marker(self, marker)
    307 else:
    308     try:
--> 309         Path(marker)
    310         self._marker_function = self._set_vertices
    311     except ValueError:

File [/usr/lib/python3/dist-packages/matplotlib/path.py:127](http://localhost:8888/usr/lib/python3/dist-packages/matplotlib/path.py#line=126), in Path.__init__(self, vertices, codes, _interpolation_steps, closed, readonly)
     96 def __init__(self, vertices, codes=None, _interpolation_steps=1,
     97              closed=False, readonly=False):
     98     """
     99     Create a new path with the given vertices and codes.
    100 
   (...)
    125         and codes as read-only arrays.
    126     """
--> 127     vertices = _to_unmasked_float_array(vertices)
    128     if vertices.ndim != 2 or vertices.shape[1] != 2:
    129         raise ValueError(
    130             "'vertices' must be a 2D list or array with shape Nx2")

File [/usr/lib/python3/dist-packages/matplotlib/cbook/__init__.py:1390](http://localhost:8888/usr/lib/python3/dist-packages/matplotlib/cbook/__init__.py#line=1389), in _to_unmasked_float_array(x)
   1388     return np.ma.asarray(x, float).filled(np.nan)
   1389 else:
-> 1390     return np.asarray(x, float)

TypeError: float() argument must be a string or a number, not 'MarkerStyle'
SebastianCa commented 4 days ago

Hi @evaristesome, could you please tell us about your system configuration? Which version of Sionna, TensorFlow NumPy and Matplotlib are you using?

evaristesome commented 3 days ago

Hi @SebastianCa , Here are the different versions installed: TensorFlow: 2.13.1 Numpy: 1.24.0 Matplotlib: 3.1.2 Sionna: 0.19.0

SebastianCa commented 3 days ago

Can you please upgrade to matplotlib >= 3.5.3. That should solve the problem.

evaristesome commented 3 days ago

Problem solved after upgrading matplotlib to 3.7.5. Thanks for the support!