Changeset 316b9c1 in sasview
- Timestamp:
- Jun 11, 2018 9:30:11 AM (7 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:
- c7634fd, 9e96dbd, 8a51dea0
- Parents:
- 9258c43c (diff), 1270e3c (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. - git-author:
- Paul Kienzle <pkienzle@…> (06/11/18 09:30:11)
- git-committer:
- GitHub <noreply@…> (06/11/18 09:30:11)
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
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/sasgui/perspectives/calculator/model_editor.py
rc6dfb9f r9258c43c 663 663 Do the layout for parameter related widgets 664 664 """ 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" 665 param_txt = wx.StaticText(self, -1, 'Fit Parameters: ') 666 667 param_tip = "#Set the parameters and their initial values.\n" 670 668 param_tip += "#Example:\n" 671 669 param_tip += "A = 1\nB = 1" … … 681 679 (self.param_tcl, 1, wx.EXPAND | wx.ALL, 10)]) 682 680 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 681 701 682 def _layout_function(self): … … 899 880 description = self.desc_tcl.GetValue() 900 881 param_str = self.param_tcl.GetText() 901 pd_param_str = self.pd_param_tcl.GetText()902 882 func_str = self.function_tcl.GetText() 903 883 # No input for the model function … … 905 885 if func_str.count('return') > 0: 906 886 self.write_file(self.fname, name, description, param_str, 907 pd_param_str,func_str)887 func_str) 908 888 try: 909 889 result, msg = check_model(self.fname), None … … 945 925 self.warning = msg 946 926 947 def write_file(self, fname, name, desc_str, param_str, pd_param_str,func_str):927 def write_file(self, fname, name, desc_str, param_str, func_str): 948 928 """ 949 929 Write content in file … … 952 932 :param desc_str: content of the description strings 953 933 :param param_str: content of params; Strings 954 :param pd_param_str: content of params requiring polydispersity; Strings955 934 :param func_str: content of func; Strings 956 935 """ … … 966 945 # Write out parameters 967 946 param_names = [] # to store parameter names 968 pd_params = []969 947 out_f.write('parameters = [ \n') 970 948 out_f.write('# ["name", "units", default, [lower, upper], "type", "description"],\n') … … 973 951 out_f.write(" ['%s', '', %s, [-inf, inf], '', '%s'],\n" 974 952 % (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 953 out_f.write(' ]\n') 981 954 982 955 # Write out function definition 956 out_f.write('\n') 983 957 out_f.write('def Iq(%s):\n' % ', '.join(['x'] + param_names)) 984 958 out_f.write(' """Absolute scattering"""\n') … … 990 964 out_f.write(' import numpy as np') 991 965 for func_line in func_str.split('\n'): 992 out_f.write('%s%s\n' % ( spaces4, func_line))966 out_f.write('%s%s\n' % (' ', func_line)) 993 967 out_f.write('## uncomment the following if Iq works for vector x\n') 994 968 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 969 1001 970 # Create place holder for Iqxy … … 1128 1097 description = """%(description)s""" 1129 1098 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 1099 ''' 1156 1100 -
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 = [ -
test/corfunc/test/utest_corfunc.py
rf53d684 r6ef75fa6 74 74 while True: 75 75 time.sleep(0.001) 76 if not self.calculator.transform_isrunning(): 76 if (not self.calculator.transform_isrunning() and 77 self.transformation is not None): 77 78 break 78 79 79 def transform_callback(self, transforms): 80 transform1, transform3, idf = transforms 80 transform1, transform3, idf = self.transformation 81 81 self.assertIsNotNone(transform1) 82 82 self.assertAlmostEqual(transform1.y[0], 1) 83 83 self.assertAlmostEqual(transform1.y[-1], 0, 5) 84 85 def transform_callback(self, transforms): 84 86 self.transformation = transforms 85 87
Note: See TracChangeset
for help on using the changeset viewer.