anomaly-detection-material-parameters-calibration

Sionna param calibration (research proj)
git clone https://git.ea.contact/anomaly-detection-material-parameters-calibration
Log | Files | Refs | README

transmitter.py (3524B)


      1 #
      2 # SPDX-FileCopyrightText: Copyright (c) 2021-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
      3 # SPDX-License-Identifier: Apache-2.0
      4 #
      5 """
      6 Class implementing a transmitter
      7 """
      8 
      9 import tensorflow as tf
     10 from .radio_device import RadioDevice
     11 from .utils import dbm_to_watt
     12 
     13 class Transmitter(RadioDevice):
     14     # pylint: disable=line-too-long
     15     r"""
     16     Class defining a transmitter
     17 
     18     The ``position``, ``orientation``, and ``power_dbm`` properties can be assigned to a TensorFlow
     19     variable or tensor. In the latter case, the tensor can be the output of a callable,
     20     such as a Keras layer implementing a neural network. In the former case, it
     21     can be set to a trainable variable:
     22 
     23     .. code-block:: Python
     24 
     25         tx = Transmitter(name="my_tx",
     26                          position=tf.Variable([0, 0, 0], dtype=tf.float32),
     27                          orientation=tf.Variable([0, 0, 0], dtype=tf.float32),
     28                          power_dbm=tf.Variable(44, dtype=tf.float32))
     29 
     30     Parameters
     31     ----------
     32     name : str
     33         Name
     34 
     35     position : [3], float
     36         Position :math:`(x,y,z)` [m] as three-dimensional vector
     37 
     38     power_dbm: float
     39         Transmit power [dBm]
     40 
     41     orientation : [3], float
     42         Orientation :math:`(\alpha, \beta, \gamma)` [rad] specified
     43         through three angles corresponding to a 3D rotation
     44         as defined in :eq:`rotation`.
     45         This parameter is ignored if ``look_at`` is not `None`.
     46         Defaults to [0,0,0].
     47 
     48     look_at : [3], float | :class:`~sionna.rt.Transmitter` | :class:`~sionna.rt.Receiver` | :class:`~sionna.rt.RIS` | :class:`~sionna.rt.Camera` | None
     49         A position or the instance of a :class:`~sionna.rt.Transmitter`,
     50         :class:`~sionna.rt.Receiver`, :class:`~sionna.rt.RIS`, or :class:`~sionna.rt.Camera` to look at.
     51         If set to `None`, then ``orientation`` is used to orientate the device.
     52 
     53     color : [3], float
     54         Defines the RGB (red, green, blue) ``color`` parameter for the device as displayed in the previewer and renderer.
     55         Each RGB component must have a value within the range :math:`\in [0,1]`.
     56         Defaults to `[0.160, 0.502, 0.725]`.
     57 
     58     dtype : tf.complex
     59         Datatype to be used in internal calculations.
     60         Defaults to `tf.complex64`.
     61     """
     62 
     63     def __init__(self,
     64                  name,
     65                  position,
     66                  orientation=(0.,0.,0.),
     67                  look_at=None,
     68                  power_dbm=44,
     69                  color=(0.160, 0.502, 0.725),
     70                  dtype=tf.complex64):
     71 
     72         # Initialize the base class Object
     73         super().__init__(name=name,
     74                          position=position,
     75                          orientation=orientation,
     76                          look_at=look_at,
     77                          color=color,
     78                          dtype=dtype)
     79 
     80         self.power_dbm = power_dbm
     81 
     82     @property
     83     def power_dbm(self):
     84         """ tf.float : Get/set transmit power [dBm] """
     85         return self._power_dbm
     86 
     87     @power_dbm.setter
     88     def power_dbm(self, value):
     89         if isinstance(value, tf.Variable):
     90             if value.dtype != self._rdtype:
     91                 msg = f"`power_dbm` must have dtype={self._rdtype}"
     92                 raise TypeError(msg)
     93             else:
     94                 self._power_dbm = value
     95         else:
     96             self._power_dbm = tf.cast(value, dtype=self._rdtype)
     97 
     98     @property
     99     def power(self):
    100         """ tf.float : Get the transmit power [W] """
    101         return dbm_to_watt(self._power_dbm)