Statistic Notebook for NMR

The following statistics can be created with this notebook:

  • Statistics of the utilization time (based on “duration”) of each instrument. (per year, month, calendar week, comparison heatmap)

  • Statistics of the different types of NMR experiment of each instrument.

A chart per instrument is created as html.

Important: The statistics are only generated for a period between 21.09.1677 and 11.04.2262. All other data is excluded from the statistics.If only the “discarded” time or “modified on” time falls within the period, the date is only removed from the statistics for “discarded”/”modified on”.

To run this notebook you need a Jupyter kernel. A kernel is a Python environment that executes the code from your notebook. If no Jupyter kernel is set up yet, you can register one with the following command in the terminal:

python -m ipykernel install --user --name env_name --display-name "YourName"

Imports

Please import all necessary modules first by executing the following section

import sys, os
sys.path.append(os.path.abspath("..")) # for local imports
sys.path.append("/home/zischka/Documents/logs-py-public-solutions/logs-py-solutions-public/pypi-package") # TODO: Remove after testing
from datetime import datetime # for begin_date and end_date

from LOGS import LOGS
from LOGS_solutions.GenerateStatistics.StatisticNMR.StatisticsDurationTime import StatisticsDurationTime
from LOGS_solutions.GenerateStatistics.StatisticNMR.StatisticsTypesOfExperiments import StatisticsTypesOfExperiments

Parameters

Please set the parameters as you like.

target_path: The target path, where all statistics should be saved. Default: Within the folder containing the script, a new folder “statistics” is created in which all statistics are saved.

begin_date: Lowest date limit of datastes used for statistics to be created. Has to be a datetime object.
Default: None (no limit)

end_date: Highest date limit of datasets used for statistics to be created. Has to be a datetime object.
Default: None (no limit)

target_path = "./statistics"
begin_date = None # begin_date example: datetime(2024, 1, 1)
end_date = None # end_date example: datetime(2024, 2, 28)

Initialize class objects

Please make sure that the logs.json config file is in the same folder as the other classes and the notebook.

If the formatting of the config file is not clear, refer to the instructions for help: https://docs.logs-python.com/pages/setup.html

The different classes do the following:

  • StatisticsDurationTime: Generates reports with the statistics for the utilization time of each instrument.

  • StatisticsTypesOfInstruments: Generates a statistical analysis of the different types of NMR experiments of each instrument.

logs = LOGS()
statistics_duration_time = StatisticsDurationTime(logs, begin_date, end_date, target_path)
statistics_types_experiments = StatisticsTypesOfExperiments(logs, begin_date, end_date, target_path)

Create Statistics

If you would like to create all statistics, simply complete the following section. If you only want to create one specific statistic, please comment out the other.

statistics_duration_time.create_statistic()
statistics_types_experiments.create_statistic()
2025-11-19 16:19:37,216 - INFO - Starting to generate a statistical analysis of the utilization time.
2025-11-19 16:19:37,244 - INFO - Processing datasets with the format 'BrukerNMR' and 'VarianNMR' in the given time frame: begin date: 2007-09-18 00:00:00+02:00 - end date: 2025-10-25 00:00:00+02:00.
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[6], line 1
----> 1 statistics_duration_time.create_statistic()
      2 statistics_types_experiments.create_statistic()

File ~/Documents/logs-py-public-solutions/logs-py-solutions-public/pypi-package/LOGS_solutions/GenerateStatistics/StatisticNMR/StatisticsDurationTime.py:377, in StatisticsDurationTime.create_statistic(self)
    369         self._logger_dur_time.info(
    370             "%d/%d datasets processed.",
    371             count,
    372             datasets_total,
    373         )
    375     count += 1
--> 377     instrument_dict = self.update_instrument_dict(dataset, instrument_dict)
    379 self._logger_dur_time.info(
    380     "Finished processing datasets with the format 'BrukerNMR' and 'NMR (Varian)'."
    381 )
    383 # Create the statistics for the utilization time of each instrument

File ~/Documents/logs-py-public-solutions/logs-py-solutions-public/pypi-package/LOGS_solutions/GenerateStatistics/StatisticNMR/StatisticsDurationTime.py:274, in StatisticsDurationTime.update_instrument_dict(self, dataset, dataset_instrument_dict)
    267     self._logger_dur_time.error(
    268         "Could not fetch the full dataset. %s It will not be included in the statistic. %s",
    269         dataset.name,
    270         e,
    271     )
    272     return dataset_instrument_dict
--> 274 if self.check_duration(dataset):
    275     return dataset_instrument_dict
    277 # If the data set has no instrument

File ~/Documents/logs-py-public-solutions/logs-py-solutions-public/pypi-package/LOGS_solutions/GenerateStatistics/StatisticNMR/StatisticsDurationTime.py:123, in StatisticsDurationTime.check_duration(self, dataset)
    114 def check_duration(self, dataset: Dataset) -> bool:
    115     """Check if the duration parameter of the data set is empty or None.
    116 
    117     Write the data set to one of the following csv files:
   (...)
    120     - DurationTime.csv: If the duration parameter of the data set is not empty.
    121     """
--> 123     if dataset.instrument is None or dataset.instrument == "":
    124         instrument_name = "No_Instrument"
    125         instrument_id = 0

AttributeError: 'Dataset_Dataset__LOGS_3_1_' object has no attribute 'instrument'