NSDF file reader

nsdfreader Module

Reader for NSDF format

class nsdf.nsdfreader.NSDFReader(filename)[source]

Bases: object

Reader for NSDF files.

This class encapsulates an NSDF file and provides utility functions to read the data in an organized manner.

contributor

List of contributors to the content of this file.

description

Description of the file. A text string.

event_populations

Names of the populations for which event variables have been recorded.

get_event_data(population, variable)[source]

Get event variable recorded from population.

In NSDF a variable is recorded from a population of sources and data is organized as population/variable. This function retrieve this dataset and creates EventData object containing (source, data) pairs.

Parameters:
  • population (str) – name of the population from which this data was recorded.
  • variable (str) – name of the variable this data represents.

Returns: nsdf.EventData

Note: Data is converted to float64 for VLEN dialect.

get_event_vars(population)[source]

Returns the names of event variables recorded for population.

Parameters:population (str) – name of the population.
Returns:names of the groups storing event variables.
Return type:list of str
get_nonuniform_data(population, variable)[source]

Get nonuniform data variable under population.

In NSDF a variable is recorded from a population of sources and data is organized as population/variable. This function retrieve this dataset and creates NonuniformData object containing (source, data) pairs. In case all the sources share the same sampling times, it is the NonuniformRegularData, a subclass of NonuniformData and contains the sampling times as a separate array. Otherwise, data is tuple of variable values and sampling times.

Parameters:
  • population (str) – name of the population from which this data was recorded.
  • variable (str) – name of the variable this data represents.
Returns:

nsdf.NonuniformRegularData if dialect of the file is NUREGULAR. nsdf.NonuniformData otherwise.

Note: Data is converted to float64 for VLEN dialect.

get_nonuniform_vars(population)[source]

Returns the names of nonuniform variables recorded for population.

Parameters:population (str) – name of the population.
Returns:names of the groups storing nonuniform variables.
Return type:list of str
get_uniform_data(population, variable)[source]

Returns a UniformData object contents for recorded variable from population.

Parameters:
  • population (str) – name of the population.
  • variable (str) – name of the variable.
Returns:

dataobject – data container filled with

source, data, dt and units.

Return type:

nsdf.UniformData

get_uniform_dataset(population, varname)[source]

Returns the data sources and data contents for recorded variable varname from population.

Parameters:
  • population (str) – name of the population.
  • varname (str) – name of the variable.
Returns:

sources is an dataset containing the source identifiers and data is a 2D dataset whose i-th row is the data from the i-th entry in sources.

Return type:

(sources, data)

get_uniform_dt(population, varname)[source]

Returns sampling interval and time-unit for the uniform dataset varname recorded from population.

Parameters:
  • population (str) – name of the population of sources.
  • varname (str) – name of the recorded variable.
Returns:

dt is the sampling interval for this dataset and unit is a string representing the unit of time.

Return type:

(dt, unit)

get_uniform_row(srcid, field)[source]

Get the data for field variable recorded from source with unique id srcid.

Parameters:
  • srcid (str) – unique id of the source.
  • varname (str) – name of the variable.
Returns:

(data, unit, times, timeunit)

get_uniform_ts(population, varname)[source]

Returns an array of sampling times and time-unit for the uniform dataset varname recorded from population.

Parameters:
  • population (str) – name of the population of sources.
  • varname (str) – name of the recorded variable.
Returns:

times is an array of doubles containing the sampling time for each column of the dataset and unit is a string representing the unit of time.

Return type:

(times, unit)

get_uniform_vars(population)[source]

Returns the names of uniform variables recorded for population.

Parameters:population (str) – name of the population.
Returns:names of the datasets storing uniform variables.
Return type:list of str
license

License information about the file. This is text string.

method

(numerical) methods applied in generating the data.

nonuniform_populations

Names of the populations for which variables have been recorded with nonuniform sampling.

rights

The rights of the file contents.

software

Software (one or more) used to generate the data in the file.

tend

End time of the simulation/recording.

title

Title of the file

tstart

Start time of the simulation / data recording. A string representation of the timestamp in ISO format

uniform_populations

Names of the populations for which variables have been recorded with uniform sampling.