SpectroFile#

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

Spectro file associated with timestamps.

Spectro files are npz files with Time and Sxx arrays. Metadata (time_resolution) are stored as separate arrays.

Initialize a SpectroFile object with a path and a begin timestamp.

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 bin 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.

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_base_file(file: BaseFile) SpectroFile#

Return a SpectroFile object from a BaseFile object.

get_fft() ShortTimeFFT#

Return the ShortTimeFFT used for computing the spectrogram.

Returns#

ShortTimeFFT:

The ShortTimeFFT used for computing the spectrogram. It is instantiated back from the parameters stored in the npz file.

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

Return the spectro data between start and stop from the file.

The data is a 2D array representing the sxx values of the spectrogram.

Parameters#

start: pandas.Timestamp

Timestamp corresponding to the first time bin to read.

stop: pandas.Timestamp

Timestamp after the last time bin to read.

Returns#

numpy.ndarray:

The spectrogram data between start and stop.