skdh.io.ReadApdmH5#
- class skdh.io.ReadApdmH5(sensor_location, localize_timestamps=True, gravity_acceleration=9.81, ext_error='warn')#
Read a H5 file produced by the APDM software into memory. Acceleration values are returned in units of g.
- Parameters:
- sensor_locationstr
Sensor location to get data from. Looks at the Label 0 key to find the desired sensor.
- localize_timestampsbool, optional
Convert timestamps to local time from UTC. Default is True. Uses APDM’s timezone offset attribute for the sensor being extracted. Ignored if a time-zone name is provided (tz_name) in the predict method.
- gravity_accelerationfloat, optional
Acceleration due to gravity. Used to convert values to units of g. Default is 9.81 m/s^2.
- ext_error{“warn”, “raise”, “skip”}, optional
What to do if the file extension does not match the expected extension (.h5). 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)Read the data from an APDM file, getting the data from the specified sensor.
save_results(results, file_name)Save the results of the processing pipeline to a csv file
trim_data(trim_start_factor, start_key, ...)Trim data based on either a start factor or start/end keys
trim_data_factor(trim_start_factor, *, time, ...)Trim raw data based on a factor of seconds.
trim_data_time(start_key, end_key, tz_name, ...)Trim raw data based on provided date-times
Notes
Given that APDM systems are typically designed to be used in-lab, and not collect significant amounts of data (ie less than a day), there is no day windowing available for APDM data.
Some of the default options for locations are: - Left/Right Foot - Left/Right Lower Leg - Left/Right Upper Leg - Lumbar - Sternum
- predict(*, file)#
Read the data from an APDM file, getting the data from the specified sensor.
- Parameters:
- file{str, pathlib.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 provided, and localize_timestamps is True, will check the offset matches that from the file. If not provided, will convert to local time as specified by localize_timestamps.
- Returns:
- datadict
Dictionary of the data contained in the file.
- Raises:
- ValueError
If the file name is not provided.
- ValueError
If the time-zone name offset does not match the offset in the file itself.
- FileNotFoundError
If the file does not exist.
- skdh.io.SensorNotFoundError
If the specified sensor name was not found.