nenupy.io.tf_utils.crop_subband_edges

nenupy.io.tf_utils.crop_subband_edges(data, n_channels, lower_edge_channels=0, higher_edge_channels=0)[source]

Set edge channels of each subband to NaN. Each subband of data is determined thanks to n_channels (and the function reshape_to_subbands()). This method is a bit faster than remove_channels_per_subband() but it is restricted to edge channels. The other method is prefered for its polyvalence.

Parameters:
  • data (ndarray) – Data to be corrected, must be at least two-dimensional, the first two dimensions being respectively the time and the frequency

  • n_channels (int) – Number of channels per subband

  • lower_edge_channels (int) – Number of channels to set to NaN for the lowest part of each subband, by default 0

  • higher_edge_channels (int) – Number of channels to set to NaN for the highest part of each subband, by default 0

Returns:

Corrected data, same shape as input array

Return type:

ndarray

Raises:

ValueError – Raised if the cropped channels are greater than n_channels.

Examples

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

>>> result = crop_subband_edges(
        data=np.ones((2, 10)),
        n_channels=5,
        lower_edge_channels=1, # set to NaN the first channel of each subband
        higher_edge_channels=0
    )
>>> print(result)
[[nan  1.  1.  1.  1. nan  1.  1.  1.  1.]
[nan  1.  1.  1.  1. nan  1.  1.  1.  1.]]

>>> result = crop_subband_edges(
        data=np.ones((2, 10)),
        n_channels=5,
        lower_edge_channels=0,
        higher_edge_channels=2 # set to NaN the last 2 channels of each subband
    )
>>> print(result)
[[ 1.  1.  1. nan nan  1.  1.  1. nan nan]
[ 1.  1.  1. nan nan  1.  1.  1. nan nan]]