Loading .gitignore +1 −1 Original line number Diff line number Diff line .idea .pyc .DS_Store trame/air-sans/.gitignore +2 −1 Original line number Diff line number Diff line Loading @@ -28,3 +28,4 @@ __pycache__ build examples .ipynb_checkpoints cache trame/air-sans/README.rst +6 −1 Original line number Diff line number Diff line Loading @@ -33,3 +33,8 @@ Binder usage ------------ `Test it with Binder <https://mybinder.org/v2/gh/Kitware/air-sans/HEAD>`_ Running as standalone app ------- python -m air_sans.app.main --app No newline at end of file trame/air-sans/air_sans/app/core.py +72 −7 Original line number Diff line number Diff line Loading @@ -16,9 +16,11 @@ from .ui import ( Transmission, ) from .instrument.d11_plus import D11_Plus from .instrument.gpsans import GP_SANS from .visualization import Visualization from .utilities import file_search as fs from .utilities import file_load as fl from .utilities import galaxy logger = logging.getLogger(__name__) logger.setLevel(logging.INFO) Loading Loading @@ -58,7 +60,7 @@ class AirSans: data = args.data # search directory contents self.state.dirs = fs.get_directory_structure(data) self.state.dirs = galaxy.get_directory_structure(data) self.state.files = [] self.state.file = None Loading @@ -66,6 +68,7 @@ class AirSans: self.state.data = None self.state.center_data = None self.state.pixel_ratio = 2.0 self.state.selected_device = "GP-SANS" self.ui = self._build_ui() Loading @@ -77,6 +80,9 @@ class AirSans: def ctrl(self): return self.server.controller def demo(self): self.server.state.files = galaxy.get_file_list("d5cc1998a2fd4eef") self.selected_file(self.server.state.files[0]) def _build_ui(self): self.state.trame__title = "air-sans" with SinglePageWithDrawerLayout(self.server) as layout: Loading @@ -100,6 +106,9 @@ class AirSans: vuetify.VIcon(icon, small=True) vuetify.VSpacer() with vuetify.VBtn(icon=True, click=self.demo): vuetify.VIcon("mdi-undo") with layout.drawer as drawer: drawer.width = 350 Loading @@ -125,23 +134,79 @@ class AirSans: @change("selectedDevice") def on_device_change(self, selectedDevice, **kwargs): self.server.state.selected_device = selectedDevice if selectedDevice == "D11+": self._selected_device = D11_Plus() if selectedDevice == "GP-SANS": self._selected_device = GP_SANS() def select_directory(self, active_nodes): self.server.state.directory_label = None self._active_directory = None if len(active_nodes): node_id = active_nodes[0] if isinstance(node_id, str): self.server.state.directory_label = os.path.basename(node_id) if "name" in node_id: self.server.state.directory_label = f"{node_id['name']}" self._active_directory = node_id self.server.state.files = fs.get_file_list(node_id) self.server.state.files = galaxy.get_file_list(node_id["id"]) def selected_file(self, file): if self.state.selected_device=="GP-SANS": return self.selected_file_gpsans(file) if self.state.selected_device=="D11+": return self.selected_file_d11(file) def selected_file_gpsans(self, file): state = self.server.state state.file = file data = galaxy.load_mantid(state.file) # pixel_y = data["/entry0/D11/Detector 1/pixel_size_y"].nxdata[0].item() # pixel_x = data["/entry0/D11/Detector 1/pixel_size_x"].nxdata[0].item() # state.pixel_ratio = pixel_y / pixel_x # detector1 = data["/entry0/D11/Detector 1/data"] # detector1_2d = detector1[:, :, 0] ny, nx = data.shape state.pixel_ratio = 1 state.center_ny = ny state.center_nx = nx # d1 = numpy.zeros(detector1_2d.shape, dtype=numpy.int32, order="C") # for i in range(0, nx - 1): # for j in range(0, ny - 1): # d1[j, i] = detector1_2d[j, i] #self._viz.set_center_data(d1.transpose()) self._viz.set_center_data(data.transpose()) # detector2 = data["/entry0/D11/Detector 2/data"] # detector2_2d = detector2[:, :, 0] # ny, nx = detector2_2d.shape # state.left_ny = ny # state.left_nx = nx # d2 = numpy.zeros(detector2_2d.shape, dtype=numpy.int32, order="C") # for i in range(0, nx - 1): # for j in range(0, ny - 1): # d2[j, i] = detector2_2d[j, i] # self._viz.set_left_data(d2.transpose()) # # detector3 = data["/entry0/D11/Detector 3/data"] # detector3_2d = detector3[:, :, 0] # ny, nx = detector3_2d.shape # state.right_ny = ny # state.right_nx = nx # d3 = numpy.zeros(detector3_2d.shape, dtype=numpy.int32, order="C") # for i in range(0, nx - 1): # for j in range(0, ny - 1): # d3[j, i] = detector3_2d[j, i] # self._viz.set_right_data(d3.transpose()) self._viz.create_gpsans_fig() state.figure_ready = True def selected_file_d11(self, file): state = self.server.state state.file = file data = fl.load(self._active_directory, state.file) data = galaxy.load(state.file) pixel_y = 1.0 pixel_x = 1.0 # print(pixel_y / pixel_x, pixel_x, type(pixel_x), pixel_y, type(pixel_y)) Loading trame/air-sans/air_sans/app/instrument/ORNL_cg2.ini 0 → 100755 +30 −0 Original line number Diff line number Diff line %***** Facility & Instrument Names***** Facility=ORNL Instrument=cg2 RunCode %***** File name handleing parameters ***** inst_params.filename.numeric_length = 4; inst_params.filename.lead_string = 'xxxxxxxxx'; inst_params.filename.tail_string = []; inst_params.filename.extension_string = ['.xml']; inst_params.filename.data_loader = 'raw_read_ornl_sans'; %Misc inst_params.guide_size = [40e-3, 40e-3]; %[x,y] inst_params.attenuators = [1, 3.605, 43.85, 553.544, 3456, 22973.37, 69043]; %Attenautors 0, 1, 2, 3 etc. %***** Describe Detector(s) ***** inst_params.detectors = 1; inst_params.detector1.type = 'tube'; inst_params.detector1.view_position = 'centre'; inst_params.detector1.name = 'Rear'; inst_params.detector1.nominal_det_translation = [0, 0]; %mm [x y] inst_params.detector1.dead_time = 0.6*10^-6; %the direction of this matrix determines the direction of the tubes inst_params.detector1.pixels = [192, 256]; %Number of pixels, x,y inst_params.detector1.pixel_size = [5.5, 3.94]; %mm [x y] inst_params.detector1.nominal_beam_centre = [96.5, 128.5]; %[x y] inst_params.detector1.imask_file = 'ornl_cg2_msk.msk'; inst_params.detector1.relative_efficiency = 1; inst_params.detector1.efficiency_file = ''; Loading
trame/air-sans/.gitignore +2 −1 Original line number Diff line number Diff line Loading @@ -28,3 +28,4 @@ __pycache__ build examples .ipynb_checkpoints cache
trame/air-sans/README.rst +6 −1 Original line number Diff line number Diff line Loading @@ -33,3 +33,8 @@ Binder usage ------------ `Test it with Binder <https://mybinder.org/v2/gh/Kitware/air-sans/HEAD>`_ Running as standalone app ------- python -m air_sans.app.main --app No newline at end of file
trame/air-sans/air_sans/app/core.py +72 −7 Original line number Diff line number Diff line Loading @@ -16,9 +16,11 @@ from .ui import ( Transmission, ) from .instrument.d11_plus import D11_Plus from .instrument.gpsans import GP_SANS from .visualization import Visualization from .utilities import file_search as fs from .utilities import file_load as fl from .utilities import galaxy logger = logging.getLogger(__name__) logger.setLevel(logging.INFO) Loading Loading @@ -58,7 +60,7 @@ class AirSans: data = args.data # search directory contents self.state.dirs = fs.get_directory_structure(data) self.state.dirs = galaxy.get_directory_structure(data) self.state.files = [] self.state.file = None Loading @@ -66,6 +68,7 @@ class AirSans: self.state.data = None self.state.center_data = None self.state.pixel_ratio = 2.0 self.state.selected_device = "GP-SANS" self.ui = self._build_ui() Loading @@ -77,6 +80,9 @@ class AirSans: def ctrl(self): return self.server.controller def demo(self): self.server.state.files = galaxy.get_file_list("d5cc1998a2fd4eef") self.selected_file(self.server.state.files[0]) def _build_ui(self): self.state.trame__title = "air-sans" with SinglePageWithDrawerLayout(self.server) as layout: Loading @@ -100,6 +106,9 @@ class AirSans: vuetify.VIcon(icon, small=True) vuetify.VSpacer() with vuetify.VBtn(icon=True, click=self.demo): vuetify.VIcon("mdi-undo") with layout.drawer as drawer: drawer.width = 350 Loading @@ -125,23 +134,79 @@ class AirSans: @change("selectedDevice") def on_device_change(self, selectedDevice, **kwargs): self.server.state.selected_device = selectedDevice if selectedDevice == "D11+": self._selected_device = D11_Plus() if selectedDevice == "GP-SANS": self._selected_device = GP_SANS() def select_directory(self, active_nodes): self.server.state.directory_label = None self._active_directory = None if len(active_nodes): node_id = active_nodes[0] if isinstance(node_id, str): self.server.state.directory_label = os.path.basename(node_id) if "name" in node_id: self.server.state.directory_label = f"{node_id['name']}" self._active_directory = node_id self.server.state.files = fs.get_file_list(node_id) self.server.state.files = galaxy.get_file_list(node_id["id"]) def selected_file(self, file): if self.state.selected_device=="GP-SANS": return self.selected_file_gpsans(file) if self.state.selected_device=="D11+": return self.selected_file_d11(file) def selected_file_gpsans(self, file): state = self.server.state state.file = file data = galaxy.load_mantid(state.file) # pixel_y = data["/entry0/D11/Detector 1/pixel_size_y"].nxdata[0].item() # pixel_x = data["/entry0/D11/Detector 1/pixel_size_x"].nxdata[0].item() # state.pixel_ratio = pixel_y / pixel_x # detector1 = data["/entry0/D11/Detector 1/data"] # detector1_2d = detector1[:, :, 0] ny, nx = data.shape state.pixel_ratio = 1 state.center_ny = ny state.center_nx = nx # d1 = numpy.zeros(detector1_2d.shape, dtype=numpy.int32, order="C") # for i in range(0, nx - 1): # for j in range(0, ny - 1): # d1[j, i] = detector1_2d[j, i] #self._viz.set_center_data(d1.transpose()) self._viz.set_center_data(data.transpose()) # detector2 = data["/entry0/D11/Detector 2/data"] # detector2_2d = detector2[:, :, 0] # ny, nx = detector2_2d.shape # state.left_ny = ny # state.left_nx = nx # d2 = numpy.zeros(detector2_2d.shape, dtype=numpy.int32, order="C") # for i in range(0, nx - 1): # for j in range(0, ny - 1): # d2[j, i] = detector2_2d[j, i] # self._viz.set_left_data(d2.transpose()) # # detector3 = data["/entry0/D11/Detector 3/data"] # detector3_2d = detector3[:, :, 0] # ny, nx = detector3_2d.shape # state.right_ny = ny # state.right_nx = nx # d3 = numpy.zeros(detector3_2d.shape, dtype=numpy.int32, order="C") # for i in range(0, nx - 1): # for j in range(0, ny - 1): # d3[j, i] = detector3_2d[j, i] # self._viz.set_right_data(d3.transpose()) self._viz.create_gpsans_fig() state.figure_ready = True def selected_file_d11(self, file): state = self.server.state state.file = file data = fl.load(self._active_directory, state.file) data = galaxy.load(state.file) pixel_y = 1.0 pixel_x = 1.0 # print(pixel_y / pixel_x, pixel_x, type(pixel_x), pixel_y, type(pixel_y)) Loading
trame/air-sans/air_sans/app/instrument/ORNL_cg2.ini 0 → 100755 +30 −0 Original line number Diff line number Diff line %***** Facility & Instrument Names***** Facility=ORNL Instrument=cg2 RunCode %***** File name handleing parameters ***** inst_params.filename.numeric_length = 4; inst_params.filename.lead_string = 'xxxxxxxxx'; inst_params.filename.tail_string = []; inst_params.filename.extension_string = ['.xml']; inst_params.filename.data_loader = 'raw_read_ornl_sans'; %Misc inst_params.guide_size = [40e-3, 40e-3]; %[x,y] inst_params.attenuators = [1, 3.605, 43.85, 553.544, 3456, 22973.37, 69043]; %Attenautors 0, 1, 2, 3 etc. %***** Describe Detector(s) ***** inst_params.detectors = 1; inst_params.detector1.type = 'tube'; inst_params.detector1.view_position = 'centre'; inst_params.detector1.name = 'Rear'; inst_params.detector1.nominal_det_translation = [0, 0]; %mm [x y] inst_params.detector1.dead_time = 0.6*10^-6; %the direction of this matrix determines the direction of the tubes inst_params.detector1.pixels = [192, 256]; %Number of pixels, x,y inst_params.detector1.pixel_size = [5.5, 3.94]; %mm [x y] inst_params.detector1.nominal_beam_centre = [96.5, 128.5]; %[x y] inst_params.detector1.imask_file = 'ornl_cg2_msk.msk'; inst_params.detector1.relative_efficiency = 1; inst_params.detector1.efficiency_file = '';