Skip to content

load binary folder - progress bar displaying incorrect number of files #13

@mathieudpnt

Description

@mathieudpnt

Hi,

When I use a DateFilter with load_pamguard_binary_folder, the progress bar shows the total number of .pgdf files in the folder, rather than the number of files that actually match the date filter.

Example:

from pathlib import Path
from pandas import Timestamp

from pypamguard import load_pamguard_binary_folder
from pypamguard.core.filters import DateFilter, Filters
from pypamguard.logger import Verbosity, logger

audio_path = Path(r"Z:\Bioacoustique\DATASETS\CETIROISE\F_Sud_Liniou\Phase_10\Sylence")
binary = Path(r"L:\acoustock\Bioacoustique\DATASETS\CETIROISE\ANALYSE\PAMGUARD_threshold_7\PHASE_10_POINT_F")

begin = Timestamp("2025-01-20T12:25:00+00:00")
end = Timestamp("2025-01-25T09:00:00+00:00")

logger.set_verbosity(Verbosity.ERROR)

filter_obj = Filters(
    {
    "daterange": DateFilter(start_date=begin, end_date=end, ordered=True)
    }
)

data, _, _ = load_pamguard_binary_folder(binary, "*/*.pgdf", filters=filter_obj)

Output:

>>> data, _, _ = load_pamguard_binary_folder(binary, "*/*.pgdf", filters=filter_obj)
  4%|▎         | 111/3050 [00:10<04:35, 10.65it/s]
>>>

Even though only a subset of files is actually loaded based on the date filter, the progress bar shows the total number of files (3050) rather than the filtered number.

I’ve considered pre-filtering files by their datetime in the filename, but I’m afraid this might exclude detections at the boundaries (last file before the start date or first file after the end date).

Is there a recommended way to make the progress bar reflect the actual number of files processed after filtering?

Thanks!

Metadata

Metadata

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions