BaseData#

class osekit.core_api.base_data.BaseData(items: list[TItem] | None = None, begin: Timestamp | None = None, end: Timestamp | None = None, name: str | None = None)#

Base class for the Data objects.

Data corresponds to data scattered through different Files. The data is accessed via an Item object per File.

Initialize a BaseData from a list of Items.

Parameters#

items: list[BaseItem] | None

List of the Items constituting the Data. Defaulted to an empty item ranging from begin to end.

begin: Timestamp | None

Only effective if items is None. Set the begin of the empty data.

end: Timestamp | None

Only effective if items is None. Set the end of the empty data.

name: str | None

Name of the exported files.

property begin: Timestamp#

Return the begin timestamp of the data.

static create_directories(path: Path) None#

Create the directory in which the data will be written.

The actual data writing is left to the specified classes.

property end: Timestamp#

Trim the end timestamp of the data.

End can only be set to an anterior date from the original end.

property files: set[TFile]#

All files referred to by the Data.

classmethod from_dict(dictionary: dict) BaseData#

Deserialize a BaseData from a dictionary.

Parameters#

dictionary: dict

The serialized dictionary representing the BaseData.

Returns#

AudioData

The deserialized BaseData.

classmethod from_files(files: list[TFile], begin: Timestamp | None = None, end: Timestamp | None = None, name: str | None = None) BaseData[TItem, TFile]#

Return a base DataBase object from a list of Files.

Parameters#

files: list[TFile]

List of Files containing the data.

begin: Timestamp | None

Begin of the data object. Defaulted to the begin of the first file.

end: Timestamp | None

End of the data object. Defaulted to the end of the last file.

name: str | None

Name of the exported files.

Returns#

BaseData[TItem, TFile]: The BaseData object.

get_value() ndarray#

Get the concatenated values from all Items.

property is_empty: bool#

Return true if every item of this data object is empty.

classmethod items_from_files(files: list[TFile], begin: Timestamp | None = None, end: Timestamp | None = None) list[BaseItem]#

Return a list of Items from a list of Files and timestamps.

The Items range from begin to end. They point to the files that match their timestamps.

Parameters#

files: list[TFile]

The Files encapsulated in the Data object.

begin: pandas.Timestamp | None

The begin of the Data object. defaulted to the begin of the first File.

end: pandas.Timestamp | None

The end of the Data object. defaulted to the end of the last File.

Returns#

list[BaseItem]

The list of Items that point to the files.

Abstract method for linking data to a file in a given folder.

Linking is intended for data objects that have been written to disk. After linking the data to the written file, it will have a single item that matches the File properties. The folder should contain a file named as str(self).extension.

Parameters#

folder: Path

Folder in which is the file to which the BaseData instance should be linked.

property name: str#

Name of the exported files.

split(nb_subdata: int = 2) list[BaseData]#

Split the data object in the specified number of subdata.

Parameters#

nb_subdata: int

Number of subdata in which to split the data.

Returns#

list[BaseData]

The list of BaseData subdata objects.

to_dict() dict#

Serialize a BaseData to a dictionary.

Returns#

dict:

The serialized dictionary representing the BaseData.

write(folder: Path, link: bool = False) None#

Abstract method for writing data to file.