diff --git a/examples/json_map/current.nxs b/examples/json_map/current.nxs new file mode 100644 index 000000000..302a97e4f Binary files /dev/null and b/examples/json_map/current.nxs differ diff --git a/examples/json_map/merge_partial_appdefs.mapping.json b/examples/json_map/merge_partial_appdefs.mapping.json new file mode 100644 index 000000000..9a7b27590 --- /dev/null +++ b/examples/json_map/merge_partial_appdefs.mapping.json @@ -0,0 +1,41 @@ +{ + "/@default": "entry", + "/ENTRY[entry]/@default": "data", + + "/ENTRY[entry]/DATA[data]/voltage": 0, + "/ENTRY[entry]/DATA[data]/current": 0, + "/ENTRY[entry]/DATA[data]/temperature": 0, + "/ENTRY[entry]/DATA[data]/@axes": ["voltage"], + "/ENTRY[entry]/DATA[data]/@signal": "current_295C", + "/ENTRY[entry]/DATA[data]/@auxiliary_signals": ["current_300C", "current_305C", "current_310C"], + "/ENTRY[entry]/INSTRUMENT[instrument]/ENVIRONMENT[environment]/voltage_controller/calibration_time": "2022-05-30T16:37:03.909201+02:00", + "/ENTRY[entry]/INSTRUMENT[instrument]/ENVIRONMENT[environment]/voltage_controller/run_control": 0, + "/ENTRY[entry]/INSTRUMENT[instrument]/ENVIRONMENT[environment]/voltage_controller/value": {"link": "voltage_and_temperature.nxs:/entry/instrument/environment/voltage_controller/value"}, + "/ENTRY[entry]/INSTRUMENT[instrument]/ENVIRONMENT[environment]/voltage_controller/value/@units": "V", + "/ENTRY[entry]/INSTRUMENT[instrument]/ENVIRONMENT[environment]/temperature_controller/calibration_time": "2022-05-30T16:37:03.909201+02:00", + "/ENTRY[entry]/INSTRUMENT[instrument]/ENVIRONMENT[environment]/temperature_controller/run_control": 0, + "/ENTRY[entry]/INSTRUMENT[instrument]/ENVIRONMENT[environment]/temperature_controller/value": {"link": "voltage_and_temperature.nxs:/entry/instrument/environment/temperature_controller/value"}, + "/ENTRY[entry]/INSTRUMENT[instrument]/ENVIRONMENT[environment]/temperature_controller/value/@units": "°C", + "/ENTRY[entry]/INSTRUMENT[instrument]/ENVIRONMENT[environment]/current_sensor/calibration_time": "2022-05-30T16:37:03.909201+02:00", + "/ENTRY[entry]/INSTRUMENT[instrument]/ENVIRONMENT[environment]/current_sensor/run_control": 0, + "/ENTRY[entry]/INSTRUMENT[instrument]/ENVIRONMENT[environment]/current_sensor/value": {"link": "current.nxs:/entry/instrument/environment/current_sensor/value"}, + "/ENTRY[entry]/INSTRUMENT[instrument]/ENVIRONMENT[environment]/current_sensor/value/@units": "A", + "/ENTRY[entry]/INSTRUMENT[instrument]/ENVIRONMENT[environment]/independent_controllers": ["voltage_controller", "temperature_control"], + "/ENTRY[entry]/INSTRUMENT[instrument]/ENVIRONMENT[environment]/measurement_sensors": ["current_sensor"], + "/ENTRY[entry]/INSTRUMENT[instrument]/ENVIRONMENT[environment]/NXpid[heating_pid]/description": "The heating current is controlled by a virtual PID device (internally in EPICS). The input value for the PID is the measured temperature of the sample. The output of the PID is the heating current.", + "/ENTRY[entry]/INSTRUMENT[instrument]/ENVIRONMENT[environment]/NXpid[heating_pid]/pv_sensor/value_log/value": {"link": "/entry/instrument/environment/current_sensor/value"}, + "/ENTRY[entry]/INSTRUMENT[instrument]/ENVIRONMENT[environment]/NXpid[heating_pid]/setpoint": {"link": "/entry/instrument/environment/temperature_controller/value"}, + "/ENTRY[entry]/INSTRUMENT[instrument]/ENVIRONMENT[environment]/NXpid[heating_pid]/K_p_value": "0.05", + "/ENTRY[entry]/INSTRUMENT[instrument]/ENVIRONMENT[environment]/NXpid[heating_pid]/K_i_value": "0.2", + "/ENTRY[entry]/INSTRUMENT[instrument]/ENVIRONMENT[environment]/NXpid[heating_pid]/K_d_value": "0.2", + "/ENTRY[entry]/PROCESS[process]/program": "Bluesky", + "/ENTRY[entry]/PROCESS[process]/program/@version": "1.6.7", + "/ENTRY[entry]/SAMPLE[sample]/name": "super", + "/ENTRY[entry]/SAMPLE[sample]/atom_types": "Si, C", + "/ENTRY[entry]/definition": "NXiv_temp", + "/ENTRY[entry]/definition/@version": "1", + "/ENTRY[entry]/experiment_identifier": "dbdfed37-35ed-4aee-a465-aaa0577205b1", + "/ENTRY[entry]/experiment_description": "A simple IV temperature experiment.", + "/ENTRY[entry]/start_time": "2022-05-30T16:37:03.909201+02:00" + +} \ No newline at end of file diff --git a/examples/json_map/merged.nxs b/examples/json_map/merged.nxs new file mode 100644 index 000000000..d3e8ef0fd Binary files /dev/null and b/examples/json_map/merged.nxs differ diff --git a/examples/json_map/voltage_and_temperature.nxs b/examples/json_map/voltage_and_temperature.nxs new file mode 100644 index 000000000..a58930efe Binary files /dev/null and b/examples/json_map/voltage_and_temperature.nxs differ diff --git a/pynxtools/dataconverter/readers/json_map/reader.py b/pynxtools/dataconverter/readers/json_map/reader.py index 65a2eb7c5..c2fc6565a 100644 --- a/pynxtools/dataconverter/readers/json_map/reader.py +++ b/pynxtools/dataconverter/readers/json_map/reader.py @@ -59,7 +59,7 @@ def get_val_nested_keystring_from_dict(keystring, data): def is_path(keystring): """Checks whether a given value in the mapping is a mapping path or just data""" - return isinstance(keystring, str) and keystring[0] == "/" + return isinstance(keystring, str) and len(keystring) > 0 and keystring[0] == "/" def fill_undocumented(mapping, template, data):