GetItem¶
- class baseband_tasks.shaping.GetItem(ih, item)[source] [edit on github]¶
Bases:
baseband_tasks.shaping.ChangeSampleShapeBase
Index or slice the samples of a stream.
Useful to select, e.g., a specific frequency band or polariazation.
- Parameters
- ihtask or
baseband
stream reader Input data stream.
- itemint, slice, list of int, or array of int
Anything that can slice a numpy array. Should only attempt to slice the samples, not the time axis.
- ihtask or
See also
GetSlice
slice the time axis and index or slice the samples
Reshape
to reshape the samples
Transpose
to transpose sample axes
ReshapeAndTranspose
to reshape the samples and transpose the axes
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, with very little data in the last channel. To produce a stream with just the first three channels kept, one could do:>>> import numpy as np, astropy.units as u, baseband >>> from baseband_tasks.shaping import GetItem >>> 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) >>> gih = GetItem(fh, slice(0, 6)) >>> gih.read(2).shape (2, 6) >>> gih.polarization array(['L', 'R', 'L', 'R', 'L', 'R'], dtype='<U1') >>> gih.frequency <Quantity [311.25, 311.25, 327.25, 327.25, 343.25, 343.25] MHz> >>> gih.sideband array(1, dtype=int8) >>> fh.close()
Methods Summary
task
(data)Get the preset item from the data.
Methods Documentation
- task(data)[source] [edit on github]¶
Get the preset item from the data.