Skip to content

Commit

Permalink
Fix #41 Add current date to DANDI plots page
Browse files Browse the repository at this point in the history
  • Loading branch information
oruebel committed Jul 31, 2024
1 parent 91df03e commit 3466667
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/nwb_project_analytics/dandistats.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from matplotlib import dates as mpl_dates
from hdmf_docutils.doctools.output import PrintHelper
from hdmf_docutils.doctools.rst import RSTDocument, RSTFigure
import datetime


class DANDIStats:
Expand Down Expand Up @@ -242,7 +243,7 @@ def plot_number_of_dandisets_by_date(dandistats_df: pd.DataFrame,
linewidth=0.5)
for label in ax.get_xticklabels(which='major'):
label.set(rotation=30, horizontalalignment='right')
ax.set_ylabel('# of NWB Dandisets')
ax.set_ylabel('# of NWB dandisets')
ax.set_xlabel("Date created")
# Formatting the x-axis to show dates correctly
plt.gca().xaxis.set_major_locator(mpl_dates.DayLocator(interval=180))
Expand Down Expand Up @@ -275,7 +276,7 @@ def plot_size_of_dandisets_by_date(dandistats_df: pd.DataFrame,
for label in ax.get_xticklabels(which='major'):
label.set(rotation=30, horizontalalignment='right')
ax.set_xlabel("Date")
_ = ax.set_ylabel("TB of NWB on the archive")
_ = ax.set_ylabel("TB of NWB data on Dandi")
# Formatting the x-axis to show dates correctly
plt.gca().xaxis.set_major_locator(mpl_dates.DayLocator(interval=180))
plt.gca().xaxis.set_major_formatter(mpl_dates.DateFormatter('%Y-%m-%d'))
Expand Down Expand Up @@ -307,7 +308,7 @@ def plot_number_of_nwbfiles_by_date(dandistats_df: pd.DataFrame,
for label in ax.get_xticklabels(which='major'):
label.set(rotation=30, horizontalalignment='right')
ax.set_xlabel("Date")
_ = ax.set_ylabel("# NWB files on the archive")
_ = ax.set_ylabel("# files in NWB dandisets")
# Formatting the x-axis to show dates correctly
plt.gca().xaxis.set_major_locator(mpl_dates.DayLocator(interval=180))
plt.gca().xaxis.set_major_formatter(mpl_dates.DateFormatter('%Y-%m-%d'))
Expand Down Expand Up @@ -340,14 +341,22 @@ def create_dandistats_pages(cls,
read_cache=load_cached_results,
write_cache=cache_results,
print_status=print_status)
dandistat_figures = []

current_datetime = datetime.datetime.now()
formatted_datetime = current_datetime.strftime("%Y-%m-%d %H:%M:%S")

# Render all the figures
if print_status:
PrintHelper.print("CREATING DANDI NWB figures and rst", PrintHelper.BOLD)
dandistat_figures = []
dandistats_rst = RSTDocument()
dandistats_rst.add_label("dandi-statistics")
dandistats_rst.add_section("DANDI: NWB Data Statistics")
dandistats_rst.add_text(dandistats_rst.newline)
dandistats_rst.add_text(dandistats_rst.newline)
dandistats_rst.add_text(f"Plots rendered on: {formatted_datetime}")
dandistats_rst.add_text(dandistats_rst.newline)
dandistats_rst.add_text(dandistats_rst.newline)
dandistats_rst.add_subsection("NWB data on DANDI over time")
# Figure 1
count_figpath = os.path.join(out_dir, 'nwb_dandiset_count_by_date.png')
Expand Down

0 comments on commit 3466667

Please sign in to comment.