READ ME

The Sionna_Ray_Tracking.ipynb file contains code that can be used to iteratively estimate material parameters of materials used in a Mitsuba scene with a moving scatterer.

The code was run on Linux Ubuntu 22.04.4 LTS. Several steps have to be done before running the code. First of all, Python must be installed. We used the Miniconda distribution of Python 3.11.9. It is highly recommended to use virtual environment. The following libraries must be installed to run the code:
1)sionna
2)tensorflow
3)matplotlib.pyplot
4)numpy
5)math
6)pandas
7)scipy
8)time
9)sklearn.metrics
10)seaborn
11)quantiphy
The best way is to start with the installation of TensorFlow. This can be quite challenging. NVIDIA® GPU drivers, CUDA® Toolkit 12.3. and cuDNN SDK 8.9.7. are required for GPU support. Command python3 -c "import tensorflow as tf; print(tf.config.list_physical_devices('GPU'))" can verify if TensorFlow is installed correctly. A list of GPU devices must be returned. One can find more information about how to install TensorFlow on https://www.tensorflow.org/install/pip. Install the sionna library after successful installation of TensorFlow. Finally, install all the other libraries. Jupiter notebook support must be installed to run the Sionna_Ray_Tracking.ipynb file. The sionna.yml file can be used to set up the environment.

User has to set the path to the Mitsuba scene (.xml), paths to rx and tx data files, frequency, pci and offset of the vehicle towards the receiver. The whole code can be run as one block then. The code is divided into several main parts:
Configuration and Imports - Libraries are imported here, and some necessary configuration concerning GPU support takes place.
Definitions of Functions - Functions that are used to load the tx and rx data, for successive tracing and calculation of paths, RSRP and some utility functions. Here is a list of the functions:
	convert_to_radians(data) - Converts angles in data from degrees to radians.
	replace_tx(txdata, pci, correction=[0,0,0]) - Deletes old tx(s) and inserts new tx into the scene.
	add_receivers(measLocations) - Deletes old rx(s) and inserts new rx(s) to measLocations.
	compute_RSRP(paths, gain=0) - Computes RSRP.
	compute_RSRP_successively(paths, gain=0) - Executes compute_RSRP function in for loop.
	trace_paths_successively(...) - Executes sionna.rt.Scene.trace_paths function successively and moves rx before every execution of the function.
	compute_fields_successively(traced_paths, check_scene=True, scat_random_phases=True, info = False) - Executes sionna.rt.Scene.compute_fields function in a for loop.
	compute_paths_successively(...) - Executes trace_paths_successively function and then executes compute_fields_successively function.
	replace_value(array, value, value_to_replace=float('-inf')) - Does what it says.
	material_info(so, frequencies) - Prits parameters of material assigned to the object so.
	used_materials() - Prints list of materials used in the scene.
	replace_material(old_material, new_material) - Replaces old_material with new_material.
	replace_material_with_trainable(...) - Replaces material (or all materials) with trainable materials. Material parameters can be specified. Material parameters of the old material are used otherwise. 
	statistics(data_1, data_2, MAE=True, STD=True, r=True, show=True, path=None, file=None) - Computes MAE, STD and correlation of data_1 and data_2.
	path_type_statistics(measurement, paths, path_type, path_type_not=[]) - Creates a subarray of paths and measurement on the basis of path_type and path_type_not. Calculates statistics of the subarrays.
	def trace_paths_train(...) - Similar to trace_paths_successively but moves train object alongside rx.
	def compute_paths_train(...) - Executes sionna.rt.Scene.compute_paths function successively and moves rx as well as a vehicle before every execution of the function.
Configure Scene - Scene frequency is configured, rx and tx data are loaded, antenna arrays are configured, and tx antenna is inserted into the scene.
Show Scene - An image of the scene is rendered.
Machine Learning - Material parameters are optimised.