DataGetterMixin

class Data_Reduction.DataGetterMixin

Bases: object

Class for getting data from a CSV file.

Methods Summary

get_data_channels(data[, ignore])

Gets or sets the names of the signal columns

initialize(filename[, delimiter, names, …])

Get the data and make a data structure for the observations.

make_channels(signals[, props])

Assign properties to the channels.

make_data_struct(data, metadata, signals)

Takes a text table with headers and converts it into a numpy ndarray.

open_datafile(filename[, delimiter, names, …])

Opens and reads a data file

Methods Documentation

get_data_channels(data, ignore=None)

Gets or sets the names of the signal columns

Column names are separated into metadata and signals. Names in ignore re ignored. Names in aliases are replaced. :param data: data read from text file :type data: ndarray :param ignore: columns to ignore; default None :type ignore: list of str

Returns

metadata, signals

Return type

(list of str, list of str)

initialize(filename, delimiter=' ', names=True, skip_header=0, source=None)

Get the data and make a data structure for the observations.

This is not included by default in __init__() to keep it simple for subclasses.

Parameters
  • filename (str) – name only, required; the path is provided

  • delimiter (str) – what separates the columns

  • names (bool) – the first line has column names

  • skip_header (int) – number of rows to skip

make_channels(signals, props=None)

Assign properties to the channels.

The prop keys are “freq”, “pol”, and “IFtype”.

Parameters

props (dict of dicts) – signal channel properties.

make_data_struct(data, metadata, signals)

Takes a text table with headers and converts it into a numpy ndarray.

That means that a column can be extracted using data[label].

Parameters
  • data ((ndarray) the data from the text file) –

  • metadata ((list of str) the column names for metadata) –

  • signals ((list of str) the column names for power-like data) –

open_datafile(filename, delimiter=' ', names=True, skip_header=0)

Opens and reads a data file

This is used by Malargue (one data files) and GAVRT (one data file for each signal).

Parameters
  • filename (str) – text data file name

  • delimiter (str) – separator between columns (default: whitespace)

  • names (bool) – file row has column names (default: True)

  • skip_header (int) – number of rows to skip at beginning of file

Returns

Return type

ndarray