- Timestamp:
- Aug 18, 2016 8:33:24 AM (8 years ago)
- Branches:
- master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- 3d6ab79
- Parents:
- 7bd6860a
- Location:
- src/sas
- Files:
-
- 1 deleted
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/perspectives/file_converter/converter_panel.py
r254f088 re9e777c 19 19 from sas.sasgui.guiframe.documentation_window import DocumentationWindow 20 20 from sas.sasgui.guiframe.dataFitting import Data1D 21 from sas.sascalc.dataloader.data_info import Data2D 21 22 from sas.sasgui.guiframe.utils import check_float 22 23 from sas.sascalc.file_converter.cansas_writer import CansasWriter 23 24 from sas.sascalc.file_converter.otoko_loader import OTOKOLoader 24 25 from sas.sascalc.file_converter.bsl_loader import BSLLoader 25 from sas.sascalc.file_converter. convert_bsl_thread import ConvertBSLThread26 from sas.sascalc.file_converter.nxcansas_writer import NXcanSASWriter 26 27 from sas.sascalc.dataloader.data_info import Detector 27 28 from sas.sascalc.dataloader.data_info import Sample … … 57 58 self.parent = parent 58 59 self.meta_frames = [] 59 self.to_convert = {}60 self.bsl_thread = None61 60 62 61 # GUI inputs … … 233 232 frame_data[frame] = loader.load_data() 234 233 235 # TODO: Tidy this up236 234 # Prepare axes values (arbitrary scale) 237 x_data = [] 238 y_data = range(loader.n_pixels) * loader.n_rasters 239 for i in range(loader.n_rasters): 240 x_data += [i] * loader.n_pixels 241 242 return x_data, y_data, frame_data 235 x_data = loader.n_rasters * range(1,loader.n_pixels+1) 236 y_data = [loader.n_pixels * [i] for i in range(1, loader.n_rasters+1)] 237 y_data = np.reshape(y_data, (1, loader.n_pixels*loader.n_rasters))[0] 238 239 return (x_data, y_data), (loader.n_rasters, loader.n_pixels), frame_data 243 240 244 241 def ask_frame_range(self, n_frames): … … 293 290 return 294 291 295 if self.bsl_thread is not None and self.bsl_thread.isrunning():296 self.to_convert = {}297 self.bsl_thread.stop()298 return299 300 292 self.sample.ID = self.title 301 293 … … 308 300 else: # self.data_type == 'bsl' 309 301 310 x, y, frame_data = self.extract_bsl_data(self.iq_input.GetPath()) 302 (x, y), dimensions, frame_data = \ 303 self.extract_bsl_data(self.iq_input.GetPath()) 311 304 if x == None and y == None and frame_data == None: 312 305 # Cancelled by user 313 306 return 314 307 315 self.to_convert = frame_data 316 317 frame_number, data = self.to_convert.popitem() 318 self.bsl_thread = ConvertBSLThread((x, y), data, 319 self.output.GetPath(), frame_number=frame_number, 320 updatefn=self.conversion_update, 321 completefn=self.conversion_complete) 322 self.bsl_thread.queue() 323 324 self.convert_btn.SetLabel("Stop Conversion") 308 dataset = [] 309 for i_data in frame_data.values(): 310 i_data = np.reshape(i_data, (1, i_data.size))[0] 311 data2d = Data2D(data=i_data, qx_data=x, qy_data=y) 312 dataset.append(data2d) 313 w = NXcanSASWriter() 314 dimensions = [dimensions] * len(dataset) 315 w.write(dataset, self.output.GetPath(), dimensions=dimensions) 316 317 wx.PostEvent(self.parent.manager.parent, 318 StatusEvent(status="Conversion completed.")) 325 319 return 326 320 … … 389 383 StatusEvent(status="Conversion completed.")) 390 384 391 def conversion_update(self, msg="", exception=None):392 if exception is not None:393 msg = str(exception)394 wx.PostEvent(self.parent.manager.parent,395 StatusEvent(status=msg, info='error'))396 else:397 wx.PostEvent(self.parent.manager.parent,398 StatusEvent(status=msg))399 400 def conversion_complete(self, success=True):401 msg = "Conversion of {} ".format(self.bsl_thread.frame_filename)402 403 if success:404 msg += "completed"405 else:406 msg += "failed"407 wx.PostEvent(self.parent.manager.parent,408 StatusEvent(status=msg))409 410 if len(self.to_convert) == 0:411 self.convert_btn.SetLabel("Convert")412 self.bsl_thread = None413 wx.PostEvent(self.parent.manager.parent,414 StatusEvent(status="Conversion finished"))415 else:416 n, data = self.to_convert.popitem()417 self.bsl_thread.frame_data = data418 self.bsl_thread.frame_number = n419 self.bsl_thread.queue()420 421 422 385 def on_help(self, event): 423 386 """ … … 511 474 self.on_collapsible_pane(None) 512 475 self.metadata_section.Disable() 513 self.output.SetWildcard(" IGOR/DAT 2D file in Q_map (*.dat)|*.DAT")476 self.output.SetWildcard("NXcanSAS HDF5 File (*.h5)|*.h5") 514 477 else: 515 478 self.q_input.Enable() … … 693 656 694 657 def on_close(self, event): 695 if self.panel.bsl_thread is not None \696 and self.panel.bsl_thread.isrunning():697 self.panel.bsl_thread.stop()698 658 if self.manager is not None: 699 659 self.manager.converter_frame = None
Note: See TracChangeset
for help on using the changeset viewer.