BaseFile#

class osekit.core_api.base_file.BaseFile(path: PathLike | str, begin: Timestamp | None = None, end: Timestamp | None = None, strptime_format: str | list[str] | None = None, timezone: str | pytz.timezone | None = None)#

Base class for the File objects.

A File object associates file-written data to timestamps.

Initialize a File object with a path and timestamps.

The begin timestamp can either be provided as a parameter or parsed from the filename according to the provided strptime_format.

Parameters#

path: PathLike | str

Full path to the file.

begin: pandas.Timestamp | None

Timestamp corresponding to the first data point in the file. If it is not provided, strptime_format is mandatory. If both begin and strptime_format are provided, begin will overrule the timestamp embedded in the filename.

end: pandas.Timestamp | None

(Optional) Timestamp after the last data point in the file.

strptime_format: str | None

The strptime format used in the text. It should use valid strftime codes (https://strftime.org/). Example: ‘%y%m%d_%H:%M:%S’.

timezone: str | pytz.timezone | None

The timezone in which the file should be localized. If None, the file begin/end will be tz-naive. If different from a timezone parsed from the filename, the timestamps’ timezone will be converted from the parsed timezone to the specified timezone.

classmethod from_dict(serialized: dict) BaseFile#

Return a BaseFile object from a dictionary.

Parameters#

serialized: dict

The serialized dictionary representing the BaseFile.

Returns#

BaseFile:

The deserialized BaseFile object.

move(folder: Path) None#

Move the file to the target folder.

Parameters#

folder: Path

destination folder where the file will be moved.

read(start: Timestamp, stop: Timestamp) np.ndarray#

Return the data that is between start and stop from the file.

This is an abstract method and should be overridden with actual implementations.

Parameters#

start: pandas.Timestamp

Timestamp corresponding to the first data point to read.

stop: pandas.Timestamp

Timestamp after the last data point to read.

Returns#

The data between start and stop.

to_dict() dict#

Serialize a BaseFile to a dictionary.

Returns#

dict:

The serialized dictionary representing the BaseFile.