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.
- 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: list of str: names of the groups storing event variables.
- 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: list of str: names of the groups storing nonuniform variables.
- 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, data): 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.
- 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, unit) : dt is the sampling interval for this dataset and unit is a string representing the unit of time.
- 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, unit) : 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.
- get_uniform_vars(population)[source]¶
Returns the names of uniform variables recorded for population.
Parameters: population (str) – name of the population. Returns: list of str: names of the datasets storing uniform variables.
- nonuniform_populations[source]¶
Names of the populations for which variables have been recorded with nonuniform sampling.