Changeset cd57c7d4 in sasview for src/sas/sasgui
- Timestamp:
- Sep 11, 2017 10:12:16 AM (7 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, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- b1f20d1
- Parents:
- c9ecd1b (diff), e2b2473 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - Location:
- src/sas/sasgui
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/guiframe/local_perspectives/data_loader/data_loader.py
r235f514 rdcb91cf 11 11 12 12 from sas.sascalc.dataloader.loader import Loader 13 from sas.sascalc.dataloader.loader_exceptions import NoKnownLoaderException 13 14 from sas.sasgui.guiframe.plugin_base import PluginBase 14 15 from sas.sasgui.guiframe.events import StatusEvent … … 41 42 APPLICATION_WLIST = config.APPLICATION_WLIST 42 43 44 43 45 class Plugin(PluginBase): 44 46 … … 56 58 """ 57 59 # menu for data files 58 menu_list = []59 60 data_file_hint = "load one or more data in the application" 60 61 menu_list = [('&Load Data File(s)', data_file_hint, self.load_data)] 61 62 gui_style = self.parent.get_style() 62 63 style = gui_style & GUIFRAME.MULTIPLE_APPLICATIONS 63 style1 = gui_style & GUIFRAME.DATALOADER_ON64 64 if style == GUIFRAME.MULTIPLE_APPLICATIONS: 65 65 # menu for data from folder … … 102 102 self.get_data(file_list) 103 103 104 105 104 def can_load_data(self): 106 105 """ … … 108 107 """ 109 108 return True 110 111 109 112 110 def _load_folder(self, event): … … 140 138 """ 141 139 if error is not None or str(error).strip() != "": 142 dial = wx.MessageDialog(self.parent, str(error), 'Error Loading File', 140 dial = wx.MessageDialog(self.parent, str(error), 141 'Error Loading File', 143 142 wx.OK | wx.ICON_EXCLAMATION) 144 143 dial.ShowModal() … … 149 148 """ 150 149 if os.path.isdir(path): 151 return [os.path.join(os.path.abspath(path), filename) for filename in os.listdir(path)] 150 return [os.path.join(os.path.abspath(path), filename) for filename 151 in os.listdir(path)] 152 152 153 153 def _process_data_and_errors(self, item, p_file, output, message): … … 178 178 for p_file in path: 179 179 basename = os.path.basename(p_file) 180 # Skip files that start with a period 181 if basename.startswith("."): 182 msg = "The folder included a potential hidden file - %s." \ 183 % basename 184 msg += " Do you wish to load this file as data?" 185 msg_box = wx.MessageDialog(None, msg, 'Warning', 186 wx.OK | wx.CANCEL) 187 if msg_box.ShowModal() == wx.ID_CANCEL: 188 continue 180 189 _, extension = os.path.splitext(basename) 181 190 if extension.lower() in EXTENSIONS: … … 213 222 info="info") 214 223 215 except: 216 logger.error(sys.exc_value) 217 218 error_message = "The Data file you selected could not be loaded.\n" 219 error_message += "Make sure the content of your file" 220 error_message += " is properly formatted.\n" 221 error_message += "When contacting the SasView team, mention the" 222 error_message += " following:\n" 223 error_message += "Error: " + str(sys.exc_info()[1]) 224 file_errors[basename] = [error_message] 225 self.load_update(output=output, message=error_message, info="warning") 224 except NoKnownLoaderException as e: 225 exception_occurred = True 226 logger.error(e.message) 227 228 error_message = "Loading data failed!\n" + e.message 229 self.load_update(output=None, message=e.message, info="warning") 230 231 except Exception as e: 232 exception_occurred = True 233 logger.error(e.message) 234 235 file_err = "The Data file you selected could not be " 236 file_err += "loaded.\nMake sure the content of your file" 237 file_err += " is properly formatted.\n" 238 file_err += "When contacting the SasView team, mention the" 239 file_err += " following:\n" 240 file_err += e.message 241 file_errors[basename] = [file_err] 226 242 227 243 if len(file_errors) > 0: … … 233 249 error_message += message + "\n" 234 250 error_message += "\n" 235 self.load_update(output=output, message=error_message, info="error") 236 237 self.load_complete(output=output, message="Loading data complete!", 238 info="info") 251 if not exception_occurred: # Some data loaded but with errors 252 self.load_update(output=output, message=error_message, info="error") 253 254 if not exception_occurred: # Everything loaded as expected 255 self.load_complete(output=output, message="Loading data complete!", 256 info="info") 257 else: 258 self.load_complete(output=None, message=error_message, info="error") 259 239 260 240 261 def load_update(self, output=None, message="", info="warning"): … … 245 266 wx.PostEvent(self.parent, StatusEvent(status=message, info=info, 246 267 type="progress")) 247 def load_complete(self, output, message="", error_message="", path=None, 248 info="warning"): 249 """ 250 post message to status bar and return list of data 251 """ 252 wx.PostEvent(self.parent, StatusEvent(status=message, 253 info=info, 268 269 def load_complete(self, output, message="", info="warning"): 270 """ 271 post message to status bar and return list of data 272 """ 273 wx.PostEvent(self.parent, StatusEvent(status=message, info=info, 254 274 type="stop")) 255 # if error_message != "": 256 # self.load_error(error_message) 257 self.parent.add_data(data_list=output) 275 if output is not None: 276 self.parent.add_data(data_list=output) -
src/sas/sasgui/perspectives/file_converter/converter_panel.py
red9f872 r19296dc 24 24 from sas.sascalc.file_converter.otoko_loader import OTOKOLoader 25 25 from sas.sascalc.file_converter.bsl_loader import BSLLoader 26 from sas.sascalc.file_converter.ascii2d_loader import ASCII2DLoader 26 27 from sas.sascalc.file_converter.nxcansas_writer import NXcanSASWriter 27 28 from sas.sascalc.dataloader.data_info import Detector … … 35 36 _STATICBOX_WIDTH = 410 36 37 _BOX_WIDTH = 200 37 PANEL_SIZE = 48038 PANEL_SIZE = 520 38 39 FONT_VARIANT = 0 39 40 else: … … 41 42 _STATICBOX_WIDTH = 430 42 43 _BOX_WIDTH = 200 43 PANEL_SIZE = 5 0044 PANEL_SIZE = 540 44 45 FONT_VARIANT = 1 45 46 … … 352 353 w.write(frame_data, output_path) 353 354 355 def convert_2d_data(self, dataset): 356 metadata = self.get_metadata() 357 for key, value in metadata.iteritems(): 358 setattr(dataset[0], key, value) 359 360 w = NXcanSASWriter() 361 w.write(dataset, self.output.GetPath()) 362 354 363 def on_convert(self, event): 355 364 """Called when the Convert button is clicked""" … … 367 376 qdata, iqdata = self.extract_otoko_data(self.q_input.GetPath()) 368 377 self.convert_1d_data(qdata, iqdata) 378 elif self.data_type == 'ascii2d': 379 loader = ASCII2DLoader(self.iq_input.GetPath()) 380 data = loader.load() 381 dataset = [data] # ASCII 2D only ever contains 1 frame 382 self.convert_2d_data(dataset) 369 383 else: # self.data_type == 'bsl' 370 384 dataset = self.extract_bsl_data(self.iq_input.GetPath()) … … 372 386 # Cancelled by user 373 387 return 374 375 metadata = self.get_metadata() 376 for key, value in metadata.iteritems(): 377 setattr(dataset[0], key, value) 378 379 w = NXcanSASWriter() 380 w.write(dataset, self.output.GetPath()) 388 self.convert_2d_data(dataset) 389 381 390 except Exception as ex: 382 391 msg = str(ex) … … 399 408 def validate_inputs(self): 400 409 msg = "You must select a" 401 if self.q_input.GetPath() == '' and self.data_type != 'bsl': 410 if self.q_input.GetPath() == '' and self.data_type != 'bsl' \ 411 and self.data_type != 'ascii2d': 402 412 msg += " Q Axis input file." 403 413 elif self.iq_input.GetPath() == '': … … 472 482 dtype = event.GetEventObject().GetName() 473 483 self.data_type = dtype 474 if dtype == 'bsl' :484 if dtype == 'bsl' or dtype == 'ascii2d': 475 485 self.q_input.SetPath("") 476 486 self.q_input.Disable() … … 500 510 501 511 instructions = ( 502 "Select linked single column 1D ASCII files containing the Q-axis and " 503 "Intensity-axis data, or 1D BSL/OTOKO files, or a 2D BSL/OTOKO file, " 504 "then choose where to save the converted file, and click Convert.\n" 505 "1D ASCII and BSL/OTOKO files can be converted to CanSAS (XML) or " 506 "NXcanSAS (HDF5) formats. 2D BSL/OTOKO files can only be converted to " 507 "the NXcanSAS format.\n" 508 "Metadata can be optionally added for the CanSAS XML format." 512 "If converting a 1D dataset, select linked single-column ASCII files " 513 "containing the Q-axis and intensity-axis data, or a 1D BSL/OTOKO file." 514 " If converting 2D data, select an ASCII file in the ISIS 2D file " 515 "format, or a 2D BSL/OTOKO file. Choose where to save the converted " 516 "file and click convert.\n" 517 "One dimensional ASCII and BSL/OTOKO files can be converted to CanSAS " 518 "(XML) or NXcanSAS (HDF5) formats. Two dimensional datasets can only be" 519 " converted to the NXcanSAS format.\n" 520 "Metadata can also be optionally added to the output file." 509 521 ) 510 522 … … 526 538 wx.ALIGN_CENTER_VERTICAL, 5) 527 539 radio_sizer = wx.BoxSizer(wx.HORIZONTAL) 528 ascii_btn = wx.RadioButton(self, -1, "ASCII ", name="ascii",540 ascii_btn = wx.RadioButton(self, -1, "ASCII 1D", name="ascii", 529 541 style=wx.RB_GROUP) 530 542 ascii_btn.Bind(wx.EVT_RADIOBUTTON, self.datatype_changed) 531 543 radio_sizer.Add(ascii_btn) 544 ascii2d_btn = wx.RadioButton(self, -1, "ASCII 2D", name="ascii2d") 545 ascii2d_btn.Bind(wx.EVT_RADIOBUTTON, self.datatype_changed) 546 radio_sizer.Add(ascii2d_btn) 532 547 otoko_btn = wx.RadioButton(self, -1, "BSL 1D", name="otoko") 533 548 otoko_btn.Bind(wx.EVT_RADIOBUTTON, self.datatype_changed) 534 549 radio_sizer.Add(otoko_btn) 535 input_grid.Add(radio_sizer, (y,1), (1,1), wx.ALL, 5)536 550 bsl_btn = wx.RadioButton(self, -1, "BSL 2D", name="bsl") 537 551 bsl_btn.Bind(wx.EVT_RADIOBUTTON, self.datatype_changed) 538 552 radio_sizer.Add(bsl_btn) 553 input_grid.Add(radio_sizer, (y,1), (1,1), wx.ALL, 5) 539 554 y += 1 540 555 … … 549 564 y += 1 550 565 551 iq_label = wx.StaticText(self, -1, "Intensity -AxisData: ")566 iq_label = wx.StaticText(self, -1, "Intensity Data: ") 552 567 input_grid.Add(iq_label, (y,0), (1,1), wx.ALIGN_CENTER_VERTICAL, 5) 553 568 … … 647 662 648 663 def __init__(self, parent=None, title='File Converter', base=None, 649 manager=None, size=(PANEL_SIZE * 1.05, PANEL_SIZE / 1.1),664 manager=None, size=(PANEL_SIZE * 0.96, PANEL_SIZE * 0.9), 650 665 *args, **kwargs): 651 666 kwargs['title'] = title -
src/sas/sasgui/perspectives/file_converter/file_converter.py
r463e7ffc r94e3572 25 25 Returns a set of menu entries 26 26 """ 27 help_txt = "Convert single column ASCII data to CanSAS format"27 help_txt = "Convert ASCII or BSL/OTOKO data to CanSAS or NXcanSAS formats" 28 28 return [("File Converter", help_txt, self.on_file_converter)] 29 29 -
src/sas/sasgui/perspectives/file_converter/media/file_converter_help.rst
rd73998c r59decb81 18 18 * Single-column ASCII data, with lines that end without any delimiter, 19 19 or with a comma or semi-colon delimiter 20 * 2D `ISIS ASCII formatted 21 <http://www.isis.stfc.ac.uk/instruments/loq/software/ 22 colette-ascii-file-format-descriptions9808.pdf>`_ data 20 23 * `1D BSL/OTOKO format 21 24 <http://www.diamond.ac.uk/Beamlines/Soft-Condensed-Matter/small-angle/ … … 36 39 37 40 1) Select the files containing your Q-axis and Intensity-axis data 38 2) Choose whether the files are in ASCII , 1D BSL/OTOKO or 2D BSL/OTOKO format41 2) Choose whether the files are in ASCII 1D, ASCII 2D, 1D BSL/OTOKO or 2D BSL/OTOKO format 39 42 3) Choose where you would like to save the converted file 40 43 4) Optionally, input some metadata such as sample size, detector name, etc … … 47 50 file, a dialog will appear asking which frames you would like converted. You 48 51 may enter a start frame, end frame & increment, and all frames in that subset 49 will be converted. For example, entering 0, 50 and 10 will convert frames 0, 52 will be converted. For example, entering 0, 50 and 10 will convert frames 0, 50 53 10, 20, 30, 40 & 50. 51 54 … … 56 59 single file, so there is an option in the *Select Frame* dialog to output each 57 60 frame to its own file. The single file option will produce one file with 58 multiple `<SASdata>` elements. The multiple file option will output a separate 59 file with one `<SASdata>` element for each frame. The frame number will also be 61 multiple `<SASdata>` elements. The multiple file option will output a separate 62 file with one `<SASdata>` element for each frame. The frame number will also be 60 63 appended to the file name. 61 64 62 The multiple file option is not available when exporting to NXcanSAS because 65 The multiple file option is not available when exporting to NXcanSAS because 63 66 the HDF5 format is more efficient at handling large amounts of data. 64 67 -
src/sas/sasgui/guiframe/config.py
ra1b8fee rce2819b 48 48 '''This work benefited from the use of the SasView application, originally developed under NSF Award DMR-0520547. SasView also contains code developed with funding from the EU Horizon 2020 programme under the SINE2020 project Grant No 654000.''' 49 49 _acknowledgement_citation = \ 50 '''M. Doucet et al. SasView Version 4.1 , Zenodo, 10.5281/zenodo.438138'''50 '''M. Doucet et al. SasView Version 4.1.2, Zenodo, 10.5281/zenodo.825675''' 51 51 52 52 _acknowledgement = \ -
src/sas/sasgui/guiframe/documentation_window.py
r959eb01 r6a455cd3 75 75 logger.error("Could not find Sphinx documentation at %s \ 76 76 -- has it been built?", file_path) 77 elif WX_SUPPORTS_HTML2: 78 # Complete HTML/CSS support! 79 self.view = html.WebView.New(self) 80 self.view.LoadURL(url) 81 self.Show() 77 #Commenting following 5 lines, so default browser is forced 78 #This is due to CDN mathjax discontinuation of service, intenal help 79 #browser should be back with qt version 80 #Note added by Wojtek Potrzebowski, July 4th 2017 81 # elif WX_SUPPORTS_HTML2: 82 # # Complete HTML/CSS support! 83 # self.view = html.WebView.New(self) 84 # self.view.LoadURL(url) 85 # self.Show() 82 86 else: 83 87 logger.error("No html2 support, popping up a web browser") -
src/sas/sasgui/perspectives/fitting/fitpage.py
red2276f r6a455cd3 1236 1236 wx.PostEvent(self.parent, new_event) 1237 1237 # update list of plugins if new plugin is available 1238 custom_model = CUSTOM_MODEL1239 1238 mod_cat = self.categorybox.GetStringSelection() 1240 if mod_cat == custom_model: 1239 if mod_cat == CUSTOM_MODEL: 1240 temp_id = self.model.id 1241 1241 temp = self.parent.update_model_list() 1242 for v in self.parent.model_dictionary.values(): 1243 if v.id == temp_id: 1244 self.model = v() 1245 break 1242 1246 if temp: 1243 1247 self.model_list_box = temp -
src/sas/sasgui/perspectives/fitting/fitpanel.py
r67b0a99 rc9ecd1b 92 92 # state must be cloned 93 93 state = page.get_state().clone() 94 if data is not None or page.model is not None: 94 # data_list only populated with real data 95 # Fake object in data from page.get_data() if model is selected 96 if len(page.data_list) is not 0 and page.model is not None: 95 97 new_doc = self._manager.state_reader.write_toXML(data, 96 98 state, 97 99 batch_state) 100 # Fit #2 through #n are append to first fit 98 101 if doc is not None and hasattr(doc, "firstChild"): 99 child = new_doc.firstChild.firstChild 100 doc.firstChild.appendChild(child) 102 # Only append if properly formed new_doc 103 if new_doc is not None and hasattr(new_doc, "firstChild"): 104 child = new_doc.firstChild.firstChild 105 doc.firstChild.appendChild(child) 106 # First fit defines the main document 101 107 else: 102 108 doc = new_doc … … 395 401 temp_data = page.get_data() 396 402 if temp_data is not None and temp_data.id in data: 397 self.SetSelection(pos) 398 self.on_close_page(event=None) 399 temp = self.GetSelection() 400 self.DeletePage(temp) 403 self.close_page_with_data(temp_data) 401 404 if self.sim_page is not None: 402 405 if len(self.sim_page.model_list) == 0: … … 404 407 self.SetSelection(pos) 405 408 self.on_close_page(event=None) 406 temp = self.GetSelection() 407 self.DeletePage(temp) 409 self.DeletePage(pos) 408 410 self.sim_page = None 409 411 self.batch_on = False -
src/sas/sasgui/perspectives/fitting/models.py
rb1c2011 rb682c6a 20 20 from sas.sasgui.guiframe.CategoryInstaller import CategoryInstaller 21 21 from sasmodels.sasview_model import load_custom_model, load_standard_models 22 from sas.sasgui.perspectives.fitting.fitpage import CUSTOM_MODEL 22 23 23 24 logger = logging.getLogger(__name__) … … 265 266 temp = {} 266 267 if self.is_changed(): 267 return _find_models() 268 temp = _find_models() 269 self.last_time_dir_modified = time.time() 270 return temp 268 271 logger.info("plugin model : %s" % str(temp)) 269 272 return temp … … 312 315 if os.path.isdir(plugin_dir): 313 316 temp = os.path.getmtime(plugin_dir) 314 if self.last_time_dir_modified !=temp:317 if self.last_time_dir_modified < temp: 315 318 is_modified = True 316 319 self.last_time_dir_modified = temp … … 323 326 new models were added else return empty dictionary 324 327 """ 328 self.plugins = [] 325 329 new_plugins = self.findModels() 326 if len(new_plugins) > 0: 327 for name, plug in new_plugins.iteritems(): 328 if name not in self.stored_plugins.keys(): 329 self.stored_plugins[name] = plug 330 self.plugins.append(plug) 331 self.model_dictionary[name] = plug 332 self.model_combobox.set_list("Plugin Models", self.plugins) 330 if new_plugins: 331 for name, plug in new_plugins.items(): 332 self.stored_plugins[name] = plug 333 self.plugins.append(plug) 334 self.model_dictionary[name] = plug 335 self.model_combobox.set_list(CUSTOM_MODEL, self.plugins) 333 336 return self.model_combobox.get_list() 334 337 else:
Note: See TracChangeset
for help on using the changeset viewer.