Transpose¶
- class baseband_tasks.shaping.Transpose(ih, sample_axes)[source] [edit on github]¶
Bases:
baseband_tasks.shaping.ChangeSampleShapeBase
Reshapes the axes of the samples of a stream.
Useful to ensure bring, e.g., frequencies and polarizations in groups before dechannelizing.
- Parameters
See also
Reshape
to reshape the samples
ReshapeAndTranspose
to reshape the samples and transpose the axes
GetItem
index or slice the samples
GetSlice
slice the time axis and index or slice the samples
ChangeSampleShape
to change the samples with a user-supplied function.
Examples
The VDIF example file from
Baseband
has 8 threads which contain 4 channels and 2 polarizations. To produce a stream in which the sample axes are polarization and frequency, one could do:>>> import numpy as np, astropy.units as u, baseband >>> from baseband_tasks.shaping import ChangeSampleShape >>> fh = baseband.open(baseband.data.SAMPLE_VDIF) >>> fh.frequency = 311.25 * u.MHz + (np.arange(8.) // 2) * 16. * u.MHz >>> fh.sideband = 1 >>> fh.polarization = np.tile(['L', 'R'], 4) >>> rh = Reshape(fh, (4, 2)) >>> th = Transpose(rh, (2, 1)) >>> th.read(2).shape (2, 2, 4) >>> th.polarization array([['L'], ['R']], dtype='<U1') >>> th.frequency <Quantity [311.25, 327.25, 343.25, 359.25] MHz> >>> th.sideband array(1, dtype=int8) >>> fh.close()
Note that the example above could also be done in one go using
ReshapeAndTranspose
.Methods Summary
task
(data)Transpose the axes of data.
Methods Documentation
- task(data)[source] [edit on github]¶
Transpose the axes of data.