nenupy.io.tf_utils.blocks_to_tf_data

nenupy.io.tf_utils.blocks_to_tf_data(data, n_block_times, n_channels)[source]

Parse time-frequency data at the reading of a .spectra file. Invert the halves of each beamlet and reshape the array in 2D (time, frequency) or 4D (time, frequency, 2, 2).

Parameters:
  • data (Array) – Raw data. Number of dimensions should either be 4 (n_block, n_subband, n_time_per_block, n_channels) or 6 (n_block, n_subband, n_time_per_block, n_channels, 2, 2)

  • n_block_times (int) – Number of time blocks

  • n_channels (int) – Number of frequency channels in each beamlet

Returns:

Data reshaped

Return type:

Array

Raises:
  • ValueError – Raised if n_channels is odd

  • IndexError – Raised if the number of dimensions of data is different than 4 or 6

Warning

Usage only within Spectra.

Example

>>> from nenupy.io.tf_utils import blocks_to_tf_data
>>> import numpy as np

>>> n_block = 5
>>> n_subband = 32
>>> n_time_per_block = 24
>>> n_channels = 8
>>> data = np.ones(((n_block, n_subband, n_time_per_block, n_channels, 2, 2)))
>>> data_reshaped = blocks_to_tf_data(
        data=data,
        n_block_times=n_time_per_block,
        n_channels=n_channels
    )
>>> data_reshaped.shape
(120, 256, 2, 2)