GetItem¶
- class baseband_tasks.shaping.GetItem(ih, item)[source] [edit on github]¶
Bases:
ChangeSampleShapeBaseIndex or slice the samples of a stream.
Useful to select, e.g., a specific frequency band or polariazation.
- Parameters:
- ihtask or
basebandstream 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
GetSliceslice the time axis and index or slice the samples
Reshapeto reshape the samples
Transposeto transpose sample axes
ReshapeAndTransposeto reshape the samples and transpose the axes
ChangeSampleShapeto change the samples with a user-supplied function.
Examples
The VDIF example file from
Basebandhas 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.