Internal API
Subpackages
- nixio.cmd package
- nixio.exceptions package
- nixio.hdf5 package
- Submodules
- nixio.hdf5.h5dataset module
- nixio.hdf5.h5group module
H5Group
H5Group.copy()
H5Group.create_dataset()
H5Group.create_from_h5obj()
H5Group.create_link()
H5Group.delete()
H5Group.delete_all()
H5Group.find_children()
H5Group.get_attr()
H5Group.get_by_id()
H5Group.get_by_id_or_name()
H5Group.get_by_name()
H5Group.get_by_pos()
H5Group.get_data()
H5Group.get_dataset()
H5Group.group
H5Group.has_by_id()
H5Group.has_data()
H5Group.open_group()
H5Group.parent
H5Group.set_attr()
H5Group.write_data()
- Module contents
- nixio.test package
- Subpackages
- Submodules
- nixio.test.test_block module
TestBlock
TestBlock.setUp()
TestBlock.tearDown()
TestBlock.test_block_data_arrays()
TestBlock.test_block_definition()
TestBlock.test_block_eq()
TestBlock.test_block_find_sources()
TestBlock.test_block_groups()
TestBlock.test_block_id()
TestBlock.test_block_multi_tags()
TestBlock.test_block_name()
TestBlock.test_block_sources()
TestBlock.test_block_tags()
TestBlock.test_block_timestamps()
TestBlock.test_block_type()
TestBlock.test_copy_on_block()
- nixio.test.test_compression module
- nixio.test.test_container module
TestContainer
TestContainer.setUp()
TestContainer.tearDown()
TestContainer.test_bad_appends()
TestContainer.test_delete_links_da()
TestContainer.test_delete_links_multitag()
TestContainer.test_delete_links_references()
TestContainer.test_delete_links_section_link()
TestContainer.test_delete_links_sections()
TestContainer.test_delete_links_sources()
TestContainer.test_delete_links_tag()
TestContainer.test_delete_links_tag_features()
TestContainer.test_file_references()
TestContainer.test_index_getter()
TestContainer.test_link_container_index_getter()
TestContainer.test_link_container_name_getter()
TestContainer.test_link_parent_references()
TestContainer.test_name_getter()
TestContainer.test_parent_references()
- nixio.test.test_data_array module
TestDataArray
TestDataArray.setUp()
TestDataArray.tearDown()
TestDataArray.test_array_unicode()
TestDataArray.test_data_array_coefficients()
TestDataArray.test_data_array_data()
TestDataArray.test_data_array_definition()
TestDataArray.test_data_array_dimensions()
TestDataArray.test_data_array_dtype()
TestDataArray.test_data_array_eq()
TestDataArray.test_data_array_exp_origin()
TestDataArray.test_data_array_id()
TestDataArray.test_data_array_indexing()
TestDataArray.test_data_array_label()
TestDataArray.test_data_array_multi_slicing()
TestDataArray.test_data_array_name()
TestDataArray.test_data_array_numpy_indexing()
TestDataArray.test_data_array_sources()
TestDataArray.test_data_array_timestamps()
TestDataArray.test_data_array_type()
TestDataArray.test_data_array_unit()
TestDataArray.test_data_deletion()
TestDataArray.test_dim_one_based()
TestDataArray.test_get_slice()
TestDataArray.test_outofbounds_indexing()
TestDataArray.test_single_value_retrieval()
TestDataArray.test_timestamp_autoupdate()
TestDataArray.test_timestamp_noautoupdate()
- nixio.test.test_data_frame module
TestDataFrame
TestDataFrame.setUp()
TestDataFrame.tearDown()
TestDataFrame.test_append_column()
TestDataFrame.test_append_rows()
TestDataFrame.test_column_name_collision()
TestDataFrame.test_create_with_list()
TestDataFrame.test_create_without_dtypes()
TestDataFrame.test_data_frame_eq()
TestDataFrame.test_data_frame_type()
TestDataFrame.test_data_type()
TestDataFrame.test_df_shape()
TestDataFrame.test_index_column_by_name()
TestDataFrame.test_read_cell()
TestDataFrame.test_read_column()
TestDataFrame.test_read_row()
TestDataFrame.test_timestamp_autoupdate()
TestDataFrame.test_timestamp_noautoupdate()
TestDataFrame.test_unit()
TestDataFrame.test_write_cell()
TestDataFrame.test_write_column()
TestDataFrame.test_write_row()
- nixio.test.test_data_view module
TestDataView
TestDataView.setUp()
TestDataView.tearDown()
TestDataView.test_data_view_ellipsis()
TestDataView.test_data_view_fancy_slicing()
TestDataView.test_data_view_oob()
TestDataView.test_data_view_read()
TestDataView.test_data_view_read_2d_str_array()
TestDataView.test_data_view_write_direct()
TestDataView.test_data_view_write_index()
- nixio.test.test_dimensions module
TestDimension
TestDimension.setUp()
TestDimension.tearDown()
TestDimension.test_append_dim_init()
TestDimension.test_range_dim_ticks_resize()
TestDimension.test_range_dimension()
TestDimension.test_range_dimension_modes()
TestDimension.test_sample_dimension()
TestDimension.test_sampled_dimension_modes()
TestDimension.test_set_dim_invalid_labels()
TestDimension.test_set_dim_label_resize()
TestDimension.test_set_dim_labels_array()
TestDimension.test_set_dimension()
TestDimension.test_set_dimension_modes()
TestLinkDimension
TestLinkDimension.setUp()
TestLinkDimension.tearDown()
TestLinkDimension.test_data_array_linking_errors()
TestLinkDimension.test_data_array_range_link_dimension()
TestLinkDimension.test_data_array_self_link_range_dimension()
TestLinkDimension.test_data_array_self_link_set_dimension()
TestLinkDimension.test_data_array_set_link_dimension()
TestLinkDimension.test_data_frame_linking_errors()
TestLinkDimension.test_data_frame_range_link_dimension()
TestLinkDimension.test_data_frame_set_link_dimension()
TestLinkDimension.test_range_link_tick_replacement()
TestLinkDimension.test_sampled_dimension_unsupported()
TestLinkDimension.test_write_linked_array_props()
TestLinkDimension.test_write_linked_dataframe_props()
- nixio.test.test_feature module
TestFeatures
TestFeatures.setUp()
TestFeatures.tearDown()
TestFeatures.test_create_diff_link_type_style()
TestFeatures.test_feature_data()
TestFeatures.test_feature_dataframe()
TestFeatures.test_feature_eq()
TestFeatures.test_feature_id()
TestFeatures.test_feature_link_type()
TestFeatures.test_feature_on_group()
TestFeatures.test_timestamp_autoupdate()
TestFeatures.test_timestamp_noautoupdate()
- nixio.test.test_file module
TestFile
TestFile.setUp()
TestFile.tearDown()
TestFile.test_context_open()
TestFile.test_copy_on_file()
TestFile.test_file_blocks()
TestFile.test_file_find_sections()
TestFile.test_file_format()
TestFile.test_file_sections()
TestFile.test_file_timestamps()
TestFile.test_order_tracking()
TestFile.test_timestamp_autoupdate()
TestFile.test_timestamp_noautoupdate()
TestFileVer
TestFileVer.backend
TestFileVer.fformat
TestFileVer.filever
TestFileVer.setUp()
TestFileVer.set_header()
TestFileVer.tearDown()
TestFileVer.test_bad_format()
TestFileVer.test_bad_id()
TestFileVer.test_bad_tuple()
TestFileVer.test_no_open()
TestFileVer.test_read_only()
TestFileVer.test_read_write()
TestFileVer.try_open()
- nixio.test.test_group module
TestGroups
TestGroups.setUp()
TestGroups.tearDown()
TestGroups.test_group_data_arrays()
TestGroups.test_group_definition()
TestGroups.test_group_eq()
TestGroups.test_group_get_by_name()
TestGroups.test_group_id()
TestGroups.test_group_invalid_add()
TestGroups.test_group_multi_tags()
TestGroups.test_group_name()
TestGroups.test_group_tags()
TestGroups.test_group_timestamps()
TestGroups.test_group_type()
- nixio.test.test_multi_tag module
TestMultiTags
TestMultiTags.setUp()
TestMultiTags.tearDown()
TestMultiTags.test_multi_tag_data_coefficients()
TestMultiTags.test_multi_tag_definition()
TestMultiTags.test_multi_tag_eq()
TestMultiTags.test_multi_tag_extents()
TestMultiTags.test_multi_tag_feature_data()
TestMultiTags.test_multi_tag_feature_dataframe()
TestMultiTags.test_multi_tag_features()
TestMultiTags.test_multi_tag_flex()
TestMultiTags.test_multi_tag_id()
TestMultiTags.test_multi_tag_name()
TestMultiTags.test_multi_tag_new_constructor()
TestMultiTags.test_multi_tag_positions()
TestMultiTags.test_multi_tag_references()
TestMultiTags.test_multi_tag_tagged_data()
TestMultiTags.test_multi_tag_tagged_data_1d()
TestMultiTags.test_multi_tag_tagged_data_slice_mode()
TestMultiTags.test_multi_tag_timestamps()
TestMultiTags.test_multi_tag_type()
TestMultiTags.test_multi_tag_units()
TestMultiTags.test_tagged_range_dim()
TestMultiTags.test_tagged_sampled_dim()
TestMultiTags.test_tagged_set_dim()
TestMultiTags.test_timestamp_autoupdate()
TestMultiTags.test_timestamp_noautoupdate()
- nixio.test.test_nix_compatibility module
check_block_children_counts()
check_group_children_counts()
compare()
runcpp()
test_blocks()
test_data_arrays()
test_data_frames()
test_full_file_read()
test_full_file_write()
test_full_write()
test_groups()
test_multi_tag_features()
test_multi_tag_references()
test_multi_tags()
test_properties()
test_sections()
test_tags()
validate()
- nixio.test.test_property module
TestProperties
TestProperties.setUp()
TestProperties.tearDown()
TestProperties.test_empties()
TestProperties.test_extend_values()
TestProperties.test_property_definition()
TestProperties.test_property_dependency()
TestProperties.test_property_dependency_value()
TestProperties.test_property_eq()
TestProperties.test_property_id()
TestProperties.test_property_name()
TestProperties.test_property_reference()
TestProperties.test_property_uncertainty()
TestProperties.test_property_unit()
TestProperties.test_property_value_origin()
TestProperties.test_property_values()
TestProperties.test_unicode_values()
- nixio.test.test_section module
TestSections
TestSections.setUp()
TestSections.tearDown()
TestSections.test_copy_on_sections()
TestSections.test_inverse_search()
TestSections.test_parent()
TestSections.test_property_reference()
TestSections.test_section_definition()
TestSections.test_section_eq()
TestSections.test_section_find_sections()
TestSections.test_section_id()
TestSections.test_section_link()
TestSections.test_section_name()
TestSections.test_section_properties()
TestSections.test_section_repository()
TestSections.test_section_sections()
TestSections.test_section_type()
TestSections.test_timestamp_autoupdate()
TestSections.test_timestamp_noautoupdate()
- nixio.test.test_source module
TestSources
TestSources.setUp()
TestSources.tearDown()
TestSources.test_deep_linking()
TestSources.test_inverse_search()
TestSources.test_parent_source()
TestSources.test_referring_objects()
TestSources.test_source_definition()
TestSources.test_source_eq()
TestSources.test_source_find_sources()
TestSources.test_source_id()
TestSources.test_source_name()
TestSources.test_source_sources()
TestSources.test_source_timestamps()
TestSources.test_source_type()
TestSources.test_sources_extend()
- nixio.test.test_tag module
TestTags
TestTags.setUp()
TestTags.tearDown()
TestTags.test_flex()
TestTags.test_tag_definition()
TestTags.test_tag_eq()
TestTags.test_tag_extent()
TestTags.test_tag_feature_data()
TestTags.test_tag_feature_dataframe()
TestTags.test_tag_features()
TestTags.test_tag_id()
TestTags.test_tag_name()
TestTags.test_tag_position()
TestTags.test_tag_references()
TestTags.test_tag_tagged_data()
TestTags.test_tag_tagged_data_slice_mode()
TestTags.test_tag_timestamps()
TestTags.test_tag_type()
TestTags.test_tag_units()
TestTags.test_tagged_range_dim()
TestTags.test_tagged_sampled_dim()
TestTags.test_tagged_set_dim()
TestTags.test_timestamp_autoupdate()
TestTags.test_timestamp_noautoupdate()
- nixio.test.test_util module
TestUtil
TestUtil.setUp()
TestUtil.tearDown()
TestUtil.test_name_check()
TestUtil.test_name_sanitizer()
TestUtil.test_unit_is_atomic()
TestUtil.test_unit_is_compound()
TestUtil.test_unit_is_si()
TestUtil.test_unit_sanitizer()
TestUtil.test_unit_scalable()
TestUtil.test_unit_scaling()
TestUtil.test_unit_split()
TestUtil.test_unit_split_compound()
- nixio.test.test_validator module
TestValidate
TestValidate.print_all_results()
TestValidate.setUp()
TestValidate.tearDown()
TestValidate.test_all_valid()
TestValidate.test_check_block()
TestValidate.test_check_data_array_bad_dims()
TestValidate.test_check_data_array_coefficients()
TestValidate.test_check_data_array_invalid_unit()
TestValidate.test_check_data_array_wrong_labels()
TestValidate.test_check_data_array_wrong_ticks()
TestValidate.test_check_file()
TestValidate.test_check_group()
TestValidate.test_check_multi_tag_invalid_unit()
TestValidate.test_check_multi_tag_mismatch_dim()
TestValidate.test_check_multi_tag_mismatch_units()
TestValidate.test_check_multi_tag_no_pos()
TestValidate.test_check_multi_tag_pos_ext_mismatch()
TestValidate.test_check_property()
TestValidate.test_check_range_dim_invalid_unit()
TestValidate.test_check_range_dim_no_ticks()
TestValidate.test_check_range_dim_unsorted_ticks()
TestValidate.test_check_sampled_dim_bad_interval()
TestValidate.test_check_sampled_dim_bad_unit()
TestValidate.test_check_sampled_dim_no_interval()
TestValidate.test_check_sampled_dim_no_unit()
TestValidate.test_check_section()
TestValidate.test_check_source()
TestValidate.test_check_tag_invalid_unit()
TestValidate.test_check_tag_mismatch_dim()
TestValidate.test_check_tag_mismatch_units()
TestValidate.test_check_tag_no_pos()
TestValidate.test_check_tag_pos_ext_mismatch()
TestValidate.test_incorrect_dim_index()
TestValidate.test_invalid_dim_index()
- nixio.test.tmp module
- Module contents
- nixio.util package
Submodules
nixio.block module
- class nixio.block.Block(nixfile, nixparent, h5group, compression=Compression.Auto)
Bases:
Entity
- create_data_array(name='', array_type='', dtype=None, shape=None, data=None, compression=Compression.Auto, copy_from=None, keep_copy_id=True, label=None, unit=None)
Create/copy a new data array for this block. Either
shape
ordata
must be given. If both are given their shape must agree. Ifdtype
is not specified it will default to 64-bit floating points.- Parameters:
name (str) – The name of the data array to create/copy.
array_type (str) – The type of the data array.
dtype (
numpy.dtype
) – Which data-type to use for storageshape (tuple of int or long) – Layout (dimensionality and extent)
data (array-like data) – Data to write after storage has been created
compression (
Compression
) – En-/disable dataset compression.copy_from (nixio.DataArray) – The DataArray to be copied, None in normal mode
keep_copy_id (bool) – Specify if the id should be copied in copy mode
label (str) – The label, defaults to None.
unit (str) – The unit of the stored data. Defaults to None.
- Returns:
The newly created data array.
- Return type:
- create_data_frame(name='', type_='', col_dict=None, col_names=None, col_dtypes=None, data=None, compression=Compression.No, copy_from=None, keep_copy_id=True)
Create/copy a new data frame for this block. Either
col_dict
orcol_name
andcol_dtypes
must be given. If both are given,col_dict
will be used.- Parameters:
name (str) – The name of the data frame to create/copy.
type (str) – The type of the data frame.
col_dict (dict or OrderedDict of {str: type}) – The dictionary that specifies column names and data type in each column
col_names (tuples or list or np.array of string) – The collection of name of all columns in order
col_dtypes (tuples or list or np.array of type) – The collection of data type of all columns in order
data (array-like data with compound data type as specified in the columns) – Data to write after storage has been created
compression (
Compression
) – En-/disable dataset compression.copy_from (nixio.DataFrame) – The DataFrame to be copied, None in normal mode
keep_copy_id (bool) – Specify if the id should be copied in copy mode
- Returns:
The newly created data frame.
- Return type:
- create_group(name, type_)
Create a new group on this block.
- Parameters:
name (str) – The name of the group to create.
type (str) – The type of the group.
- Returns:
The newly created group.
- Return type:
- create_multi_tag(name='', type_='', positions=None, extents=None, copy_from=None, keep_copy_id=True)
Create/copy a new multi tag for this block.
- Parameters:
name (str) – The name of the tag to create/copy.
type (str) – The type of tag.
positions (nixio.DataArray) – A data array defining all positions of the tag.
copy_from (nixio.MultiTag) – The MultiTag to be copied, None in normal mode
keep_copy_id (bool) – Specify if the id should be copied in copy mode
- Returns:
The newly created tag.
- Return type:
- classmethod create_new(nixparent, h5parent, name, type_, compression)
- create_source(name, type_)
Create a new source on this block.
- Parameters:
name (str) – The name of the source to create.
type (str) – The type of the source.
- Returns:
The newly created source.
- Return type:
- create_tag(name='', type_='', position=0, copy_from=None, keep_copy_id=True)
Create/copy a new tag for this block.
- Parameters:
name (str) – The name of the tag to create/copy.
type (str) – The type of tag.
position – Coordinates of the start position in units of the respective data dimension.
copy_from (nixio.Tag) – The Tag to be copied, None in normal mode
keep_copy_id (bool) – Specify if the id should be copied in copy mode
- Returns:
The newly created tag.
- Return type:
- property data_arrays
A property containing all data arrays of a block. DataArray entities can be obtained via their index or by their id. Data arrays can be deleted from the list. Adding a data array is done using the Blocks create_data_array method. This is a read only attribute.
- property data_frames
- find_sources(filtr=<function Block.<lambda>>, limit=None)
Get all sources in this block recursively.
This method traverses the tree of all sources in the block. The traversal is accomplished via breadth first and can be limited in depth. On each node or source a filter is applied. If the filter returns true the respective source will be added to the result list. By default a filter is used that accepts all sources.
- Parameters:
filtr (function) – A filter function
limit (int) – The maximum depth of traversal
- Returns:
A list containing the matching sources.
- Return type:
list of nixio.Source
- property groups
A property containing all groups of a block. Group entities can be obtained via their index or by their id. Groups can be deleted from the list. Adding a Group is done using the Blocks create_group method. This is a read only attribute.
- property metadata
Associated metadata of the entity. Sections attached to the entity via this attribute can provide additional annotations. This is an optional read-write property, and can be None if no metadata is available.
- Type:
- property multi_tags
A property containing all multi tags of a block. MultiTag entities can be obtained via their index or by their id. Tags can be deleted from the list. Adding tags is done using the Blocks create_multi_tag method. This is a read only attribute.
- pprint(indent=2, max_length=120, extra=True, start_depth=0)
Pretty Printing the Data and MetaData Tree of the whole File
- Parameters:
indent (int) – The length of one indentation space
max_length (int) – Maximum length of each line of output
extra (bool) – True to print extra information of Entities
start_depth (int) – Starting depth of indentation
- property sources
A property containing all sources of a block. Sources can be obtained via their index or by their id. Sources can be deleted from the list. Adding sources is done using the Blocks create_source method. This is a read only attribute.
- property tags
A property containing all tags of a block. Tag entities can be obtained via their index or by their id. Tags can be deleted from the list. Adding tags is done using the Blocks create_tag method. This is a read only attribute.
nixio.compression module
nixio.container module
- class nixio.container.Container(name, nixfile, parent, itemclass)
Bases:
object
Container acts as an interface to container groups in the backend. In the case of HDF5, this is a group that is used as a container for other groups.
- Examples of Containers:
Block.data_arrays Block.tags Block.multi_tags Source.sources
- Parameters:
name – Name of the container
parent – Parent NIX object where this container will be created
itemclass – The class of the objects this container holds (for
checking and instantiations)
- items()
- class nixio.container.LinkContainer(name, parent, itemclass, itemstore)
Bases:
Container
A LinkContainer acts as an interface to container groups in the backend that hold links to objects already contained in a Container.
Objects are added to a LinkContainer using the ‘append’ method, as opposed to Containers which get populated by the parent object ‘create’ methods.
An important difference between a LinkContainer and a Container is that links to objects are indexed by their ‘id’ whereas objects in Containers are indexed by ‘name’.
- Examples of LinkContainers:
Group.data_arrays Group.tags Group.multi_tags
- Parameters:
name – Name of the container
parent – Parent H5Group where this container will be created
itemclass – The class of the objects this container holds (for checking and instantiations)
itemstore – The location (Container) where the original objects are stored and linked to.
- append(item)
- extend(items)
nixio.data_array module
- class nixio.data_array.DataArray(nixfile, nixparent, h5group)
-
- append_range_dimension(ticks=None, label=None, unit=None)
Append a new RangeDimension to the list of existing dimension descriptors.
- Parameters:
ticks (list of float) – The ticks of the RangeDimension to create.
label (str) – The label of the dimension
unit (str) – The physical unit of the dimension
- Returns:
The newly created RangeDimension.
- Return type:
- append_range_dimension_using_self(index=None)
Convenience function to append a new RangeDimension to the list of existing dimensions that uses the DataArray itself as provider for the ticks. This is a replacement for rdim = array.append_range_dimension() rdim.link_data_array(self, index)
- Parameters:
index – The slice of the DataArray that contains the tick values. This must be a vector of the data. Defaults to [-1], i.e. the full first dimension.
- Type:
list of int
- Returns:
the newly created nixio.RangeDimension
- Return type:
- append_sampled_dimension(sampling_interval, label=None, unit=None, offset=None)
Append a new SampledDimension to the list of existing dimension descriptors.
- Parameters:
sampling_interval (float) – The sampling interval of the SetDimension to create.
label (str) – The label of the dimension
unit (str) – The physical unit of the dimension
offset (float) – The offset between 0 and the first sample
- Returns:
The newly created SampledDimension.
- Return type:
- append_set_dimension(labels=None)
Append a new SetDimension to the list of existing dimension descriptors.
- Parameters:
labels (list or convertible to list) – The set of sample labels
- Returns:
The newly created SetDimension.
- Return type:
- classmethod create_new(nixfile, nixparent, h5parent, name, type_, data_type, shape, compression)
- delete_dimensions()
Delete all the dimension descriptors for this DataArray.
- property dimensions
A property containing all dimensions of a DataArray. Dimensions can be obtained via their index. Adding dimensions is done using the respective append methods for dimension descriptors. This is a read only attribute.
- Type:
Container of dimension descriptors.
- property dtype
The data type of the data stored in the DataArray. This is a read only property.
- Returns:
The data type
- Return type:
- property expansion_origin
The expansion origin of the calibration polynomial. This is a read-write property and can be set to None. The default value is 0.
- Type:
float
- get_slice(positions, extents=None, mode=DataSliceMode.Index)
Reads a slice of the data. The slice can be specified either in indices or in data coordinates. For example, if the DataArray stores 1D data spanning one second in time sampled with 1kHz (1000 data points). If one wants to read the data of the interval 0.25 to 0.5 seconds, one can use either of the following statements:
- ```
interval_data = data_array.get_slice([250], [500], mode=DataSliceMode.Index)[:] interval_data = data_array.get_slice([0.25],[0.25], mode=DataSliceMode.Data)[:]
Note: The extents are not the end positions but the extent of the slice! In the case of regularly sampled dimensions, reaching beyond the start of end of the respective dimension will cause an exception. For irregularly sampled data no exception will be raised but the returned DataView might be invalid and empty.
- Parameters:
positions (list length must match dimensionality of the data.) – Specifies the start of the data slice. List of either indices or data positions depending on the DataSliceMode.
extents (list, defaults to None) – Specifies the extents of the slice for each dimension.
mode (nixio.DataSliceMode) – Specifies how positions and extents are interpreted, they are either treated as indices (DataSliceMode.Index) or as positions in data coordinates (DataSliceMode.Data), Defaults to nixio.DataSliceMode.Index.
- Raises:
nixio.IncompatibleDimensions: if length of positions or, if given, extents does not match the rank of the data.
- Raises:
ValueError: if an invalid slice mode is given
- Returns:
A nixio.DataView object
- Return type:
nixio.DataView
- iter_dimensions()
1-based index dimension iterator. The method returns a generator which returns the index starting from one and the dimensions.
- property label
The label of the DataArray. The label corresponds to the label of the x-axis of a plot. This is a read-write property and can be set to None.
- Type:
str
- property metadata
Associated metadata of the entity. Sections attached to the entity via this attribute can provide additional annotations. This is an optional read-write property, and can be None if no metadata is available.
- Type:
- property polynom_coefficients
The polynomial coefficients for the calibration. By default this is set to a {0.0, 1.0} for a linear calibration with zero offset. This is a read-write property and can be set to None
- Return type:
list of float
- property sources
A property containing all Sources referenced by the DataArray. Sources can be obtained by index or their id. Sources can be removed from the list, but removing a referenced Source will not remove it from the file. New Sources can be added using the append method of the list. This is a read only attribute.
- property unit
The unit of the values stored in the DataArray. This is a read-write property and can be set to None.
- Type:
str
nixio.data_frame module
- class nixio.data_frame.DataFrame(nixfile, nixparent, h5group)
-
- append_column(column, name, datatype=None)
Append a new column to the DataFrame In case of string, it will be better to set explicitly the datatype.
- Parameters:
column (array-like data) – The new column
name (str) – The name of new column
datatype (nixio.DataType) – The DataType of new column
- append_rows(data)
Append a new row to the DataFrame. The data supplied must be iterable.
- Parameters:
data (array-like data) – The new row
- property column_names
The dtype is the list of names of all columns in the DatFrame. This is a read only property.
- Type:
list of str
- property columns
The dtype is the list of names and data types of all columns in the DatFrame. This is a read only property.
- Type:
list of tuples
- classmethod create_new(nixfile, nixparent, h5parent, name, type_, shape, col_dtype, compression)
- property df_shape
The df_shape is the shape of the DataFrame in (number of rows, number of columns) format. This is a read only property.
- Type:
tuple
- property dtype
The dtype is the list of DataTypes of all columns in the DatFrame. This is a read only property.
- Type:
list of DataType
- property metadata
Associated metadata of the entity. Sections attached to the entity via this attribute can provide additional annotations. This is an optional read-write property, and can be None if no metadata is available.
- Type:
- print_table(row_sl=None, col_sl=None)
Print the whole DataFrame as a table
- Parameters:
row_sl (slice or iterable of int) – Rows to be printed; None for printing all rows
col_sl (slice or iterable of int) – Columns to be printed; None for printing all columns
- read_cell(position=None, col_name=None, row_idx=None)
Read a cell in the DataFrame
- Parameters:
position (tuple or list or array with length 2) – Position of the targeted cell
col_name (str) – The column name in which the targeted cell belongs to
row_idx (list of int) – A length 1 list that specify on which row the targeted cell is located
- read_columns(index=None, name=None, slc=None, group_by_cols=False)
Read one or multiple (part of) column(s) in the DataFrame
- Parameters:
index (list of int) – Index of column(s) to be returned
name (list of str) – Name of column(s) to be returned
slc (slice) – The part of each column to be returned
group_by_cols (bool) – True for group return values by columns, False for group by rows. Only applicable for reading multiple columns
- read_rows(index)
Read one or multiple row(s) in the DataFrame
- Parameters:
index (list of int) – Index of row(s) to be returned
- row_count()
Return the total number of rows
- property units
The unit of the values stored in the DataFrame. This is a read-write property and can be set to None.
- Type:
array of str
- write_cell(cell, position=None, col_name=None, row_idx=None)
Overwrite a cell in the DataFrame
- Parameters:
cell (same type as the specified column) – The new cell
position (tuple or list or array with length 2) – Position of the targeted cell
col_name (str) – The column name in which the targeted cell belongs to
row_idx (list of int) – A length 1 list that specify on which row the targeted cell is located
- write_column(column, index=None, name=None)
Overwrite an existing column. Either index or name of the column should be provided.
- Parameters:
column (array-like data) – The new column
index (string) – The index of the column that is written to
name (str) – The name of the column that is written to
- write_rows(rows, index)
Overwrite one or multiple existing row(s)
- Parameters:
rows ((nested) array-like data) – The new rows(s) and their data
index (list of int) – Index of rows(s) to be overwritten
- write_to_csv(filename, mode='w')
Export the whole DataFrame to a CSV file
- Parameters:
filename (str) – The resulted/ targeted CSV file to write to/ create
mode (str) – The column name in which the targeted cell belongs to
nixio.data_set module
- class nixio.data_set.DataSet
Bases:
object
Data IO object for DataArray.
- append(data, axis=0)
Append
data
to the DataSet along theaxis
specified.- Parameters:
data – The data to append. Shape must agree except for the specified axis
axis – Along which axis to append the data to
- property data_extent
The size of the data.
- Type:
tuple of int
- property data_type
The data type of the data stored in the DataArray. This is a read only property.
- Type:
- property dtype
- Type:
numpy.dtype
object holding type information about the data stored in the DataSet.
- len()
Length of the first dimension. Equivalent to DataSet.shape[0].
- Type:
int or long
- read_direct(data)
Directly read all data stored in the
DataSet
intodata
. The supplied data must be anumpy.ndarray
that matches the DataSet’s shape, must have C-style contiguous memory layout and must be writeable (seenumpy.ndarray.flags
andndarray
for more information).- Parameters:
data (
numpy.ndarray
) – The array where data is being read into
- property shape
- Type:
tuple of data array dimensions.
- property size
Number of elements in the DataSet, i.e. the product of the elements in
shape
.- Type:
int
- write_direct(data)
Directly write all of
data
to theDataSet
. The supplied data must be anumpy.ndarray
that matches the DataSet’s shape and must have C-style contiguous memory layout (seenumpy.ndarray.flags
andndarray
for more information).- Parameters:
data (
numpy.ndarray
) – The array which contents is being written
nixio.data_view module
nixio.datatype module
- class nixio.datatype.DataType
Bases:
object
- Bool
alias of
bool_
- Double
alias of
float64
- Float
alias of
float32
- FloatTypes = (<class 'numpy.float32'>, <class 'numpy.float64'>)
- Int16
alias of
int16
- Int32
alias of
int32
- Int64
alias of
int64
- Int8
alias of
int8
- IntTypes = (<class 'numpy.int8'>, <class 'numpy.int16'>, <class 'numpy.int32'>, <class 'numpy.int64'>, <class 'numpy.uint8'>, <class 'numpy.uint16'>, <class 'numpy.uint32'>, <class 'numpy.uint64'>)
- String
alias of
str_
- UInt16
alias of
uint16
- UInt32
alias of
uint32
- UInt64
alias of
uint64
- UInt8
alias of
uint8
- classmethod get_dtype(value)
- classmethod is_numeric_dtype(dtype)
nixio.dimension_type module
nixio.dimensions module
- class nixio.dimensions.Dimension(nixfile, data_array, index)
Bases:
object
- property dimension_link
If the dimension has a DimensionLink to a data object, returns the DimensionLink object, otherwise returns None.
- property dimension_type
- property has_link
Return True if this Dimension links to a data object (DataArray or DataFrame). Read-only property.
- property index
- property label
- link_data_array(data_array, index)
- link_data_frame(data_frame, index)
- remove_link()
- class nixio.dimensions.DimensionContainer(name, nixfile, parent, itemclass)
Bases:
Container
DimensionContainer extends Container to support returning different types of Dimension classes on return.
- class nixio.dimensions.DimensionLink(nixfile, nixparent, h5group)
Bases:
object
Links a Dimension to a data object (DataArray or DataFrame).
A single vector of values from the underlying data object must be specified to serve as the ticks or labels for the associated Dimension.
A single vector of a DataArray.
A single column of a DataFrame.
- classmethod create_new(nixfile, nixparent, h5parent, dataobj, dotype, index)
- property file
- property id
- property index
- property label
Returns the label of the linked data object: For DataArray links, returns the label. For DataFrame links, returns the name of the column specified by the LinkDimension’s index.
- property linked_data
- property unit
Returns the unit from the linked data object (DataArray or DataFrame) specified by the LinkDimension’s index.
- property values
Returns the values (vector or column) from the linked data object (DataArray or DataFrame) specified by the LinkDimension’s index.
- class nixio.dimensions.IndexMode(value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None)
Bases:
Enum
IndexMode is used to define the behaviour of the index_of() methods.
- GEQ = 'geq'
- GreaterOrEqual = 'geq'
- LEQ = 'leq'
- Less = 'less'
- LessOrEqual = 'leq'
- class nixio.dimensions.RangeDimension(data_array, index)
Bases:
Dimension
- axis(count, start=0)
Get an axis as defined by this range dimension.
- Parameters:
count – A positive integer specifying the length of the axis (no of points).
start – positive integer, indicates the starting tick.
- Returns:
The created axis
- Return type:
list
- classmethod create_new(data_array, index, ticks)
- index_of(position, mode=IndexMode.LessOrEqual, ticks=None)
Returns the index of a certain position in the dimension. Raises IndexError if the position is out of bounds (depending on mode).
- Parameters:
position – The position.
mode – The IndexMode to use (default LessOrEqual). The default value (LessOrEqual) will return the index of the position that matches a tick if it matches a dimension tick exactly. If it does not match a tick, the previous index is returned. If the mode is Less, the previous index of the matching tick is always returned. If the mode is GreaterOrEqual and the position does not match a tick exactly, the next index is returned.
ticks (iterable) – Optional, the ticks stored in this dimension. If not passed as argument, they are (re)read from file.
- Returns:
The matching index
- Return type:
int
- property is_alias
In versions < 1.5 a RangeDimension that was referring to the DataArray it describes was called an AliasRangeDimension. This has been made more flexible by allowing to link to any DataArray or DataFrame. For downward compatibility this method has been re-introduced in 1.5.1.
- Returns:
True, if this dimension links to a DataArray, False otherwise
- Return type:
bool
- property label
- link_data_array(data_array, index)
- link_data_frame(data_frame, index)
- range_indices(start_position, end_position, mode=SliceMode.Exclusive)
Returns the start and end indices in this dimension that are matching to the given start and end position.
- Parameters:
start_position (float) – the start position of the range.
end_position (float) – the end position of the range.
mode (nixio.SliceMode) – The nixio.SliceMode. Defaults to nixio.SliceMode.Exclusive, i.e. the end position is not part of the range.
- Returns:
The respective start and end indices. None, if range is empty
- Return type:
tuple of int
- Raises:
ValueError if invalid mode is given
- Raises:
Index Error if start position is greater than end position.
- tick_at(index)
Returns the tick at the given index. Will throw an Exception if the index is out of bounds.
- Parameters:
index – The index.
- Returns:
The corresponding position.
- Return type:
double
- property ticks
- property unit
- class nixio.dimensions.SampledDimension(data_array, index)
Bases:
Dimension
- axis(count, start=None, start_position=None)
Get an axis as defined by this nixio.SampledDimension. It either starts at the offset of the dimension, a number of sample points later, or at a given position. The latter must not be less than the offset. If start and start_position are given, start takes precedence.
- Parameters:
count (int) – A positive integer specifying the length of the axis (no of samples).
start (int) – positive integer, indicates the starting sample. Defaults to None. Precedes over the start_position.
start_position (double) – The start position of the axis. Defaults to None.
- Raises:
ValueError if start is negative or if the start_position is given and is less than offset.
- Returns:
The created axis
- Return type:
tuple
- classmethod create_new(data_array, index, sample)
- index_of(position, mode=IndexMode.LessOrEqual)
Returns the index of a certain position in the dimension. Raises IndexError if the position is out of bounds (depending on mode).
- Parameters:
position – The position.
mode – The IndexMode to use (default LessOrEqual). The default value (LessOrEqual) will return the index of the position calculated based on the dimension offset and sampling_interval if it matches a dimension tick exactly. If it does not match a tick, the previous index is returned. If the mode is Less, the previous index of the calculated position is always returned. If the mode is GreaterOrEqual and the calculated position does not match a tick exactly, the next index is returned.
- Returns:
The matching index.
- Return type:
int
- link_data_array(*_)
- link_data_frame(*_)
- property offset
- position_at(index)
Returns the position corresponding to a given index.
- Parameters:
index – A positive integer.
- Returns:
The position matching to the index.
- Return type:
float
- range_indices(start_position, end_position, mode=SliceMode.Exclusive)
Returns the start and end indices in this dimension that are matching to the given start and end position.
- Parameters:
start_position (float) – the start position of the range.
end_position (float) – the end position of the range.
mode (nixio.SliceMode) – The nixio.SliceMode. Defaults to nixio.SliceMode.Exclusive, i.e. the end position is not part of the range.
- Returns:
The respective start and end indices. None, if the range is empty!
- Return type:
tuple of int
- Raises:
ValueError if invalid mode is given
- Raises:
Index Error if start position is greater than end position.
- property sampling_interval
- property unit
- class nixio.dimensions.SetDimension(data_array, index)
Bases:
Dimension
- classmethod create_new(data_array, index)
- index_of(position, mode=IndexMode.LessOrEqual, dim_labels=None)
Returns the index of a certain position in the dimension. Raises IndexError if the position is out of bounds (depending on mode and number of labels).
- Parameters:
position – The position.
mode – The IndexMode to use (default LessOrEqual). The modes LessOrEqual and GreaterOrEqual will return the integer representation of the position if it is equal to the nearest integer. If the position is not an integer (or is not equal to the nearest integer), then the value is rounded down (for LessOrEqual) or rounded up (for GreaterOrEqual). If the mode is Less, the previous integer is always returned.
dim_labels (iterable) – The labels of this dimension, if None (default) the labels will be read from file.
- Returns:
The matching index
- Return type:
int
- property labels
- range_indices(start_position, end_position, mode=SliceMode.Exclusive)
Returns the start and end indices in this dimension that are matching to the given start and end position.
- Parameters:
start_position (float) – the start position of the range.
end_position (float) – the end position of the range.
mode (nixio.SliceMode) – The nixio.SliceMode. Defaults to nixio.SliceMode.Exclusive, i.e. the end position is not part of the range.
- Returns:
The respective start and end indices. None, if the range is empty
- Return type:
tuple of int
- Raises:
ValueError if invalid mode is given
- Raises:
Index Error if start position is greater than end position.
nixio.entity module
- class nixio.entity.Entity(nixfile, nixparent, h5group)
Bases:
object
- classmethod create_new(nixfile, nixparent, h5parent, name=None, type_=None)
- property created_at
The creation time of the entity. This is a read-only property. Use force_created_at in order to change the creation time.
- Return type:
int
- property definition
The definition of the entity. The definition can contain a textual description of the entity. This is an optional read-write property, and can be None if no definition is available.
- Type:
str
- property file
Reference to the NIX File object. This is a read-only property.
- Return type:
- force_created_at(time=None)
Sets the creation time created_at to the given time (default: current time).
- Parameters:
time (int) – The time to set.
- force_updated_at(time=None)
Sets the update time updated_at to the given time. (default: current time)
- Parameters:
time (int) – The time to set.
- property id
A property providing the ID of the Entity. The id is generated automatically, therefore the property is read-only.
- Return type:
str
- property name
The name of an entity. The name serves as a human readable identifier. This is a read-only property; entities cannot be renamed.
- Type:
str
- property type
The type of the entity. The type is used in order to add semantic meaning to the entity. This is a read-write property, but it can’t be set to None.
- Type:
str
- property updated_at
The time of the last update of the entity. This is a read-only property. Use force_updated_at in order to change the update time.
- Return type:
int
nixio.feature module
- class nixio.feature.Feature(nixfile, nixparent, h5group)
Bases:
object
- classmethod create_new(nixfile, nixparent, h5parent, data, link_type)
- property created_at
The creation time of the entity. This is a read-only property. Use force_created_at in order to change the creation time.
- Return type:
int
- property data
- property file
- property id
- property link_type
- property updated_at
The time of the last update of the entity. This is a read-only property. Use force_updated_at in order to change the update time.
- Return type:
int
nixio.file module
- class nixio.file.File(path, mode='a', compression=Compression.Auto, auto_update_timestamps=True)
Bases:
object
- property auto_update_timestamps
If enabled, automatically updates the ‘updated_at’ attribute when an object’s data or attributes are changed.
- Type:
bool
- property blocks
A property containing all blocks of a file. Blocks can be obtained by their name, id or index. Blocks can be deleted from the list, when a block is deleted all its content (data arrays, tags and sources) will be also deleted from the file. Adding new Block is done via the create_block method of File. This is a read-only attribute.
- close()
Closes an open file.
- copy_section(obj, children=True, keep_id=True, name='')
Copy a section to the file.
- Parameters:
obj (nixio.Section) – The Section to be copied
children (bool) – Specify if the copy should be recursive
keep_id (bool) – Specify if the id should be kept
name (str) – Name of copied section, Default is name of source section
- Returns:
The copied section
- Return type:
- create_block(name='', type_='', compression=Compression.Auto, copy_from=None, keep_copy_id=True)
Create a new block inside the file.
- Parameters:
name (str) – The name of the block to create.
type (str) – The type of the block.
compression – No, DeflateNormal, Auto (default: Auto)
copy_from (nixio.Block) – The Block to be copied, None in normal mode
keep_copy_id (bool) – Specify if the id should be copied in copy mode
- Returns:
The newly created block.
- Return type:
- create_section(name, type_='undefined', oid=None)
Create a new metadata section inside the file.
- Parameters:
name (str) – The name of the section to create.
type (str) – The type of the section.
oid (str) – object id, UUID string as specified in RFC 4122. If no id is provided, an id will be generated and assigned.
- Returns:
The newly created section.
- Return type:
- property created_at
The creation time of the file. This is a read-only property. Use force_created_at in order to change the creation time.
- Return type:
int
- find_sections(filtr=<function File.<lambda>>, limit=None)
Get all sections and their child sections recursively.
This method traverses the trees of all sections. The traversal is accomplished via breadth first and can be limited in depth. On each node or section a filter is applied. If the filter returns true the respective section will be added to the result list. By default a filter is used that accepts all sections.
- Parameters:
filtr (function) – A filter function
limit (int) – The maximum depth of traversal
- Returns:
A list containing the matching sections.
- Return type:
list of nixio.Section
- flush()
- force_created_at(time=None)
Sets the creation time created_at to the given time (default: current time).
- Parameters:
time (int) – The time to set
- force_updated_at(time=None)
Sets the update time updated_at to the given time. (default: current time)
- Parameters:
time (int) – The time to set (default: now)
- property format
The format of the file. This read only property should always have the value ‘nix’.
- Type:
str
- property id
- is_open()
Checks whether a file is open or closed.
- Returns:
True if the file is open, False otherwise.
- Return type:
bool
- classmethod open(path, mode='a', compression=Compression.Auto, backend=None, auto_update_timestamps=True)
Open a NIX file, or create it if it does not exist.
- Parameters:
path – Path to file
mode – FileMode ReadOnly, ReadWrite, or Overwrite. (default: ReadWrite)
compression – No, DeflateNormal, Auto (default: Auto)
auto_update_timestamps – Enable/disable automatic updating of ‘updated_at’ timestamp. (default: True)
- Returns:
nixio.File object
- pprint(indent=2, max_length=120, extra=True, max_depth=3)
Pretty Printing the Data and MetaData Tree of the whole File
- Parameters:
indent (int) – The length of one indentation space
max_length (int) – Maximum length of each line of output
extra (bool) – True to print extra information of Entities
max_depth (int) – Maximum recursion being printed in MetaData tree
- property sections
A property containing all root Sections of a file. Specific root Sections can be obtained by their name, id or index. Sections can be deleted from this list. Notice: when a section is deleted all its child section and properties will be removed too. Adding a new Section is done via the crate_section method of File. This is a read-only property.
- property updated_at
The time of the last update of the file. This is a read-only property. Use force_updated_at in order to change the update time.
- Return type:
int
- validate()
- property version
The file format version.
- Type:
tuple
- nixio.file.can_read(nixfile)
- nixio.file.can_write(nixfile)
- nixio.file.make_fapl()
- nixio.file.make_fcpl()
- nixio.file.map_file_mode(mode)
nixio.group module
- class nixio.group.Group(nixfile, nixparent, h5group)
Bases:
Entity
- classmethod create_new(nixfile, nixparent, h5parent, name, type_)
- property data_arrays
A property containing all data arrays referenced by the group. Referenced data arrays can be obtained by index or their id. References can be removed from the list, removing a referenced DataArray will not remove it from the file. New references can be added using the append method of the list. This is a read only attribute.
- property data_frames
A property containing all data frames referenced by the group. Referenced data frames can be obtained by index or their id. References can be removed from the list, removing a referenced DataFrame will not remove it from the file. New references can be added using the append method of the list. This is a read only attribute.
- property metadata
Associated metadata of the entity. Sections attached to the entity via this attribute can provide additional annotations. This is an optional read-write property, and can be None if no metadata is available.
- Type:
- property multi_tags
A property containing all MultiTags referenced by the group. MultiTags can be obtained by index or their id. MultiTags can be removed from the list, removing a referenced MultiTag will not remove it from the file. New MultiTags can be added using the append method of the list. This is a read only attribute.
- property sources
A property containing all Sources referenced by the Group. Sources can be obtained by index or their id. Sources can be removed from the list, but removing a referenced Source will not remove it from the file. New Sources can be added using the append method of the list. This is a read only attribute.
- property tags
A property containing all tags referenced by the group. Tags can be obtained by index or their id. Tags can be removed from the list, removing a referenced Tag will not remove it from the file. New Tags can be added using the append method of the list. This is a read only attribute.
nixio.info module
nixio.link_type module
nixio.multi_tag module
- class nixio.multi_tag.MultiTag(nixfile, nixparent, h5group)
Bases:
BaseTag
- classmethod create_new(nixfile, nixparent, h5parent, name, type_, positions)
- property extents
The extents defined by the tag. This is an optional read-write property and may be set to None.
- Type:
nixio.DataArray or None
- feature_data(posidx, featidx, stop_rule=SliceMode.Exclusive)
- property metadata
Associated metadata of the entity. Sections attached to the entity via this attribute can provide additional annotations. This is an optional read-write property, and can be None if no metadata is available.
- Type:
- property positions
The positions defined by the tag. This is a read-write property.
- Type:
- property references
A property containing all data arrays referenced by the tag. Referenced data arrays can be obtained by index or their id. References can be removed from the list, removing a referenced DataArray will not remove it from the file. New references can be added using the append method of the list. This is a read only attribute.
- Type:
nixio.LinkContainer of nixio.DataArray
- retrieve_data(posidx, refidx)
- retrieve_feature_data(posidx, featidx)
- property sources
A property containing all Sources referenced by the MultiTag. Sources can be obtained by index or their id. Sources can be removed from the list, but removing a referenced Source will not remove it from the file. New Sources can be added using the append method of the list. This is a read only attribute.
- tagged_data(posidx, refidx, stop_rule=SliceMode.Exclusive)
nixio.property module
- class nixio.property.OdmlType(value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None)
Bases:
Enum
OdmlType provides all types currently supported by the odML data format. It provides additional information about the nature of the values of an odML Property.
- Boolean = 'boolean'
- Date = 'date'
- Datetime = 'datetime'
- Float = 'float'
- Int = 'int'
- Person = 'person'
- String = 'string'
- Text = 'text'
- Time = 'time'
- URL = 'url'
- compatible(value)
compatible returns True or False depending on whether a passed value can be mapped to an OdmlType or not.
- Parameters:
value – Any single value
- Returns:
Boolean
- classmethod get_odml_type(dtype)
get_odml_type returns the appropriate OdmlType for a handed in nix value DataType.
- Parameters:
dtype – nix DataType
- Returns:
OdmlType
- class nixio.property.Property(nixfile, nixparent, h5dataset)
Bases:
Entity
An odML Property
- classmethod create_new(nixfile, nixparent, h5parent, name, dtype, shape=None, oid=None)
- property data_type
- property definition
The definition of the entity. The definition can contain a textual description of the entity. This is an optional read-write property, and can be None if no definition is available.
- Type:
str
- delete_values()
- property dependency
- property dependency_value
- extend_values(data)
Extends values to existing data. Suitable when new data is nested or original data is long.
- property name
The name of an entity. The name serves as a human readable identifier. This is a read-only property; entities cannot be renamed.
- Type:
str
- property odml_type
- pprint(indent=2, max_length=80, current_depth=-1)
Pretty print method. Method is called in Section.pprint()
- property reference
- property uncertainty
- property unit
- property value_origin
- property values
nixio.section module
- class nixio.section.S(section_type, section=None)
Bases:
object
- class nixio.section.Section(nixfile, nixparent, h5group)
Bases:
Entity
- copy_section(obj, children=True, keep_id=True, name='')
Copy a section to the section.
- Parameters:
obj (nixio.Section) – The Section to be copied
children (bool) – Specify if the copy should be recursive
keep_id (bool) – Specify if the id should be kept
name (str) – Name of copied section, Default is name of source section
- Returns:
The copied section
- Return type:
- classmethod create_new(nixfile, nixparent, h5parent, name, type_, oid=None)
- create_property(name='', values_or_dtype=0, oid=None, copy_from=None, keep_copy_id=True)
Add a new property to the section.
- Parameters:
name (str) – The name of the property to create/copy.
values_or_dtype (list of values or a nixio.DataType) – The values of the property or a valid DataType.
oid (str) – object id, UUID string as specified in RFC 4122. If no id is provided, an id will be generated and assigned.
copy_from (nixio.Property) – The Property to be copied, None in normal mode
keep_copy_id (bool) – Specify if the id should be copied in copy mode
- Returns:
The newly created property.
- Return type:
- create_section(name, type_='undefined', oid=None)
Creates a new subsection that is a child of this section entity.
- Parameters:
name (str) – The name of the section to create.
type (str) – The type of the section.
oid (str) – object id, UUID string as specified in RFC 4122. If no id is provided, an id will be generated and assigned.
- Returns:
The newly created section.
- Return type:
Get all related sections of this section.
The result can be filtered. On each related section a filter is applied. If the filter returns true the respective section will be added to the result list. By default a filter is used that accepts all sections.
- Parameters:
filtr (function) – A filter function
- Returns:
A list containing the matching related sections.
- Return type:
list of nixio.Section
- find_sections(filtr=<function Section.<lambda>>, limit=None)
Get all child sections recursively. This method traverses the trees of all sections. The traversal is accomplished via breadth first and can be limited in depth. On each node or section a filter is applied. If the filter returns true the respective section will be added to the result list. By default a filter is used that accepts all sections.
- Parameters:
filtr (function) – A filter function
limit (int) – The maximum depth of traversal
- Returns:
A list containing the matching sections.
- Return type:
list of nixio.Section
- inherited_properties()
- items()
- property link
Link to another section. If a section is linked to another section, the linking section inherits all properties from the target section. This is an optional read-write property and may be set to None.
- Type:
- property parent
The parent section. This is a read-only property. For root sections this property is always None.
Accessing this property can be slow when the metadata tree is large.
- Type:
- pprint(indent=2, max_depth=-1, max_length=80, current_depth=0)
Pretty print method.
- Parameters:
indent (int) – The number of indentation spaces per recursion
max_depth (int) – The maximum times of recursion, -1 for the full depth
max_length (int) – The maximum length of each line of output
current_depth (int) – The current times of recursion
- property props
A property containing all Property entities associated with the section. Properties can be accessed by name, index, or id. Properties can be deleted from the list. Adding new Properties is done using the create_property method. This is a read-only attribute.
- Type:
- property reference
- property referring_blocks
- property referring_data_arrays
- property referring_groups
- property referring_multi_tags
- property referring_objects
- property referring_sources
- property referring_tags
- property repository
URL to the terminology repository the section is associated with. This is an optional read-write property and may be set to None.
- Type:
str
- property sections
A property providing all child Sections of a Section. Child sections can be accessed by name, index, or id. Sections can also be deleted: if a Section is deleted, all its properties and child Sections are removed from the file too. Adding new Sections is achieved using the create_section method. This is a read-only attribute.
- Type:
nixio.source module
- class nixio.source.Source(nixfile, nixparent, h5group)
Bases:
Entity
- classmethod create_new(nixfile, nixparent, h5parent, name, type_)
- create_source(name, type_)
Create a new source as a child of the current Source.
- Parameters:
name (str) – The name of the source to create.
type (str) – The type of the source.
- Returns:
The newly created source.
- Return type:
- find_sources(filtr=<function Source.<lambda>>, limit=None)
Get all child sources of this source recursively.
This method traverses the tree of all sources. The traversal is accomplished via breadth first and can be limited in depth. On each node or source a filter is applied. If the filter returns true the respective source will be added to the result list. By default a filter is used that accepts all sources.
- Parameters:
filtr (function) – A filter function
limit (int) – The maximum depth of traversal
- Returns:
A list containing the matching sources.
- Return type:
list of nixio.Source
- property metadata
Associated metadata of the entity. Sections attached to the entity via this attribute can provide additional annotations. This is an optional read-write property, and can be None if no metadata is available.
- Type:
- property parent_block
Returns the block this source is contained in.
- Returns:
the Block containing this source
- Return type:
- property parent_source
Get the parent source of this source. If this source is at the root, None will be returned
- Returns:
the parent source
- Return type:
Source or None
- property referring_data_arrays
Returns all DataArray entities linking to this source.
- Returns:
all DataArrays referring to this source.
- Return type:
list
- property referring_multi_tags
Returns all MultiTag entities linking to this source.
- Returns:
all MultiTags referring to this source.
- Return type:
list
- property referring_objects
Returns the list of entities that link to this source.
- Returns:
all objects referring to this source.
- Return type:
list
- property referring_tags
Returns all Tag entities linking to this source.
- Returns:
all Tags referring to this source.
- Return type:
list
- property sources
A property containing child sources of a Source. Sources can be obtained via their name, index, id. Sources can be deleted from the list. Adding sources is done using the Blocks create_source method. This is a read only attribute.
nixio.source_link_container module
- class nixio.source_link_container.SourceLinkContainer(parent)
Bases:
LinkContainer
- append(item)
nixio.tag module
- class nixio.tag.BaseTag(nixfile, nixparent, h5group)
Bases:
Entity
Base class for Tag and MultiTag
- create_feature(data, link_type)
Create a new feature.
- Parameters:
data (nixio.DataArray) – The data array of this feature.
link_type (nixio.LinkType) – The link type of this feature.
- Returns:
The created feature object.
- Return type:
- property features
A property containing all features. Features can be obtained via their index or their ID. Features can be deleted from the list. Adding new features is done using the create_feature method. This is a read only attribute.
- Type:
Container of nixio.Feature.
- property units
Property containing the units of the tag. The tag must provide a unit for each dimension of the position or extent vector. This is a read-write property.
- Type:
list of str
- class nixio.tag.FeatureContainer(name, nixfile, parent, itemclass)
Bases:
Container
The FeatureContainer has one minor difference from the regular Container: A Feature can be retrieved by the ID or name of the linked DataArray as well as the ID of the feature itself.
- class nixio.tag.Tag(nixfile, nixparent, h5group)
Bases:
BaseTag
- classmethod create_new(nixfile, nixparent, h5parent, name, type_, position)
- property extent
The extent defined by the tag. This is an optional read-write property and may be set to None.
- Type:
list of float
- feature_data(featidx, stop_rule=SliceMode.Exclusive)
- property metadata
Associated metadata of the entity. Sections attached to the entity via this attribute can provide additional annotations. This is an optional read-write property, and can be None if no metadata is available.
- Type:
- property position
The position defined by the tag. This is a read-write property.
- Type:
list of float
- property references
A property containing all data arrays referenced by the tag. Referenced data arrays can be obtained by index or their id. References can be removed from the list, removing a referenced DataArray will not remove it from the file. New references can be added using the append method of the list. This is a read only attribute.
- Type:
- retrieve_data(refidx)
- retrieve_feature_data(featidx)
- property sources
A property containing all Sources referenced by the Tag. Sources can be obtained by index or their id. Sources can be removed from the list, but removing a referenced Source will not remove it from the file. New Sources can be added using the append method of the list. This is a read only attribute.
- tagged_data(refidx, stop_rule=SliceMode.Exclusive)
nixio.validator module
- class nixio.validator.ValidationError
Bases:
object
Static class for defining validation error messages
- DataFrameMismatch = 'referenced data frame for dimension {} does not have the same row count as the data array'
- DimensionMismatch = 'data dimensionality does not match number of defined dimensions'
- DimensionTypeMismatch = 'dimension_type attribute for dimension {} does not match Dimension object type'
- ExtentDimensionMismatch = 'number of entries in extent does not match number of dimensions in all referenced DataArrays'
- ExtentsDimensionMismatch = 'number of entries (in 2nd dim) in extents does not match number of dimensions in all referenced DataArrays'
- IncorrectDimensionIndex = 'index for dimension {} is set to incorrect value {}'
- InvalidDimensionIndex = 'index for dimension {} is not set to a valid value (index > 0)'
- InvalidDimensionUnit = 'unit for dimension {} is set but it is not an atomic SI unit (Note: composite units are not supported)'
- InvalidSamplingInterval = 'sampling interval for dimension {} is not valid (interval > 0)'
- InvalidUnit = 'unit is invalid: not an atomic SI (Note: composite units are not supported)'
- NoData = 'data is not set'
- NoDataType = 'data type is not set'
- NoDate = 'date is not set'
- NoID = 'no ID set'
- NoLinkType = 'link_type is not set'
- NoName = 'no name set'
- NoPosition = 'position is not set'
- NoPositions = 'positions are not set'
- NoSamplingInterval = 'sampling interval for dimension {} is not set'
- NoTicks = 'ticks for dimension {} are not set'
- NoType = 'no type set'
- PositionDimensionMismatch = 'number of entries in position does not match number of dimensions in all referenced DataArrays'
- PositionExtentMismatch = 'number of entries in position and extent do not match'
- PositionsDimensionMismatch = 'number of entries (in 2nd dim) in positions does not match number of dimensions in all referenced DataArrays'
- PositionsExtentsMismatch = 'number of entries in positions and extents do not match'
- RangeDimTicksMismatch = 'number of ticks in RangeDimension ({}) differs from the number of data entries along the corresponding data dimension'
- ReferenceUnitsIncompatible = "some of the referenced DataArrays' dimensions have units that are not convertible to the units set in the Tag (Note: composite units are not supported)"
- ReferenceUnitsMismatch = "some of the referenced DataArrays' dimensions don't have units where the Tag has; make sure that all references have the same number of dimensions as the Tag has units and that each dimension has a unit set"
- SetDimLabelsMismatch = 'number of labels in SetDimension ({}) differs from the number of data entries along the corresponding data dimension'
- UnsortedTicks = 'ticks for dimension {} are not sorted'
- class nixio.validator.ValidationWarning
Bases:
object
- InvalidUnit = 'unit is not SI or composite of SI units'
- NoExpansionOrigin = 'polynomial coefficients for calibration are set, but expansion origin is missing'
- NoFileID = 'file ID is not set'
- NoFormat = 'format is not set'
- NoPolynomialCoefficients = 'expansion origin for calibration is set, but polynomial coefficients are missing'
- NoUnit = 'unit is not set'
- NoVersion = 'version is not set'
- OffsetNoUnit = 'offset for dimension {} is set, but no valid unit is set'
- nixio.validator.check_block(block)
Validate a Block and return all errors and warnings for the block and each individual contained object.
- Returns:
A list of ‘errors’ and a list of ‘warnings’
- nixio.validator.check_data_array(da)
Validate a DataArray and its Dimensions and return all errors and warnings. Errors and warnings about Dimension objects are included in the DataArray errors and warnings lists.
- Returns:
A list of ‘errors’ and a list of ‘warnings’
- nixio.validator.check_entity(entity)
General NIX entity validator
- nixio.validator.check_feature(feat, idx)
Validate a Feature and return all errors.
- Returns:
A list of ‘errors’
- nixio.validator.check_file(nixfile)
Validate a NIX file and all contained objects and return all errors and warnings for each individual object.
- Returns:
A nested dictionary of errors and warnings. Each subdictionary
is indexed by the object with values describing the error or warning. :rtype: Dictionary
- nixio.validator.check_group(group)
Validate a Group and return all errors and warnings. Does not check contained objects.
- Returns:
A list of ‘errors’ and a list of ‘warnings’
- nixio.validator.check_multi_tag(mtag)
Validate a MultiTag and its Features and return all errors and warnings. Errors and warnings about Features are included in the MultiTag errors and warnings lists.
For Features, only the basic Entity requirements, LinkType, and the existence of a referenced DataArray are checked. The linked DataArray is not checked for validity (see check_data_array() for those validation checks).
- Returns:
A list of ‘errors’ and a list of ‘warnings’
- nixio.validator.check_property(prop, idx)
Validate a Property and return all errors.
- Returns:
A list of ‘errors’ and ‘warnings’
- nixio.validator.check_range_dimension(dim, idx)
Validate a RangeDimension and return all errors and warnings.
- Returns:
A list of ‘errors’ and a list of ‘warnings’
- nixio.validator.check_sampled_dimension(dim, idx)
Validate a SampledDimension and return all errors and warnings.
- Returns:
A list of ‘errors’ and a list of ‘warnings’
- nixio.validator.check_section(section)
Validate a Section and its Properties return all errors and warnings.
Errors and warnings about Properties are included in the Section errors and warnings lists.
- Returns:
A list of ‘errors’ and a list of ‘warnings’
- nixio.validator.check_set_dimension()
Validate a SetDimension and return all errors and warnings.
- Returns:
A list of ‘errors’ and a list of ‘warnings’
- nixio.validator.check_source(source)
Validate a Source and return all errors and warnings.
- Returns:
A list of ‘errors’ and a list of ‘warnings’
- nixio.validator.check_tag(tag)
Validate a Tag and its Features and return all errors and warnings. Errors and warnings about Features are included in the Tag errors and warnings lists.
For Features, only the basic Entity requirements, LinkType, and the existence of a referenced DataArray are checked. The linked DataArray is not checked for validity (see check_data_array() for those validation checks).
- Returns:
A list of ‘errors’ and a list of ‘warnings’
- nixio.validator.get_dim_units(data_array)
Helper function to collect the units of the dimensions of a data array
- nixio.validator.tag_units_match_refs_units(tag_units, refs_units)
Module contents
- class nixio.Block(nixfile, nixparent, h5group, compression=Compression.Auto)
Bases:
Entity
- create_data_array(name='', array_type='', dtype=None, shape=None, data=None, compression=Compression.Auto, copy_from=None, keep_copy_id=True, label=None, unit=None)
Create/copy a new data array for this block. Either
shape
ordata
must be given. If both are given their shape must agree. Ifdtype
is not specified it will default to 64-bit floating points.- Parameters:
name (str) – The name of the data array to create/copy.
array_type (str) – The type of the data array.
dtype (
numpy.dtype
) – Which data-type to use for storageshape (tuple of int or long) – Layout (dimensionality and extent)
data (array-like data) – Data to write after storage has been created
compression (
Compression
) – En-/disable dataset compression.copy_from (nixio.DataArray) – The DataArray to be copied, None in normal mode
keep_copy_id (bool) – Specify if the id should be copied in copy mode
label (str) – The label, defaults to None.
unit (str) – The unit of the stored data. Defaults to None.
- Returns:
The newly created data array.
- Return type:
- create_data_frame(name='', type_='', col_dict=None, col_names=None, col_dtypes=None, data=None, compression=Compression.No, copy_from=None, keep_copy_id=True)
Create/copy a new data frame for this block. Either
col_dict
orcol_name
andcol_dtypes
must be given. If both are given,col_dict
will be used.- Parameters:
name (str) – The name of the data frame to create/copy.
type (str) – The type of the data frame.
col_dict (dict or OrderedDict of {str: type}) – The dictionary that specifies column names and data type in each column
col_names (tuples or list or np.array of string) – The collection of name of all columns in order
col_dtypes (tuples or list or np.array of type) – The collection of data type of all columns in order
data (array-like data with compound data type as specified in the columns) – Data to write after storage has been created
compression (
Compression
) – En-/disable dataset compression.copy_from (nixio.DataFrame) – The DataFrame to be copied, None in normal mode
keep_copy_id (bool) – Specify if the id should be copied in copy mode
- Returns:
The newly created data frame.
- Return type:
- create_group(name, type_)
Create a new group on this block.
- Parameters:
name (str) – The name of the group to create.
type (str) – The type of the group.
- Returns:
The newly created group.
- Return type:
- create_multi_tag(name='', type_='', positions=None, extents=None, copy_from=None, keep_copy_id=True)
Create/copy a new multi tag for this block.
- Parameters:
name (str) – The name of the tag to create/copy.
type (str) – The type of tag.
positions (nixio.DataArray) – A data array defining all positions of the tag.
copy_from (nixio.MultiTag) – The MultiTag to be copied, None in normal mode
keep_copy_id (bool) – Specify if the id should be copied in copy mode
- Returns:
The newly created tag.
- Return type:
- classmethod create_new(nixparent, h5parent, name, type_, compression)
- create_source(name, type_)
Create a new source on this block.
- Parameters:
name (str) – The name of the source to create.
type (str) – The type of the source.
- Returns:
The newly created source.
- Return type:
- create_tag(name='', type_='', position=0, copy_from=None, keep_copy_id=True)
Create/copy a new tag for this block.
- Parameters:
name (str) – The name of the tag to create/copy.
type (str) – The type of tag.
position – Coordinates of the start position in units of the respective data dimension.
copy_from (nixio.Tag) – The Tag to be copied, None in normal mode
keep_copy_id (bool) – Specify if the id should be copied in copy mode
- Returns:
The newly created tag.
- Return type:
- property data_arrays
A property containing all data arrays of a block. DataArray entities can be obtained via their index or by their id. Data arrays can be deleted from the list. Adding a data array is done using the Blocks create_data_array method. This is a read only attribute.
- property data_frames
- find_sources(filtr=<function Block.<lambda>>, limit=None)
Get all sources in this block recursively.
This method traverses the tree of all sources in the block. The traversal is accomplished via breadth first and can be limited in depth. On each node or source a filter is applied. If the filter returns true the respective source will be added to the result list. By default a filter is used that accepts all sources.
- Parameters:
filtr (function) – A filter function
limit (int) – The maximum depth of traversal
- Returns:
A list containing the matching sources.
- Return type:
list of nixio.Source
- property groups
A property containing all groups of a block. Group entities can be obtained via their index or by their id. Groups can be deleted from the list. Adding a Group is done using the Blocks create_group method. This is a read only attribute.
- property metadata
Associated metadata of the entity. Sections attached to the entity via this attribute can provide additional annotations. This is an optional read-write property, and can be None if no metadata is available.
- Type:
- property multi_tags
A property containing all multi tags of a block. MultiTag entities can be obtained via their index or by their id. Tags can be deleted from the list. Adding tags is done using the Blocks create_multi_tag method. This is a read only attribute.
- pprint(indent=2, max_length=120, extra=True, start_depth=0)
Pretty Printing the Data and MetaData Tree of the whole File
- Parameters:
indent (int) – The length of one indentation space
max_length (int) – Maximum length of each line of output
extra (bool) – True to print extra information of Entities
start_depth (int) – Starting depth of indentation
- property sources
A property containing all sources of a block. Sources can be obtained via their index or by their id. Sources can be deleted from the list. Adding sources is done using the Blocks create_source method. This is a read only attribute.
- property tags
A property containing all tags of a block. Tag entities can be obtained via their index or by their id. Tags can be deleted from the list. Adding tags is done using the Blocks create_tag method. This is a read only attribute.
- class nixio.Compression(value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None)
Bases:
Enum
- Auto = 'Auto'
- DeflateNormal = 'DeflateNormal'
- No = 'None'
- class nixio.DataArray(nixfile, nixparent, h5group)
-
- append_range_dimension(ticks=None, label=None, unit=None)
Append a new RangeDimension to the list of existing dimension descriptors.
- Parameters:
ticks (list of float) – The ticks of the RangeDimension to create.
label (str) – The label of the dimension
unit (str) – The physical unit of the dimension
- Returns:
The newly created RangeDimension.
- Return type:
- append_range_dimension_using_self(index=None)
Convenience function to append a new RangeDimension to the list of existing dimensions that uses the DataArray itself as provider for the ticks. This is a replacement for rdim = array.append_range_dimension() rdim.link_data_array(self, index)
- Parameters:
index – The slice of the DataArray that contains the tick values. This must be a vector of the data. Defaults to [-1], i.e. the full first dimension.
- Type:
list of int
- Returns:
the newly created nixio.RangeDimension
- Return type:
- append_sampled_dimension(sampling_interval, label=None, unit=None, offset=None)
Append a new SampledDimension to the list of existing dimension descriptors.
- Parameters:
sampling_interval (float) – The sampling interval of the SetDimension to create.
label (str) – The label of the dimension
unit (str) – The physical unit of the dimension
offset (float) – The offset between 0 and the first sample
- Returns:
The newly created SampledDimension.
- Return type:
- append_set_dimension(labels=None)
Append a new SetDimension to the list of existing dimension descriptors.
- Parameters:
labels (list or convertible to list) – The set of sample labels
- Returns:
The newly created SetDimension.
- Return type:
- classmethod create_new(nixfile, nixparent, h5parent, name, type_, data_type, shape, compression)
- delete_dimensions()
Delete all the dimension descriptors for this DataArray.
- property dimensions
A property containing all dimensions of a DataArray. Dimensions can be obtained via their index. Adding dimensions is done using the respective append methods for dimension descriptors. This is a read only attribute.
- Type:
Container of dimension descriptors.
- property dtype
The data type of the data stored in the DataArray. This is a read only property.
- Returns:
The data type
- Return type:
- property expansion_origin
The expansion origin of the calibration polynomial. This is a read-write property and can be set to None. The default value is 0.
- Type:
float
- get_slice(positions, extents=None, mode=DataSliceMode.Index)
Reads a slice of the data. The slice can be specified either in indices or in data coordinates. For example, if the DataArray stores 1D data spanning one second in time sampled with 1kHz (1000 data points). If one wants to read the data of the interval 0.25 to 0.5 seconds, one can use either of the following statements:
- ```
interval_data = data_array.get_slice([250], [500], mode=DataSliceMode.Index)[:] interval_data = data_array.get_slice([0.25],[0.25], mode=DataSliceMode.Data)[:]
Note: The extents are not the end positions but the extent of the slice! In the case of regularly sampled dimensions, reaching beyond the start of end of the respective dimension will cause an exception. For irregularly sampled data no exception will be raised but the returned DataView might be invalid and empty.
- Parameters:
positions (list length must match dimensionality of the data.) – Specifies the start of the data slice. List of either indices or data positions depending on the DataSliceMode.
extents (list, defaults to None) – Specifies the extents of the slice for each dimension.
mode (nixio.DataSliceMode) – Specifies how positions and extents are interpreted, they are either treated as indices (DataSliceMode.Index) or as positions in data coordinates (DataSliceMode.Data), Defaults to nixio.DataSliceMode.Index.
- Raises:
nixio.IncompatibleDimensions: if length of positions or, if given, extents does not match the rank of the data.
- Raises:
ValueError: if an invalid slice mode is given
- Returns:
A nixio.DataView object
- Return type:
nixio.DataView
- iter_dimensions()
1-based index dimension iterator. The method returns a generator which returns the index starting from one and the dimensions.
- property label
The label of the DataArray. The label corresponds to the label of the x-axis of a plot. This is a read-write property and can be set to None.
- Type:
str
- property metadata
Associated metadata of the entity. Sections attached to the entity via this attribute can provide additional annotations. This is an optional read-write property, and can be None if no metadata is available.
- Type:
- property polynom_coefficients
The polynomial coefficients for the calibration. By default this is set to a {0.0, 1.0} for a linear calibration with zero offset. This is a read-write property and can be set to None
- Return type:
list of float
- property sources
A property containing all Sources referenced by the DataArray. Sources can be obtained by index or their id. Sources can be removed from the list, but removing a referenced Source will not remove it from the file. New Sources can be added using the append method of the list. This is a read only attribute.
- property unit
The unit of the values stored in the DataArray. This is a read-write property and can be set to None.
- Type:
str
- class nixio.DataFrame(nixfile, nixparent, h5group)
-
- append_column(column, name, datatype=None)
Append a new column to the DataFrame In case of string, it will be better to set explicitly the datatype.
- Parameters:
column (array-like data) – The new column
name (str) – The name of new column
datatype (nixio.DataType) – The DataType of new column
- append_rows(data)
Append a new row to the DataFrame. The data supplied must be iterable.
- Parameters:
data (array-like data) – The new row
- property column_names
The dtype is the list of names of all columns in the DatFrame. This is a read only property.
- Type:
list of str
- property columns
The dtype is the list of names and data types of all columns in the DatFrame. This is a read only property.
- Type:
list of tuples
- classmethod create_new(nixfile, nixparent, h5parent, name, type_, shape, col_dtype, compression)
- property df_shape
The df_shape is the shape of the DataFrame in (number of rows, number of columns) format. This is a read only property.
- Type:
tuple
- property dtype
The dtype is the list of DataTypes of all columns in the DatFrame. This is a read only property.
- Type:
list of DataType
- property metadata
Associated metadata of the entity. Sections attached to the entity via this attribute can provide additional annotations. This is an optional read-write property, and can be None if no metadata is available.
- Type:
- print_table(row_sl=None, col_sl=None)
Print the whole DataFrame as a table
- Parameters:
row_sl (slice or iterable of int) – Rows to be printed; None for printing all rows
col_sl (slice or iterable of int) – Columns to be printed; None for printing all columns
- read_cell(position=None, col_name=None, row_idx=None)
Read a cell in the DataFrame
- Parameters:
position (tuple or list or array with length 2) – Position of the targeted cell
col_name (str) – The column name in which the targeted cell belongs to
row_idx (list of int) – A length 1 list that specify on which row the targeted cell is located
- read_columns(index=None, name=None, slc=None, group_by_cols=False)
Read one or multiple (part of) column(s) in the DataFrame
- Parameters:
index (list of int) – Index of column(s) to be returned
name (list of str) – Name of column(s) to be returned
slc (slice) – The part of each column to be returned
group_by_cols (bool) – True for group return values by columns, False for group by rows. Only applicable for reading multiple columns
- read_rows(index)
Read one or multiple row(s) in the DataFrame
- Parameters:
index (list of int) – Index of row(s) to be returned
- row_count()
Return the total number of rows
- property units
The unit of the values stored in the DataFrame. This is a read-write property and can be set to None.
- Type:
array of str
- write_cell(cell, position=None, col_name=None, row_idx=None)
Overwrite a cell in the DataFrame
- Parameters:
cell (same type as the specified column) – The new cell
position (tuple or list or array with length 2) – Position of the targeted cell
col_name (str) – The column name in which the targeted cell belongs to
row_idx (list of int) – A length 1 list that specify on which row the targeted cell is located
- write_column(column, index=None, name=None)
Overwrite an existing column. Either index or name of the column should be provided.
- Parameters:
column (array-like data) – The new column
index (string) – The index of the column that is written to
name (str) – The name of the column that is written to
- write_rows(rows, index)
Overwrite one or multiple existing row(s)
- Parameters:
rows ((nested) array-like data) – The new rows(s) and their data
index (list of int) – Index of rows(s) to be overwritten
- write_to_csv(filename, mode='w')
Export the whole DataFrame to a CSV file
- Parameters:
filename (str) – The resulted/ targeted CSV file to write to/ create
mode (str) – The column name in which the targeted cell belongs to
- class nixio.DataSliceMode(value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None)
Bases:
Enum
- Data = 2
- Index = 1
- class nixio.DataType
Bases:
object
- Bool
alias of
bool_
- Double
alias of
float64
- Float
alias of
float32
- FloatTypes = (<class 'numpy.float32'>, <class 'numpy.float64'>)
- Int16
alias of
int16
- Int32
alias of
int32
- Int64
alias of
int64
- Int8
alias of
int8
- IntTypes = (<class 'numpy.int8'>, <class 'numpy.int16'>, <class 'numpy.int32'>, <class 'numpy.int64'>, <class 'numpy.uint8'>, <class 'numpy.uint16'>, <class 'numpy.uint32'>, <class 'numpy.uint64'>)
- String
alias of
str_
- UInt16
alias of
uint16
- UInt32
alias of
uint32
- UInt64
alias of
uint64
- UInt8
alias of
uint8
- classmethod get_dtype(value)
- classmethod is_numeric_dtype(dtype)
- class nixio.DimensionType(value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None)
Bases:
Enum
- Range = 'range'
- Sample = 'sample'
- Set = 'set'
- class nixio.Feature(nixfile, nixparent, h5group)
Bases:
object
- classmethod create_new(nixfile, nixparent, h5parent, data, link_type)
- property created_at
The creation time of the entity. This is a read-only property. Use force_created_at in order to change the creation time.
- Return type:
int
- property data
- property file
- property id
- property link_type
- property updated_at
The time of the last update of the entity. This is a read-only property. Use force_updated_at in order to change the update time.
- Return type:
int
- class nixio.File(path, mode='a', compression=Compression.Auto, auto_update_timestamps=True)
Bases:
object
- property auto_update_timestamps
If enabled, automatically updates the ‘updated_at’ attribute when an object’s data or attributes are changed.
- Type:
bool
- property blocks
A property containing all blocks of a file. Blocks can be obtained by their name, id or index. Blocks can be deleted from the list, when a block is deleted all its content (data arrays, tags and sources) will be also deleted from the file. Adding new Block is done via the create_block method of File. This is a read-only attribute.
- close()
Closes an open file.
- copy_section(obj, children=True, keep_id=True, name='')
Copy a section to the file.
- Parameters:
obj (nixio.Section) – The Section to be copied
children (bool) – Specify if the copy should be recursive
keep_id (bool) – Specify if the id should be kept
name (str) – Name of copied section, Default is name of source section
- Returns:
The copied section
- Return type:
- create_block(name='', type_='', compression=Compression.Auto, copy_from=None, keep_copy_id=True)
Create a new block inside the file.
- Parameters:
name (str) – The name of the block to create.
type (str) – The type of the block.
compression – No, DeflateNormal, Auto (default: Auto)
copy_from (nixio.Block) – The Block to be copied, None in normal mode
keep_copy_id (bool) – Specify if the id should be copied in copy mode
- Returns:
The newly created block.
- Return type:
- create_section(name, type_='undefined', oid=None)
Create a new metadata section inside the file.
- Parameters:
name (str) – The name of the section to create.
type (str) – The type of the section.
oid (str) – object id, UUID string as specified in RFC 4122. If no id is provided, an id will be generated and assigned.
- Returns:
The newly created section.
- Return type:
- property created_at
The creation time of the file. This is a read-only property. Use force_created_at in order to change the creation time.
- Return type:
int
- find_sections(filtr=<function File.<lambda>>, limit=None)
Get all sections and their child sections recursively.
This method traverses the trees of all sections. The traversal is accomplished via breadth first and can be limited in depth. On each node or section a filter is applied. If the filter returns true the respective section will be added to the result list. By default a filter is used that accepts all sections.
- Parameters:
filtr (function) – A filter function
limit (int) – The maximum depth of traversal
- Returns:
A list containing the matching sections.
- Return type:
list of nixio.Section
- flush()
- force_created_at(time=None)
Sets the creation time created_at to the given time (default: current time).
- Parameters:
time (int) – The time to set
- force_updated_at(time=None)
Sets the update time updated_at to the given time. (default: current time)
- Parameters:
time (int) – The time to set (default: now)
- property format
The format of the file. This read only property should always have the value ‘nix’.
- Type:
str
- property id
- is_open()
Checks whether a file is open or closed.
- Returns:
True if the file is open, False otherwise.
- Return type:
bool
- classmethod open(path, mode='a', compression=Compression.Auto, backend=None, auto_update_timestamps=True)
Open a NIX file, or create it if it does not exist.
- Parameters:
path – Path to file
mode – FileMode ReadOnly, ReadWrite, or Overwrite. (default: ReadWrite)
compression – No, DeflateNormal, Auto (default: Auto)
auto_update_timestamps – Enable/disable automatic updating of ‘updated_at’ timestamp. (default: True)
- Returns:
nixio.File object
- pprint(indent=2, max_length=120, extra=True, max_depth=3)
Pretty Printing the Data and MetaData Tree of the whole File
- Parameters:
indent (int) – The length of one indentation space
max_length (int) – Maximum length of each line of output
extra (bool) – True to print extra information of Entities
max_depth (int) – Maximum recursion being printed in MetaData tree
- property sections
A property containing all root Sections of a file. Specific root Sections can be obtained by their name, id or index. Sections can be deleted from this list. Notice: when a section is deleted all its child section and properties will be removed too. Adding a new Section is done via the crate_section method of File. This is a read-only property.
- property updated_at
The time of the last update of the file. This is a read-only property. Use force_updated_at in order to change the update time.
- Return type:
int
- validate()
- property version
The file format version.
- Type:
tuple
- class nixio.Group(nixfile, nixparent, h5group)
Bases:
Entity
- classmethod create_new(nixfile, nixparent, h5parent, name, type_)
- property data_arrays
A property containing all data arrays referenced by the group. Referenced data arrays can be obtained by index or their id. References can be removed from the list, removing a referenced DataArray will not remove it from the file. New references can be added using the append method of the list. This is a read only attribute.
- property data_frames
A property containing all data frames referenced by the group. Referenced data frames can be obtained by index or their id. References can be removed from the list, removing a referenced DataFrame will not remove it from the file. New references can be added using the append method of the list. This is a read only attribute.
- property metadata
Associated metadata of the entity. Sections attached to the entity via this attribute can provide additional annotations. This is an optional read-write property, and can be None if no metadata is available.
- Type:
- property multi_tags
A property containing all MultiTags referenced by the group. MultiTags can be obtained by index or their id. MultiTags can be removed from the list, removing a referenced MultiTag will not remove it from the file. New MultiTags can be added using the append method of the list. This is a read only attribute.
- property sources
A property containing all Sources referenced by the Group. Sources can be obtained by index or their id. Sources can be removed from the list, but removing a referenced Source will not remove it from the file. New Sources can be added using the append method of the list. This is a read only attribute.
- property tags
A property containing all tags referenced by the group. Tags can be obtained by index or their id. Tags can be removed from the list, removing a referenced Tag will not remove it from the file. New Tags can be added using the append method of the list. This is a read only attribute.
- class nixio.IndexMode(value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None)
Bases:
Enum
IndexMode is used to define the behaviour of the index_of() methods.
- GEQ = 'geq'
- GreaterOrEqual = 'geq'
- LEQ = 'leq'
- Less = 'less'
- LessOrEqual = 'leq'
- class nixio.LinkType(value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None)
Bases:
Enum
- Indexed = 'indexed'
- Tagged = 'tagged'
- Untagged = 'untagged'
- class nixio.MultiTag(nixfile, nixparent, h5group)
Bases:
BaseTag
- classmethod create_new(nixfile, nixparent, h5parent, name, type_, positions)
- property extents
The extents defined by the tag. This is an optional read-write property and may be set to None.
- Type:
nixio.DataArray or None
- feature_data(posidx, featidx, stop_rule=SliceMode.Exclusive)
- property metadata
Associated metadata of the entity. Sections attached to the entity via this attribute can provide additional annotations. This is an optional read-write property, and can be None if no metadata is available.
- Type:
- property positions
The positions defined by the tag. This is a read-write property.
- Type:
- property references
A property containing all data arrays referenced by the tag. Referenced data arrays can be obtained by index or their id. References can be removed from the list, removing a referenced DataArray will not remove it from the file. New references can be added using the append method of the list. This is a read only attribute.
- Type:
nixio.LinkContainer of nixio.DataArray
- retrieve_data(posidx, refidx)
- retrieve_feature_data(posidx, featidx)
- property sources
A property containing all Sources referenced by the MultiTag. Sources can be obtained by index or their id. Sources can be removed from the list, but removing a referenced Source will not remove it from the file. New Sources can be added using the append method of the list. This is a read only attribute.
- tagged_data(posidx, refidx, stop_rule=SliceMode.Exclusive)
- class nixio.OdmlType(value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None)
Bases:
Enum
OdmlType provides all types currently supported by the odML data format. It provides additional information about the nature of the values of an odML Property.
- Boolean = 'boolean'
- Date = 'date'
- Datetime = 'datetime'
- Float = 'float'
- Int = 'int'
- Person = 'person'
- String = 'string'
- Text = 'text'
- Time = 'time'
- URL = 'url'
- compatible(value)
compatible returns True or False depending on whether a passed value can be mapped to an OdmlType or not.
- Parameters:
value – Any single value
- Returns:
Boolean
- classmethod get_odml_type(dtype)
get_odml_type returns the appropriate OdmlType for a handed in nix value DataType.
- Parameters:
dtype – nix DataType
- Returns:
OdmlType
- class nixio.Property(nixfile, nixparent, h5dataset)
Bases:
Entity
An odML Property
- classmethod create_new(nixfile, nixparent, h5parent, name, dtype, shape=None, oid=None)
- property data_type
- property definition
The definition of the entity. The definition can contain a textual description of the entity. This is an optional read-write property, and can be None if no definition is available.
- Type:
str
- delete_values()
- property dependency
- property dependency_value
- extend_values(data)
Extends values to existing data. Suitable when new data is nested or original data is long.
- property name
The name of an entity. The name serves as a human readable identifier. This is a read-only property; entities cannot be renamed.
- Type:
str
- property odml_type
- pprint(indent=2, max_length=80, current_depth=-1)
Pretty print method. Method is called in Section.pprint()
- property reference
- property uncertainty
- property unit
- property value_origin
- property values
- class nixio.RangeDimension(data_array, index)
Bases:
Dimension
- axis(count, start=0)
Get an axis as defined by this range dimension.
- Parameters:
count – A positive integer specifying the length of the axis (no of points).
start – positive integer, indicates the starting tick.
- Returns:
The created axis
- Return type:
list
- classmethod create_new(data_array, index, ticks)
- index_of(position, mode=IndexMode.LessOrEqual, ticks=None)
Returns the index of a certain position in the dimension. Raises IndexError if the position is out of bounds (depending on mode).
- Parameters:
position – The position.
mode – The IndexMode to use (default LessOrEqual). The default value (LessOrEqual) will return the index of the position that matches a tick if it matches a dimension tick exactly. If it does not match a tick, the previous index is returned. If the mode is Less, the previous index of the matching tick is always returned. If the mode is GreaterOrEqual and the position does not match a tick exactly, the next index is returned.
ticks (iterable) – Optional, the ticks stored in this dimension. If not passed as argument, they are (re)read from file.
- Returns:
The matching index
- Return type:
int
- property is_alias
In versions < 1.5 a RangeDimension that was referring to the DataArray it describes was called an AliasRangeDimension. This has been made more flexible by allowing to link to any DataArray or DataFrame. For downward compatibility this method has been re-introduced in 1.5.1.
- Returns:
True, if this dimension links to a DataArray, False otherwise
- Return type:
bool
- property label
- link_data_array(data_array, index)
- link_data_frame(data_frame, index)
- range_indices(start_position, end_position, mode=SliceMode.Exclusive)
Returns the start and end indices in this dimension that are matching to the given start and end position.
- Parameters:
start_position (float) – the start position of the range.
end_position (float) – the end position of the range.
mode (nixio.SliceMode) – The nixio.SliceMode. Defaults to nixio.SliceMode.Exclusive, i.e. the end position is not part of the range.
- Returns:
The respective start and end indices. None, if range is empty
- Return type:
tuple of int
- Raises:
ValueError if invalid mode is given
- Raises:
Index Error if start position is greater than end position.
- tick_at(index)
Returns the tick at the given index. Will throw an Exception if the index is out of bounds.
- Parameters:
index – The index.
- Returns:
The corresponding position.
- Return type:
double
- property ticks
- property unit
- class nixio.S(section_type, section=None)
Bases:
object
- class nixio.SampledDimension(data_array, index)
Bases:
Dimension
- axis(count, start=None, start_position=None)
Get an axis as defined by this nixio.SampledDimension. It either starts at the offset of the dimension, a number of sample points later, or at a given position. The latter must not be less than the offset. If start and start_position are given, start takes precedence.
- Parameters:
count (int) – A positive integer specifying the length of the axis (no of samples).
start (int) – positive integer, indicates the starting sample. Defaults to None. Precedes over the start_position.
start_position (double) – The start position of the axis. Defaults to None.
- Raises:
ValueError if start is negative or if the start_position is given and is less than offset.
- Returns:
The created axis
- Return type:
tuple
- classmethod create_new(data_array, index, sample)
- index_of(position, mode=IndexMode.LessOrEqual)
Returns the index of a certain position in the dimension. Raises IndexError if the position is out of bounds (depending on mode).
- Parameters:
position – The position.
mode – The IndexMode to use (default LessOrEqual). The default value (LessOrEqual) will return the index of the position calculated based on the dimension offset and sampling_interval if it matches a dimension tick exactly. If it does not match a tick, the previous index is returned. If the mode is Less, the previous index of the calculated position is always returned. If the mode is GreaterOrEqual and the calculated position does not match a tick exactly, the next index is returned.
- Returns:
The matching index.
- Return type:
int
- link_data_array(*_)
- link_data_frame(*_)
- property offset
- position_at(index)
Returns the position corresponding to a given index.
- Parameters:
index – A positive integer.
- Returns:
The position matching to the index.
- Return type:
float
- range_indices(start_position, end_position, mode=SliceMode.Exclusive)
Returns the start and end indices in this dimension that are matching to the given start and end position.
- Parameters:
start_position (float) – the start position of the range.
end_position (float) – the end position of the range.
mode (nixio.SliceMode) – The nixio.SliceMode. Defaults to nixio.SliceMode.Exclusive, i.e. the end position is not part of the range.
- Returns:
The respective start and end indices. None, if the range is empty!
- Return type:
tuple of int
- Raises:
ValueError if invalid mode is given
- Raises:
Index Error if start position is greater than end position.
- property sampling_interval
- property unit
- class nixio.Section(nixfile, nixparent, h5group)
Bases:
Entity
- copy_section(obj, children=True, keep_id=True, name='')
Copy a section to the section.
- Parameters:
obj (nixio.Section) – The Section to be copied
children (bool) – Specify if the copy should be recursive
keep_id (bool) – Specify if the id should be kept
name (str) – Name of copied section, Default is name of source section
- Returns:
The copied section
- Return type:
- classmethod create_new(nixfile, nixparent, h5parent, name, type_, oid=None)
- create_property(name='', values_or_dtype=0, oid=None, copy_from=None, keep_copy_id=True)
Add a new property to the section.
- Parameters:
name (str) – The name of the property to create/copy.
values_or_dtype (list of values or a nixio.DataType) – The values of the property or a valid DataType.
oid (str) – object id, UUID string as specified in RFC 4122. If no id is provided, an id will be generated and assigned.
copy_from (nixio.Property) – The Property to be copied, None in normal mode
keep_copy_id (bool) – Specify if the id should be copied in copy mode
- Returns:
The newly created property.
- Return type:
- create_section(name, type_='undefined', oid=None)
Creates a new subsection that is a child of this section entity.
- Parameters:
name (str) – The name of the section to create.
type (str) – The type of the section.
oid (str) – object id, UUID string as specified in RFC 4122. If no id is provided, an id will be generated and assigned.
- Returns:
The newly created section.
- Return type:
Get all related sections of this section.
The result can be filtered. On each related section a filter is applied. If the filter returns true the respective section will be added to the result list. By default a filter is used that accepts all sections.
- Parameters:
filtr (function) – A filter function
- Returns:
A list containing the matching related sections.
- Return type:
list of nixio.Section
- find_sections(filtr=<function Section.<lambda>>, limit=None)
Get all child sections recursively. This method traverses the trees of all sections. The traversal is accomplished via breadth first and can be limited in depth. On each node or section a filter is applied. If the filter returns true the respective section will be added to the result list. By default a filter is used that accepts all sections.
- Parameters:
filtr (function) – A filter function
limit (int) – The maximum depth of traversal
- Returns:
A list containing the matching sections.
- Return type:
list of nixio.Section
- inherited_properties()
- items()
- property link
Link to another section. If a section is linked to another section, the linking section inherits all properties from the target section. This is an optional read-write property and may be set to None.
- Type:
- property parent
The parent section. This is a read-only property. For root sections this property is always None.
Accessing this property can be slow when the metadata tree is large.
- Type:
- pprint(indent=2, max_depth=-1, max_length=80, current_depth=0)
Pretty print method.
- Parameters:
indent (int) – The number of indentation spaces per recursion
max_depth (int) – The maximum times of recursion, -1 for the full depth
max_length (int) – The maximum length of each line of output
current_depth (int) – The current times of recursion
- property props
A property containing all Property entities associated with the section. Properties can be accessed by name, index, or id. Properties can be deleted from the list. Adding new Properties is done using the create_property method. This is a read-only attribute.
- Type:
- property reference
- property referring_blocks
- property referring_data_arrays
- property referring_groups
- property referring_multi_tags
- property referring_objects
- property referring_sources
- property referring_tags
- property repository
URL to the terminology repository the section is associated with. This is an optional read-write property and may be set to None.
- Type:
str
- property sections
A property providing all child Sections of a Section. Child sections can be accessed by name, index, or id. Sections can also be deleted: if a Section is deleted, all its properties and child Sections are removed from the file too. Adding new Sections is achieved using the create_section method. This is a read-only attribute.
- Type:
- class nixio.SetDimension(data_array, index)
Bases:
Dimension
- classmethod create_new(data_array, index)
- index_of(position, mode=IndexMode.LessOrEqual, dim_labels=None)
Returns the index of a certain position in the dimension. Raises IndexError if the position is out of bounds (depending on mode and number of labels).
- Parameters:
position – The position.
mode – The IndexMode to use (default LessOrEqual). The modes LessOrEqual and GreaterOrEqual will return the integer representation of the position if it is equal to the nearest integer. If the position is not an integer (or is not equal to the nearest integer), then the value is rounded down (for LessOrEqual) or rounded up (for GreaterOrEqual). If the mode is Less, the previous integer is always returned.
dim_labels (iterable) – The labels of this dimension, if None (default) the labels will be read from file.
- Returns:
The matching index
- Return type:
int
- property labels
- range_indices(start_position, end_position, mode=SliceMode.Exclusive)
Returns the start and end indices in this dimension that are matching to the given start and end position.
- Parameters:
start_position (float) – the start position of the range.
end_position (float) – the end position of the range.
mode (nixio.SliceMode) – The nixio.SliceMode. Defaults to nixio.SliceMode.Exclusive, i.e. the end position is not part of the range.
- Returns:
The respective start and end indices. None, if the range is empty
- Return type:
tuple of int
- Raises:
ValueError if invalid mode is given
- Raises:
Index Error if start position is greater than end position.
- class nixio.SliceMode(value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None)
Bases:
Enum
- Exclusive = 'exclusive'
- Inclusive = 'inclusive'
- to_index_mode()
- class nixio.Source(nixfile, nixparent, h5group)
Bases:
Entity
- classmethod create_new(nixfile, nixparent, h5parent, name, type_)
- create_source(name, type_)
Create a new source as a child of the current Source.
- Parameters:
name (str) – The name of the source to create.
type (str) – The type of the source.
- Returns:
The newly created source.
- Return type:
- find_sources(filtr=<function Source.<lambda>>, limit=None)
Get all child sources of this source recursively.
This method traverses the tree of all sources. The traversal is accomplished via breadth first and can be limited in depth. On each node or source a filter is applied. If the filter returns true the respective source will be added to the result list. By default a filter is used that accepts all sources.
- Parameters:
filtr (function) – A filter function
limit (int) – The maximum depth of traversal
- Returns:
A list containing the matching sources.
- Return type:
list of nixio.Source
- property metadata
Associated metadata of the entity. Sections attached to the entity via this attribute can provide additional annotations. This is an optional read-write property, and can be None if no metadata is available.
- Type:
- property parent_block
Returns the block this source is contained in.
- Returns:
the Block containing this source
- Return type:
- property parent_source
Get the parent source of this source. If this source is at the root, None will be returned
- Returns:
the parent source
- Return type:
Source or None
- property referring_data_arrays
Returns all DataArray entities linking to this source.
- Returns:
all DataArrays referring to this source.
- Return type:
list
- property referring_multi_tags
Returns all MultiTag entities linking to this source.
- Returns:
all MultiTags referring to this source.
- Return type:
list
- property referring_objects
Returns the list of entities that link to this source.
- Returns:
all objects referring to this source.
- Return type:
list
- property referring_tags
Returns all Tag entities linking to this source.
- Returns:
all Tags referring to this source.
- Return type:
list
- property sources
A property containing child sources of a Source. Sources can be obtained via their name, index, id. Sources can be deleted from the list. Adding sources is done using the Blocks create_source method. This is a read only attribute.
- class nixio.Tag(nixfile, nixparent, h5group)
Bases:
BaseTag
- classmethod create_new(nixfile, nixparent, h5parent, name, type_, position)
- property extent
The extent defined by the tag. This is an optional read-write property and may be set to None.
- Type:
list of float
- feature_data(featidx, stop_rule=SliceMode.Exclusive)
- property metadata
Associated metadata of the entity. Sections attached to the entity via this attribute can provide additional annotations. This is an optional read-write property, and can be None if no metadata is available.
- Type:
- property position
The position defined by the tag. This is a read-write property.
- Type:
list of float
- property references
A property containing all data arrays referenced by the tag. Referenced data arrays can be obtained by index or their id. References can be removed from the list, removing a referenced DataArray will not remove it from the file. New references can be added using the append method of the list. This is a read only attribute.
- Type:
- retrieve_data(refidx)
- retrieve_feature_data(featidx)
- property sources
A property containing all Sources referenced by the Tag. Sources can be obtained by index or their id. Sources can be removed from the list, but removing a referenced Source will not remove it from the file. New Sources can be added using the append method of the list. This is a read only attribute.
- tagged_data(refidx, stop_rule=SliceMode.Exclusive)