Skip to content

Commit

Permalink
Merge pull request #4 from FAIRmat-NFDI/Update_reader_for_new_NXopt
Browse files Browse the repository at this point in the history
dataconverter works as intented and for the new NXopt version. Some necessary changes for compatibility with other applications were as well done.
  • Loading branch information
RonHildebrandt authored May 16, 2024
2 parents fd2acc9 + a100cff commit a3f1cc5
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 91 deletions.
64 changes: 35 additions & 29 deletions examples/eln_data.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'
start_time: '2022-01-27T03:35:00+00:00'
74 changes: 42 additions & 32 deletions pynxtools_ellips/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@

CONVERT_DICT = {
"unit": "@units",
"Beam_path": "BEAM_PATH[beam_path]",
"Detector": "DETECTOR[detector]",
"Data": "data_collection",
"Derived_parameters": "derived_parameters",
Expand All @@ -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 = [
Expand All @@ -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]",
}

Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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[
Expand All @@ -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"] = (
f"{plot_name} (degree)"
)
template[f"/ENTRY[entry]/plot/DATA[{key}_errors]"] = {
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, :],
}
Expand All @@ -441,30 +445,36 @@ 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"] = (
"https://github.com/FAIRmat-NFDI/nexus_definitions/"
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"] = (
"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

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
64 changes: 35 additions & 29 deletions tests/data/eln_data.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'
start_time: '2022-01-27T03:35:00+00:00'

0 comments on commit a3f1cc5

Please sign in to comment.