PFFP Folder Class¶
- class data_classes.pffpFolder.pffpDataFolder(folder_dir, pffp_id, calibration_factor_dir, survey_name=None)
Bases:
FolderA class for managing a folder containing PFFP data.
Inherits from the Folder class and provides additional functionality specific to PFFP data handling.
- folder_dir
The directory path of the folder.
- Type:
str
- pffp_id
The identifier for the PFFP.
- Type:
str
- calibration_factor_dir
Directory containing the calibration factors for the PFFP.
- Type:
str
- survey_name
The name of the survey during which the data was collected.
- Type:
str, optional
- num_pffp_files
The number of PFFP files found in the folder.
- Type:
int
- datetime_range
The date range of the data.
- Type:
str
- calibration_excel_sheet
The calibration data read from an Excel sheet.
- Type:
pandas.DataFrame, optional
- calibration_params
Calibration parameters for the sensors.
- Type:
pandas.DataFrame, optional
- num_drop_files
The number of files containing drop data.
- Type:
int
- __str__()
Return a string representation of the pffpDataFolder object.
- read_calibration_excel_sheet()
Read the calibration data from an Excel sheet.
- get_sensor_calibration_params(date_string)
Retrieve the calibration parameters for a specified date.
- store_pffp_files(recursive=False, subfolder='')
Store PFFP files from the directory.
- move_file_2_funky(file, funky_dir)
Move a file to a designated “funky” directory.
- analyze_all_files(subfolder_dir='no_drop_folder', use_pore_pressure=True, store_df=True, select_accel=['2g_accel', '18g_accel', '50g_accel', '250g_accel'], debug=False)
Analyze all files to categorize them into files with drops and files without drops.
- process_drop_files()
Process all files containing drop data and create drop objects.
- get_file_index_from_name()
Get the index of a file based on its name (not implemented).
- analyze_all_files(subfolder_dir='no_drop_folder', use_pore_pressure=True, store_df=True, select_accel=['2g_accel', '18g_accel', '50g_accel', '250g_accel'], debug=False)
Analyze all files to categorize them into files with drops and files without drops.
- Parameters:
subfolder_dir (str, optional) – The subfolder within the main folder where files with drops should be stored.
use_pore_pressure (bool, optional) – Whether to use pore pressure data in the analysis.
store_df (bool, optional) – Whether to store DataFrames for drop analysis.
select_accel (list of str, optional) – List of acceleration types to be selected.
debug (bool, optional) – Whether to print debug information.
Notes
The analysis will move files to corresponding directories and update the file lists.
- get_file_index_from_name()
Get the index of a file based on its name in the relevant file lists.
This method is intended to return the index of a file given its name, from either the pffp_files list, pffp_no_drop list, or pffp_drop list depending on its current categorization.
- Raises:
NotImplementedError – Indicates that the module for retrieving file index by name has not been implemented yet.
- get_sensor_calibration_params(date_string)
Retrieve the calibration parameters for the specified date from the calibration data.
- Parameters:
date_string (str) – The date string used to construct column names for offset and scale values.
- Raises:
IndexError – If the calibration data has not been read yet.
- move_file_2_funky(file, funky_dir)
Move a file to the designated “funky” directory.
- Parameters:
file (pffpFile) – The file object to be moved.
funky_dir (str) – The directory path where the file should be moved.
- process_drop_files()
Process all files that contain drop data and create drop objects.
This method iterates through each file in the pffp_drop_files list, processes the drops by identifying their start and end points, and creates drop objects. If a file cannot be processed due to an error, it is moved to the “funky” directory.
- Raises:
zeroLenError – If a file cannot be processed due to zero-length drops, the file is moved to the “funky” directory.
Notes
A progress bar is displayed during the processing to show the progress.
The list of drop files is updated to remove any files that were moved to the funky directory.
- read_calibration_excel_sheet()
Read the calibration data from the specified Excel sheet based on the PFFP ID.
The sheet name is constructed using the PFFP ID and is expected to be named “bluedrop_<pffp_id>”.
- store_pffp_files(recursive=False, subfolder='')
Store PFFP binary files found in the directory.
- Parameters:
recursive (bool, optional) – Whether to search subdirectories recursively.
subfolder (str, optional) – The subfolder within the main folder to search in.
- Raises:
IndexError – If the calibration parameters have not been read yet.