aerosoltools.loaders.Load_data_from_folder
- aerosoltools.loaders.Load_data_from_folder(folder_path, load_function, search_word='', max_subfolder=0, meta_checklist=['serial_number'], **kwargs)
Load and concatenate aerosol data from a folder using a specified loader function.
This function iterates over all files in the specified folder (and optionally its subfolders) that match a given search word. Each file is processed using the provided load_function. Files with incompatible metadata (based on keys in meta_checklist) are skipped. The function returns a combined aerosol data object with merged time-series and metadata.
Parameters
- folder_pathstr
Path to the folder containing the data files.
- load_functionfunction
A function that loads a single data file and returns an instance of a class like Aerosol1D, Aerosol2D, or AerosolAlt. The function must return an object with original_data, extra_data, and metadata.
- search_wordstr, optional
A string that must be present in the filename for the file to be loaded. Defaults to “” (match all files).
- max_subfolderint, optional
Depth of subfolder levels to include in the search. 0 means only the base folder is used; 1 includes immediate subfolders, etc.
- meta_checklistlist of str, optional
List of metadata keys that must be identical across all loaded files. If any key differs, the file is skipped. Defaults to [“serial_number”].
- kwargs
Additional keyword arguments passed to the load_function.
Returns
- Combined_dataAerosol1D or Aerosol2D or AerosolAlt
A combined aerosol data object. The returned object inherits from the same class as the first successfully loaded file. It includes:
Combined original_data
Combined extra_data
Merged metadata
Notes
Files that raise exceptions or fail metadata consistency checks are skipped. A message will be printed for each skipped file, along with the reason. The function will raise an exception if no valid files are found or if the returned object is not an instance of Aerosol1D, Aerosol2D, or AerosolAlt.
- Parameters:
meta_checklist (list)