From f8cc4b2061de70e7c50d84b50092dcc0705726e8 Mon Sep 17 00:00:00 2001 From: Ron Hildebrandt Date: Wed, 15 May 2024 08:32:37 +0200 Subject: [PATCH 1/3] Fix reader name in and adjust dataconverter for new NXopt version --- examples/eln_data.yaml | 64 +++++++++++++++++++++----------------- pynxtools_ellips/reader.py | 60 ++++++++++++++++++----------------- pyproject.toml | 2 +- 3 files changed, 68 insertions(+), 58 deletions(-) diff --git a/examples/eln_data.yaml b/examples/eln_data.yaml index f20f758..edd7408 100644 --- a/examples/eln_data.yaml +++ b/examples/eln_data.yaml @@ -7,44 +7,46 @@ Data: spectrum_type: wavelength spectrum_unit: angstrom Instrument: - Beam_path: - Detector: - count_time: - unit: s - value: 1.0 - detector_type: CCD spectrometer - focussing_probes: - angular_spread: - unit: rad - value: 0.2 - data_correction: false - light_source: - source_type: arc lamp - rotating_element: - revolutions: 50.0 + Detector: + count_time: + unit: s + value: 1.0 + detector_type: CCD spectrometer + focussing_probes: + angular_spread: + unit: rad + value: 0.2 + data_correction: false + light_source: + source_type: arc lamp + rotating_element: + revolutions: 50.0 Sample_stage: environment_conditions: - medium: air stage_type: manual stage - angle_of_incidence/@unit: degrees - calibration_status: no calibration - company: J. A. Woollam Co. +# angle_of_incidence/@unit: degrees + device_information: + vendor: J. A. Woollam Co. + model: RC2 (Vers. 0.0.1) ellipsometer_type: dual compensator - model: RC2 - model/@version: 0.0.1 rotating_element_type: compensator (source side) - software: CompleteEASE - software/@url: https://www.jawoollam.com/ellipsometry-software/completeease - software/version: '6.37' + software_RC2: CompleteEASE + software_RC2/@url: https://www.jawoollam.com/ellipsometry-software/completeease + software_RC2/@version: '6.37' + instrument_calibration_RC2: + calibration_status: no calibration Sample: atom_types: Si, O backside_roughness: false chemical_formula: SiO2 layer_structure: 2nm SiO2 on Si - sample_history: Commercially purchased sample sample_name: 2nm SiO2 on Si - sample_type: multi layer + physical_form: multi layer substrate: Si + environment: + sample_medium: air + history: + notes: Commercially purchased sample User: address: Zum Großen Windkanal 2, 12489 Berlin, Germany affiliation: Humboldt-Universität zu Berlin @@ -60,10 +62,14 @@ colnames: - err.Delta derived_parameter_type: depolarization experiment_description: RC2 scan on 2nm SiO2 on Si in air -experiment_identifier: exp-ID -experiment_type: NIR-Vis-UV spectroscopic ellipsometry +experiment_identifier: + identifier: exp-ID + is_persistent: "false" +experiment_type: ellipsometry +ellipsometry_experiment_type: NIR-Vis-UV spectroscopic ellipsometry filename: test-data.dat plot_name: Psi and Delta +title: RC2 Ellipsometry of 2nm SiO2 on Si sep: \t skip: 3 -start_time: '2022-01-27T03:35:00+00:00' \ No newline at end of file +start_time: '2022-01-27T03:35:00+00:00' diff --git a/pynxtools_ellips/reader.py b/pynxtools_ellips/reader.py index d44b4b4..f37d5e2 100644 --- a/pynxtools_ellips/reader.py +++ b/pynxtools_ellips/reader.py @@ -37,7 +37,6 @@ CONVERT_DICT = { "unit": "@units", - "Beam_path": "BEAM_PATH[beam_path]", "Detector": "DETECTOR[detector]", "Data": "data_collection", "Derived_parameters": "derived_parameters", @@ -52,8 +51,18 @@ "data_error": "data_collection/data_error", "depolarization": "derived_parameters/depolarization", "measured_data": "data_collection/measured_data", - "software": "software/program", - "data_software": "data_software/program", + "data_software": "software_TYPE[data_software]/program", + "experiment_identifier/identifier":"IDENTIFIER[experiment_identifier]/IDENTIFIER[identifier]", + "experiment_identifier/is_persistent":"IDENTIFIER[experiment_identifier]/IS_PERSISTENT[is_persistent]", + "software_RC2": "software_TYPE[software_RC2]/program", + "software_RC2/@url": "software_TYPE[software_RC2]/program/@url", + "software_RC2/@version": "software_TYPE[software_RC2]/program/@version", + "instrument_calibration_RC2": "instrument_calibration_DEVICE[instrument_calibration_RC2]/calibration_status", + "instrument_calibration_RC2/calibration_status": "instrument_calibration_DEVICE[instrument_calibration_RC2]/calibration_status", + "environment": "ENVIRONMENT[environment_sample]", + "history/notes": "HISTORY[history]/notes", + "light_source" : "source_TYPE[source_light]", + "source_type" : "type", } CONFIG_KEYS = [ @@ -70,8 +79,7 @@ ] REPLACE_NESTED = { - "Instrument/Beam_path": "INSTRUMENT[instrument]/BEAM_PATH[beam_path]", - "Env_Conditions": "INSTRUMENT[instrument]/sample_stage/environment_conditions", + "Inc_Det_Angles": "INSTRUMENT[instrument]", "Instrument": "INSTRUMENT[instrument]", } @@ -347,15 +355,11 @@ def populate_header_dict_with_datasets(file_paths, is_mock=False): ) def write_scan_axis(name: str, values: list, units: str): - base_path = f"Env_Conditions/PARAMETER[{name}]" - header[f"{base_path}/values"] = values - header[f"{base_path}/values/@units"] = units - header[f"{base_path}/number_of_parameters"] = len(values) - header[f"{base_path}/number_of_parameters/@units"] = "" - header[f"{base_path}/parameter_type"] = name - - header["Instrument/angle_of_incidence"] = unique_angles - for axis in ["detection_angle", "incident_angle"]: + base_path = f"Inc_Det_Angles/PARAMETER[{name}]" + header[f"{base_path}"] = values + header[f"{base_path}/@units"] = units + + for axis in ["angle_of_detection", "angle_of_incidence"]: write_scan_axis(axis, unique_angles, "degree") # Create mocked ellipsometry data template: @@ -409,7 +413,7 @@ def read( # because test-data.data has improper units like Angstroms or degrees # the fix above prevents that these incorrect units are get just blindly carried # over into the nxs file and thus causing nomas to fail - template[f"/ENTRY[entry]/plot/AXISNAME[{spectrum_type}]"] = { + template[f"/ENTRY[entry]/data_collection/AXISNAME[{spectrum_type}]"] = { "link": f"/entry/data_collection/{spectrum_type}_spectrum" } template[ @@ -421,18 +425,18 @@ def read( plot_name = header["plot_name"] for dindx in range(0, len(labels.keys())): for index, key in enumerate(data_list[dindx]): - template[f"/ENTRY[entry]/plot/DATA[{key}]"] = { + template[f"/ENTRY[entry]/data_collection/DATA[{key}]"] = { "link": "/entry/data_collection/measured_data", "shape": np.index_exp[index, dindx, :], } # MK:: Carola, Ron, Flo, Tamas, Sandor refactor the following line # using a proper unit parsing logic - template[f"/ENTRY[entry]/plot/DATA[{key}]/@units"] = "degree" + template[f"/ENTRY[entry]/data_collection/DATA[{key}]/@units"] = "degree" if dindx == 0 and index == 0: - template[f"/ENTRY[entry]/plot/DATA[{key}]/@long_name"] = ( + template[f"/ENTRY[entry]/data_collection/DATA[{key}]/@long_name"] = ( f"{plot_name} (degree)" ) - template[f"/ENTRY[entry]/plot/DATA[{key}_errors]"] = { + template[f"/ENTRY[entry]/data_collection/DATA[{key}_errors]"] = { "link": "/entry/data_collection/data_error", "shape": np.index_exp[index, dindx, :], } @@ -441,15 +445,15 @@ def read( # Define default plot showing Psi and Delta at all angles: template["/@default"] = "entry" - template["/ENTRY[entry]/@default"] = "plot" - template["/ENTRY[entry]/plot/@signal"] = f"{data_list[0][0]}" - template["/ENTRY[entry]/plot/@axes"] = spectrum_type - template["/ENTRY[entry]/plot/title"] = plot_name + template["/ENTRY[entry]/@default"] = "data_collection" + template["/ENTRY[entry]/data_collection/@signal"] = f"{data_list[0][0]}" + template["/ENTRY[entry]/data_collection/@axes"] = spectrum_type + template["/ENTRY[entry]/data_collection/title"] = plot_name # if len(data_list[0]) > 1: - template["/ENTRY[entry]/plot/@auxiliary_signals"] = data_list[0][1:] + template["/ENTRY[entry]/data_collection/@auxiliary_signals"] = data_list[0][1:] for index in range(1, len(data_list)): - template["/ENTRY[entry]/plot/@auxiliary_signals"] += data_list[index] + template["/ENTRY[entry]/data_collection/@auxiliary_signals"] += data_list[index] template["/ENTRY[entry]/definition"] = "NXellipsometry" template["/ENTRY[entry]/definition/@url"] = ( @@ -457,12 +461,12 @@ def read( f"blob/{get_nexus_version_hash()}/contributed_definitions/NXellipsometry.nxdl.xml" ) template["/ENTRY[entry]/definition/@version"] = get_nexus_version() - template["/ENTRY[entry]/program_name"] = "pynxtools" + template["/ENTRY[entry]/INSTRUMENT[instrument]/software_TYPE[software_NeXuS]/program"] = "pynxtools" try: - template["/ENTRY[entry]/program_name/@version"] = version("pynxtools") + template["/ENTRY[entry]/INSTRUMENT[instrument]/software_TYPE[software_NeXuS]/program/@version"] = version("pynxtools") except PackageNotFoundError: pass - template["/ENTRY[entry]/program_name/@url"] = ( + template["/ENTRY[entry]/INSTRUMENT[instrument]/software_TYPE[software_NeXuS]/program/@url"] = ( "https://github.com/FAIRmat-NFDI/pynxtools" ) diff --git a/pyproject.toml b/pyproject.toml index 8e08d42..06aa9ad 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,7 +26,7 @@ dependencies = [ ] [project.entry-points."pynxtools.reader"] -ellips = "pynxtools_ellips.reader:ELLIPSReader" +ellips = "pynxtools_ellips.reader:EllipsometryReader" [project.urls] "Homepage" = "https://github.com/FAIRmat-NFDI/pynxtools-ellips" From 8ef6154e3c5d895d94d507330b566ef13d2f1607 Mon Sep 17 00:00:00 2001 From: Ron Hildebrandt Date: Wed, 15 May 2024 09:26:28 +0200 Subject: [PATCH 2/3] fixing linting error (ruff) --- pynxtools_ellips/reader.py | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/pynxtools_ellips/reader.py b/pynxtools_ellips/reader.py index f37d5e2..b1c18a6 100644 --- a/pynxtools_ellips/reader.py +++ b/pynxtools_ellips/reader.py @@ -52,8 +52,8 @@ "depolarization": "derived_parameters/depolarization", "measured_data": "data_collection/measured_data", "data_software": "software_TYPE[data_software]/program", - "experiment_identifier/identifier":"IDENTIFIER[experiment_identifier]/IDENTIFIER[identifier]", - "experiment_identifier/is_persistent":"IDENTIFIER[experiment_identifier]/IS_PERSISTENT[is_persistent]", + "experiment_identifier/identifier": "IDENTIFIER[experiment_identifier]/IDENTIFIER[identifier]", + "experiment_identifier/is_persistent": "IDENTIFIER[experiment_identifier]/IS_PERSISTENT[is_persistent]", "software_RC2": "software_TYPE[software_RC2]/program", "software_RC2/@url": "software_TYPE[software_RC2]/program/@url", "software_RC2/@version": "software_TYPE[software_RC2]/program/@version", @@ -61,8 +61,8 @@ "instrument_calibration_RC2/calibration_status": "instrument_calibration_DEVICE[instrument_calibration_RC2]/calibration_status", "environment": "ENVIRONMENT[environment_sample]", "history/notes": "HISTORY[history]/notes", - "light_source" : "source_TYPE[source_light]", - "source_type" : "type", + "light_source": "source_TYPE[source_light]", + "source_type": "type", } CONFIG_KEYS = [ @@ -433,9 +433,9 @@ def read( # using a proper unit parsing logic template[f"/ENTRY[entry]/data_collection/DATA[{key}]/@units"] = "degree" if dindx == 0 and index == 0: - template[f"/ENTRY[entry]/data_collection/DATA[{key}]/@long_name"] = ( - f"{plot_name} (degree)" - ) + template[ + f"/ENTRY[entry]/data_collection/DATA[{key}]/@long_name" + ] = f"{plot_name} (degree)" template[f"/ENTRY[entry]/data_collection/DATA[{key}_errors]"] = { "link": "/entry/data_collection/data_error", "shape": np.index_exp[index, dindx, :], @@ -453,7 +453,9 @@ def read( # if len(data_list[0]) > 1: template["/ENTRY[entry]/data_collection/@auxiliary_signals"] = data_list[0][1:] for index in range(1, len(data_list)): - template["/ENTRY[entry]/data_collection/@auxiliary_signals"] += data_list[index] + template["/ENTRY[entry]/data_collection/@auxiliary_signals"] += data_list[ + index + ] template["/ENTRY[entry]/definition"] = "NXellipsometry" template["/ENTRY[entry]/definition/@url"] = ( @@ -461,14 +463,18 @@ def read( f"blob/{get_nexus_version_hash()}/contributed_definitions/NXellipsometry.nxdl.xml" ) template["/ENTRY[entry]/definition/@version"] = get_nexus_version() - template["/ENTRY[entry]/INSTRUMENT[instrument]/software_TYPE[software_NeXuS]/program"] = "pynxtools" + template[ + "/ENTRY[entry]/INSTRUMENT[instrument]/software_TYPE[software_NeXuS]/program" + ] = "pynxtools" try: - template["/ENTRY[entry]/INSTRUMENT[instrument]/software_TYPE[software_NeXuS]/program/@version"] = version("pynxtools") + template[ + "/ENTRY[entry]/INSTRUMENT[instrument]/software_TYPE[software_NeXuS]/program/@version" + ] = version("pynxtools") except PackageNotFoundError: pass - template["/ENTRY[entry]/INSTRUMENT[instrument]/software_TYPE[software_NeXuS]/program/@url"] = ( - "https://github.com/FAIRmat-NFDI/pynxtools" - ) + template[ + "/ENTRY[entry]/INSTRUMENT[instrument]/software_TYPE[software_NeXuS]/program/@url" + ] = "https://github.com/FAIRmat-NFDI/pynxtools" return template From a100cff0ac528f79e277adc6e29928c9b2018259 Mon Sep 17 00:00:00 2001 From: Ron Hildebrandt Date: Thu, 16 May 2024 09:13:46 +0200 Subject: [PATCH 3/3] missed to change eln_data.yaml in tests/data --- tests/data/eln_data.yaml | 64 ++++++++++++++++++++++------------------ 1 file changed, 35 insertions(+), 29 deletions(-) diff --git a/tests/data/eln_data.yaml b/tests/data/eln_data.yaml index f20f758..edd7408 100644 --- a/tests/data/eln_data.yaml +++ b/tests/data/eln_data.yaml @@ -7,44 +7,46 @@ Data: spectrum_type: wavelength spectrum_unit: angstrom Instrument: - Beam_path: - Detector: - count_time: - unit: s - value: 1.0 - detector_type: CCD spectrometer - focussing_probes: - angular_spread: - unit: rad - value: 0.2 - data_correction: false - light_source: - source_type: arc lamp - rotating_element: - revolutions: 50.0 + Detector: + count_time: + unit: s + value: 1.0 + detector_type: CCD spectrometer + focussing_probes: + angular_spread: + unit: rad + value: 0.2 + data_correction: false + light_source: + source_type: arc lamp + rotating_element: + revolutions: 50.0 Sample_stage: environment_conditions: - medium: air stage_type: manual stage - angle_of_incidence/@unit: degrees - calibration_status: no calibration - company: J. A. Woollam Co. +# angle_of_incidence/@unit: degrees + device_information: + vendor: J. A. Woollam Co. + model: RC2 (Vers. 0.0.1) ellipsometer_type: dual compensator - model: RC2 - model/@version: 0.0.1 rotating_element_type: compensator (source side) - software: CompleteEASE - software/@url: https://www.jawoollam.com/ellipsometry-software/completeease - software/version: '6.37' + software_RC2: CompleteEASE + software_RC2/@url: https://www.jawoollam.com/ellipsometry-software/completeease + software_RC2/@version: '6.37' + instrument_calibration_RC2: + calibration_status: no calibration Sample: atom_types: Si, O backside_roughness: false chemical_formula: SiO2 layer_structure: 2nm SiO2 on Si - sample_history: Commercially purchased sample sample_name: 2nm SiO2 on Si - sample_type: multi layer + physical_form: multi layer substrate: Si + environment: + sample_medium: air + history: + notes: Commercially purchased sample User: address: Zum Großen Windkanal 2, 12489 Berlin, Germany affiliation: Humboldt-Universität zu Berlin @@ -60,10 +62,14 @@ colnames: - err.Delta derived_parameter_type: depolarization experiment_description: RC2 scan on 2nm SiO2 on Si in air -experiment_identifier: exp-ID -experiment_type: NIR-Vis-UV spectroscopic ellipsometry +experiment_identifier: + identifier: exp-ID + is_persistent: "false" +experiment_type: ellipsometry +ellipsometry_experiment_type: NIR-Vis-UV spectroscopic ellipsometry filename: test-data.dat plot_name: Psi and Delta +title: RC2 Ellipsometry of 2nm SiO2 on Si sep: \t skip: 3 -start_time: '2022-01-27T03:35:00+00:00' \ No newline at end of file +start_time: '2022-01-27T03:35:00+00:00'