- Timestamp:
- Sep 20, 2018 12:44:12 PM (6 years ago)
- Branches:
- ticket-1094-headless
- Children:
- 1dc134e6
- Parents:
- a072198 (diff), 912e645 (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
- Files:
-
- 7 added
- 25 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sascalc/dataloader/readers/abs_reader.py
re3775c6 rbd5c3b1 171 171 172 172 try: 173 _x = float(toks[ 0])173 _x = float(toks[4]) 174 174 _y = float(toks[1]) 175 175 _dy = float(toks[2]) -
src/sas/sascalc/fit/pagestate.py
raca687a r840ac87 144 144 ################################################################################ 145 145 import time 146 import re 146 147 import os 147 148 import sys … … 773 774 name = value.split(':', 1)[1].strip() 774 775 file_value = "File name:" + name 776 #Truncating string so print doesn't complain of being outside margins 777 if sys.platform != "win32": 778 MAX_STRING_LENGHT = 50 779 if len(file_value) > MAX_STRING_LENGHT: 780 file_value = "File name:.."+file_value[-MAX_STRING_LENGHT+10:] 775 781 file_name = CENTRE % file_value 776 782 if len(title) == 0: … … 848 854 html_str, text_str, title = self._get_report_string() 849 855 # Allow 2 figures to append 850 image_links = [FEET_2%fig for fig in fig_urls] 851 856 #Constraining image width for OSX and linux, so print doesn't complain of being outside margins 857 if sys.platform == "win32": 858 image_links = [FEET_2%fig for fig in fig_urls] 859 else: 860 image_links = [FEET_2_unix%fig for fig in fig_urls] 852 861 # final report html strings 853 862 report_str = html_str + ELINE.join(image_links) 854 863 report_str += FEET_3 855 864 return report_str, text_str 856 865 … … 1081 1090 if node.get('version'): 1082 1091 # Get the version for model conversion purposes 1083 self.version = tuple(int(e) for e in1084 str.split(node.get('version'), "."))1092 x = re.sub('[^\d.]', '', node.get('version')) 1093 self.version = tuple(int(e) for e in str.split(x, ".")) 1085 1094 # The tuple must be at least 3 items long 1086 1095 while len(self.version) < 3: … … 1495 1504 """ 1496 1505 FEET_2 = \ 1497 """<img src="%s" ></img> 1506 """<img src="%s"></img> 1507 """ 1508 FEET_2_unix = \ 1509 """<img src="%s" width="540"></img> 1498 1510 """ 1499 1511 FEET_3 = \ -
src/sas/sasgui/guiframe/config.py
r1efbc190 r8ac05a5 33 33 _do_aboutbox = True 34 34 _do_acknowledge = True 35 _do_release = True 35 36 _do_tutorial = True 36 37 _acknowledgement_preamble =\ … … 49 50 _acknowledgement_citation = \ 50 51 '''M. Doucet et al. SasView Version 4.1.2, Zenodo, 10.5281/zenodo.825675''' 51 52 52 _acknowledgement = \ 53 53 '''This work was originally developed as part of the DANSE project funded by the US NSF under Award DMR-0520547,\n but is currently maintained by a collaboration between UTK, UMD, NIST, ORNL, ISIS, ESS, ILL, ANSTO, TU Delft, DLS, and the scattering community.\n\n SasView also contains code developed with funding from the EU Horizon 2020 programme under the SINE2020 project (Grant No 654000).\nA list of individual contributors can be found at: http://www.sasview.org/contact.html … … 94 94 _corner_image = os.path.join(icon_path, "angles_flat.png") 95 95 _welcome_image = os.path.join(icon_path, "SVwelcome.png") 96 _copyright = "(c) 2009 - 201 7, UTK, UMD, NIST, ORNL, ISIS, ESS, ILL, ANSTO, TU Delft, and DLS"96 _copyright = "(c) 2009 - 2018, UTK, UMD, NIST, ORNL, ISIS, ESS, ILL, ANSTO, TU Delft, and DLS" 97 97 marketplace_url = "http://marketplace.sasview.org/" 98 98 -
src/sas/sasgui/guiframe/gui_manager.py
rb963b20 r8ac05a5 1276 1276 1277 1277 wx_id = wx.NewId() 1278 self._help_menu.Append(wx_id, '&Documentation', ' ')1278 self._help_menu.Append(wx_id, '&Documentation', 'Help documentation for SasView') 1279 1279 wx.EVT_MENU(self, wx_id, self._onSphinxDocs) 1280 1280 1281 1281 if config._do_tutorial and (IS_WIN or sys.platform == 'darwin'): 1282 1282 wx_id = wx.NewId() 1283 self._help_menu.Append(wx_id, '&Tutorial', 'Software tutorial') 1283 # Pluralised both occurences of 'Tutorial' in the line below 1284 # S King, Sep 2018 1285 self._help_menu.Append(wx_id, '&Tutorials', 'Tutorials on how to use SasView') 1284 1286 wx.EVT_MENU(self, wx_id, self._onTutorial) 1287 1288 if config.marketplace_url: 1289 wx_id = wx.NewId() 1290 self._help_menu.Append(wx_id, '&Model marketplace', 'Plug-in fitting models for SasView') 1291 wx.EVT_MENU(self, wx_id, self._on_marketplace_click) 1292 1293 if config._do_release: 1294 wx_id = wx.NewId() 1295 self._help_menu.Append(wx_id, '&Release notes', 1296 'SasView release notes and known issues') 1297 wx.EVT_MENU(self, wx_id, self._onRelease) 1285 1298 1286 1299 if config._do_acknowledge: … … 1293 1306 logger.info("Doing help menu") 1294 1307 wx_id = wx.NewId() 1295 self._help_menu.Append(wx_id, '&About', ' Software information')1308 self._help_menu.Append(wx_id, '&About', 'Information about SasView') 1296 1309 wx.EVT_MENU(self, wx_id, self._onAbout) 1297 1298 if config.marketplace_url:1299 wx_id = wx.NewId()1300 self._help_menu.Append(wx_id, '&Model marketplace', '')1301 wx.EVT_MENU(self, wx_id, self._on_marketplace_click)1302 1310 1303 1311 # Checking for updates … … 2137 2145 dialog.ShowModal() 2138 2146 2147 def _onRelease(self, evt): 2148 """ 2149 Pop up the release notes 2150 2151 :param evt: menu event 2152 2153 """ 2154 # S King, Sep 2018 2155 2156 from documentation_window import DocumentationWindow 2157 _TreeLocation = "user/release.html" 2158 DocumentationWindow(self, -1, _TreeLocation, "", 2159 "SasView Documentation") 2160 2139 2161 def _onTutorial(self, evt): 2140 2162 """ … … 2144 2166 2145 2167 """ 2146 if config._do_tutorial: 2147 path = config.TUTORIAL_PATH 2148 if IS_WIN: 2149 try: 2150 from sas.sasgui.guiframe.pdfview import PDFFrame 2151 dialog = PDFFrame(None, -1, "Tutorial", path) 2152 # put icon 2153 self.put_icon(dialog) 2154 dialog.Show(True) 2155 except: 2156 logger.error("Error in _onTutorial: %s" % sys.exc_value) 2157 try: 2158 # Try an alternate method 2159 logger.error( 2160 "Could not open the tutorial pdf, trying xhtml2pdf") 2161 from xhtml2pdf import pisa 2162 pisa.startViewer(path) 2163 except: 2164 logger.error( 2165 "Could not open the tutorial pdf with xhtml2pdf") 2166 msg = "This feature requires 'PDF Viewer'\n" 2167 wx.MessageBox(msg, 'Error') 2168 else: 2169 try: 2170 command = "open '%s'" % path 2171 os.system(command) 2172 except: 2173 try: 2174 # Try an alternate method 2175 logger.error( 2176 "Could not open the tutorial pdf, trying xhtml2pdf") 2177 from xhtml2pdf import pisa 2178 pisa.startViewer(path) 2179 except: 2180 logger.error( 2181 "Could not open the tutorial pdf with xhtml2pdf") 2182 msg = "This feature requires the Preview application\n" 2183 wx.MessageBox(msg, 'Error') 2168 # Action changed from that in 2.x/3.x/4.0.x/4.1.x 2169 # Help >> Tutorial used to bring up a pdf of the 2170 # original 2.x tutorial. 2171 # Code below, implemented from 4.2.0, redirects 2172 # action to the Tutorials page of the help 2173 # documentation to give access to all available 2174 # tutorials 2175 # S King, Sep 2018 2176 2177 from documentation_window import DocumentationWindow 2178 _TreeLocation = "user/tutorial.html" 2179 DocumentationWindow(self, -1, _TreeLocation, "", 2180 "SasView Documentation") 2184 2181 2185 2182 def _onSphinxDocs(self, evt): -
src/sas/sasgui/guiframe/local_perspectives/plotting/parameters_panel_slicer.py
ra26f67f ra20a255 251 251 self.bck.Add(self.batch_slicer_button, (iy, ix), (1, 1), 252 252 wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 253 # Help button 254 255 self.bt_help = wx.Button(self, wx.NewId(), "HELP") 256 self.bt_help.SetToolTipString( 257 "Help for the slicer parameters and batch slicing.") 258 self.bck.Add(self.bt_help, (iy, 1), (1, 1), 259 wx.ALIGN_RIGHT | wx.ADJUST_MINSIZE, 15) 260 wx.EVT_BUTTON(self, self.bt_help.GetId(), self.on_help) 261 253 262 iy += 1 254 263 self.bck.Add((5, 5), (iy, ix), (1, 1), 255 264 wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 5) 265 256 266 self.bck.Layout() 257 267 self.bck.Fit(self) … … 535 545 self.default_value += "_{0}".format(key).split(" [")[0] 536 546 self.default_value += "-{:.2f}".format(params[key]) 547 548 def on_help(self, event=None): 549 """ 550 Opens a help window for the slicer parameters/batch slicing window 551 :param event: 552 :return: 553 """ 554 from sas.sasgui.guiframe.documentation_window import DocumentationWindow 555 556 _TreeLocation = "user/sasgui/guiframe/graph_help.html" 557 _doc_viewer = DocumentationWindow(self, wx.ID_ANY, _TreeLocation, 558 "#d-data-averaging", 559 "Data Explorer Help") -
src/sas/sasgui/guiframe/media/graph_help.rst
r5ed76f8 rde68f78 266 266 267 267 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 268 .. _d_data_averaging: 268 269 269 270 2D data averaging … … 301 302 Alternatively, once a 'slicer' is active you can also select the region to 302 303 average by bringing back the *Dataset Menu* and selecting *Edit Slicer 303 Parameters*. A dialog window will appear in which you can enter values to 304 define a region or select the number of points to plot (*nbins*). 304 Parameters and Batch Fitting*. A dialog window will appear in which you can 305 enter values to define a region, select the number of points to plot (*nbins*), 306 or apply the slicer to any or all other 2D data plots. 305 307 306 308 A separate plot window will also have appeared, displaying the requested … … 315 317 316 318 To remove a 'slicer', bring back the *Dataset menu* and select *Clear Slicer*. 319 320 Batch Slicing 321 ^^^^^^^^^^^^^ 322 323 A slicer can be applied to any or all existing 2D data plots using the 'Slicer 324 Parameters' window. To open the window, select *Edit Slicer Parameters and Batch 325 Fitting* in the *Dataset Menu* (see Invoking_the_dataset_menu_). Batch slicing 326 options are available at the bottom of the window. 327 328 Select the 2D plots you want to apply the slicer to. All 2D plots are selected 329 by default. The resulting 1D data for all slicers can be saved as a text file 330 and then sent to fitting by selecting the *Auto save generated 1D* check box. 331 Sending data to the fitting perspective requires the data be saved. 332 333 Once the auto save check box is selected, you can select where the files are 334 saved. The file name for the saved data is the slicer name plus the file name 335 of the original data set, plus what is in the *Append to file name* field. The 336 default value in the append to field includes the names and values for all of 337 the slicer parameters. 338 339 The batch of slices can be sent to fitting if desired, with three options 340 available. The first is to not fit the data, the second is to send the 341 slices to individual fit pages, and the third is to send all sliced data to a 342 single batch fit window. 343 344 Clicking *Apply Slicer to Selected Plots* will create a slicer for each selected 345 plot with the parameters entered in the 'Slicer Parameters' window. Depending on 346 the options selected the data may then be saved, loaded as separate data sets in 347 the data manager panel, and finally sent to fitting. 317 348 318 349 Unmasked circular average -
src/sas/sasgui/guiframe/report_dialog.py
r69a6897 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__) … … 27 28 class BaseReportDialog(wx.Dialog): 28 29 29 def __init__(self, report_list, *args, **kwds):30 def __init__(self, report_list, imgRAM, fig_urls, *args, **kwds): 30 31 """ 31 32 Initialization. The parameters added to Dialog are: … … 37 38 kwds["image"] = 'Dynamic Image' 38 39 40 #MemoryFSHandle for storing images 41 self.imgRAM = imgRAM 42 #Images location in urls 43 self.fig_urls = fig_urls 39 44 # title 40 45 self.SetTitle("Report") … … 66 71 button_close = wx.Button(self, wx.ID_OK, "Close") 67 72 button_close.SetToolTipString("Close this report window.") 73 button_close.Bind(wx.EVT_BUTTON, self.onClose, 74 id=button_close.GetId()) 68 75 hbox.Add(button_close) 69 76 button_close.SetFocus() … … 75 82 hbox.Add(button_print) 76 83 77 button_save = wx.Button(self, wx.NewId(), "Save") 78 button_save.SetToolTipString("Save this report.") 79 button_save.Bind(wx.EVT_BUTTON, self.onSave, id=button_save.GetId()) 80 hbox.Add(button_save) 84 if sys.platform != "darwin": 85 button_save = wx.Button(self, wx.NewId(), "Save") 86 button_save.SetToolTipString("Save this report.") 87 button_save.Bind(wx.EVT_BUTTON, self.onSave, id=button_save.GetId()) 88 hbox.Add(button_save) 81 89 82 90 # panel for report page … … 111 119 printh.PrintText(self.report_html) 112 120 113 def OnClose(self, event=None): 121 122 def onClose(self, event=None): 114 123 """ 115 124 Close the Dialog 116 125 : event: Close button event 117 126 """ 118 self.Close() 127 for fig in self.fig_urls: 128 ReportImageHandler.remove_figure(fig) 129 130 self.Destroy() 119 131 120 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
rc6dfb9f 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 … … 663 670 Do the layout for parameter related widgets 664 671 """ 665 param_txt = wx.StaticText(self, -1, 'Fit Parameters NOT requiring' + \ 666 ' polydispersity (if any): ') 667 668 param_tip = "#Set the parameters NOT requiring polydispersity " + \ 669 "and their initial values.\n" 672 param_txt = wx.StaticText(self, -1, 'Fit Parameters: ') 673 674 param_tip = "#Set the parameters and their initial values.\n" 670 675 param_tip += "#Example:\n" 671 676 param_tip += "A = 1\nB = 1" … … 681 686 (self.param_tcl, 1, wx.EXPAND | wx.ALL, 10)]) 682 687 683 # Parameters with polydispersity684 pd_param_txt = wx.StaticText(self, -1, 'Fit Parameters requiring ' + \685 'polydispersity (if any): ')686 687 pd_param_tip = "#Set the parameters requiring polydispersity and " + \688 "their initial values.\n"689 pd_param_tip += "#Example:\n"690 pd_param_tip += "C = 2\nD = 2"691 newid = wx.NewId()692 self.pd_param_tcl = EditWindow(self, newid, wx.DefaultPosition,693 wx.DefaultSize,694 wx.CLIP_CHILDREN | wx.SUNKEN_BORDER)695 self.pd_param_tcl.setDisplayLineNumbers(True)696 self.pd_param_tcl.SetToolTipString(pd_param_tip)697 698 self.param_sizer.AddMany([(pd_param_txt, 0, wx.LEFT, 10),699 (self.pd_param_tcl, 1, wx.EXPAND | wx.ALL, 10)])700 688 701 689 def _layout_function(self): … … 899 887 description = self.desc_tcl.GetValue() 900 888 param_str = self.param_tcl.GetText() 901 pd_param_str = self.pd_param_tcl.GetText()902 889 func_str = self.function_tcl.GetText() 903 890 # No input for the model function … … 905 892 if func_str.count('return') > 0: 906 893 self.write_file(self.fname, name, description, param_str, 907 pd_param_str,func_str)894 func_str) 908 895 try: 909 896 result, msg = check_model(self.fname), None … … 945 932 self.warning = msg 946 933 947 def write_file(self, fname, name, desc_str, param_str, pd_param_str,func_str):934 def write_file(self, fname, name, desc_str, param_str, func_str): 948 935 """ 949 936 Write content in file … … 952 939 :param desc_str: content of the description strings 953 940 :param param_str: content of params; Strings 954 :param pd_param_str: content of params requiring polydispersity; Strings955 941 :param func_str: content of func; Strings 956 942 """ … … 966 952 # Write out parameters 967 953 param_names = [] # to store parameter names 968 pd_params = []969 954 out_f.write('parameters = [ \n') 970 955 out_f.write('# ["name", "units", default, [lower, upper], "type", "description"],\n') … … 973 958 out_f.write(" ['%s', '', %s, [-inf, inf], '', '%s'],\n" 974 959 % (pname, pvalue, desc)) 975 for pname, pvalue, desc in self.get_param_helper(pd_param_str):976 param_names.append(pname)977 pd_params.append(pname)978 out_f.write(" ['%s', '', %s, [-inf, inf], 'volume', '%s'],\n"979 % (pname, pvalue, desc))980 960 out_f.write(' ]\n') 981 961 982 962 # Write out function definition 963 out_f.write('\n') 983 964 out_f.write('def Iq(%s):\n' % ', '.join(['x'] + param_names)) 984 965 out_f.write(' """Absolute scattering"""\n') … … 990 971 out_f.write(' import numpy as np') 991 972 for func_line in func_str.split('\n'): 992 out_f.write('%s%s\n' % ( spaces4, func_line))973 out_f.write('%s%s\n' % (' ', func_line)) 993 974 out_f.write('## uncomment the following if Iq works for vector x\n') 994 975 out_f.write('#Iq.vectorized = True\n') 995 996 # If polydisperse, create place holders for form_volume, ER and VR997 if pd_params:998 out_f.write('\n')999 out_f.write(CUSTOM_TEMPLATE_PD % {'args': ', '.join(pd_params)})1000 976 1001 977 # Create place holder for Iqxy … … 1128 1104 description = """%(description)s""" 1129 1105 1130 '''1131 1132 CUSTOM_TEMPLATE_PD = '''\1133 def form_volume(%(args)s):1134 """1135 Volume of the particles used to compute absolute scattering intensity1136 and to weight polydisperse parameter contributions.1137 """1138 return 0.01139 1140 def ER(%(args)s):1141 """1142 Effective radius of particles to be used when computing structure factors.1143 1144 Input parameters are vectors ranging over the mesh of polydispersity values.1145 """1146 return 0.01147 1148 def VR(%(args)s):1149 """1150 Volume ratio of particles to be used when computing structure factors.1151 1152 Input parameters are vectors ranging over the mesh of polydispersity values.1153 """1154 return 1.01155 1106 ''' 1156 1107 -
src/sas/sasgui/perspectives/calculator/pyconsole.py
r4627657 re2663b7 28 28 Check that the model on the path can run. 29 29 """ 30 # TODO: fix model caching 31 # model_test.run_one() is directly forcing a reload of the module, but 32 # sasview_model is caching models that have already been loaded. 33 # If the sasview load happens before the test, then the module is 34 # reloaded out from under it, which causes the global variables in 35 # the model function definitions to be cleared (at least in python 2.7). 36 # To fix the proximal problem of models failing on test, perform the 37 # run_one() tests first. To fix the deeper problem we should either 38 # remove caching from sasmodels.sasview_model.load_custom_model() or 39 # add caching to sasmodels.custom.load_custom_kernel_module(). Another 40 # option is to add a runTests method to SasviewModel which runs the 41 # test suite directly from the model info structure. Probably some 42 # combination of options: 43 # (1) have this function (check_model) operate on a loaded model 44 # so that caching isn't needed in sasview_models.load_custom_model 45 # (2) add the runTests method to SasviewModel so that tests can 46 # be run on a loaded module. 47 # 48 # Also, note that the model test suite runs the equivalent of the 49 # "try running the model" block below, and doesn't need to be run 50 # twice. The reason for duplicating the block here is to generate 51 # an exception that show_model_output can catch. Need to write the 52 # runTests method so that it returns success flag as well as output 53 # string so that the extra test is not necessary. 54 55 # check the model's unit tests run 56 from sasmodels.model_test import run_one 57 result = run_one(path) 58 59 # remove cached version of the model, if any 60 from sasmodels import sasview_model 61 sasview_model.MODEL_BY_PATH.pop(path, None) 62 30 63 # try running the model 31 from sasmodels.sasview_model import load_custom_model 32 Model = load_custom_model(path) 64 Model = sasview_model.load_custom_model(path) 33 65 model = Model() 34 66 q = np.array([0.01, 0.1]) … … 36 68 qx, qy = np.array([0.01, 0.01]), np.array([0.1, 0.1]) 37 69 Iqxy = model.evalDistribution([qx, qy]) 38 39 # check the model's unit tests run40 from sasmodels.model_test import run_one41 result = run_one(path)42 70 43 71 return result -
src/sas/sasgui/perspectives/calculator/resolution_calculator_panel.py
r7432acb r1cf490b6 18 18 matplotlib.use('WXAgg') 19 19 from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas 20 from matplotlib.backends.backend_wxagg import NavigationToolbar2Wx as Toolbar20 from matplotlib.backends.backend_wxagg import NavigationToolbar2WxAgg as Toolbar 21 21 from matplotlib.backend_bases import FigureManagerBase 22 22 # Wx-Pylab magic for displaying plots within an application's window. -
src/sas/sasgui/perspectives/calculator/slit_length_calculator_panel.py
r7432acb rd788619 248 248 Complete the loading and compute the slit size 249 249 """ 250 if isinstance(data, list): 251 data = data[0] 250 252 if data is None or data.__class__.__name__ == 'Data2D': 251 253 if self.parent.parent is None: -
src/sas/sasgui/perspectives/fitting/basepage.py
r1f4d708 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 … … 641 642 # get the strings for report 642 643 report_str, text_str = self.state.report(fig_urls=refs) 643 644 644 # Show the dialog 645 645 report_list = [report_str, text_str, images] 646 dialog = ReportDialog(report_list, None, wx.ID_ANY, "")646 dialog = ReportDialog(report_list, imgRAM, refs, None, wx.ID_ANY, "") 647 647 dialog.Show() 648 648 … … 652 652 by plotting, putting it into wx.FileSystem image object 653 653 """ 654 images = [] 655 refs = [] 656 657 # For no figures in the list, prepare empty plot 658 if figs is None or len(figs) == 0: 659 figs = [None] 660 661 # Loop over the list of figures 662 # use wx.MemoryFSHandler 663 imgRAM = wx.MemoryFSHandler() 664 for fig in figs: 665 if fig is not None: 666 ind = figs.index(fig) 667 canvas = canvases[ind] 668 669 # store the image in wx.FileSystem Object 670 wx.FileSystem.AddHandler(wx.MemoryFSHandler()) 671 672 # index of the fig 673 ind = figs.index(fig) 674 675 # AddFile, image can be retrieved with 'memory:filename' 676 name = 'img_fit%s.png' % ind 677 refs.append('memory:' + name) 678 imgRAM.AddFile(name, canvas.bitmap, wx.BITMAP_TYPE_PNG) 679 680 # append figs 681 images.append(fig) 682 683 return imgRAM, images, refs 684 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 685 660 686 661 def on_save(self, event): … … 1472 1447 # we need to check here ourselves. 1473 1448 if not is_modified: 1474 is_modified = (self._check_value_enter(self.fittable_param) 1475 or self._check_value_enter(self.fixed_param) 1476 or self._check_value_enter(self.parameters)) 1449 is_modified = self._check_value_enter(self.fittable_param) 1450 is_modified = self._check_value_enter( 1451 self.fixed_param) or is_modified 1452 is_modified = self._check_value_enter( 1453 self.parameters) or is_modified 1477 1454 1478 1455 # Here we should check whether the boundaries have been modified. … … 1536 1513 data=[self.data]) 1537 1514 # Check the values 1538 is_modified = (self._check_value_enter(self.fittable_param)1539 or self._check_value_enter(self.fixed_param)1540 or self._check_value_enter(self.parameters))1515 is_modified = self._check_value_enter(self.fittable_param) 1516 is_modified = self._check_value_enter(self.fixed_param) or is_modified 1517 is_modified = self._check_value_enter(self.parameters) or is_modified 1541 1518 1542 1519 # If qmin and qmax have been modified, update qmin and qmax and … … 2324 2301 2325 2302 # Update value in model if it has changed 2326 if value != self.model.getParam(name): 2303 if (value != self.model.getParam(name) or 2304 (np.isnan(value) and np.isnan(self.model.getParam(name)))): 2327 2305 self.model.setParam(name, value) 2328 2306 is_modified = True … … 2551 2529 # draw 2552 2530 self._draw_model() 2531 self.Layout() 2553 2532 self.Refresh() 2554 2533 except Exception: … … 2799 2778 Function called when 'Help' button is pressed next to model 2800 2779 of interest. This calls DocumentationWindow from 2801 documentation_window.py. It will load the top level of the model 2802 help documenation sphinx generated html if no model is presented. 2803 If a model IS present then if documention for that model exists 2804 it will load to that point otherwise again it will go to the top. 2805 For Wx2.8 and below is used (i.e. non-released through installer) 2806 a browser is loaded and the top of the model documentation only is 2807 accessible because webbrowser module does not pass anything after 2808 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 2809 2791 2810 2792 :param event: on Help Button pressed event 2811 2793 """ 2812 2794 2813 if self.model is not None: 2795 if (self.model is not None) and (self.categorybox.GetValue() 2796 != "Plugin Models"): 2814 2797 name = self.formfactorbox.GetValue() 2815 2798 _TreeLocation = 'user/models/%s.html' % name -
src/sas/sasgui/perspectives/fitting/fitpage.py
re870702 r840ac87 705 705 706 706 ix = 3 707 ctl2 = wx.TextCtrl(self, wx.ID_ANY, 708 size=(_BOX_WIDTH / 1.3, 20), 709 style=0) 707 ctl2 = BGTextCtrl(self, wx.ID_ANY, 708 size=(_BOX_WIDTH / 1.3, 20)) 710 709 711 710 self.sizer4_4.Add(ctl2, (iy, ix), (1, 1), … … 1997 1996 self.on_smear_helper() 1998 1997 self.on_set_focus(None) 1998 self.Layout() 1999 1999 self.Refresh() 2000 2000 # update model plot with new data information … … 2891 2891 text2.Hide() 2892 2892 ix += 1 2893 ctl2 = wx.TextCtrl(self, wx.ID_ANY,2894 size=(_BOX_WIDTH / 1.2, 20) , style=0)2893 ctl2 = BGTextCtrl(self, wx.ID_ANY, 2894 size=(_BOX_WIDTH / 1.2, 20)) 2895 2895 sizer.Add(ctl2, (iy, ix), (1, 1), 2896 2896 wx.EXPAND | wx.ADJUST_MINSIZE, 0) -
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/media/fitting_help.rst
r47ace50 r9258c43c 180 180 *checked*\ . 181 181 182 Also note that the 'Fit Parameters' have been split into two sections: those183 which can be polydisperse (shape and orientation parameters) and those which are184 not (eg, scattering length densities).185 186 182 A model file generated by this option can be viewed and further modified using 187 183 the :ref:`Advanced_Plugin_Editor` . 188 184 189 **SasView version 4.2** made it possible to specify whether a plugin created with 190 the *New Plugin Model* dialog is actually a form factor P(Q) or a structure factor 191 S(Q). To do this, simply add one or other of the following lines under the *import* 192 statements. 185 Note that the New Plugin Model Feature currently does not allow for parameters 186 to be polydisperse. However they can be edited in the Advanced Editor. 187 188 189 **SasView version 4.2** made it possible to specify whether a plugin created 190 with the *New Plugin Model* dialog is actually a form factor P(Q) or a structure 191 factor S(Q). To do this, simply add one or other of the following lines under 192 the *import* statements. 193 193 194 194 For a form factor:: … … 200 200 structure_factor = True 201 201 202 If the plugin is a structure factor it is *also* necessary to add two variables to203 t he parameter list::202 If the plugin is a structure factor it is *also* necessary to add two variables 203 to the parameter list:: 204 204 205 205 parameters = [ -
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/sasview/local_config.py
rb963b20 r8ac05a5 33 33 _do_aboutbox = True 34 34 _do_acknowledge = True 35 _do_release = True 35 36 _do_tutorial = True 36 37 _acknowledgement_preamble =\ … … 48 49 '''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 50 _acknowledgement_citation = \ 50 '''M. Doucet et al. SasView Version 4.1.2, Zenodo, 10.5281/zenodo.825675''' 51 51 '''M. Doucet et al. SasView Version 4.2, Zenodo, 10.5281/zenodo.1412041''' 52 52 _acknowledgement = \ 53 53 '''This work was originally developed as part of the DANSE project funded by the US NSF under Award DMR-0520547,\n but is currently maintained by a collaboration between UTK, UMD, NIST, ORNL, ISIS, ESS, ILL, ANSTO, TU Delft, DLS, and the scattering community.\n\n SasView also contains code developed with funding from the EU Horizon 2020 programme under the SINE2020 project (Grant No 654000).\nA list of individual contributors can be found at: http://www.sasview.org/contact.html … … 94 94 _corner_image = os.path.join(icon_path, "angles_flat.png") 95 95 _welcome_image = os.path.join(icon_path, "SVwelcome.png") 96 _copyright = "(c) 2009 - 201 7, UTK, UMD, NIST, ORNL, ISIS, ESS, ILL, ANSTO, TU Delft, and DLS"96 _copyright = "(c) 2009 - 2018, UTK, UMD, NIST, ORNL, ISIS, ESS, ILL, ANSTO, TU Delft, and DLS" 97 97 marketplace_url = "http://marketplace.sasview.org/" 98 98 -
src/sas/sasview/media/README.txt
r914ba0a r356af60e 1 The files in this folder are what get shipped in the installer \media folder. 2 3 The help documentation gets shipped in the /doc folder. 4 1 5 This Tutorial.pdf is what appears when you click on 'Tutorial' under 'Help' 2 in the menu bar.6 in the SasView menu bar. It has been manually copied over from sasview/docs/sasview. 3 7 4 The source files are in: /sasview/docs/sasview 5 6 The getting_started_with_sasview.pdf has been manually added here until the auto-generated LibreOffice doc build is up and running. 8 The new tutorial pdfs here have been manually copied over from the website /downloads folder. -
src/sas/sasview/sasview.py
r20fa5fe r1270e3c 43 43 from sas.sasgui.guiframe.gui_manager import SasViewApp 44 44 self.gui = SasViewApp(0) 45 if sys.platform == "darwin": 46 self.check_sasmodels_compiler() 45 47 # Set the application manager for the GUI 46 48 self.gui.set_manager(self) … … 130 132 self.gui.MainLoop() 131 133 134 def check_sasmodels_compiler(self): 135 """ 136 Checking c compiler for sasmodels and raises xcode command line 137 tools for installation 138 """ 139 #wx should be importable at this stage 140 import wx 141 import subprocess 142 #Generic message box created becuase standard MessageBox is not moveable 143 class GenericMessageBox(wx.Dialog): 144 def __init__(self, parent, text, title = ''): 145 146 wx.Dialog.__init__(self, parent, -1, title = title, 147 size = (360,200), pos=(20,60), 148 style = wx.STAY_ON_TOP | wx.DEFAULT_DIALOG_STYLE) 149 panel = wx.Panel(self, -1) 150 top_row_sizer = wx.BoxSizer(wx.HORIZONTAL) 151 152 error_bitmap = wx.ArtProvider.GetBitmap( 153 wx.ART_ERROR, wx.ART_MESSAGE_BOX 154 ) 155 error_bitmap_ctrl = wx.StaticBitmap(panel, -1) 156 error_bitmap_ctrl.SetBitmap(error_bitmap) 157 label = wx.StaticText(panel, -1, text) 158 top_row_sizer.Add(error_bitmap_ctrl, flag=wx.ALL, border=10) 159 top_row_sizer.Add(label, flag=wx.ALIGN_CENTER_VERTICAL) 160 161 #Create the OK button in the bottom row. 162 ok_button = wx.Button(panel, wx.ID_OK ) 163 self.Bind(wx.EVT_BUTTON, self.on_ok, source=ok_button) 164 ok_button.SetFocus() 165 ok_button.SetDefault() 166 167 sizer = wx.BoxSizer(wx.VERTICAL) 168 sizer.Add(top_row_sizer) 169 sizer.Add(ok_button, flag=wx.ALIGN_CENTER | wx.ALL, border=5) 170 panel.SetSizer(sizer) 171 172 def on_ok(self, event): 173 self.Destroy() 174 175 logger = logging.getLogger(__name__) 176 try: 177 subprocess.check_output(["cc","--version"], stderr=subprocess.STDOUT) 178 except subprocess.CalledProcessError as exc: 179 dlg = GenericMessageBox(parent=None, 180 text='No compiler installed. Please install command line\n' 181 'developers tools by clicking \"Install\" in another winodw\n\n' 182 'Alternatively click \"Not Now\" and use OpenCL\n' 183 'compiler, which can be set up from menu Fitting->OpenCL Options\n\n', 184 title = 'Compiler Info') 185 dlg.Show() 186 logger.error("No compiler installed. %s\n"%(exc)) 187 logger.error(traceback.format_exc()) 132 188 133 189 def setup_logging(): -
src/sas/sascalc/fit/BumpsFitting.py
r1386b2f r0aeba4e 2 2 BumpsFitting module runs the bumps optimizer. 3 3 """ 4 from __future__ import print_function 5 4 6 import os 5 7 from datetime import timedelta, datetime … … 9 11 10 12 from bumps import fitters 13 11 14 try: 12 15 from bumps.options import FIT_CONFIG 16 # Preserve bumps default fitter in case someone wants it later 17 BUMPS_DEFAULT_FITTER = FIT_CONFIG.selected_id 13 18 # Default bumps to use the Levenberg-Marquardt optimizer 14 19 FIT_CONFIG.selected_id = fitters.LevenbergMarquardtFit.id … … 17 22 except ImportError: 18 23 # CRUFT: Bumps changed its handling of fit options around 0.7.5.6 24 # Preserve bumps default fitter in case someone wants it later 25 BUMPS_DEFAULT_FITTER = fitters.FIT_DEFAULT 19 26 # Default bumps to use the Levenberg-Marquardt optimizer 20 27 fitters.FIT_DEFAULT = 'lm' … … 126 133 if initial_values is not None: 127 134 self._reset_pars(fitted, initial_values) 135 #print("constraints", constraints) 128 136 self.constraints = dict(constraints) 129 137 self.set_fitted(fitted) … … 222 230 def _setup(self): 223 231 exprs = {} 224 for M in self.models: 225 exprs.update((".".join((M.name, k)), v) for k, v in M.constraints.items()) 232 for model in self.models: 233 exprs.update((".".join((model.name, k)), v) 234 for k, v in model.constraints.items()) 226 235 if exprs: 227 symtab = dict((".".join(( M.name, k)), p)228 for Min self.models229 for k, p in M.parameters().items())236 symtab = dict((".".join((model.name, k)), p) 237 for model in self.models 238 for k, p in model.parameters().items()) 230 239 self.update = compile_constraints(symtab, exprs) 231 240 else:
Note: See TracChangeset
for help on using the changeset viewer.