StatisticEntities package
Submodules
LOGS_solutions.GenerateStatistics.StatisticEntities.StatisticHandlerEntities module
- class LOGS_solutions.GenerateStatistics.StatisticEntities.StatisticHandlerEntities.StatisticHandlerEntities(logs, begin_date, end_date, target_path, logger)[source]
Bases:
CommonHandler
Abstract class for creating statistics.
- create_blockdiagram_month(dates_list, entity_title)[source]
Creates a block diagram per month.
- Parameters:
dates_list (
List
) – list with all dates of the entity type.entity_title (
str
) – E.g. ‘datasets for instrument x’.
- Return type:
Figure
- Returns:
Figure with the block diagram with the title “Number of {entity_title} per month and year”
- create_csv_file(sorted_list, entity, statistical_unit, path)[source]
Creates a csv file of the statistics.
- Parameters:
sorted_list (
List
) – sorted list with all acquisition dates of each datasetentity (
str
) – Name of the entity that is part of the statistics (e.g. dataset for dataset_count)statistical_unit (
str
) – Unit for which the statistics were preparedpath (
str
) – Path where the csv file should be saved
- create_csv_file_prep_dis(dictionary_prep, dictionary_dis, dictionary_prep_str, dictionary_dis_str, entity, statistical_unit, path)[source]
Creates a csv file of the statistics of how many entities (like samples) where prepared/created or deleted/modified by the statistical unit (person). Used for statistics for entities whose person can prepare and delete.
- Parameters:
dictionary_prep (
Dict
) – Dictionary with all elements of the unit and a sorted list of the preparation/creation data for each element. dictionary_prep = {key: [entity_name, date1, date2, …]}dictionary_dis (
Dict
) – Dictionary with all elements of the unit and a sorted list of the discarded or modified data for each element. dictionary_dis = {key: [entity_name, date1, date2, …]}dictionary_prep_str (
str
) – String indicating whether the dictionary contains preparation or creation data, etc. e.g: “Prepared”dictionary_dis_str (
str
) – String indicating whether the dictionary contains discarded or modified data, etc. e.g: “Discarded”entity (
str
) – Name of the entity that is part of the statistics (e.g. dataset for dataset_count)statistical_unit (
str
) – Unit for which the statistics were prepared (e.g. person)path (
Path
) – Path where the csv file should be saved
- create_plot_day(dates_list, entity_title, show_num=True)[source]
Creates a heat map with the number of the entitiy within a calendar week per month over all years.
- Parameters:
dates_list (
List
) – list with all dates of the entity typeentity_title (
str
) – E.g. ‘datasets for instrument x’show_num (
bool
) – Boolean if the number should be shown in the heatmap
- Return type:
Figure
- Returns:
Figure with the heatmap with title “Number of {entity_title} per day and week over all months and years”
- create_plot_instrument(entity_path, instrument_data, cutoff=0)[source]
Creates the plots for the extracted data of StatisticInstruments and the question “Which and how many experiments, projects and samples were created per instrument”.
- Parameters:
entity_path (
Path
) – Path, where the statistic should be saved.instrument_data (
Dict
) – Dictionary with the instrument data.cutoff (
int
) – Cutoff value for the plots.
- create_plot_instrument_list(instrument_id, instrument_name, data, statistic_entity, cutoff=0)[source]
Creates a pie chart for the distribution of the statistic entity (e.g. Distribution of experiments of instrument x).
- Parameters:
instrument_id (
int
) – ID of the instrument.instrument_name (
str
) – Name of the instrument.data – Data for the distribution.
statistic_entity (
str
) – Entity for which the distribution is created. (e.g. “experiments”)cutoff (
int
) – Cutoff value for the distribution.
- Return type:
Figure
- Returns:
Figure with the pie chart with the title “Distribution of {statistic_entity} of {instrument_name} (ID: {instrument_id}) with cutoff {cutoff}” or “Distribution of {statistic_entity} of {instrument_name} (ID: {instrument_id})”
- create_plot_list(dates_list, entity_path, entity, statistical_unit, csv_bool, show_num=True)[source]
Creates the plots for one entity.
- Parameters:
dates_list (
List
) – The list with the acquisition dates of the entity.entity_path (
Path
) – Path, where the statistic should be saved.entity (
str
) – Entity on which the statistics are based, e.g.: “samples”.statistical_unit (
str
) – Entity as instrument for which the statistics are generated, e.g.: “logs_group”.csv_bool (
bool
) – Boolean if the csv file should be created or not.show_num (
bool
) – Boolean if the number should be shown in the heatmap
- create_plot_month(dates_list, entity_title, show_num=True)[source]
Creates a heatmap per month in a year.
- Parameters:
dates_list (
List
) – list with all dates of the entity typeentity_title (
str
) – E.g. ‘datasets for instrument x’show_num (
bool
) – Boolean if the number should be shown in the heatmap
- Return type:
Figure
- Returns:
Figure with the heatmap with the title “Number of {entity_title} per month and year”
- create_plot_of_dict(dictionary, entity_path, entity, statistical_unit, csv_bool, show_num=True)[source]
Creates the plots for all entries in the dictionary.
- Parameters:
dictionary (
Dict
) – The dictionary with the entries to be plotted.entity_path (
Path
) – Path, where the statistic should be saved.entity (
str
) – Entity on which the statistics are based, e.g.: “Samples prepared” or “Samples”.statistical_unit (
str
) – Entity for which the statistics are generated, “e.g.: “person”.csv_bool (
bool
) – Boolean if the csv file should be created or not.show_num (
bool
) – Boolean if the number should be shown in the heatmap
- create_plot_week(dates_list, entity_title, show_num=True)[source]
Creates a heat map with the number of data records within a calendar week per year.
::param dates_list: list with all dates of the entity type :param title: E.g. ‘datasets for instrument x’ :type show_num:
bool
:param show_num: Boolean if the number should be shown in the heatmap- Return type:
Figure
- Returns:
Figure with the heatmap with title “Number of {entity_type} per calendar week and year”
- create_plot_year(dates_list, entity_title)[source]
Creates a block diagram per year.
- Parameters:
dates_list (
List
) – list with all dates of the entity type.entity_title (
str
) – E.g. ‘datasets for instrument x’.
- Return type:
Figure
- Returns:
Figure with the block diagram with the title “Number of {entity_title} per year”
LOGS_solutions.GenerateStatistics.StatisticEntities.StatisticsDatasets module
- class LOGS_solutions.GenerateStatistics.StatisticEntities.StatisticsDatasets.StatisticsDatasets(logs, target_path='./statistics', begin_date=None, end_date=None, show_num=True, persons=[], instruments=[])[source]
Bases:
StatisticHandlerEntities
Class for creating the statistics for the data sets. Includes the following statistics: How many data sets were created per time unit (day, week, month, year). The acquisition date is used. The statistics are output per - LOGS group - Person (or filtered by a specific person) - Instrument (or filtered by a specific person)
The result is a CSV file per person, logs-group and instrument and a pdf per logs-group, person and instrument.
- create_statistic()[source]
Generates the statistics for the datasets. The statistics include: How many projects, samples and data sets were created per time unit (day, week, month, year). The acquisition date is used. The statistics are output per - LOGS group - Person (or filtered by a specific person) - Instrument (or filtered by a specific person) (only for statistic of data sets)
The result is a CSV file per person, logs group and instrument and a pdf per logs group, person and instrument.
- update_instrument_dict(dataset, dataset_instrument_dict)[source]
Updates the dictionary of instruments based on the provided dataset. The dictionary is updated with the instrument associated with the data set. The acquisition date is added to the associated list in the dictionary.
- Parameters:
dataset (
Dataset
) – The dataset from which instrument details and acquisition dates are extracted.dataset_instrument_dict (
Dict
) – A dictionary mapping instrument IDs to lists that contain the instrument’s name and previously recorded acquisition dates. Structure: {instrument_id: [instrument_name, …acquisition_dates]}
- Return type:
Dict
- Returns:
An updated dictionary where each key is an instrument ID and each value is a list with the instrument name as the first element followed by all acquisition dates (both existing and newly added). Structure: {instrument_id: [instrument_name, acquisition_date1, acquisition_date2, …]}
- update_person_dict_dataset(dataset, dataset_person_dict)[source]
Updates the dictionary of persons based on the provided dataset. The dictionary is updated with the owner of the data set. The acquisition date is added to the associated list in the dictionary.
- Parameters:
dataset (
Dataset
) – The dataset from which person details and acquisition dates are extracted.dataset_person_dict (
Dict
) – A dictionary mapping person IDs to lists that contain the person’s name and previously recorded acquisition dates. Structure: {person-id: [person-name, …acquisition_dates]}
- Return type:
Dict
- Returns:
An updated dictionary where each key is an person ID and each value is a list with the person name as the first element followed by all acquisition dates (both existing and newly added). Structure: {person_id: [person_name, acquisition_date1, acquisition_date2, …]}
LOGS_solutions.GenerateStatistics.StatisticEntities.StatisticsInstruments module
- class LOGS_solutions.GenerateStatistics.StatisticEntities.StatisticsInstruments.StatisticsInstruments(logs, target_path='./statistics', begin_date=None, end_date=None, instruments=[], cutoff=0)[source]
Bases:
StatisticHandlerEntities
Class for creating the statistics for the instruements.
Includes the following statistics: Which and how many experiments, projects and samples were created per instrument.
- create_statistic()[source]
Generates the statistics for the instruments.
The statistics are created for the following: - Number of projects, samples and experiments per instrument and without instrument.
- get_dataset_instruments()[source]
Retrieves all instruments from the datasets and organizes them in a nested dictionary structure.
Each entry in the dictionary represents an instrument, where the key is the instrument_id and the value is a tuple containing: - instrument_name: Name of the instrument as a string. - projects: A dictionary of all associated projects, where each key is the projectID and the value is a list containing the projectName and the number of projects. - samples: A dictionary of all associated samples, where each key is the sampleID and the value is a list containing the sampleName and the number of samples. - experiments: A dictionary of all associated experiments, where each key is the experimentID and the value is a list containing the experimentName and the number of experiments.
- Return type:
Dict
- Returns:
A dictionary with the structure {instrument_id: ( instrument_name, {projectID: [projectName, num], …}, {sampleID: [sampleName, num], …}, {experimentID: [experimentName, num], …} ), …}
LOGS_solutions.GenerateStatistics.StatisticEntities.StatisticsProjects module
- class LOGS_solutions.GenerateStatistics.StatisticEntities.StatisticsProjects.StatisticsProjects(logs, target_path='./statistics', begin_date=None, end_date=None, show_num=True, persons=[])[source]
Bases:
StatisticHandlerEntities
Class for creating the statistics for the projects.
Includes the following statistics: How many projects were created per time unit (day, week, month, year). The statistics are output per - LOGS group - Person (or filtered by a specific person)
For the statistics of projects per log-group “created on” is used. For the statistcs of projects per person “created on” and “modified on” is used.
The result is a CSV file per person and logs-group and a pdf per logs-group, person and instrument.
- create_statistic()[source]
Generates the statistics for the projects.
Includes the following statistics: How many projects were created per time unit (day, week, month, year). The statistics are output per - LOGS group - Person (or filtered by a specific person)
For the statistics of projects per logs-group “created on” is used. For the statistcs of projects per person “created on” and “modified on” is used.
The result is a CSV file per person, logs-group and instrument and a pdf per logs-group, person and instrument.
- update_person_dict_project(project, project_person_crtd_dict, project_person_mod_dict)[source]
Updates the dictionary of persons who created the project and who modified the project based on the provided project.
- Parameters:
project (
Project
) – The project from which person details and created date and discard date are extracted.project_person_crtd_dict (
Dict
) – Dictionary of all persons with a list of the creation date of their created projects.project_person_mod_dict (
Dict
) – Dictionary of all persons with a list of the modification date of their modified projects.
- Return type:
Tuple
[Dict
,Dict
]- Returns:
An tuple of two updated dictionaries (project_person_crtd_dict, project_person_mod_dict), where each key is an person ID and each value is a list with the person name as the first element followed by all creation dates/modification dates (both existing and newly added). Structure: project_person_crtd_dict: {person_id: [person_name, creationDate1, creationDate2, …]} project_person_mod_dict: {person_id: [person_name, modificationDate1, modificationDate2, …]}
LOGS_solutions.GenerateStatistics.StatisticEntities.StatisticsSamples module
- class LOGS_solutions.GenerateStatistics.StatisticEntities.StatisticsSamples.StatisticsSamples(logs, target_path='./statistics', begin_date=None, end_date=None, show_num=True, persons=[])[source]
Bases:
StatisticHandlerEntities
Class for creating the statistics for the samples.
Includes the following statistics: How many samples were created per time unit (day, week, month, year). The statistics are output per - LOGS group - Person (or filtered by a specific person)
For the statistics of samples per logs-group “prepared at” is used. For the statistcs of samples per person “prepared at” and “discarded at” is used.
The result is a CSV file per person and logs-group and a pdf per logs-group, person and instrument.
- create_statistic()[source]
Generates the statistics for the samples. Includes the following statistics: How many samples were created per time unit (day, week, month, year). The statistics are output per - LOGS group - Person (or filtered by a specific person)
For the statistics of samples per logs-group “prepared at” is used. For the statistcs of samples per person “prepared at” and “discarded at” is used.
The result is a CSV file per person and logs-group and a pdf per logs-group, person and instrument.
- update_person_dict_sample(sample, sample_person_prep_dict, sample_person_dis_dict)[source]
Updates the dictionary of persons who prepared the sample and who discarded the sample based on the provided sample. Only data where the date is provided is considered.
- Parameters:
sample (
Sample
) – The sample from which person details and preparation date and discard date are extracted.sample_person_prep_dict (
Dict
) – Dictionary of all persons with a list of the preparation date of their prepared samples.sample_person_dis_dict (
Dict
) – Dictionary of all persons with a list of the discard date of their discarded samples.
- Return type:
Tuple
[Dict
,Dict
]- Returns:
An tuple of two updated dictionaries (sample_person_prep_dict, sample_person_dis_dict), where each key is an person ID and each value is a list with the person name as the first element followed by all preparation dates/discard dates (both existing and newly added). Structure: sample_person_prep_dict: {person_id: [person_name, preparationDate1, preparationDate2, …]} sample_person_dis_dict: {person_id: [person_name, discardDate1, discardDate2, …]}