Skip to content

Commit

Permalink
minor mostly loggin changes in metagen for clarity and fix xtick plot…
Browse files Browse the repository at this point in the history
… warning message
  • Loading branch information
danellecline committed Aug 21, 2024
1 parent f92cd8d commit fbbdc05
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion pbp/meta_gen/gen_iclisten.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def run(self):

self.log.info(
f"{self.log_prefix} Found {len(wav_files)} files to process that "
f"cover the period {start_dt} - {end_dt}"
f"cover the expanded period {start_dt} - {end_dt}"
)

if len(wav_files) == 0:
Expand Down
5 changes: 2 additions & 3 deletions pbp/meta_gen/gen_nrs.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ def run(self):
blobs = bucket_obj.list_blobs(prefix=prefix)
for i, blob in enumerate(blobs):
f_path = f"gs://{bucket}/{blob.name}"
self.log.info(f"Found {f_path}")
f_dt = utils.get_datetime(f_path, self.prefixes)
if f_dt is None:
continue
Expand All @@ -108,13 +107,13 @@ def run(self):
sound_files.append(WavFile(self.log, f_path, f_dt))
# delay to avoid 400 error
if i % 100 == 0:
self.log.info(f"{i} files processed")
self.log.info(f"{i} files searched...found {len(sound_files)} files that match the search pattern")
time.sleep(1)
if f_dt > end_dt:
break

self.log.info(
f"Found {len(sound_files)} files to process that cover the period {start_dt} - {end_dt}"
f"Found {len(sound_files)} files to process that cover the expanded period {start_dt} - {end_dt}"
)

if len(sound_files) == 0:
Expand Down
2 changes: 1 addition & 1 deletion pbp/meta_gen/gen_soundtrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def run(self):
continue

self.log.info(
f"Found {len(wav_files)} files to process that cover the period {start_dt} - {end_dt}"
f"Found {len(wav_files)} files to process that cover the expanded period {start_dt} - {end_dt}"
)

if len(wav_files) == 0:
Expand Down
7 changes: 2 additions & 5 deletions pbp/meta_gen/json_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def run(self):

# get the file list that covers the requested day
self.log.info(
f'Found {len(day_df)} files from day {self.day}, starting {day_df.iloc[0]["start"]} ending {day_df.iloc[-1]["end"]}'
f'Found {len(day_df)} files for day {self.day}, between {day_df.iloc[0]["start"]} and {day_df.iloc[-1]["end"]}'
)

# if there are no files, then return
Expand Down Expand Up @@ -172,10 +172,7 @@ def no_jitter(self, day_df: pd.DataFrame) -> pd.DataFrame:
:return:
The corrected dataframe
"""
self.log.warning(
f"Cannot correct {self.day}. Using file start times as is, setting jitter to 0 and using "
f"calculated end times."
)
self.log.info(f"Using file start times as is, setting jitter to 0 and calculating end times.")
# calculate the difference between each row start time and save as diff in a copy of the dataframe
day_df = day_df.copy()
day_df["diff"] = day_df["start"].diff()
Expand Down
4 changes: 3 additions & 1 deletion pbp/meta_gen/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,11 @@ def plot_daily_coverage(instrument_type: InstrumentType, df: pd.DataFrame, base_
plot = daily_sum_df["coverage"].plot()
plot.set_ylabel("Daily Coverage (%)")
plot.set_xlabel("Date")
plot.set_xticklabels([x.strftime('%Y-%m-%d') for x in daily_sum_df.index])
plot.set_xticks(daily_sum_df.index.values)
# Angle the x-axis labels for better readability and force them to be in the format YYYY-MM-DD
plot.set_xticklabels([x.strftime('%Y-%m-%d') for x in daily_sum_df.index])
plot.set_xticklabels(plot.get_xticklabels(), rotation=45, horizontalalignment='right')
# Adjust the title based on the instrument type
if instrument_type == InstrumentType.NRS:
plot.set_title("Daily Coverage of NRS Recordings")
elif instrument_type == InstrumentType.ICLISTEN:
Expand Down

0 comments on commit fbbdc05

Please sign in to comment.