skdh.io.ReadNumpyFile#
- class skdh.io.ReadNumpyFile(time_is_local=True, allow_pickle=False, ext_error='warn')#
Read a Numpy compressed file into memory. The file should have been created by numpy.savez. The data contained is read in unprocessed - ie acceleration is already assumed to be in units of ‘g’ and time in units of seconds. No day windowing is performed. Expected keys are time and accel. If fs is present, it is used as well.
- Parameters:
- time_is_localbool, optional
If any timestamp arrays are naive/local. Default is True. If True, and a tz_name is provided, output timestamps will be UTC, and require conversion to the local time.
- allow_picklebool, optional
Allow pickled objects in the NumPy file. Default is False, which is the safer option. For more information see
numpy.load().- ext_error{“warn”, “raise”, “skip”}, optional
What to do if the file extension does not match the expected extension (.npz). Default is “warn”. “raise” raises a ValueError. “skip” skips the file reading altogether and attempts to continue with the pipeline.
Methods
convert_timestamps(t)Convert a timestamp/array of timestamps to a datetime object
predict(*, file[, tz_name])Read the data from a numpy compressed file.
save_results(results, file_name)Save the results of the processing pipeline to a csv file
- predict(*, file, tz_name=None)#
Read the data from a numpy compressed file.
- Parameters:
- file{str, Path}
Path to the file to read. Must either be a string, or be able to be converted by str(file).
- tz_name{None, str}, optional
IANA time-zone name for the recording location. If not provided, timestamps will represent local time naively. This means they will not account for any time changes due to Daylight Saving Time.
- Returns:
- datadict
Dictionary of the data contained in the file.
- Raises:
- ValueError
If the file name is not provided.
Notes
The keys in data depend on which data the file contained. Potential keys are:
accel: acceleration [g]
time: timestamps [s]
fs: sampling frequency in Hz.