Statistic Notebook for Entities
The following statistics can be created with this notebook:
How many projects, samples and datasets were created per time unit (day, week, month, year).
The statistics are output per
LOGS group
Person (or filtered by a specific person)
Inventory Item (or filtered by a specific person) (only for statistic of datasets)
Plots are created showing the respective number per year, month, calendar week and day and written to a html. In addition, csv files are created with the respective information.
For samples, the statistics on “prepared” and “discarded” are created for each person. For projects, statistics on “entered on” and “modified on” are created for each person.
For the datasets the acquisition date is used. For the statistics of projects per group “entered on” is used. For the statistcs of projects per person “created on” and “modified on” is used.
Which and how many projects and samples were created per inventory item.
A chart per inventory item is created as a 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
from datetime import datetime
from LOGS import LOGS
from LOGS_solutions.GenerateStatistics.StatisticEntities.StatisticsDatasets import StatisticsDatasets
from LOGS_solutions.GenerateStatistics.StatisticEntities.StatisticsProjects import StatisticsProjects
from LOGS_solutions.GenerateStatistics.StatisticEntities.StatisticsSamples import StatisticsSamples
from LOGS_solutions.GenerateStatistics.StatisticEntities.StatisticsInventoryItems import StatisticsInventoryItems
Parameters
Please set the parameters as you like.
The following parameters are for all scripts:
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 for statistics to be created. Has to be a datetime object. Statistics of datasets and inevntory items are filtered based on the dataset acquisition date. Statistics of projects and samples are filtered based on enteredOn.
Default: None (no limit)end_date: Highest date limit for statistics to be created. Has to be a datetime object. Statistics of datasets and inventory items are filtered based on the dataset acquisition date. Statistics of projects and samples are filtered based on enteredOn.
Default: None (no limit)
Specific Parameter for the statistics of datasets, projects and samples:
show_num_heatmap: Boolean if the number should be shown in the heatmap.
Default: Truepersons: List of persons for statistics. Has to be a list of the person ids. Please write 0 for “No person”. If the list is empty the statistics of all persons will be created.
Default: []
Specific Parameter for the statistics of datasets:
inv_ids: List of inventory IDs to be included in the statistics.
(for example the id of the inventory “instruments”)
if empty, no statistic of inventories will be created.inv_item_ids: List of inventory item IDs to be included in the statistics. If the list is empty the statistics of all inventory_items in the given inventories will be created.
(for example the id of the inventory Item “Intrument1”)
For “No inventory item” use 0
Default: []
Specific Parameter for the statistics of inventories:
count_cf_ids: Custom field id of the inventory items to be counted Has to be a set, the data type of the custom fields has to be “Entity Reference”.
count_inv_ids: Inventory ids, if not every inventory item of every inventory linked to the custom field should be used for the statistic
Optional: If not set inventory items of all inventories linked to the custom field will be includedcount_inv_item_ids: Inventory item ids, if not every inventory item should be included in the statistic
Optional: If not set every inventory item linked to the custom field will be included.
For “No inventory item” use 0sample_cf_ids: Custom fields with sample inventory items which should be the categories for the statistics
Optional: If not set, no statistics over this custom fields will be preparedprojects: If set to 1, projects will be used as a category
Default: 1cutoff: Only the statistics that correspond to >= the cut-off are displayed. The cutoff refers to the number of the respective entity. The cutoff must be an integer.
Default: 0
## for all scripts
target_path = "./statistics_Entities"
begin_date = None # begin_date example: datetime(2024, 1, 1)
end_date = None # end_date example: datetime(2024, 2, 28)
# datasets, projects, samples
show_num_heatmap = True
persons = []
# datasets only
inv_ids = [2]
inv_item_ids = []
# insventories only
count_cf_id = 5 # custom field ID of inventory items, e.g. 5
count_inv_ids = []
count_inv_item_ids = []
sample_cf_id = 3 # custom field ID of inventory items, e.g. 3
projects = 1
cutoff = 0
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:
StatisticsDatasets: How many datasets were created per time unit for LOGS group, persons and inevntory items
StatisticsProjects: How many projects were entered on per time unit for LOGS group, persons
StatisticsSamples: How many samples were entered on per time unit for LOGS group, persons
StatisticsInventories: Which and how many projects and samples were entered on per inventory item with the given ID
logs = LOGS()
statistics_dataset = StatisticsDatasets(logs, inv_ids, target_path, begin_date, end_date, show_num_heatmap, persons=persons, inv_item_ids=inv_item_ids)
statistics_projects = StatisticsProjects(logs, target_path, begin_date, end_date, show_num_heatmap, persons=persons)
statistics_samples = StatisticsSamples(logs, target_path, begin_date, end_date, show_num_heatmap, persons=persons)
statistics_inventory_items = StatisticsInventoryItems(logs, count_cf_id, count_inv_ids, count_inv_item_ids, sample_cf_id, projects, target_path, begin_date, end_date, cutoff=cutoff)
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 others.
statistics_dataset.create_statistic()
statistics_projects.create_statistic()
statistics_samples.create_statistic()
statistics_inventory_items.create_statistic()