diff --git a/cnr-ifn.mi/README.md b/cnr-ifn.mi/README.md index 1ea50ef7..37b42eb4 100644 --- a/cnr-ifn.mi/README.md +++ b/cnr-ifn.mi/README.md @@ -6,7 +6,7 @@ This repository contains the software developed during the internship at CNR-IFN - **LabLogbook**: Integrated within the existing UdyniManagement Django project, LabLogbook is a web-based application designed for efficient experiment and sample management, coupled with a comprehensive digital logbook. Furthermore, it exposes RESTful APIs, laying the groundwork for the future development of a robust FAIR (Findable, Accessible, Interoperable, Reusable) data infrastructure within the UDynI laboratories. - **Important Note**: LabLogbook is not a standalone application. To run it, is necessary to set up the UdyniManagement project first by following the instructions provided below. + **Important Note**: LabLogbook is not a standalone application. To run it, it is necessary to set up the UdyniManagement project first by following the instructions provided below. ## UdyniManagement Setup @@ -46,7 +46,7 @@ sudo apt install libsasl2-dev ### Django Project Configuration -1. **Apply Migrations:** These commands ensure your database schema is up-to-date with the project's models. +1. **Apply Migrations:** These commands ensure your database schema is up to date with the project's models. ```bash python3 manage.py makemigrations diff --git a/cnr-ifn.mi/UdyniManagement/AccountManagement/forms.py b/cnr-ifn.mi/UdyniManagement/AccountManagement/forms.py index 3e7478af..8e198d42 100644 --- a/cnr-ifn.mi/UdyniManagement/AccountManagement/forms.py +++ b/cnr-ifn.mi/UdyniManagement/AccountManagement/forms.py @@ -5,7 +5,7 @@ from django.conf import settings from AccountManagement.models import RegistrationRequest # import the settings file -from .ldap import UdyniLdap +from AccountManagement.ldap import UdyniLdap UserModel = get_user_model() diff --git a/cnr-ifn.mi/UdyniManagement/AccountManagement/urls.py b/cnr-ifn.mi/UdyniManagement/AccountManagement/urls.py index fef6136d..28438cf8 100644 --- a/cnr-ifn.mi/UdyniManagement/AccountManagement/urls.py +++ b/cnr-ifn.mi/UdyniManagement/AccountManagement/urls.py @@ -1,7 +1,7 @@ from django.urls import path, reverse_lazy from django.views.generic.base import RedirectView -from . import views +from AccountManagement import views urlpatterns = [ diff --git a/cnr-ifn.mi/UdyniManagement/AccountManagement/views.py b/cnr-ifn.mi/UdyniManagement/AccountManagement/views.py index 39b74b53..4f545e67 100644 --- a/cnr-ifn.mi/UdyniManagement/AccountManagement/views.py +++ b/cnr-ifn.mi/UdyniManagement/AccountManagement/views.py @@ -22,9 +22,9 @@ from UdyniManagement.menu import UdyniMenu from UdyniManagement.views import ListViewMenu, CreateViewMenu, TemplateViewMenu, UpdateViewMenu, DeleteViewMenu, FormViewMenu, udyni_error_view -from .ldap import UdyniLdap -from .forms import SetPasswordForm, PasswordChangeForm, PasswordResetForm, RegistrationForm, AccountCreationForm, AccountRejectionForm, UserDeleteForm, EditProfileForm -from .models import RegistrationRequest +from AccountManagement.ldap import UdyniLdap +from AccountManagement.forms import SetPasswordForm, PasswordChangeForm, PasswordResetForm, RegistrationForm, AccountCreationForm, AccountRejectionForm, UserDeleteForm, EditProfileForm +from AccountManagement.models import RegistrationRequest # ======================= diff --git a/cnr-ifn.mi/UdyniManagement/Accounting/forms.py b/cnr-ifn.mi/UdyniManagement/Accounting/forms.py index ffba262e..46747413 100644 --- a/cnr-ifn.mi/UdyniManagement/Accounting/forms.py +++ b/cnr-ifn.mi/UdyniManagement/Accounting/forms.py @@ -1,5 +1,5 @@ from django import forms -from .models import GAE +from Accounting.models import GAE class GaeForm(forms.ModelForm): diff --git a/cnr-ifn.mi/UdyniManagement/Accounting/urls.py b/cnr-ifn.mi/UdyniManagement/Accounting/urls.py index 7f0b15fe..1374fad7 100644 --- a/cnr-ifn.mi/UdyniManagement/Accounting/urls.py +++ b/cnr-ifn.mi/UdyniManagement/Accounting/urls.py @@ -1,7 +1,7 @@ from django.urls import path, reverse_lazy from django.views.generic.base import RedirectView -from . import views +from Accounting import views urlpatterns = [ # Gestione GAE diff --git a/cnr-ifn.mi/UdyniManagement/Accounting/utils.py b/cnr-ifn.mi/UdyniManagement/Accounting/utils.py index d2c169ba..dad43840 100644 --- a/cnr-ifn.mi/UdyniManagement/Accounting/utils.py +++ b/cnr-ifn.mi/UdyniManagement/Accounting/utils.py @@ -1,7 +1,7 @@ import datetime from collections import OrderedDict from django.db.models import Q, F, Sum -from .models import SplitBudget, SplitVariazione, SplitImpegno +from Accounting.models import SplitBudget, SplitVariazione, SplitImpegno def create_split_accounting_detail(contab): # First we get the budget diff --git a/cnr-ifn.mi/UdyniManagement/Accounting/views.py b/cnr-ifn.mi/UdyniManagement/Accounting/views.py index e30ba8ec..26f5aeac 100644 --- a/cnr-ifn.mi/UdyniManagement/Accounting/views.py +++ b/cnr-ifn.mi/UdyniManagement/Accounting/views.py @@ -13,10 +13,10 @@ from UdyniManagement.menu import UdyniMenu from UdyniManagement.views import ListViewMenu, CreateViewMenu, TemplateViewMenu, UpdateViewMenu, DeleteViewMenu -from .models import VoceSpesa, GAE, Stanziamento, Variazione, Impegno, Mandato -from .models import SplitContab, SplitBudget, SplitImpegno, SplitVariazione -from .forms import GaeForm -from .utils import create_split_accounting_detail +from Accounting.models import VoceSpesa, GAE, Stanziamento, Variazione, Impegno, Mandato +from Accounting.models import SplitContab, SplitBudget, SplitImpegno, SplitVariazione +from Accounting.forms import GaeForm +from Accounting.utils import create_split_accounting_detail # ============================= diff --git a/cnr-ifn.mi/UdyniManagement/LabLogbook/forms.py b/cnr-ifn.mi/UdyniManagement/LabLogbook/forms.py index a1d0adc9..f8313057 100644 --- a/cnr-ifn.mi/UdyniManagement/LabLogbook/forms.py +++ b/cnr-ifn.mi/UdyniManagement/LabLogbook/forms.py @@ -1,5 +1,5 @@ from django import forms -from .models import Comment, CommentContent +from LabLogbook.models import Comment, CommentContent class CommentForm(forms.ModelForm): class Meta: diff --git a/cnr-ifn.mi/UdyniManagement/LabLogbook/models.py b/cnr-ifn.mi/UdyniManagement/LabLogbook/models.py index cfc9cd4a..d588315b 100644 --- a/cnr-ifn.mi/UdyniManagement/LabLogbook/models.py +++ b/cnr-ifn.mi/UdyniManagement/LabLogbook/models.py @@ -3,7 +3,6 @@ from django.db import models from mptt.models import MPTTModel, TreeForeignKey # used for Comments from django.contrib.auth import get_user_model -from django.core.exceptions import ValidationError UserModel = get_user_model() diff --git a/cnr-ifn.mi/UdyniManagement/LabLogbook/tests.py b/cnr-ifn.mi/UdyniManagement/LabLogbook/tests.py index 57c325de..088b424c 100644 --- a/cnr-ifn.mi/UdyniManagement/LabLogbook/tests.py +++ b/cnr-ifn.mi/UdyniManagement/LabLogbook/tests.py @@ -2,7 +2,7 @@ from django.urls import reverse from django.utils.timezone import now, timedelta from django.contrib.auth import get_user_model -from .models import Laboratory, ExperimentalStation, Sample, Experiment, SampleForExperiment +from LabLogbook.models import Laboratory, ExperimentalStation, Sample, Experiment, SampleForExperiment import json UserModel = get_user_model() diff --git a/cnr-ifn.mi/UdyniManagement/LabLogbook/urls.py b/cnr-ifn.mi/UdyniManagement/LabLogbook/urls.py index 8120c8c9..8c87b7e7 100644 --- a/cnr-ifn.mi/UdyniManagement/LabLogbook/urls.py +++ b/cnr-ifn.mi/UdyniManagement/LabLogbook/urls.py @@ -1,5 +1,5 @@ -from . import views -from . import views_api +from LabLogbook import views +from LabLogbook import views_api from UdyniManagement.views import EmptyView from django.urls import path, reverse_lazy diff --git a/cnr-ifn.mi/UdyniManagement/LabLogbook/views.py b/cnr-ifn.mi/UdyniManagement/LabLogbook/views.py index 9c4b9ae4..73a3b5e8 100644 --- a/cnr-ifn.mi/UdyniManagement/LabLogbook/views.py +++ b/cnr-ifn.mi/UdyniManagement/LabLogbook/views.py @@ -1,11 +1,10 @@ -from .models import Laboratory, Sample, ExperimentalStation, Experiment, SampleForExperiment, Measurement, File, Comment, CommentContent -from .forms import CommentForm, CommentContentForm +from LabLogbook.models import Laboratory, Sample, ExperimentalStation, Experiment, SampleForExperiment, Measurement, File, Comment, CommentContent +from LabLogbook.forms import CommentForm, CommentContentForm from UdyniManagement.views import ListViewMenu, CreateViewMenu, UpdateViewMenu, DeleteViewMenu from UdyniManagement.menu import UdyniMenu from django.contrib.auth.mixins import PermissionRequiredMixin from django.views import View -from django.db.models import Prefetch from django.shortcuts import get_object_or_404, render, redirect from django.urls import reverse_lazy diff --git a/cnr-ifn.mi/UdyniManagement/LabLogbook/views_api.py b/cnr-ifn.mi/UdyniManagement/LabLogbook/views_api.py index 5cfde5c3..2661cfdf 100644 --- a/cnr-ifn.mi/UdyniManagement/LabLogbook/views_api.py +++ b/cnr-ifn.mi/UdyniManagement/LabLogbook/views_api.py @@ -1,7 +1,7 @@ -from .models import ExperimentalStation -from .models import Experiment -from .models import SampleForExperiment -from .models import Measurement, Sample, File, Comment, CommentContent +from LabLogbook.models import ExperimentalStation +from LabLogbook.models import Experiment +from LabLogbook.models import SampleForExperiment +from LabLogbook.models import Measurement, Sample, File, Comment, CommentContent import json from django.views import View diff --git a/cnr-ifn.mi/UdyniManagement/Projects/forms.py b/cnr-ifn.mi/UdyniManagement/Projects/forms.py index 5948d4b8..dd389c0e 100644 --- a/cnr-ifn.mi/UdyniManagement/Projects/forms.py +++ b/cnr-ifn.mi/UdyniManagement/Projects/forms.py @@ -1,5 +1,5 @@ from django import forms -from .models import ResearcherRole, Project +from Projects.models import ResearcherRole, Project class ResearcherRoleForm(forms.ModelForm): diff --git a/cnr-ifn.mi/UdyniManagement/Projects/urls.py b/cnr-ifn.mi/UdyniManagement/Projects/urls.py index c0c1ec8f..bc90a89e 100644 --- a/cnr-ifn.mi/UdyniManagement/Projects/urls.py +++ b/cnr-ifn.mi/UdyniManagement/Projects/urls.py @@ -1,7 +1,7 @@ from django.urls import path, reverse_lazy from django.views.generic.base import RedirectView -from . import views +from Projects import views urlpatterns = [ path('', RedirectView.as_view(url=reverse_lazy('project_view'), permanent=False), name='projects_index'), diff --git a/cnr-ifn.mi/UdyniManagement/Projects/views.py b/cnr-ifn.mi/UdyniManagement/Projects/views.py index e94bc579..6b15bce6 100644 --- a/cnr-ifn.mi/UdyniManagement/Projects/views.py +++ b/cnr-ifn.mi/UdyniManagement/Projects/views.py @@ -2,11 +2,11 @@ from django.urls import reverse_lazy from django.db.models import F, Subquery -from .models import Researcher, ResearcherRole, Project, WorkPackage, ConflictOfInterest +from Projects.models import Researcher, ResearcherRole, Project, WorkPackage, ConflictOfInterest from django.contrib.auth.mixins import PermissionRequiredMixin -from .forms import ResearcherRoleForm, ProjectForm +from Projects.forms import ResearcherRoleForm, ProjectForm from django.views import View from UdyniManagement.views import ListViewMenu, CreateViewMenu, UpdateViewMenu, DeleteViewMenu diff --git a/cnr-ifn.mi/UdyniManagement/Reporting/admin.py b/cnr-ifn.mi/UdyniManagement/Reporting/admin.py index 74cc45fb..1100ead8 100644 --- a/cnr-ifn.mi/UdyniManagement/Reporting/admin.py +++ b/cnr-ifn.mi/UdyniManagement/Reporting/admin.py @@ -1,5 +1,5 @@ from django.contrib import admin -from .models import BankHoliday, EpasCode, PersonnelCost, PresenceData, ReportingPeriod, ReportedWork, ReportedMission, ReportedWorkWorkpackage, TimesheetHours +from Reporting.models import BankHoliday, EpasCode, PersonnelCost, PresenceData, ReportingPeriod, ReportedWork, ReportedMission, ReportedWorkWorkpackage, TimesheetHours # Register your models here. admin.site.register(BankHoliday) diff --git a/cnr-ifn.mi/UdyniManagement/Reporting/timesheets.py b/cnr-ifn.mi/UdyniManagement/Reporting/timesheets.py index f12a280a..ea60a86d 100644 --- a/cnr-ifn.mi/UdyniManagement/Reporting/timesheets.py +++ b/cnr-ifn.mi/UdyniManagement/Reporting/timesheets.py @@ -3,9 +3,9 @@ from django.db.models import Q, F, Sum, Value, Subquery, OuterRef from django.db.models.functions import ExtractYear, ExtractMonth, Coalesce -from .models import EpasCode, PresenceData, ReportedWork, ReportedMission, TimesheetHours -from .utils import check_bank_holiday, get_workpackages_fractions -from .utils import ReportingError +from Reporting.models import EpasCode, PresenceData, ReportedWork, ReportedMission, TimesheetHours +from Reporting.utils import check_bank_holiday, get_workpackages_fractions +from Reporting.utils import ReportingError from Tags.templatetags import tr_month diff --git a/cnr-ifn.mi/UdyniManagement/Reporting/utils.py b/cnr-ifn.mi/UdyniManagement/Reporting/utils.py index b1643339..ef4d0954 100644 --- a/cnr-ifn.mi/UdyniManagement/Reporting/utils.py +++ b/cnr-ifn.mi/UdyniManagement/Reporting/utils.py @@ -4,7 +4,7 @@ from django.db.models import Q from Tags.templatetags.tr_month import month_num2it -from .models import BankHoliday +from Reporting.models import BankHoliday def process_presences(xls, researcher): diff --git a/cnr-ifn.mi/UdyniManagement/Reporting/views.py b/cnr-ifn.mi/UdyniManagement/Reporting/views.py index 30248aea..6cede1fe 100644 --- a/cnr-ifn.mi/UdyniManagement/Reporting/views.py +++ b/cnr-ifn.mi/UdyniManagement/Reporting/views.py @@ -10,16 +10,16 @@ from django.db.models.functions import ExtractYear, ExtractMonth, Concat, Coalesce, Floor, Least from Projects.models import Project, Researcher, ResearcherRole, WorkPackage, ConflictOfInterest -from .models import EpasCode, BankHoliday, PersonnelCost, PresenceData, ReportingPeriod, ReportedWork, ReportedWorkWorkpackage, ReportedMission, TimesheetHours +from Reporting.models import EpasCode, BankHoliday, PersonnelCost, PresenceData, ReportingPeriod, ReportedWork, ReportedWorkWorkpackage, ReportedMission, TimesheetHours -from .forms import AddReportedMissionForm, EpasCodeUpdateForm, PresenceInputForm, ReportedWorkForm #, ReportingAddForm +from Reporting.forms import AddReportedMissionForm, EpasCodeUpdateForm, PresenceInputForm, ReportedWorkForm #, ReportingAddForm -from .utils import process_presences, summarize_presences, serialize_presences -from .utils import unserialize_presences, check_presences_unique, check_bank_holiday -from .utils import get_workpackages_fractions -from .utils import ReportingError -from .timesheets import CheckTimesheetData, GetTimesheetData -from .print import PrintPFDTimesheet +from Reporting.utils import process_presences, summarize_presences, serialize_presences +from Reporting.utils import unserialize_presences, check_presences_unique, check_bank_holiday +from Reporting.utils import get_workpackages_fractions +from Reporting.utils import ReportingError +from Reporting.timesheets import CheckTimesheetData, GetTimesheetData +from Reporting.print import PrintPFDTimesheet from Tags.templatetags import tr_month diff --git a/cnr-ifn.mi/UdyniManagement/UdyniManagement/settings/development.example.py b/cnr-ifn.mi/UdyniManagement/UdyniManagement/settings/development.example.py index 208a95ee..4932b025 100644 --- a/cnr-ifn.mi/UdyniManagement/UdyniManagement/settings/development.example.py +++ b/cnr-ifn.mi/UdyniManagement/UdyniManagement/settings/development.example.py @@ -1,8 +1,8 @@ # Development settings # NOTE: when running Django rename to development.py and set the environment variable DJANGO_SETTINGS_MODULE=UdyniManagement.settings.development -from . import * # Import base settings from settings/__init__.py -from .development_logging import LOGGING # Import logging configuration for production +from UdyniManagement.settings import * # Import base settings from settings/__init__.py +from UdyniManagement.settings.development_logging import LOGGING # Import logging configuration for production # Secret key SECRET_KEY = 'django-insecure-#m^ta)8wnr+v=@o*t5#n&coip**2brq!!j@b8i8-=_+j$3zo9=' diff --git a/cnr-ifn.mi/UdyniManagement/UdyniManagement/settings/production.example.py b/cnr-ifn.mi/UdyniManagement/UdyniManagement/settings/production.example.py index 13dbf1a1..97e07266 100644 --- a/cnr-ifn.mi/UdyniManagement/UdyniManagement/settings/production.example.py +++ b/cnr-ifn.mi/UdyniManagement/UdyniManagement/settings/production.example.py @@ -1,8 +1,8 @@ # Production settings # NOTE: when running Django rename to production.py and set the environment variable DJANGO_SETTINGS_MODULE=UdyniManagement.settings.production -from . import * # Import base settings from settings/__init__.py -from production_logging import LOGGING # Import logging configuration for production +from UdyniManagement.settings import * # Import base settings from settings/__init__.py +from UdyniManagement.settings.production_logging import LOGGING # Import logging configuration for production # Secret key SECRET_KEY = '*****************' # Set this to a secure random value diff --git a/cnr-ifn.mi/UdyniManagement/UdyniManagement/urls.py b/cnr-ifn.mi/UdyniManagement/UdyniManagement/urls.py index fee7ff7d..21f601fc 100644 --- a/cnr-ifn.mi/UdyniManagement/UdyniManagement/urls.py +++ b/cnr-ifn.mi/UdyniManagement/UdyniManagement/urls.py @@ -15,8 +15,8 @@ """ from django.contrib import admin from django.urls import include, path -from . import views -from .menu import menu_include +from UdyniManagement import views +from UdyniManagement.menu import menu_include urlpatterns = [ diff --git a/cnr-ifn.mi/UdyniManagement/UdyniManagement/views.py b/cnr-ifn.mi/UdyniManagement/UdyniManagement/views.py index 7c132188..4b03543c 100644 --- a/cnr-ifn.mi/UdyniManagement/UdyniManagement/views.py +++ b/cnr-ifn.mi/UdyniManagement/UdyniManagement/views.py @@ -9,7 +9,7 @@ from django.views.generic.edit import CreateView, UpdateView, DeleteView, FormView from django.contrib.auth.mixins import LoginRequiredMixin, PermissionRequiredMixin -from .menu import UdyniMenu +from UdyniManagement.menu import UdyniMenu # ============================================= diff --git a/cnr-ifn.mi/UdyniManagement/sigla/urls.py b/cnr-ifn.mi/UdyniManagement/sigla/urls.py index ee43b5f8..fda256f5 100644 --- a/cnr-ifn.mi/UdyniManagement/sigla/urls.py +++ b/cnr-ifn.mi/UdyniManagement/sigla/urls.py @@ -1,6 +1,6 @@ from django.urls import path, reverse_lazy -from . import views +from sigla import views urlpatterns = [ diff --git a/cnr-ifn.mi/UdyniManagement/sigla/views.py b/cnr-ifn.mi/UdyniManagement/sigla/views.py index 7f826b8f..b40334de 100644 --- a/cnr-ifn.mi/UdyniManagement/sigla/views.py +++ b/cnr-ifn.mi/UdyniManagement/sigla/views.py @@ -12,7 +12,7 @@ from UdyniManagement.menu import UdyniMenu -from .sigla import SIGLA +from sigla.sigla import SIGLA from Accounting.models import GAE diff --git a/cnr-ifn.mi/udyninexus/udyninexus/__init__.py b/cnr-ifn.mi/udyninexus/udyninexus/__init__.py index 1290267f..fd7fab4c 100644 --- a/cnr-ifn.mi/udyninexus/udyninexus/__init__.py +++ b/cnr-ifn.mi/udyninexus/udyninexus/__init__.py @@ -1,9 +1,9 @@ -from .classes.NexusContainer import NexusContainer -from .classes.Beam import Beam -from .classes.Detector import Detector -from .classes.Source import Source -from .classes.Sample import Sample -from .classes.Data import Axis, Data -from .write_nexus import write_nexus -from .exceptions import NexusSaveError, NexusValidationError -from .logging_settings import set_log_level, set_log_file \ No newline at end of file +from udyninexus.classes.NexusContainer import NexusContainer +from udyninexus.classes.Beam import Beam +from udyninexus.classes.Detector import Detector +from udyninexus.classes.Source import Source +from udyninexus.classes.Sample import Sample +from udyninexus.classes.Data import Axis, Data +from udyninexus.write_nexus import write_nexus +from udyninexus.exceptions import NexusSaveError, NexusValidationError +from udyninexus.logging_settings import set_log_level, set_log_file \ No newline at end of file diff --git a/cnr-ifn.mi/udyninexus/udyninexus/classes/Beam.py b/cnr-ifn.mi/udyninexus/udyninexus/classes/Beam.py index f8f4b81a..94cc928a 100644 --- a/cnr-ifn.mi/udyninexus/udyninexus/classes/Beam.py +++ b/cnr-ifn.mi/udyninexus/udyninexus/classes/Beam.py @@ -1,11 +1,24 @@ -from .Instrument import Instrument -from ..utils import create_property_check_type, create_property_check_in_valid_values -from .Source import Source +from udyninexus.classes.Instrument import Instrument +from udyninexus.classes.Source import Source +from udyninexus.utils import create_property_check_type, create_property_check_in_valid_values from typing import Literal class Beam(Instrument): + """ + Represents the characteristics of a beam used in spectroscopy experiments. + + Attributes: + name_in_nexus (str): Identifier used in the NeXus file. The beam will be saved inside the 'instrument' group under the name 'beam\_\'. + beam_type (str): Specify the role of the beam ('pump' or 'probe'). + parameter_reliability (str): Indicates how the beam characteristics were obtained ('measured', 'nominal'). + incident_wavelength (int): Wavelength of the incident beam. + incident_wavelength_units (str): Units of the incident wavelength ('nm', 'um'). + incident_polarization (int): Polarization value of the incident beam. + beam_polarization_type (str): Type of beam polarization ('linear', 'circular', 'elliptically', 'unpolarized'). + associated_source (Source): Device that emitted the beam. In the NeXus file the path to the source will be specified in the 'associated_source' NXfield. + """ def __init__(self, name_in_nexus: str = None, beam_type: Literal['pump', 'probe'] = None, diff --git a/cnr-ifn.mi/udyninexus/udyninexus/classes/Data.py b/cnr-ifn.mi/udyninexus/udyninexus/classes/Data.py index 3c246d38..6cec20f6 100644 --- a/cnr-ifn.mi/udyninexus/udyninexus/classes/Data.py +++ b/cnr-ifn.mi/udyninexus/udyninexus/classes/Data.py @@ -1,9 +1,21 @@ -from ..utils import create_property_check_one_dimensional_axis_data, create_property_check_isinstance, create_property_check_type, create_property_check_type_for_lists -from .Instrument import Instrument +from udyninexus.classes.Instrument import Instrument +from udyninexus.utils import create_property_check_one_dimensional_axis_data, create_property_check_isinstance, create_property_check_type, create_property_check_type_for_lists + from typing import Optional, List, Any class Axis: + """ + Represents a one-dimensional axis in data. + + Attributes: + name (str): Name used to identify this axis in the NeXus file. This will be the key under which the signal data is stored. + data (List): A one-dimensional sequence of values representing the axis (e.g., range(10)). + units (str): The unit of measurement for the axis values (e.g., 'nm', 'ms'). Defaults to 'index' if not specified. + related_instrument (Instrument): Reference to the instrument that controls or is associated with this axis.\ + If specified the signal data will be stored inside this instrument's group in the NeXus file and linked via an NXlink in the 'data' group.\ + Otherwise the data of the axis will be directly saved inside the 'data' group. + """ def __init__(self, name: str = None, data: Optional[List] = None, @@ -23,6 +35,17 @@ def __init__(self, class Data: + """ + Represents measured signal data. + + Attributes: + signal_name (str): Name used to identify the signal in the NeXus file. This will be the key under which the signal data is stored. + signal_data: A multi-dimensional array of values representing the signal measurements. + signal_units (str): Unit of measurement for the signal values (e.g., 'nm', 'ms'). + signal_related_instrument (Instrument): Reference to the instrument that measured the signal. The signal data will be stored inside this instrument's group in the NeXus file and linked via an NXlink in the 'data' group. + axes (List[Axis]): List of axes associated with the signal data. + """ + def __init__(self, signal_name: str = None, signal_data: Any = None, # it must be a data with a shape (multi dimensional array) diff --git a/cnr-ifn.mi/udyninexus/udyninexus/classes/Detector.py b/cnr-ifn.mi/udyninexus/udyninexus/classes/Detector.py index 78cbddbf..b12534ee 100644 --- a/cnr-ifn.mi/udyninexus/udyninexus/classes/Detector.py +++ b/cnr-ifn.mi/udyninexus/udyninexus/classes/Detector.py @@ -1,10 +1,18 @@ -from .Instrument import Instrument -from ..utils import create_property_check_in_valid_values +from udyninexus.classes.Instrument import Instrument +from udyninexus.utils import create_property_check_in_valid_values from typing import Literal class Detector(Instrument): + """ + Represents the characteristics of a detector used in spectroscopy experiments. + + Attributes: + name_in_nexus (str): Identifier used in the NeXus file. The detector will be saved inside the 'instrument' group under the name 'detector\_\'. + detector_channel_type (str): Type of detector based on the number of channels ('single-channel' or 'multichannel'). + detector_type (str): Type of detector ('CCD', 'photomultiplier', 'photodiode', 'avalanche-photodiode', 'streak camera', 'bolometer', 'golay detectors', 'pyroelectric detector', 'deuterated triglycine sulphate'). + """ def __init__(self, name_in_nexus: str = None, detector_channel_type : Literal['single-channel', 'multichannel'] = None, diff --git a/cnr-ifn.mi/udyninexus/udyninexus/classes/Instrument.py b/cnr-ifn.mi/udyninexus/udyninexus/classes/Instrument.py index 8eedb733..89743aa8 100644 --- a/cnr-ifn.mi/udyninexus/udyninexus/classes/Instrument.py +++ b/cnr-ifn.mi/udyninexus/udyninexus/classes/Instrument.py @@ -1,6 +1,13 @@ -from ..utils import create_property_check_type +from udyninexus.utils import create_property_check_type + class Instrument: + """ + Base class for an istrument used in spectroscopy experiments, all the instrument inherit from this class. + + Attributes: + name_in_nexus (str): Identifier used in the NeXus file. The specific instrument will be saved inside the 'instrument' group under the name '\\_\'. + """ def __init__(self, name_in_nexus: str = None ): diff --git a/cnr-ifn.mi/udyninexus/udyninexus/classes/NexusContainer.py b/cnr-ifn.mi/udyninexus/udyninexus/classes/NexusContainer.py index 12eb1ee7..0379dbaa 100644 --- a/cnr-ifn.mi/udyninexus/udyninexus/classes/NexusContainer.py +++ b/cnr-ifn.mi/udyninexus/udyninexus/classes/NexusContainer.py @@ -1,17 +1,32 @@ -from ..utils import create_property_check_type, create_property_check_in_valid_values, create_property_check_type_for_lists, get_time_now -from .Beam import Beam -from .Detector import Detector -from .Source import Source -from .Sample import Sample -from .Data import Data - +from udyninexus.classes.Beam import Beam +from udyninexus.classes.Detector import Detector +from udyninexus.classes.Source import Source +from udyninexus.classes.Sample import Sample +from udyninexus.classes.Data import Data +from udyninexus.utils import create_property_check_type, create_property_check_in_valid_values, create_property_check_type_for_lists, get_time_now from typing import List, Literal from datetime import datetime class NexusContainer: + """ + Class used for storing all the data to write on the NeXus file. + Attributes: + title (str): Title of the experiment. + identifier_experiment (int): Identifier of the experiment used inside the laboratories (Experiment ID in LabLogbook). + experiment_type (str): Type of spectroscopy experiment ('photoluminescence', 'transmission spectroscopy', 'reflection spectroscopy'). + experiment_sub_type (str): Specify the generic experiment type ('time resolved', 'imaging', 'pump-probe'). + experiment_description (str): Free-text description of the experiment. + beams (List[Beam]): Beams used in the experiment. + detectors (List[Detector]): Detectors used in the experiment. + sources (List[Source]): Sources of the beams used in the experiment. + sample (Sample): Sample used in the experiment. + data (Data): Experimental data. + start_time (datetime): Start time of the experiment. It can be setted with the current time using set_start_time_now method. + end_time (datetime): Time of experiment end. It can be setted with the current time using set_end_time_now method. + """ def __init__(self, title: str = None, identifier_experiment: int = None, diff --git a/cnr-ifn.mi/udyninexus/udyninexus/classes/Sample.py b/cnr-ifn.mi/udyninexus/udyninexus/classes/Sample.py index 9573aff8..25436aac 100644 --- a/cnr-ifn.mi/udyninexus/udyninexus/classes/Sample.py +++ b/cnr-ifn.mi/udyninexus/udyninexus/classes/Sample.py @@ -1,7 +1,14 @@ -from ..utils import create_property_check_type +from udyninexus.utils import create_property_check_type class Sample: + """ + Represents the characteristics of the sample used in a spectroscopy experiment. + + Attributes: + name (str): Name of the sample. + sample_id (int): Identifier of the sample used inside the laboratories (Sample ID in LabLogbook). + """ def __init__(self, name: str = None, sample_id: int = None diff --git a/cnr-ifn.mi/udyninexus/udyninexus/classes/Source.py b/cnr-ifn.mi/udyninexus/udyninexus/classes/Source.py index 19f260a7..65e62057 100644 --- a/cnr-ifn.mi/udyninexus/udyninexus/classes/Source.py +++ b/cnr-ifn.mi/udyninexus/udyninexus/classes/Source.py @@ -1,10 +1,18 @@ -from .Instrument import Instrument -from ..utils import create_property_check_in_valid_values +from udyninexus.classes.Instrument import Instrument +from udyninexus.utils import create_property_check_in_valid_values from typing import Literal class Source(Instrument): + """ + Represents the characteristics of a source emitting a beam used in spectroscopy experiments. + + Attributes: + name_in_nexus (str): Identifier used in the NeXus file. The source will be saved inside the 'instrument' group under the name 'source\_\'. + type (str): Type of source ('Synchrotron X-ray Source', 'Rotating Anode X-ray', 'Fixed Tube X-ray', 'UV Laser', 'Optical Laser', 'Laser', 'Dye-Laser',\ + 'Broadband Tunable Light Source', 'Halogen lamp', 'LED', 'Mercury Cadmium Telluride', 'Deuterium Lamp', 'Xenon Lamp', 'Globar'). + """ def __init__(self, name_in_nexus: str = None, type: Literal['Synchrotron X-ray Source', 'Rotating Anode X-ray', 'Fixed Tube X-ray', diff --git a/cnr-ifn.mi/udyninexus/udyninexus/logging_settings.py b/cnr-ifn.mi/udyninexus/udyninexus/logging_settings.py index e45d527e..8be083e9 100644 --- a/cnr-ifn.mi/udyninexus/udyninexus/logging_settings.py +++ b/cnr-ifn.mi/udyninexus/udyninexus/logging_settings.py @@ -1,6 +1,7 @@ import logging from typing import Literal + logging.basicConfig( level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s', diff --git a/cnr-ifn.mi/udyninexus/udyninexus/nexus_validation.py b/cnr-ifn.mi/udyninexus/udyninexus/nexus_validation.py index 6f04f5e8..77f14130 100644 --- a/cnr-ifn.mi/udyninexus/udyninexus/nexus_validation.py +++ b/cnr-ifn.mi/udyninexus/udyninexus/nexus_validation.py @@ -1,11 +1,11 @@ -from .classes.NexusContainer import NexusContainer -from .classes.Beam import Beam -from .classes.Detector import Detector -from .classes.Source import Source -from .classes.Sample import Sample -from .classes.Data import Axis, Data -from .utils import get_shape -from .logging_settings import logger +from udyninexus.classes.NexusContainer import NexusContainer +from udyninexus.classes.Beam import Beam +from udyninexus.classes.Detector import Detector +from udyninexus.classes.Source import Source +from udyninexus.classes.Sample import Sample +from udyninexus.classes.Data import Axis, Data +from udyninexus.utils import get_shape +from udyninexus.logging_settings import logger def _get_invalid_none_attributes(instance_name: str, instance, allowed_none: set) -> list[str]: diff --git a/cnr-ifn.mi/udyninexus/udyninexus/write_nexus.py b/cnr-ifn.mi/udyninexus/udyninexus/write_nexus.py index 339ded21..d98b491d 100644 --- a/cnr-ifn.mi/udyninexus/udyninexus/write_nexus.py +++ b/cnr-ifn.mi/udyninexus/udyninexus/write_nexus.py @@ -2,22 +2,22 @@ # - Add parameters for specifying compression # - Create methods for editing definition in NexusDataContainer, for now it's hardcoded since the lab will only use an implementation of NXoptical_spectroscopy -from .classes.NexusContainer import NexusContainer -from .classes.Instrument import Instrument -from .classes.Source import Source -from .classes.Beam import Beam -from .classes.Data import Axis -from .classes.Detector import Detector -from .nexus_validation import errors_in_nexus_container -from .logging_settings import logger -from .exceptions import NexusValidationError, NexusSaveError +from udyninexus.classes.NexusContainer import NexusContainer +from udyninexus.classes.Instrument import Instrument +from udyninexus.classes.Source import Source +from udyninexus.classes.Beam import Beam +from udyninexus.classes.Data import Axis +from udyninexus.classes.Detector import Detector +from udyninexus.nexus_validation import errors_in_nexus_container +from udyninexus.logging_settings import logger +from udyninexus.exceptions import NexusValidationError, NexusSaveError from nexusformat.nexus import * from pathlib import Path def _obtain_reference(data_name: str, related_instrument: Instrument): - '''Givne the name of a data and the instrument that generated it, return the path the data should be saved into''' + '''Give the name of a data and the instrument that generated it, return the path the data should be saved into''' related_instrument_type = type(related_instrument) if related_instrument_type == Source: