nenupy.io.tf.TFPipeline
- class nenupy.io.tf.TFPipeline(data_obj, *tasks)[source]
Bases:
objectClass to manage the series of tasks designed to be applied to time-frequency data.
- __init__(data_obj, *tasks)[source]
Generate an instance of
TFPipeline.
Methods
__init__(data_obj, *tasks)Generate an instance of
TFPipeline.append(operation)Append a pipeline task at the end of the list of planned tasks.
contains(task_name)Check if the pipeline contains a
TFTasknamedtask_name.info([return_str])Display the current pipeline configuration.
insert(operation, index)Insert a pipeline task at a given position among the list of planned tasks.
remove(*args)Remove a task from the list.
run(time_unix, frequency_hz, data)Run all the tasks registered in the pipeline.
Set the default pipeline.
Attributes
Attribute listing all the available parameters.
- contains(task_name)[source]
Check if the pipeline contains a
TFTasknamedtask_name.- Parameters:
- Returns:
Whether the task is present or not.
- Return type:
Example
>>> from nenupy.io.tf import Spectra, TFPipeline >>> pipeline = TFPipeline( Spectra("/my/file.spectra") ) >>> pipeline.contains("Correct bandpass") True
- info(return_str=False)[source]
Display the current pipeline configuration. The tasks are ordered as they will be applied. Tasks in parenthesis are not considered ‘activated’. This can happen because the task is looking for an argument in
parameterswhose value does not fulfill the requirements.- Parameters:
return_str (
bool, optional) – Return the information message as a string variable, by defaultFalse.- Returns:
If
return_stris set toTrue, the message is returned as a string variable.- Return type:
Example
>>> from nenupy.io.tf import Spectra, TFPipeline, TFTask >>> sp = Spectra("/my/file.spectra") >>> pipeline = TFPipeline(sp, TFTask.correct_bandpass(), TFTask.correct_faraday_rotation()) >>> pipeline.info() Pipeline configuration: 0 - Correct bandpass (1 - Correct faraday rotation)
- insert(operation, index)[source]
Insert a pipeline task at a given position among the list of planned tasks.
- Parameters:
operation (
TFTask) – The task to perform.index (
int) – Index at which theoperationshould be inserted (seelist.insert()).
- Raises:
- property parameters
Attribute listing all the available parameters. Each time a
TFTaskis run, itsupdate()method is called and this parameter list is passed.- Returns:
Pipeline parameters.
- Return type:
- remove(*args)[source]
Remove a task from the list.
- Parameters:
*args (
strorint) – If an integer is found, the task indexed at the corresponding value will be removed. If a string is found, the first instance of theTFTaskwhosenamecorresponds toargwill be removed.- Raises:
TypeError – If
argscontains any item that is neitherintnorstr.
Example
>>> from nenupy.io.tf import Spectra, TFPipeline, TFTask >>> pipeline = TFPipeline( Spectra("/my/file.spectra") ) >>> pipeline.set_default() >>> pipeline.info() Pipeline configuration: 0 - Correct bandpass (1 - Remove subband channels) (2 - Rebin in time) (3 - Rebin in frequency) 4 - Compute Stokes parameters >>> pipeline.remove("Rebin in frequency", 1) >>> pipeline.info() Pipeline configuration: 0 - Correct bandpass (1 - Rebin in time) 2 - Compute Stokes parameters
- run(time_unix, frequency_hz, data)[source]
Run all the tasks registered in the pipeline.
- Parameters:
time_unix (
ndarray) – Original array of time samples in Unix format (should match the first dimension ofdata).frequency_hz (
ndarray) – Original array of frequency samples in Hz (should match the second dimension ofdata)data (
Array) – Original data array, its shape should be(time, frequency, 2, 2).
- Returns:
Returns quantities equivalent to the inputs. The sizes of
time_unixandfrequency_hzmay have change (if rebinning steps have been included in the pipeline for instance). The first two dimensions ofdatashould still match those oftime_unixandfrequency_hz. The last dimensions depend on the polarization computation.- Return type:
- set_default()[source]
Set the default pipeline. This will reset any existing list of
TFTask. This method also reset the parameters configuration (listed inparameters). The list of tasks is:Bandpass correction (
correct_bandpass())Remove channels at the subband edges (
remove_channels())Rebin the data in time (
time_rebin())Rebin the data in frequency (
frequency_rebin())Convert the data to Stokes parameters (
get_stokes())