Grids

Loading grids

waveport.load_grid(path: str | Path, geometry: GridGeometry | None = None) → list[Grid]

Load a grid file given its path

The function takes the name of the file containing the grid and returns a Grid object:

import waveport

cut = waveport.load_grid("my_antenna_pattern.grid")

The function is able to automatically decompress .gz and .bz2 files.

The geometry parameter is needed to specify the kind of geometry used in the file, as TICRA does not record this information in grid files. If you are unsure, leave the default (None).

waveport.loads_grid(contents: str, geometry: waveport._core.GridGeometry | None = None) → list[waveport._core.Grid]

Parse a string containing the contents of a TICRA grid file

This function accepts a text string that contains the contents of a TICRA grid file. It should be used whenever a file is not physically present on a storage device but was received by any other means, e.g., through a socket or as the output of a decompression program.

Note that you can use load_grid() if the file you want to load was compressed using GZip or BZip2, as the function handles the decompression automatically.

The Grid class

class waveport.Grid

The contents of a TICRA grid file

This class contains all the information loaded from a .grd file.

It is typically instantiated by the functions loads_grid() (which reads the contents from a pre-loaded text string) and load_grid() (which takes a filename as parameter and loads its contents).

property coefficients

The components of the electric field \(\vec E\)

This is a NumPy array of rank 3 and shape (n_y, n_x, n_comp), where n_x is the fastest-varying angle and n_y the slowest-varying angle. The value of n_comp is either 2 or 3, whether the simulation was done in the near or far field.

The value of n_y is the same as Grid.num_of_values_along_y, n_x is the same as Grid.num_of_values_along_x, and n_comp is the same as Grid.component_count.

property component_count

The number of components per sample.

It can be one of the following values:

  • 2: only the tangential components of the electric vector are recorded (far field)

  • 3: the three components of the electric vector are recorded (near field)

property component_type

The way the polarization vector is encoded.

This type specifies the axes used to decompose the electric vector \(\vec E\) along the two transverse directions. Refer to the TICRA User’s manual for an explanation of each of these entries.

property frequency_hz

The frequency used to compute the coefficients

Frequency (in Hz) used to compute the values of the electric field on the grid.

property geometry

The type of geometry used in the grid

This is an enumeration GridGeometry that describes the kind of geometry that was used in the grid.

A word of caution: the TICRA cut file format does not encode the geometry in the file. This information must be usually provided externally, i.e., through the parameter geometry when calling loads_grid() or load_grid().

property grid_type

Kind of parameterization used for the grid

This is an instance of the GridType enum that specifies how the grid was defined.

property num_of_values_along_x

Number of values sampled along the X component

The X component is typically an angle, and it is the fastest-varying one.

property num_of_values_along_y

Number of values sampled along the Y component

The Y component is typically an angle, and it is the slowest-varying one.

property x_vector

The array of values for the X component

The X component is typically an angle, and it is the fastest-varying one.

property y_vector

The array of values for the Y component

The Y component is typically an angle, and it is the slowest-varying one.

Enumerations

class waveport.GridGeometry(*values)
SPHERICAL = 0
PLANAR = 1
SURFACE = 2
CYLINDRICAL = 3
class waveport.GridType(*values)
UV = 1
RHO_PHI = 2
XY = 3
ELEVATION_OVER_AZIMUTH = 4
ELEVATION_AND_AZIMUTH = 5
AZIMUTH_OVER_ELEVATION = 6
THETA_PHI = 7
PHI_Z = 8
AZIMUTH_OVER_ELEVATION_EDX = 9
ELEVATION_OVER_AZIMUTH_EDX = 10
class waveport.ComponentType(*values)
LINEAR_THETA_PHI = 1
CIRCULAR = 2
CO_CROSS = 3
LINEAR_ALONG_POL_ELLIPSE = 4
XPD_THETA_PHI = 5
XPD_CIRCULAR = 6
XPD_CO_CROSS = 7
XPD_POL_ELLIPSE = 8
TOTAL_POWER_AND_CIRCULAR_RATIO = 9
POYNTING_VECTOR = 11