imucal.management.find_closest_calibration_info_to_date#
- imucal.management.find_closest_calibration_info_to_date(sensor_id: str, cal_time: datetime, folder: path_t | None = None, recursive: bool = True, filter_cal_type: str | None = None, custom_validator: Callable[[CalibrationInfo], bool] | None = None, before_after: str | None = None, warn_thres: timedelta = datetime.timedelta(days=30), ignore_file_not_found: bool | None = False) Path | None [source]#
Find the calibration file for a sensor_type, that is closes to a given date.
As this only checks the filenames, this might return a false positive depending on your folder structure and naming.
- Parameters:
- sensor_id
A unique id to identify the calibrated sensor
- cal_time
time and date to look for
- folder
Basepath of the folder to search. If None, tries to find a default calibration
- recursive
If the folder should be searched recursive or not.
- filter_cal_type
Whether only files obtain with a certain calibration type should be found. This will look for the
CalType
inside the json file and hence cause performance problems. If None, all found files (over all potential subfolders) will be returned.- custom_validator
A custom function that will be called with the CalibrationInfo object of each potential match. This needs load the json file of each match and could cause performance issues with many calibration files.
- before_after
Can either be ‘before’ or ‘after’, if the search should be limited to calibrations that were either before or after the specified date. If None the closest value will be returned, ignoring if it was before or after the measurement.
- warn_thres
If the distance to the closest calibration is larger than this threshold, a warning is emitted
- ignore_file_not_found
If True this function will not raise an error, but rather return
None
, if no calibration files were found for the specific sensor_type.
- Returns:
- cal_file_path or None
The path to a suitable calibration file, or
None
, if no suitable file could be found.
See also
nilspodlib.calibration_utils.find_calibrations_for_sensor
Notes
If there are multiple calibrations that have the same date/hour/minute distance form the measurement, the calibration before the measurement will be chosen. This can be overwritten using the
before_after
para.
Examples using imucal.management.find_closest_calibration_info_to_date
#
Annotate a session and perform a Ferraris Calibration