antennareader

antennareader.reader

Module Description

The antennareader module provides functionalities for reading antenna pattern data from an XML file format and performing various operations on the data. It includes a class AntennaPattern that allows users to read antenna pattern data from an XML file, interpolate the data for finer spacing, and convert it to a healpix format.

The module is designed to work with Pandas DataFrames and supports data manipulation, interpolation, and conversion to healpix format, which is useful for antenna pattern analysis and visualization.

It also offers methods to retrieve volume data for a given quantity and frequencies.

class AntennaPattern(antennaPath: str, frange: Tuple[float, float] = (0, inf), new_antenna_conventions: dict = {})[source]

Bases: object

This class reads antenna pattern data from an XML file and provides methods to work with the pattern data, interpolate it, convert it to healpix format, and more.

Parameters

antennaPathstr

The path of the XML file containing the antenna pattern data.

frangeTuple[float, float], optional

The frequency range of interest, by default [0, np.inf].

new_antenna_conventionsdict, optional

A dictionary of new antenna conventions to apply for coordinate adjustments, by default an empty dictionary.

Attributes

_xml_dictdefaultdict

A defaultdict containing the antenna pattern data parsed from the XML file.

_quantity_listlist

A list of the different quantities available in the antenna pattern data.

show_quantitiesmethod

Prints the list of available quantities.

Methods

get_raw() -> dict:

Returns the antenna pattern data as a dictionary.

get(frequency: float, quantity: str, interp_phi: list = None, interp_theta: list = None,

return_interp_func: bool = False, return_with_updated_conventions: bool = True) -> pd.DataFrame: Returns antenna pattern data as a pandas DataFrame for the given frequency and quantity. Interpolates the data based on interp_phi and interp_theta if provided.

get_volumetric_dataset(quantity: str, frequencies: Union[List[float], np.ndarray, None] = None) -> pd.DataFrame:

Get volume data for a given quantity and frequencies.

convert2hp(frequency: float, shift_phi: float = 0, flip_theta: bool = False, flip_phi: bool = False, in_degrees: bool = True, quantity: str = “absolute”, add_invisible_sky: bool = False) -> Data2hpmap:

Convert the antenna pattern data to healpix format at a given frequency.

Returns

Data2hpmap

A Data2hpmap object containing the antenna pattern data in healpix format.

Notes

This class provides functionality to work with antenna pattern data, including interpolation, coordinate adjustments, and conversion to healpix format.

Example

# Create an instance of AntennaPattern antenna_inst = AntennaPattern(antennaPath=”path/to/antenna.xml”)

# Get antenna pattern data for a specific frequency and quantity data = antenna_inst.get(frequency=50, quantity=”theta_amp”)

# Convert the antenna pattern data to healpix format healpix_data = antenna_inst.convert2hp(frequency=50)

convert2hp(frequency: float, shift_phi: float = 0, flip_theta: bool = False, flip_phi: bool = False, in_degrees: bool = True, quantity: str = 'absolute', add_invisible_sky: bool = False) Data2hpmap[source]

Convert the antenna pattern data to healpix format at a given frequency.

Parameters

frequencyfloat

The frequency at which to extract the antenna pattern data.

shift_phifloat, optional

The amount of rotation around the z-axis, in degrees.

flip_thetabool, optional

If True, the antenna pattern is flipped about the x-axis.

flip_phibool, optional

If True, the antenna pattern is flipped about the y-axis.

in_degreesbool, optional

If True, the antenna pattern data is assumed to be in degrees. If False, the data is assumed to be in radians.

quantitystr, optional

The quantity to extract. Must be one of the keys of the antenna pattern data.

add_invisible_skybool, optional

If True, add the invisible sky pixels to the healpix map. If False, only the visible pixels are included in the map.

Returns

Data2hpmap

A Data2hpmap object containing the antenna pattern data in healpix format.

get(frequency: float, quantity: str, interp_phi: Optional[list] = None, interp_theta: Optional[list] = None, return_interp_func: bool = False, return_with_updated_conventions: bool = True) DataFrame[source]

Get the antenna pattern data for a given frequency and quantity.

Parameters

frequencyfloat

The frequency for which to retrieve the antenna pattern data.

quantitystr

The quantity to retrieve. Valid values are “absolute”, “theta_amp”, “phi_amp”, “theta_phase”, and “phi_phase”.

interp_philist, optional

A list of phi values for which to interpolate the data. Defaults to None.

interp_thetalist, optional

A list of theta values for which to interpolate the data. Defaults to None.

return_interp_funcbool, optional

Whether to return the interpolation function. Defaults to False.

Returns

pd.DataFrame

A pandas DataFrame containing the antenna pattern data for the chosen frequency and quantity. The rows are the phi angles and columns are the theta angles.

get_raw() dict[source]

Returns the antenna pattern data as a dictionary.

Returns

dict

A dictionary containing the antenna pattern data.

get_volumetric_dataset(quantity: str, frequencies: Optional[Union[List[float], ndarray]] = None) DataFrame[source]

Get volume data for a given quantity and frequencies.

Parameters

quantitystr

The quantity to retrieve volume data for.

frequenciesUnion[List[float], np.ndarray, None], optional

Frequencies for which volume data is requested. It can be either a list or a numpy array of floats. If not provided (None), the method will use default frequencies from the antenna_inst object.

Returns

pd.DataFrame

A Pandas DataFrame containing volume data for the specified quantity and frequencies. The DataFrame is indexed by the frequencies and may have multiple columns depending on the structure of the data retrieved.

show_quantities()[source]

Prints the available quantities of the antenna pattern data.