Changeset 9a0fc50 in sasview for src/sas/sasgui
- Timestamp:
- Sep 13, 2018 2:31:36 PM (6 years ago)
- Branches:
- master, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, unittest-saveload
- Children:
- 43313e72
- Parents:
- feec1cb (diff), 356af60e (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:
-
- 1 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/guiframe/report_dialog.py
r91552b5 rd0ce666f 7 7 import sys 8 8 import wx.html as html 9 from sas.sasgui.guiframe.report_image_handler import ReportImageHandler 9 10 10 11 logger = logging.getLogger(__name__) … … 70 71 button_close = wx.Button(self, wx.ID_OK, "Close") 71 72 button_close.SetToolTipString("Close this report window.") 73 button_close.Bind(wx.EVT_BUTTON, self.onClose, 74 id=button_close.GetId()) 72 75 hbox.Add(button_close) 73 76 button_close.SetFocus() … … 117 120 118 121 119 def OnClose(self, event=None):122 def onClose(self, event=None): 120 123 """ 121 124 Close the Dialog … … 123 126 """ 124 127 for fig in self.fig_urls: 125 self.imgRAM.RemoveFile(fig)128 ReportImageHandler.remove_figure(fig) 126 129 127 self. Close()130 self.Destroy() 128 131 129 132 def HTML2PDF(self, data, filename): -
src/sas/sasgui/perspectives/calculator/media/slit_calculator_help.rst
r5ed76f8 r346745a 11 11 ----------- 12 12 13 This tool enables X-ray users to calculate the slit size (FWHM/2) for smearing 14 based on their half beam profile data. 13 This tool enables X-ray users to calculate the slit size (FWHM/2) for resolution 14 smearing purposes based on their half beam profile data (as Q vs Intensity; any 15 other data fields are ignored). 15 16 16 *NOTE! Whilst it may have some more generic applicability, the calculator has 17 only been tested with beam profile data from Anton-Paar SAXSess:sup:`TM` software.* 17 Method 18 ------ 19 20 The tool works by sequentially summing 10 or more intensity values until a 21 maximum value is attained. It then locates the Q values for the points just before, 22 and just after, **half** of this maximum value and interpolates between them to get 23 an accurate value for the Q value for the half maximum. 24 25 NOTE! Whilst it may have some more generic applicability, the calculator has 26 only been tested with beam profile data from Anton-Paar SAXSess\ :sup:`TM`\ software. 27 The beam profile file does not carry any information about the units of the 28 Q data. It is probably |nm^-1| but the resolution calculations assume the slit 29 height/width has units of |Ang^-1|. If the beam profile data is not in these 30 units then it, or the result, must be manually converted. 18 31 19 32 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ … … 27 40 28 41 *NOTE! To see an example of the beam profile file format, visit the file 29 beam profile.DAT in your {installation_directory}/SasView/test folder.*42 beam profile.DAT in your {installation_directory}/SasView/test_1d folder.* 30 43 31 44 3) Once a data is loaded, the slit size is automatically computed and displayed 32 45 in the tool window. 33 46 34 *NOTE! The beam profile file does not carry any information about the units of35 the Q data. This calculator assumes the data has units of 1/\ |Ang|\ . If the36 data is not in these units it must be manually converted beforehand.*37 38 47 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 39 48 40 .. note:: This help document was last changed by Steve King, 0 1May201549 .. note:: This help document was last changed by Steve King, 09Sep2018 -
src/sas/sasgui/perspectives/calculator/model_editor.py
r9258c43c r9bf40e7 43 43 if sys.platform.count("win32") > 0: 44 44 FONT_VARIANT = 0 45 PNL_WIDTH = 45045 PNL_WIDTH = 500 46 46 PNL_HEIGHT = 320 47 47 else: 48 48 FONT_VARIANT = 1 49 PNL_WIDTH = 5 9049 PNL_WIDTH = 500 50 50 PNL_HEIGHT = 350 51 51 M_NAME = 'Model' … … 495 495 Choose the equation to use depending on whether we now have 496 496 a sum or multiply model then create the appropriate string 497 498 for the sum model the result will be: 499 scale_factor * (scale1 * model_1 + scale2 * model_2) + background 500 while for the multiply model it will just be: 501 scale_factor * (model_1* model_2) + background 497 502 """ 498 503 name = '' 499 504 if operator == '*': 500 505 name = 'Multi' 501 factor = 'background' 506 factor_1 = '' 507 factor_2 = '' 502 508 else: 503 509 name = 'Sum' 504 factor = 'scale_factor' 510 factor_1 = 'scale_1 * ' 511 factor_2 = 'scale_2 * ' 505 512 506 513 self._operator = operator 507 self.explanation = (" Plugin_model = scale_factor * ( model_1 {} "508 " model_2) + background").format(operator)514 self.explanation = (" Plugin_model = scale_factor * ({}model_1 {} " 515 "{}model_2) + background").format(factor_1,operator,factor_2) 509 516 self.explanationctr.SetLabel(self.explanation) 510 517 self.name = name + M_NAME -
src/sas/sasgui/perspectives/fitting/basepage.py
r8a51dea0 ra4a1ac9 31 31 32 32 from sas.sasgui.guiframe.panel_base import PanelBase 33 from sas.sasgui.guiframe.report_image_handler import ReportImageHandler 33 34 from sas.sasgui.guiframe.utils import format_number, check_float, IdList, \ 34 35 check_int … … 651 652 by plotting, putting it into wx.FileSystem image object 652 653 """ 653 images = [] 654 refs = [] 655 656 # For no figures in the list, prepare empty plot 657 if figs is None or len(figs) == 0: 658 figs = [None] 659 660 # Loop over the list of figures 661 # use wx.MemoryFSHandler 662 imgRAM = wx.MemoryFSHandler() 663 for fig in figs: 664 if fig is not None: 665 ind = figs.index(fig) 666 canvas = canvases[ind] 667 668 # store the image in wx.FileSystem Object 669 wx.FileSystem.AddHandler(wx.MemoryFSHandler()) 670 671 # index of the fig 672 ind = figs.index(fig) 673 674 # AddFile, image can be retrieved with 'memory:filename' 675 name = 'img_fit%s.png' % ind 676 refs.append('memory:' + name) 677 imgRAM.AddFile(name, canvas.bitmap, wx.BITMAP_TYPE_PNG) 678 # append figs 679 images.append(fig) 680 681 return imgRAM, images, refs 682 654 bitmaps = [] 655 for canvas in canvases: 656 bitmaps.append(canvas.bitmap) 657 imgs, refs = ReportImageHandler.set_figs(figs, bitmaps, 'fit') 658 659 return ReportImageHandler.instance, imgs, refs 683 660 684 661 def on_save(self, event): … … 2801 2778 Function called when 'Help' button is pressed next to model 2802 2779 of interest. This calls DocumentationWindow from 2803 documentation_window.py. It will load the top level of the model 2804 help documenation sphinx generated html if no model is presented. 2805 If a model IS present then if documention for that model exists 2806 it will load to that point otherwise again it will go to the top. 2807 For Wx2.8 and below is used (i.e. non-released through installer) 2808 a browser is loaded and the top of the model documentation only is 2809 accessible because webbrowser module does not pass anything after 2810 the # to the browser. 2780 documentation_window.py. It will load the top level of the html model 2781 help documenation sphinx generated if either a plugin model (which 2782 normally does not have an html help help file) is selected or if no 2783 model is selected. Otherwise, if a regula model is selected, the 2784 documention for that model will be sent to a browser window. 2785 2786 :todo the quick fix for no documentation in plugins is the if statment. 2787 However, the right way to do this would be to check whether the hmtl 2788 file exists and load the model docs if it does and the general docs if 2789 it doesn't - this will become important if we ever figure out how to 2790 build docs for plugins on the fly. Sep 9, 2018 -PDB 2811 2791 2812 2792 :param event: on Help Button pressed event 2813 2793 """ 2814 2794 2815 if self.model is not None: 2795 if (self.model is not None) and (self.categorybox.GetValue() 2796 != "Plugin Models"): 2816 2797 name = self.formfactorbox.GetValue() 2817 2798 _TreeLocation = 'user/models/%s.html' % name -
src/sas/sasgui/perspectives/fitting/gpu_options.py
r42a6e02 r388aefb 139 139 140 140 test_text = wx.StaticText(self, -1, "WARNING: Running tests can take a few minutes!") 141 test_text2 = wx.StaticText(self, -1, "NOTE: No test will run if No OpenCL is checked") 142 test_text.SetForegroundColour(wx.RED) 143 self.vbox.Add(test_text2, 0, wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 10) 141 144 self.vbox.Add(test_text, 0, wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 10) 142 145 -
src/sas/sasgui/perspectives/fitting/report_dialog.py
r69a6897 r44e8f48 72 72 filename = basename + ext 73 73 74 # save figures 75 pictures = [] 76 for num in range(self.nimages): 77 pic_name = basename + '_img%s.png' % num 78 # save the image for use with pdf writer 79 self.report_list[2][num].savefig(pic_name) 80 pictures.append(pic_name) 74 # save the images for use with pdf writer 75 pictures = [ 76 '_'.join((basename, url.split(':')[1])) for url in self.fig_urls] 77 for i, pic in enumerate(pictures): 78 self.report_list[2][i].savefig(pic) 81 79 82 80 # translate png references int html from in-memory name to on-disk name 83 html = self.report_html.replace("memory: img_fit", basename+'_img')81 html = self.report_html.replace("memory:", basename+'_') 84 82 85 83 #set file extensions -
src/sas/sasgui/perspectives/invariant/invariant_panel.py
r2469df7 r44e8f48 24 24 from sas.sasgui.guiframe.panel_base import PanelBase 25 25 from sas.sasgui.guiframe.documentation_window import DocumentationWindow 26 from sas.sasgui.guiframe.report_image_handler import ReportImageHandler 26 27 27 28 logger = logging.getLogger(__name__) … … 783 784 report_img = self.state.image 784 785 report_list = [report_html_str, report_text_str, report_img] 785 dialog = ReportDialog(report_list, None, -1, "") 786 ReportImageHandler.check_for_empty_instance() 787 imgRAM = ReportImageHandler.instance.img_holder 788 refs = [self.state.wximgbmp] 789 dialog = ReportDialog(report_list, imgRAM, refs, None, wx.ID_ANY, "") 786 790 dialog.Show() 787 791 -
src/sas/sasgui/perspectives/invariant/invariant_state.py
r2469df7 rfa412df 12 12 from lxml import etree 13 13 from sas.sascalc.dataloader.readers.cansas_reader import Reader as CansasReader 14 from sas.sasgui.guiframe.report_image_handler import ReportImageHandler 14 15 from sas.sascalc.dataloader.readers.cansas_reader import get_content 15 16 from sas.sasgui.guiframe.utils import format_number … … 611 612 wximgbmp = wx.BitmapFromImage(wximg) 612 613 # store the image in wx.FileSystem Object 613 wx.FileSystem.AddHandler(wx.MemoryFSHandler()) 614 # use wx.MemoryFSHandler 615 self.imgRAM = wx.MemoryFSHandler() 616 # AddFile, image can be retrieved with 'memory:filename' 617 self.imgRAM.AddFile('img_inv.png', wximgbmp, wx.BITMAP_TYPE_PNG) 618 619 self.wximgbmp = 'memory:img_inv.png' 620 self.image = fig 614 imgs, refs = ReportImageHandler.set_figs([fig], [wximgbmp], 'inv') 615 616 self.wximgbmp = refs[0] 617 self.image = imgs[0] 621 618 622 619 class Reader(CansasReader): -
src/sas/sasgui/perspectives/invariant/report_dialog.py
r959eb01 rd0ce666f 41 41 42 42 # put image path in the report string 43 self.report_html = self.report_list[0] % "memory:img_inv.png"43 self.report_html = self.report_list[0] % self.fig_urls[0] 44 44 # layout 45 45 self._setup_layout() -
src/sas/sasgui/guiframe/gui_manager.py
rb963b20 rfeec1cb 46 46 from sas.sasgui.guiframe.CategoryManager import CategoryManager 47 47 from sas.sascalc.dataloader.loader import Loader 48 from sas.sascalc.file_converter.nxcansas_writer import NXcanSASWriter 48 49 from sas.sasgui.guiframe.proxy import Connection 49 50 … … 2422 2423 default_name = fname 2423 2424 wildcard = "Text files (*.txt)|*.txt|"\ 2424 "CanSAS 1D files(*.xml)|*.xml" 2425 path = None 2425 "CanSAS 1D files (*.xml)|*.xml|"\ 2426 "NXcanSAS files (*.h5)|*.h5|" 2427 options = {0: ".txt", 2428 1: ".xml", 2429 2: ".h5"} 2426 2430 dlg = wx.FileDialog(self, "Choose a file", 2427 2431 self._default_save_location, … … 2433 2437 # This is MAC Fix 2434 2438 ext_num = dlg.GetFilterIndex() 2435 if ext_num == 0: 2436 ext_format = '.txt' 2437 else: 2438 ext_format = '.xml' 2439 2440 ext_format = options[ext_num] 2439 2441 path = os.path.splitext(path)[0] + ext_format 2440 2442 mypath = os.path.basename(path) 2441 2442 # Instantiate a loader 2443 loader = Loader() 2444 ext_format = ".txt" 2445 if os.path.splitext(mypath)[1].lower() == ext_format: 2443 fName = os.path.splitext(path)[0] + ext_format 2444 2445 if os.path.splitext(mypath)[1].lower() == options[0]: 2446 2446 # Make sure the ext included in the file name 2447 2447 # especially on MAC 2448 fName = os.path.splitext(path)[0] + ext_format2449 2448 self._onsaveTXT(data, fName) 2450 ext_format = ".xml" 2451 if os.path.splitext(mypath)[1].lower() == ext_format: 2449 elif os.path.splitext(mypath)[1].lower() == options[1]: 2452 2450 # Make sure the ext included in the file name 2453 2451 # especially on MAC 2454 fName = os.path.splitext(path)[0] + ext_format 2452 # Instantiate a loader 2453 loader = Loader() 2455 2454 loader.save(fName, data, ext_format) 2455 elif os.path.splitext(mypath)[1].lower() == options[2]: 2456 nxcansaswriter = NXcanSASWriter() 2457 nxcansaswriter.write([data], fName) 2456 2458 try: 2457 2459 self._default_save_location = os.path.dirname(path) … … 2528 2530 text += 'dY_min = %s: dY_max = %s\n' % (min(data.dy), max(data.dy)) 2529 2531 text += '\nData Points:\n' 2530 x_st = "X" 2532 text += "<index> \t<X> \t<Y> \t<dY> \t<dX" 2533 if data.dxl is not None and data.dxw is not None: 2534 text += "l> \t<dxw" 2535 text += ">\n" 2531 2536 for index in range(len(data.x)): 2532 2537 if data.dy is not None and len(data.dy) > index: … … 2539 2544 dx_val = 0.0 2540 2545 if data.dxl is not None and len(data.dxl) > index: 2541 if index == 0:2542 x_st = "Xl"2543 2546 dx_val = data.dxl[index] 2544 elif data.dxw is not None and len(data.dxw) > index: 2545 if index == 0: 2546 x_st = "Xw" 2547 dx_val = data.dxw[index] 2548 2549 if index == 0: 2550 text += "<index> \t<X> \t<Y> \t<dY> \t<d%s>\n" % x_st 2547 if data.dxw is not None and len(data.dxw) > index: 2548 dx_val = "%s \t%s" % (data.dxl[index], data.dxw[index]) 2549 2551 2550 text += "%s \t%s \t%s \t%s \t%s\n" % (index, 2552 2551 data.x[index], … … 2565 2564 """ 2566 2565 default_name = fname 2567 wildcard = "IGOR/DAT 2D file in Q_map (*.dat)|*.DAT" 2566 wildcard = "IGOR/DAT 2D file in Q_map (*.dat)|*.DAT|"\ 2567 "NXcanSAS files (*.h5)|*.h5|" 2568 2568 dlg = wx.FileDialog(self, "Choose a file", 2569 2569 self._default_save_location, … … 2577 2577 if ext_num == 0: 2578 2578 ext_format = '.dat' 2579 elif ext_num == 1: 2580 ext_format = '.h5' 2579 2581 else: 2580 2582 ext_format = '' … … 2584 2586 # Instantiate a loader 2585 2587 loader = Loader() 2586 2587 ext_format = ".dat" 2588 if os.path.splitext(mypath)[1].lower() == ext_format: 2588 if os.path.splitext(mypath)[1].lower() == '.dat': 2589 2589 # Make sure the ext included in the file name 2590 2590 # especially on MAC 2591 2591 fileName = os.path.splitext(path)[0] + ext_format 2592 2592 loader.save(fileName, data, ext_format) 2593 elif os.path.splitext(mypath)[1].lower() == '.h5': 2594 # Make sure the ext included in the file name 2595 # especially on MAC 2596 fileName = os.path.splitext(path)[0] + ext_format 2597 nxcansaswriter = NXcanSASWriter() 2598 nxcansaswriter.write([data], fileName) 2593 2599 try: 2594 2600 self._default_save_location = os.path.dirname(path) -
src/sas/sasgui/guiframe/local_perspectives/data_loader/data_loader.py
r2924532 r02c1608e 239 239 self.load_complete(output=output, message="Loading data complete!", 240 240 info="info") 241 else:242 self.load_complete(output=None, message=error_message, info="error")243 241 244 242 def load_update(self, message="", info="warning"):
Note: See TracChangeset
for help on using the changeset viewer.