Data containers

nsdfdata Module

Classes for NSDF data.

class nsdf.nsdfdata.EventData(*args, **kwargs)[source]

Bases: nsdf.nsdfdata.NSDFData

Stores event times recorded from data sources.

class nsdf.nsdfdata.NSDFData(name, unit=None, field=None, dtype=<Mock object at 0x7f6620c2d610>)[source]

Bases: object

Base class for NSDF Data.

name

str

name of the dataset.

unit

str

unit of the recorded quantity.

field

str

the recorded field/parameter of the source object. If unspecified it defaults to name.

dtype

numpy.dtype

type of the recorded data. Default: numpy.float64

get_all_data()[source]

Return the data for all the sources as a list.

get_data(source)[source]

Return the data for specified source

get_source_data_dict()[source]

Return a dictionary storing the mapping from source->data.

get_sources()[source]

Return the source ids as a list

put_data(source, data)[source]

Set the data array for source.

Parameters:
  • source (str) – uid of the data source.
  • data (a scalar or sequence of elements of dtype) – the data for this source.
Returns:

None

update_source_data_dict(src_data)[source]

Insert a bunch of source, data pairs.

Parameters:src_data (dict-like) – an object that is a dict or a
Returns:None

Examples

>>> data_obj = nsdf.UniformData('current', unit='pA')
>>> ika, ikdr = [0.1, 0.3, 0.5], [0.3, 0.14]
>>> data_obj.update_source_data_dict([('KA', ika), ('KDR', ikdr)])
class nsdf.nsdfdata.NonuniformData(name, unit=None, field=None, tunit=None, dtype=<Mock object at 0x7f6620c2d750>, ttype=<Mock object at 0x7f6620c2d7d0>)[source]

Bases: nsdf.nsdfdata.TimeSeriesData

Stores nonuniformly sampled data.

ttype

np.dtype data type of time points. Default np.float64

put_data(source, data)[source]

Set the data array for source.

Parameters:
  • source (str) – uid of the data source.
  • data (a 2-tuple) – the data and sampling times for this source.
Returns:

None

class nsdf.nsdfdata.NonuniformRegularData(*args, **kwargs)[source]

Bases: nsdf.nsdfdata.TimeSeriesData

Stores nonuniformly sampled data where all sources are sampled at the same time points.

get_times()[source]

Returns the sampling times for the entire dataset.

put_data(source, data)[source]

Set the data array for source.

Parameters:
  • source (str) – uid of the data source.
  • data (a scalar or sequence of elements of dtype) – the data for this source.
Returns:

None

Raises:
  • ValueError if length of data does not match that of
  • sampling times.
set_times(times, tunit=None)[source]

Set the sampling times of all the data points.

class nsdf.nsdfdata.StaticData(*args, **kwargs)[source]

Bases: nsdf.nsdfdata.NSDFData

Stores static data recorded from data sources.

class nsdf.nsdfdata.UniformData(*args, **kwargs)[source]

Bases: nsdf.nsdfdata.TimeSeriesData

Stores uniformly sampled data.

dt

float

the sampling interval of the data.

tunit

float

unit of time.

set_dt(value, unit)[source]

Set the timestep used for data recording.