Skip to content

Commit

Permalink
Improved notebook. load nexus and display in just one click. this refs
Browse files Browse the repository at this point in the history
  • Loading branch information
JeanBilheux committed Jun 20, 2024
1 parent e2b6b52 commit 92858b2
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 64 deletions.
11 changes: 8 additions & 3 deletions notebooks/__code/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,21 @@ def select_working_dir(cls, debugger_folder='', system_folder='',

full_list_instruments = cls.get_full_list_instrument()
full_list_instruments.sort()
if instrument in full_list_instruments:
default_instrument = instrument
else:
default_instrument = full_list_instruments[0]

start_path = cls.get_start_path(debugger_folder=debugger_folder,
system_folder=system_folder,
instrument=full_list_instruments[0])
instrument=default_instrument)

cls.start_path = start_path

select_instrument_ui = widgets.HBox([widgets.Label("Select Instrument",
layout=widgets.Layout(width='20%')),
widgets.Select(options=full_list_instruments,
value=full_list_instruments[0],
value=default_instrument,
layout=widgets.Layout(width='20%'))])
cls.instrument_ui = select_instrument_ui.children[1]
cls.instrument_ui.observe(cls.check_instrument_input, names='value')
Expand Down Expand Up @@ -128,7 +133,7 @@ def get_list_folders(cls, start_path=''):
start_path = config.debugger_instrument_folder[computer_name][instrument]
cls.start_path = start_path

list_folders = sorted(glob.glob(os.path.join(start_path, '*')))
list_folders = sorted(glob.glob(os.path.join(start_path, '*')), reverse=True)
short_list_folders = [os.path.basename(_folder) for _folder in list_folders if os.path.isdir(_folder)]
# short_list_folders = sorted(short_list_folders)

Expand Down
6 changes: 5 additions & 1 deletion notebooks/__code/venus_monitor_hdf5/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,13 @@ def select_event_nexus(self):
def load_data(self, nexus_file_name):

with h5py.File(nexus_file_name, 'r') as nxs:
self.nexus_file_name = nexus_file_name
self.index = np.array(nxs['entry']['monitor1']['event_index'])
self.time_offset = np.array(nxs['entry']['monitor1']['event_time_offset'])
self.time_zero = np.array(nxs['entry']['monitor1']['event_time_zero'])

self.display_all_at_once()

def define_settings(self):

# bins
Expand Down Expand Up @@ -137,7 +140,8 @@ def display_all_at_once(self):
self.calculate_data_energy()

plt.rcParams['figure.constrained_layout.use'] = True
fig, ax = plt.subplots(nrows=3, ncols=1, num='Monitor',
nexus_file_name = os.path.basename(self.nexus_file_name)
fig, ax = plt.subplots(nrows=3, ncols=1, num=f"{nexus_file_name}",
figsize=(10, 15),
)

Expand Down
91 changes: 31 additions & 60 deletions notebooks/venus_monitor_hdf5.ipynb

Large diffs are not rendered by default.

1 comment on commit 92858b2

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GitLab pipeline with NOTEBOOK_COLLECTION_NAME=IPTS_notebooks submitted for commit "https://code.ornl.gov/sns-hfir-scse/deployments/jupyter-notebooks-deploy/-/pipelines/583859"

Please sign in to comment.