import calplot
import pandas as pd
import matplotlib.pyplot as plt
import os


df = pd.concat([pd.read_pickle(f) for f in ['../MONACO_072022/detections_physeter.pkl', 'detections_physeter.pkl']])
df['date'] = pd.to_datetime(df.filename, format="%Y%m%d_%H%M%SUTC_V12.wav") + pd.to_timedelta(df.offset, unit='s')
df['pos'] = [(p>0.73).any() for p in df.prediction]
grp = df.groupby(df.date.dt.floor('d')).pos.sum()

calplot.calplot(grp, fillcolor='whitesmoke', cmap='YlGn', vmin=0, dropzero=False, colorbar=True, how=None)

plt.savefig('calendar_physeter.pdf')
plt.show()
