Skip to content

Commit

Permalink
Adds an example of merging partial nexus files
Browse files Browse the repository at this point in the history
  • Loading branch information
sherjeelshabih committed Nov 1, 2023
1 parent 8ba8376 commit c20036a
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 1 deletion.
Binary file added examples/json_map/current.nxs
Binary file not shown.
41 changes: 41 additions & 0 deletions examples/json_map/merge_partial_appdefs.mapping.json
Original file line number Diff line number Diff line change
@@ -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"

}
Binary file added examples/json_map/merged.nxs
Binary file not shown.
Binary file added examples/json_map/voltage_and_temperature.nxs
Binary file not shown.
2 changes: 1 addition & 1 deletion pynxtools/dataconverter/readers/json_map/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit c20036a

Please sign in to comment.