Changes in / [0639476:5e906207] in sasview
- Files:
-
- 27 added
- 15 deleted
- 43 edited
Legend:
- Unmodified
- Added
- Removed
-
.travis.yml
r58918de ra4974fa 12 12 system_site_packages: true 13 13 before_install: 14 - 'if [ $TRAVIS_PYTHON_VERSION == "2.7" ]; then sudo apt-get update;sudo apt-get install python-numpy python-scipy python-matplotlib libhdf5-serial-dev python-h5py fglrx opencl-headers python-pyopencl; fi'14 - 'if [ $TRAVIS_PYTHON_VERSION == "2.7" ]; then sudo apt-get update;sudo apt-get install python-numpy python-scipy python-matplotlib; fi' 15 15 16 16 install: 17 17 - pip install -r build_tools/requirements.txt 18 19 before_script:20 - "export DISPLAY=:99.0"21 - "sh -e /etc/init.d/xvfb start"22 - sleep 3 # give xvfb some time to start23 24 18 script: 25 - export WORKSPACE=/home/travis/build/SasView/ 26 - cd $WORKSPACE 27 - git clone --depth=50 --branch=master https://github.com/SasView/sasmodels.git sasmodels 19 - export WORKSPACE=/home/travis/build/SasView/sasview/ 28 20 - export PYTHONPATH=$WORKSPACE/sasview-install:$WORKSPACE/utils:$PYTHONPATH 29 - cd $WORKSPACE30 - ls -ltr31 21 - if [ ! -d "utils" ]; then mkdir utils; fi 32 - /bin/sh -xe sasview/build_tools/travis_build.sh33 # - /bin/sh -xe sasview/build_tools/jenkins_linux_test.sh22 - /bin/sh -xe build_tools/jenkins_linux_build.sh 23 - /bin/sh -xe build_tools/jenkins_linux_test.sh 34 24 - export LC_ALL=en_US.UTF-8 35 25 - export LANG=en_US.UTF-8 36 #- python setup.py docs; echo 037 #- python setup.py bdist_egg --skip-build26 - python setup.py docs; echo 0 27 - python setup.py bdist_egg --skip-build 38 28 -
Vagrantfile
r601b93d r072b52c 21 21 # Every Vagrant development environment requires a box. You can search for 22 22 # boxes at https://atlas.hashicorp.com/search. 23 config.vm.box = "ubuntu/trusty64" 23 config.vm.box = "ubuntu1404" 24 config.vm.box_url = "https://github.com/hnakamur/packer-templates/releases/download/v1.0.2/ubuntu-14-04-x64-virtualbox.box" 24 25 #config.vm.box = "fedora19" 25 26 #config.vm.box_url = "https://dl.dropboxusercontent.com/u/86066173/fedora-19.box" -
build_tools/sasview_deploy_test.au3
re9f8208 r55bbe0b2 92 92 ; Start app - DEBUG ONLY 93 93 ;;Run("C:\Program Files (x86)\SasView\SasView.exe") 94 local $sActiveWindow = "SasView - Fitting -"95 94 Local $iFailFlag = 2 96 95 ; Wait for the window 97 96 Sleep(1000) 98 Local $hWnd = WinWaitActive( $sActiveWindow, "", $lTimeout)97 Local $hWnd = WinWaitActive("SasView - Fitting -", "", $lTimeout) 99 98 Assert($hWnd, $iFailFlag) 100 99 … … 114 113 ControlClick($hWnd, "Send To", 231) 115 114 116 ;; Choose a pythonmodel115 ;; Choose a model 117 116 ControlCommand($hWnd, "", "ComboBox3", "SetCurrentSelection", 1) 117 118 118 ;; Calculate the model 119 119 ControlClick($hWnd, "Compute", 211) 120 ;; Assure we got the charts121 Local $hPlot = WinWait($sActiveWindow, "Graph2", $lTimeout)122 Assert($hPlot, $iFailFlag)123 $hPlot = WinWait($sActiveWindow, "Graph3", $lTimeout)124 Assert($hPlot, $iFailFlag)125 126 sleep(1000)127 ;; Calculate a compiled model128 ControlClick($hWnd, "Send To", 231)129 130 ;; Choose Shapes/Cylinder131 ControlCommand($hWnd, "", "ComboBox2", "SetCurrentSelection", 1)132 ControlCommand($hWnd, "", "ComboBox3", "SetCurrentSelection", 11)133 ;; Calculate the model134 ControlClick($hWnd, "Compute", 211)135 136 ;; Assure we got another chart137 $hPlot = WinWait($sActiveWindow, "Graph4", $lTimeout)138 Assert($hPlot, $iFailFlag)139 120 140 121 ;; Close SasView -
docs/sphinx-docs/source/conf.py
r9a182b2 refc27a7 60 60 # 61 61 # The short X.Y version. 62 version = '4.0 '62 version = '4.0.0' 63 63 # The full version, including alpha/beta/rc tags. 64 release = '4.0.0 '64 release = '4.0.0-alpha' 65 65 66 66 # The language for content autogenerated by Sphinx. Refer to documentation -
docs/sphinx-docs/source/user/analysis.rst
rec860a8f r8f46df7 1 .. _analysis:2 3 1 Types of Analysis 4 2 ================= -
docs/sphinx-docs/source/user/sasgui/guiframe/data_formats_help.rst
r756f288 r49148bb 3 3 .. This is a port of the original SasView html help file to ReSTructured text 4 4 .. by S King, ISIS, during SasView CodeCamp-III in Feb 2015. 5 .. WG Bouwman, DUT, added during CodeCamp-V in Oct 2016 the SESANS data format6 5 7 6 .. _Formats: … … 10 9 ============ 11 10 12 SasView reads several different 1D (I(Q) vs Q), 2D SANS(I(Qx,Qy) vs (Qx,Qy)) 13 and SESANS (P(z) vs z) 11 SasView reads several different 1D (I(Q) vs Q) and 2D (I(Qx,Qy) vs (Qx,Qy)) 14 12 data files. But please note that SasView does not at present load data where 15 13 the Q and I(Q) data are in separate files. 16 14 17 1D Formats SANS18 ---------- -----15 1D Formats 16 ---------- 19 17 20 18 SasView will read files with 2 to 4 columns of numbers in the following order: … … 48 46 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 49 47 50 2D Formats SANS51 ---------- -----48 2D Formats 49 ---------- 52 50 53 51 SasView will only read files in the NIST 2D format with the extensions … … 62 60 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 63 61 64 Format SESANS 65 --------------- 66 67 The current file extension is .ses or .sesans (not case sensitive). 68 69 The file format is to have a list of name-value pairs as a header at the top of the file, detailing general experimental parameters necessary for fitting and analyzing data. This list should contain all information necessary for the file to be 'portable' between users. 70 71 Following that is a 6 column list of instrument experimental variables: 72 73 - Spin echo length (z, in Angstroms) 74 - Spin echo length error (:math:`\Delta` z, in Angstroms) (experimental resolution) 75 - neutron wavelength (:math:`\lambda`, in Angstroms) (essential for ToF instruments) 76 - neutron wavelength error (:math:`\Delta \lambda`, in Angstroms) 77 - Normalized polarization (:math:`P/P_0`, unitless) 78 - Normalized polarization error (:math:`\Delta(P/P_0)`, unitless) (measurement error) 79 80 81 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 82 83 .. note:: This help document was last changed by Wim Bouwman, 05Oct2016 62 .. note:: This help document was last changed by Steve King, 01May2015 -
docs/sphinx-docs/source/user/sasgui/perspectives/invariant/invariant_help.rst
r9bbc074 r5f5c596 4 4 .. by S King, ISIS, during SasView CodeCamp-III in Feb 2015. 5 5 6 Invariant Calculation 7 ===================== 6 Invariant Calculation Perspective 7 ================================= 8 8 9 9 Description … … 19 19 .. image:: image001.gif 20 20 21 where *g = q* for pinhole geometry (SAS) and *g = q*\ :sub:`v`(the slit height) for21 where *g = Q* for pinhole geometry (SAS) and *g = Qv* (the slit height) for 22 22 slit geometry (USAS). 23 23 … … 45 45 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 46 46 47 Using invariant analysis48 --------------------- ---47 Using the perspective 48 --------------------- 49 49 50 50 1) Select *Invariant* from the *Analysis* menu on the SasView toolbar. … … 53 53 54 54 3) Select a dataset and use the *Send To* button on the *Data Explorer* to load 55 the dataset into the *Invariant* p anel.55 the dataset into the *Invariant* perspective. 56 56 57 4) Use the *Customised Input* boxes on the *Invariant* p anelto subtract57 4) Use the *Customised Input* boxes on the *Invariant* perspective to subtract 58 58 any background, specify the contrast (i.e. difference in SLDs - this must be 59 59 specified for the eventual value of Q*\ to be on an absolute scale), or to … … 73 73 74 74 8) If the value of Q*\ calculated with the extrapolated regions is invalid, a 75 red warning will appear at the top of the *Invariant* p anel.75 red warning will appear at the top of the *Invariant* perspective panel. 76 76 77 77 The details of the calculation are available by clicking the *Details* -
docs/sphinx-docs/source/user/tools.rst
rec860a8f reb8da5f 1 .. _tools:2 3 1 Tools 4 2 ===== -
docs/sphinx-docs/source/user/tutorial.rst
rec860a8f r13161ac 1 1 .. tutorial.rst 2 3 .. _tutorial:4 2 5 3 Tutorial -
docs/sphinx-docs/source/user/user.rst
rbdae317 r5a71761 7 7 :maxdepth: 1 8 8 9 Model Documentation <index> 10 11 Menu Bar <menu_bar> 9 SasView Model Documentation <index> 12 10 13 11 Analysis <analysis> -
docs/sphinx-docs/source/user/working.rst
rc43953ef r3a6b10d 16 16 17 17 Tutorial <tutorial.rst> 18 19 Computations with a GPU <gpu_computations>20 -
sasview/README.txt
r9a182b2 r243fbc0 4 4 1- Features 5 5 =========== 6 - New in Version 4.07 ------------------8 This release fixes the various bugs found during the alpha and beta testing9 - Improvements10 - Support for reading data files from Anton Paar Saxess instruments11 - Adds documentation on how to write custom models in the new framework12 - Bug Fixes13 - Fixes bug #604 Pringle model questions14 - Fixes bug #472 Reparameterize Teubner-Strey15 - Fixes bug #530 Numerical instabilities in Teubner Strey model16 - Fixes bug #658 ASCII reader very broken17 18 19 - New in Version 4.0 beta 120 --------------------21 This beta adds support for the magnetic and multilevel models of 3.1.222 and along with a host of bug fixes found in the alpha.23 24 - Model package changes and improvements25 - All 3.1.2 models now available in new interface26 - Old custom models should now still work27 - '''NOTE:''' These will be deprecated in a future version. Old28 custom models should be converted to the new model format which29 is now the same as the built in models and offers much better30 support.31 - Custom model editor now creates new style models32 - Custom model editor supports better error checking33 - Documentation improvements34 - Continued general cleanup35 - Other improvements/additions36 - Support for new canSAS 2D data files added37 - Plot axes range can now be set manually as well as by zooming38 - Plot annotations can now be moved around after being placed on plot.39 - The active optimizer is now listed on the top of the fit panel.40 - Linear fits now update qmin and max when the x scale limits are41 changed. Also the plot range no longer resets after a fit.42 - Bug fixes43 - Fixes bug #511 Errors in linearized fits and clean up of interface44 including Kratky representation45 - Fixes bug #186 Data operation Tool now executes when something is46 entered in the text box and does not wait for the user to hit enter47 - Fixes bug #459 plot context menu bug48 - Fixes bug #559 copy to clipboard in graph menu broken49 - Fixes bug #466 cannot remove a linear fit from graph50 - Numerous bugs introduced in the alpha51 52 53 6 54 7 - New in Version 4.0.0-alpha … … 91 44 - New in Version 3.1.2 92 45 -------------------- 93 This release is a major stability improvement, having fixed a serious bug 46 This release is a major stability improvement, having fixed a serious bug 94 47 that came to light since release 3.1.1. All users should upgrade. 95 48 96 - Fixes bug #468 broken remove constraint buttons in 49 - Fixes bug #468 broken remove constraint buttons in 97 50 simultaneous/constrained fitting panel 98 - Fixes bug #474 resulting from changes in 3.1.1 that had 51 - Fixes bug #474 resulting from changes in 3.1.1 that had 99 52 introduced an error in the high-Q of slit-smeared models. 100 - Fixes bug #478 which would cause wx to run out of IDs and result 53 - Fixes bug #478 which would cause wx to run out of IDs and result 101 54 in SasView crashing even if left alone. 102 55 - Fixes bug #479 missing help button on simultaneous/constrained fit page … … 122 75 documentation. 123 76 - The model help has been split so that the Details button now brings up 124 a very short pop-up giving the equation being used while HELP goes to 77 a very short pop-up giving the equation being used while HELP goes to 125 78 the section in the full documentation describing the model. 126 - Extensive help has also been added for the new optimizer engine (see 79 - Extensive help has also been added for the new optimizer engine (see 127 80 below) including rules of thumb on how and when to choose a given 128 81 optimizer and what the parameters do. … … 139 92 - A Nelder-Mead Simplex optimizer 140 93 - A Differential Evolution optimizer 141 - A Monte Carlo optimizer (DREAM) 94 - A Monte Carlo optimizer (DREAM) 142 95 - New models were added: 143 96 - MicelleSphCoreModel (currently residing in the Uncategorized category) … … 148 101 - RectangularHollowPrismInfThinWallsModel 149 102 - Infrastructure to allow SESANS data to be fit with models was added. This 150 will become available in a future release but can currently be used from 103 will become available in a future release but can currently be used from 151 104 the command line with some caveats. 152 105 - A number of bugs were fixed including a thread crashing issue and an … … 173 126 floating. 174 127 - Five new models have been added: PringlesModel, CoreShellEllipsoidXTModel, 175 RectangularPrismModel, RectangularHollowPrismModel and 128 RectangularPrismModel, RectangularHollowPrismModel and 176 129 RectangularHollowPrismInfThinWallsModel. 177 - The data loader now supports ILL DAT data files and reads the full meta 130 - The data loader now supports ILL DAT data files and reads the full meta 178 131 information from canSAS file formats. 179 132 - Redefined convention for specifying angular parameters for anisotropic 180 133 models. 181 - A number of minor features have been added such as permitting a log 182 distribution of points when using a model to simulate data, and the 134 - A number of minor features have been added such as permitting a log 135 distribution of points when using a model to simulate data, and the 183 136 addition of a Kratky plot option to the linear plots. 184 137 - A number of bugs have also been fixed. 185 138 - Save Project and Save Analysis now work more reliably. 186 - BETA: Magnetic contrast supporting full polarization analysis has been 139 - BETA: Magnetic contrast supporting full polarization analysis has been 187 140 implemented for some spherical and cylindrical models. 188 141 - BETA: Two new tools have been added: 189 - A generic scattering calculator which takes an atomic, magnetic or 190 SLD distribution in space and generates the appropriate 2D 191 scattering pattern. In some cases the orientationally averaged 192 (powder) 1D scattering can also be computed. Supported formats 193 include: SLD or text, PDB, and OMF magnetic moment distribution 142 - A generic scattering calculator which takes an atomic, magnetic or 143 SLD distribution in space and generates the appropriate 2D 144 scattering pattern. In some cases the orientationally averaged 145 (powder) 1D scattering can also be computed. Supported formats 146 include: SLD or text, PDB, and OMF magnetic moment distribution 194 147 file. 195 - An image viewer/converter for data in image format; this reads in 196 an image file and will attempt to convert the image pixels to 148 - An image viewer/converter for data in image format; this reads in 149 an image file and will attempt to convert the image pixels to 197 150 data. Supported formats include: TIFF, TIF, PNG, BMP, JPG. 198 151 … … 222 175 - Added more plot symbols options for 1d plots 223 176 - Added improved trapping of compiling errors to the 'New model editor' 224 - Added some intelligent outputs (e.g., Rg, background, or rod diameter 177 - Added some intelligent outputs (e.g., Rg, background, or rod diameter 225 178 depending on the choice of axis scale of the plot) to the linear fits 226 179 - Added more models 227 228 - Feature set from previous versions 180 181 - Feature set from previous versions 229 182 ----------------------------------- 230 183 - Perspectives Available … … 232 185 specific surface area. 233 186 - P(r) inversion calculator: Indirect Fourier transformation method. 234 - Fitting: the tool used for modeling and fitting 1D and 2D data to 187 - Fitting: the tool used for modeling and fitting 1D and 2D data to 235 188 analytical model functions 236 189 - Tools: provides a number of useful supplementary tools such as SLD 237 calculation 238 239 - Fitting 190 calculation 191 192 - Fitting 240 193 - Includes a large number of model functions, both form factors and structure factors. 241 194 - Support P(Q)*S(Q) for form factors that flag they can be so multiplied. … … 245 198 - Anisotropic shapes and magnetic moment modeling in 2D allow for a non-uniform 246 199 distribution of orientations of a given axis leading to modeling and fitting 247 capabilities of non azimuthaly symmetric data. 200 capabilities of non azimuthaly symmetric data. 248 201 - User can choose to weight fits or not. If using weights, the user can choose 249 202 the error bar on each point if provided in the file, the square root 250 of the intensity or the intensity itself. 203 of the intensity or the intensity itself. 251 204 - Instrumental resolution smearing of model or fits is provided with several 252 205 options: read the resolution/point fromt he file. Input a pinhole resolution … … 261 214 data set or several different sets simultaneously with the application 262 215 of advanced constraints relating fit parameters to functions of other 263 parameters (including from a different set). For example thickness of 264 shell = sin(30) times the length. 216 parameters (including from a different set). For example thickness of 217 shell = sin(30) times the length. 265 218 - Models that are the sum of two other models can be easily generated through the 266 219 SUM Model menubar item. … … 271 224 and the mathematical function of the model (box 2) and generating the 272 225 necessary *.py file. A separate advanced model editor provides a full Python 273 file editor. Either way once saved the model becomes immediately available 274 to the application. 226 file editor. Either way once saved the model becomes immediately available 227 to the application. 275 228 - A batch fitting capability allows for the analysis of a series of data sets to 276 229 a single model and provides the results in a tabular form suitable for saving 277 230 or plotting the evolution of the fit parameters with error bars (from within 278 231 the application). 279 232 280 233 - Tools 281 234 - A scattering length density calculator,including some X-ray information … … 287 240 - A slit size calculator optimized for Anton Paar Saxess is provided. 288 241 - A kiessig fringe thickness calculator is provided 289 242 290 243 - Plots and plot management 291 244 - A 3D graphing option (for 2d data/results) is provided with the view … … 301 254 - Extensive context sensitive plot/fitting/manipulation options are available 302 255 through a right mouse click pop-up menu on plots. 303 256 304 257 - Data management 305 258 - Supports 2 + column 1D ASCII data, NIST 1D and 2D data, and canSAS data 306 via plug-in mechanism which can easily allow other readers as appropriate. 259 via plug-in mechanism which can easily allow other readers as appropriate. 307 260 - 2D data is expected in Q space but for historical reasons accepts the 308 261 NIST 2D raw pixel format and will do conversion internally. … … 310 263 right clicking on a data set and choosing Data Info in the DataExplorer 311 264 or on the plots 312 - Supports loading a single file, multiple files, or a whole folder 265 - Supports loading a single file, multiple files, or a whole folder 313 266 - An optional Data Explorer is provided (default) which simplifies managing, 314 267 plotting, deleting, or setup for computation. Most functions however do … … 316 269 right click menus and the toolbar. The data explorer can be re-started 317 270 from the menu bar. 318 271 319 272 - Data manipulation 320 273 - Support various 2D averaging methods : Circular, sectors, annular, … … 322 275 - A 2D data maks editor is provided 323 276 - 2D mask can be applied to the circular averaging. 324 277 325 278 - Miscellaneous features 326 279 - limited reports can be generated in pdf format … … 343 296 2- Downloading and Installing 344 297 ============================= 345 298 346 299 *** Note 1: Much more information is available at www.sasview.org under links. 347 300 Look in the 'For Developers' section and particularly the wiki at … … 382 335 - The following modules are required (version numbers are what are used 383 336 in the windows release build): 384 337 385 338 - Common Packages 386 339 - reportlab 3.1.44 … … 399 352 - html5lib Version Installed: 0.99999 400 353 - wx Version Installed: 3.0.2.0 401 354 402 355 - Windows Specific Packages 403 356 - pywin 219 … … 405 358 - comtypes 1.1.1 406 359 - MinGW w/ gcc version 4.6.1 (WIN) 407 - vcredist_x86.exe (version 9.0.21022.8 -microsoft visual C 2008 360 - vcredist_x86.exe (version 9.0.21022.8 -microsoft visual C 2008 408 361 re-distributable) 409 362 - Innosetup (WIN - isetup 5.4.2-unicode) - used to create distributable … … 411 364 *** Note: Windows build dependencies can be set up using anaconda. Instructions 412 365 can be found at http://trac.sasview.org/wiki/AnacondaSetup 413 366 414 367 - MAC Specifc Packages 415 368 - py2app 0.7.1 416 369 417 370 418 371 3- Known Issues … … 424 377 equations will render properly. Until then they will show in their 425 378 original TeX format. 426 - If the documentation window remains stubbornly blank, try installing a 379 - If the documentation window remains stubbornly blank, try installing a 427 380 different browser and set that as your default browser. Issues have 428 381 been noted with Internet Explorer 11. 429 - Check for Updates may fail (with the status bar message ' Cannot 430 connect to the application server') if your internet connection uses 431 a proxy server. Tested resolutions for this are described on the 382 - Check for Updates may fail (with the status bar message ' Cannot 383 connect to the application server') if your internet connection uses 384 a proxy server. Tested resolutions for this are described on the 432 385 website FAQ. 433 386 - The copy and paste functions (^C, ^V) in the batch mode results grid 434 387 require two clicks: one to select the cell and a second to select the 435 contents of the cell. 388 contents of the cell. 436 389 - The tutorial has not yet been updated and is somewhat out of date 437 390 - Very old computers may struggle to run the 3.x and later releases … … 448 401 - The angular distribution angles are not clearly defined and may in 449 402 some cases lead to incorrect calculations(ticket #332) 450 403 451 404 3.2- Windows: 452 405 - If installed to same directory as old version without first removing … … 455 408 have the old name even though pointing to the new version. Usually 456 409 safest to uninstall old version prior to installing new version anyway. 457 410 458 411 3.3- MAC: 459 412 - Application normally starts up hidden. Click icon in Dock to view/use 460 application. 413 application. 461 414 - Multiprocessing does not currently work on MAC OS 462 415 463 416 3.4- Linux: 464 417 - Not well tested … … 468 421 ================== 469 422 470 - www.sasview.org. This main project site is the gateway to all 423 - www.sasview.org. This main project site is the gateway to all 471 424 information about the sasview project. It includes information 472 425 about the project, a FAQ page and links to all developer and user … … 487 440 - Latest developer builds 488 441 - https://jenkins.esss.dk/sasview/view/Master-Builds/ 442 443 -
sasview/__init__.py
r9a182b2 r801a296 1 __version__ = "4.0 "1 __version__ = "4.0.0-alpha" 2 2 __build__ = "GIT_COMMIT" 3 3 try: 4 import logging5 4 import subprocess 6 5 import os 7 import platform8 6 FNULL = open(os.devnull, 'w') 9 if platform.system() == "Windows": 10 args = ['git', 'describe', '--tags'] 11 else: 12 args = ['git describe --tags'] 13 git_revision = subprocess.check_output(args, 7 git_revision = subprocess.check_output(['git', 'rev-parse', 'HEAD'], 14 8 stderr=FNULL, 15 9 shell=True) 16 10 __build__ = str(git_revision).strip() 17 except subprocess.CalledProcessError as cpe: 18 logging.warning("Error while determining build number\n Using command:\n %s \n Output:\n %s"% (cpe.cmd,cpe.output)) 11 except: 12 import logging 13 import sys 14 logging.warning("Error while determining build number\n %s" % sys.exc_value) -
sasview/default_categories.json
ra756755 r53b9fc8 186 186 "Shape-Independent": [ 187 187 [ 188 "unified_power_Rg",189 true190 ],191 [192 188 "guinier_porod", 193 189 true -
sasview/installer_generator.py
r525aaa2 r09afe90 199 199 msg += """Source: "dist\plugin_models\*";\tDestDir: "{userdesktop}\..\.sasview\plugin_models";\t""" 200 200 msg += """Flags: recursesubdirs createallsubdirs\n""" 201 msg += """Source: "dist\compiled_models\*";\tDestDir: "{userdesktop}\..\.sasmodels\compiled_models";\t"""202 msg += """Flags: recursesubdirs createallsubdirs\n"""203 201 msg += """Source: "dist\config\custom_config.py";\tDestDir: "{userdesktop}\..\.sasview\config";\t""" 204 202 msg += """Flags: recursesubdirs createallsubdirs\n""" -
sasview/local_config.py
rc1fdf84 rd85c194 31 31 _acknowledgement_preamble =\ 32 32 '''To ensure the long term support and development of this software please''' +\ 33 ''' remember to :'''33 ''' remember to do the following.''' 34 34 _acknowledgement_preamble_bullet1 =\ 35 '''Acknowledge its use in your publications as suggested below ;'''35 '''Acknowledge its use in your publications as suggested below''' 36 36 _acknowledgement_preamble_bullet2 =\ 37 '''Reference SasView as : M. Doucet, et al. SasView Version 4.0, Zenodo''' +\ 38 ''', http://doi.org/10.5281/zenodo.159083;''' 37 '''Reference the following website: http://www.sasview.org''' 39 38 _acknowledgement_preamble_bullet3 =\ 40 '''Reference the model you used if appropriate (see documentation for refs) ;'''39 '''Reference the model you used if appropriate (see documentation for refs)''' 41 40 _acknowledgement_preamble_bullet4 =\ 42 41 '''Send us your reference for our records: developers@sasview.org''' 43 42 _acknowledgement_publications = \ 44 '''This work benefited from the use of the SasView application, originally developed under NSF Award 45 DMR-0520547. SasView also contains code developed with funding from the EU Horizon 2020 research 46 and innovation programme under the SINE2020 project Grant No 654000.''' 43 '''This work benefited from the use of the SasView application, originally 44 developed under NSF award DMR-0520547. 45 ''' 46 _acknowledgement = \ 47 '''This work originally developed as part of the DANSE project funded by the NSF 48 under grant DMR-0520547, and currently maintained by NIST, UMD, ORNL, ISIS, ESS 49 and ILL. 47 50 48 _acknowledgement = \ 49 '''This work was originally developed as part of the DANSE project funded by the US NSF under Award DMR-0520547, but is currently maintained by a 50 collaboration between UTK, UMD, NIST, ORNL, ISIS, ESS, ILL and ANSTO. SasView also contains code developed with funding from the EU Horizon 2020 51 research and innovation programme under the SINE2020 project (Grant No 654000).''' 52 51 ''' 53 52 _homepage = "http://www.sasview.org" 54 53 _download = __download_page__ … … 66 65 _umd_logo = os.path.join(icon_path, "umd_logo.png") 67 66 _sns_logo = os.path.join(icon_path, "sns_logo.png") 68 _ornl_logo = os.path.join(icon_path, "ornl_logo.png")69 67 _isis_logo = os.path.join(icon_path, "isis_logo.png") 70 68 _ess_logo = os.path.join(icon_path, "ess_logo.png") 71 69 _ill_logo = os.path.join(icon_path, "ill_logo.png") 72 _ansto_logo = os.path.join(icon_path, "ansto_logo.png")73 70 _nsf_logo = os.path.join(icon_path, "nsf_logo.png") 74 71 _danse_logo = os.path.join(icon_path, "danse_logo.png") … … 77 74 _umd_url = "http://www.umd.edu/" 78 75 _sns_url = "http://neutrons.ornl.gov/" 79 _ornl_url = "http://neutrons.ornl.gov/"80 76 _nsf_url = "http://www.nsf.gov" 81 77 _isis_url = "http://www.isis.stfc.ac.uk/" 82 78 _ess_url = "http://ess-scandinavia.eu/" 83 79 _ill_url = "http://www.ill.eu/" 84 _ansto_url = "http://www.ansto.gov.au/"85 80 _danse_url = "http://www.cacr.caltech.edu/projects/danse/release/index.html" 86 81 _inst_url = "http://www.utk.edu" 87 82 _corner_image = os.path.join(icon_path, "angles_flat.png") 88 83 _welcome_image = os.path.join(icon_path, "SVwelcome.png") 89 _copyright = "(c) 2009 - 201 6, UTK, UMD, NIST, ORNL, ISIS, ESS, ILL and ANSTO"84 _copyright = "(c) 2009 - 2013, UTK, UMD, NIST, ORNL, ISIS, ESS and ILL" 90 85 91 86 -
sasview/setup_exe.py
r9bbc074 r09afe90 165 165 self.version = local_config.__version__ 166 166 self.company_name = "SasView.org" 167 self.copyright = "copyright 2009 - 201 6"167 self.copyright = "copyright 2009 - 2013" 168 168 self.name = "SasView" 169 169 … … 208 208 import sas.sasgui.guiframe as guiframe 209 209 data_files += guiframe.data_files() 210 211 # precompile sas models into the sasview build path; doesn't matter too much212 # where it is so long as it is a place that will get cleaned up afterwards.213 import sasmodels.core214 dll_path = os.path.join(build_path, 'compiled_models')215 compiled_dlls = sasmodels.core.precompile_dlls(dll_path, dtype='double')216 217 # include the compiled models as data; coordinate the target path for the218 # data with installer_generator.py219 data_files.append(('compiled_models', compiled_dlls))220 210 221 211 import sasmodels -
src/sas/sascalc/dataloader/readers/anton_paar_saxs_reader.py
ra235f715 r80c5d46 45 45 output = None 46 46 47 def reset_state(self):47 def __init__(self): 48 48 self.current_dataset = Data1D(np.empty(0), np.empty(0), 49 49 np.empty(0), np.empty(0)) … … 72 72 73 73 ## Reinitialize the class when loading a new data file to reset all class variables 74 self. reset_state()74 self.__init__() 75 75 ## Check that the file exists 76 76 if os.path.isfile(filename): … … 84 84 self.raw_data = buff.splitlines() 85 85 self.read_data() 86 xml_intermediate = self.raw_data[self.upper:] 87 xml = ''.join(xml_intermediate) 88 self.set_xml_file(xml) 86 89 return self.output 87 90 … … 97 100 self.lower = 5 98 101 self.upper = self.lower + self.data_points 99 self.source.radiation = 'x-ray' 100 normal = float(line4[3]) 102 self.detector.distance = float(line4[1]) 101 103 self.current_dataset.source.radiation = "x-ray" 102 104 self.current_dataset.source.name = "Anton Paar SAXSess Instrument" 103 105 self.current_dataset.source.wavelength = float(line4[4]) 104 xvals = [] 105 yvals = [] 106 dyvals = [] 106 normal = line4[3] 107 107 for i in range(self.lower, self.upper): 108 index = i - self.lower109 108 data = self.raw_data[i].split() 110 xvals.insert(index, normal * float(data[0])) 111 yvals.insert(index, normal * float(data[1])) 112 dyvals.insert(index, normal * float(data[2])) 113 self.current_dataset.x = np.append(self.current_dataset.x, xvals) 114 self.current_dataset.y = np.append(self.current_dataset.y, yvals) 115 self.current_dataset.dy = np.append(self.current_dataset.dy, dyvals) 116 if self.data_points != self.current_dataset.x.size: 117 self.errors.add("Not all data was loaded properly.") 118 if self.current_dataset.dx.size != self.current_dataset.x.size: 119 dxvals = np.zeros(self.current_dataset.x.size) 120 self.current_dataset.dx = dxvals 121 if self.current_dataset.x.size != self.current_dataset.y.size: 122 self.errors.add("The x and y data sets are not the same size.") 123 if self.current_dataset.y.size != self.current_dataset.dy.size: 124 self.errors.add("The y and dy datasets are not the same size.") 125 self.current_dataset.errors = self.errors 126 self.current_dataset.xaxis("Q", q_unit) 127 self.current_dataset.yaxis("Intensity", i_unit) 128 xml_intermediate = self.raw_data[self.upper:] 129 xml = ''.join(xml_intermediate) 130 self.set_xml_string(xml) 131 dom = self.xmlroot.xpath('/fileinfo') 132 self._parse_child(dom) 109 x_val = [float(data[0])] 110 y_val = [float(data[1])] 111 dy_val = [float(data[2])] 112 self.current_dataset.x = np.append(self.current_dataset.x, x_val) 113 self.current_dataset.y = np.append(self.current_dataset.y, y_val) 114 self.current_dataset.dy = np.append(self.current_dataset.dy, dy_val) 115 self.current_dataset.xaxis("Q (%s)" % (q_unit), q_unit) 116 self.current_dataset.yaxis("Intensity (%s)" % (i_unit), i_unit) 117 self.current_dataset.detector.append(self.detector) 133 118 self.output.append(self.current_dataset) 134 135 def _parse_child(self, dom, parent=''):136 """137 Recursive method for stepping through the embedded XML138 :param dom: XML node with or without children139 """140 for node in dom:141 tagname = node.tag142 value = node.text143 attr = node.attrib144 key = attr.get("key", '')145 if len(node.getchildren()) > 1:146 self._parse_child(node, key)147 if key == "SampleDetector":148 self.current_dataset.detector.append(self.detector)149 self.detector = Detector()150 else:151 if key == "value":152 if parent == "Wavelength":153 self.current_dataset.source.wavelength = value154 elif parent == "SampleDetector":155 self.detector.distance = value156 elif parent == "Temperature":157 self.current_dataset.sample.temperature = value158 elif parent == "CounterSlitLength":159 self.detector.slit_length = value160 elif key == "unit":161 value = value.replace("_", "")162 if parent == "Wavelength":163 self.current_dataset.source.wavelength_unit = value164 elif parent == "SampleDetector":165 self.detector.distance_unit = value166 elif parent == "X":167 self.current_dataset.xaxis(self.current_dataset._xaxis, value)168 elif parent == "Y":169 self.current_dataset.yaxis(self.current_dataset._yaxis, value)170 elif parent == "Temperature":171 self.current_dataset.sample.temperature_unit = value172 elif parent == "CounterSlitLength":173 self.detector.slit_length_unit = value174 elif key == "quantity":175 if parent == "X":176 self.current_dataset.xaxis(value, self.current_dataset._xunit)177 elif parent == "Y":178 self.current_dataset.yaxis(value, self.current_dataset._yunit) -
src/sas/sascalc/dataloader/readers/ascii_reader.py
r7d94915 rb699768 33 33 ## File type 34 34 type_name = "ASCII" 35 35 36 36 ## Wildcards 37 37 type = ["ASCII files (*.txt)|*.txt", … … 41 41 ## List of allowed extensions 42 42 ext = ['.txt', '.TXT', '.dat', '.DAT', '.abs', '.ABS', 'csv', 'CSV'] 43 43 44 44 ## Flag to bypass extension check 45 45 allow_all = True 46 46 47 47 def read(self, path): 48 48 """ 49 49 Load data file 50 50 51 51 :param path: file path 52 52 53 :return: Data1D object, or None 53 54 54 55 :raise RuntimeError: when the file can't be opened 55 56 :raise ValueError: when the length of the data vectors are inconsistent … … 61 62 try: 62 63 # Read in binary mode since GRASP frequently has no-ascii 63 # characters that br eaks the open operation64 # characters that brakes the open operation 64 65 input_f = open(path,'rb') 65 66 except: … … 67 68 buff = input_f.read() 68 69 lines = buff.splitlines() 69 70 # Arrays for data storage 71 tx = numpy.zeros(0) 72 ty = numpy.zeros(0) 70 71 x = numpy.zeros(0) 72 y = numpy.zeros(0) 73 dy = numpy.zeros(0) 74 dx = numpy.zeros(0) 75 76 #temp. space to sort data 77 tx = numpy.zeros(0) 78 ty = numpy.zeros(0) 73 79 tdy = numpy.zeros(0) 74 80 tdx = numpy.zeros(0) 75 81 82 output = Data1D(x, y, dy=dy, dx=dx) 83 self.filename = output.filename = basename 84 85 data_conv_q = None 86 data_conv_i = None 87 88 if has_converter == True and output.x_unit != '1/A': 89 data_conv_q = Converter('1/A') 90 # Test it 91 data_conv_q(1.0, output.x_unit) 92 93 if has_converter == True and output.y_unit != '1/cm': 94 data_conv_i = Converter('1/cm') 95 # Test it 96 data_conv_i(1.0, output.y_unit) 97 76 98 # The first good line of data will define whether 77 99 # we have 2-column or 3-column ascii 78 100 has_error_dx = None 79 101 has_error_dy = None 80 102 81 103 #Initialize counters for data lines and header lines. 82 is_data = False 104 is_data = False # Has more than 5 lines 83 105 # More than "5" lines of data is considered as actual 84 106 # data unless that is the only data 85 m in_data_pts = 5107 mum_data_lines = 5 86 108 # To count # of current data candidate lines 87 candidate_lines = 0109 i = -1 88 110 # To count total # of previous data candidate lines 89 candidate_lines_previous = 0 90 #minimum required number of columns of data 111 i1 = -1 112 # To count # of header lines 113 j = -1 114 # Helps to count # of header lines 115 j1 = -1 116 #minimum required number of columns of data; ( <= 4). 91 117 lentoks = 2 92 118 for line in lines: 93 toks = self.splitline(line) 94 # To remember the # of columns in the current line of data 95 new_lentoks = len(toks) 119 # Initial try for CSV (split on ,) 120 toks = line.split(',') 121 # Now try SCSV (split on ;) 122 if len(toks) < 2: 123 toks = line.split(';') 124 # Now go for whitespace 125 if len(toks) < 2: 126 toks = line.split() 96 127 try: 97 if new_lentoks == 1 and not is_data:98 ## If only one item in list, no longer data99 raise ValueError100 elif new_lentoks == 0:101 ## If the line is blank, skip and continue on102 ## In case of breaks within data sets.103 continue104 elif new_lentoks != lentoks and is_data:105 ## If a footer is found, break the loop and save the data106 break107 elif new_lentoks != lentoks and not is_data:108 ## If header lines are numerical109 candidate_lines = 0110 candidate_lines_previous = 0111 112 128 #Make sure that all columns are numbers. 113 129 for colnum in range(len(toks)): 114 # Any non-floating point values throw ValueError115 130 float(toks[colnum]) 116 117 candidate_lines += 1 131 118 132 _x = float(toks[0]) 119 133 _y = float(toks[1]) 134 135 #Reset the header line counters 136 if j == j1: 137 j = 0 138 j1 = 0 139 140 if i > 1: 141 is_data = True 142 143 if data_conv_q is not None: 144 _x = data_conv_q(_x, units=output.x_unit) 145 146 if data_conv_i is not None: 147 _y = data_conv_i(_y, units=output.y_unit) 148 149 # If we have an extra token, check 150 # whether it can be interpreted as a 151 # third column. 152 _dy = None 153 if len(toks) > 2: 154 try: 155 _dy = float(toks[2]) 156 157 if data_conv_i is not None: 158 _dy = data_conv_i(_dy, units=output.y_unit) 159 160 except: 161 # The third column is not a float, skip it. 162 pass 163 164 # If we haven't set the 3rd column 165 # flag, set it now. 166 if has_error_dy == None: 167 has_error_dy = False if _dy == None else True 168 169 #Check for dx 120 170 _dx = None 121 _dy = None 122 123 #If 5 or more lines, this is considering the set data 124 if candidate_lines >= min_data_pts: 125 is_data = True 126 127 # If a 3rd row is present, consider it dy 128 if new_lentoks > 2: 129 _dy = float(toks[2]) 130 has_error_dy = False if _dy == None else True 131 132 # If a 4th row is present, consider it dx 133 if new_lentoks > 3: 134 _dx = float(toks[3]) 135 has_error_dx = False if _dx == None else True 136 137 # Delete the previously stored lines of data candidates if 138 # the list is not data 139 if candidate_lines == 1 and -1 < candidate_lines_previous < min_data_pts and \ 171 if len(toks) > 3: 172 try: 173 _dx = float(toks[3]) 174 175 if data_conv_i is not None: 176 _dx = data_conv_i(_dx, units=output.x_unit) 177 178 except: 179 # The 4th column is not a float, skip it. 180 pass 181 182 # If we haven't set the 3rd column 183 # flag, set it now. 184 if has_error_dx == None: 185 has_error_dx = False if _dx == None else True 186 187 #After talked with PB, we decided to take care of only 188 # 4 columns of data for now. 189 #number of columns in the current line 190 #To remember the # of columns in the current 191 #line of data 192 new_lentoks = len(toks) 193 194 #If the previous columns not equal to the current, 195 #mark the previous as non-data and reset the dependents. 196 if lentoks != new_lentoks: 197 if is_data == True: 198 break 199 else: 200 i = -1 201 i1 = 0 202 j = -1 203 j1 = -1 204 205 #Delete the previously stored lines of data candidates 206 # if is not data. 207 if i < 0 and -1 < i1 < mum_data_lines and \ 208 is_data == False: 209 try: 210 x = numpy.zeros(0) 211 y = numpy.zeros(0) 212 except: 213 pass 214 215 x = numpy.append(x, _x) 216 y = numpy.append(y, _y) 217 218 if has_error_dy == True: 219 #Delete the previously stored lines of 220 # data candidates if is not data. 221 if i < 0 and -1 < i1 < mum_data_lines and \ 222 is_data == False: 223 try: 224 dy = numpy.zeros(0) 225 except: 226 pass 227 dy = numpy.append(dy, _dy) 228 229 if has_error_dx == True: 230 #Delete the previously stored lines of 231 # data candidates if is not data. 232 if i < 0 and -1 < i1 < mum_data_lines and \ 233 is_data == False: 234 try: 235 dx = numpy.zeros(0) 236 except: 237 pass 238 dx = numpy.append(dx, _dx) 239 240 #Same for temp. 241 #Delete the previously stored lines of data candidates 242 # if is not data. 243 if i < 0 and -1 < i1 < mum_data_lines and\ 140 244 is_data == False: 141 245 try: 142 246 tx = numpy.zeros(0) 143 247 ty = numpy.zeros(0) 144 tdy = numpy.zeros(0)145 tdx = numpy.zeros(0)146 248 except: 147 249 pass 148 250 251 tx = numpy.append(tx, _x) 252 ty = numpy.append(ty, _y) 253 149 254 if has_error_dy == True: 255 #Delete the previously stored lines of 256 # data candidates if is not data. 257 if i < 0 and -1 < i1 < mum_data_lines and \ 258 is_data == False: 259 try: 260 tdy = numpy.zeros(0) 261 except: 262 pass 150 263 tdy = numpy.append(tdy, _dy) 151 264 if has_error_dx == True: 265 #Delete the previously stored lines of 266 # data candidates if is not data. 267 if i < 0 and -1 < i1 < mum_data_lines and \ 268 is_data == False: 269 try: 270 tdx = numpy.zeros(0) 271 except: 272 pass 152 273 tdx = numpy.append(tdx, _dx) 153 tx = numpy.append(tx, _x) 154 ty = numpy.append(ty, _y) 155 274 275 #reset i1 and flag lentoks for the next 276 if lentoks < new_lentoks: 277 if is_data == False: 278 i1 = -1 156 279 #To remember the # of columns on the current line 157 280 # for the next line of data 158 lentoks = new_lentoks 159 candidate_lines_previous = candidate_lines 160 except ValueError: 281 lentoks = len(toks) 282 283 #Reset # of header lines and counts # 284 # of data candidate lines 285 if j == 0 and j1 == 0: 286 i1 = i + 1 287 i += 1 288 except: 161 289 # It is data and meet non - number, then stop reading 162 290 if is_data == True: 163 291 break 164 292 lentoks = 2 165 has_error_dx = None 166 has_error_dy = None 293 #Counting # of header lines 294 j += 1 295 if j == j1 + 1: 296 j1 = j 297 else: 298 j = -1 167 299 #Reset # of lines of data candidates 168 candidate_lines = 0 169 except: 300 i = -1 301 302 # Couldn't parse this line, skip it 170 303 pass 171 304 172 305 input_f.close() 173 if not is_data:174 return None175 306 # Sanity check 176 if has_error_dy == True and not len( ty) == len(tdy):307 if has_error_dy == True and not len(y) == len(dy): 177 308 msg = "ascii_reader: y and dy have different length" 178 309 raise RuntimeError, msg 179 if has_error_dx == True and not len( tx) == len(tdx):310 if has_error_dx == True and not len(x) == len(dx): 180 311 msg = "ascii_reader: y and dy have different length" 181 312 raise RuntimeError, msg 182 313 # If the data length is zero, consider this as 183 314 # though we were not able to read the file. 184 if len( tx) == 0:315 if len(x) == 0: 185 316 raise RuntimeError, "ascii_reader: could not load file" 186 317 187 318 #Let's re-order the data to make cal. 188 319 # curve look better some cases 189 320 ind = numpy.lexsort((ty, tx)) 190 x = numpy.zeros(len(tx))191 y = numpy.zeros(len(ty))192 dy = numpy.zeros(len(tdy))193 dx = numpy.zeros(len(tdx))194 output = Data1D(x, y, dy=dy, dx=dx)195 self.filename = output.filename = basename196 197 321 for i in ind: 198 322 x[i] = tx[ind[i]] … … 214 338 output.dx = dx[x != 0] if has_error_dx == True\ 215 339 else numpy.zeros(len(output.x)) 216 217 output.xaxis("\\rm{Q}", 'A^{-1}') 218 output.yaxis("\\rm{Intensity}", "cm^{-1}") 219 340 341 if data_conv_q is not None: 342 output.xaxis("\\rm{Q}", output.x_unit) 343 else: 344 output.xaxis("\\rm{Q}", 'A^{-1}') 345 if data_conv_i is not None: 346 output.yaxis("\\rm{Intensity}", output.y_unit) 347 else: 348 output.yaxis("\\rm{Intensity}", "cm^{-1}") 349 220 350 # Store loading process information 221 351 output.meta_data['loader'] = self.type_name … … 223 353 raise RuntimeError, "%s is empty" % path 224 354 return output 225 355 226 356 else: 227 357 raise RuntimeError, "%s is not a file" % path 228 358 return None 229 230 def splitline(self, line):231 """232 Splits a line into pieces based on common delimeters233 :param line: A single line of text234 :return: list of values235 """236 # Initial try for CSV (split on ,)237 toks = line.split(',')238 # Now try SCSV (split on ;)239 if len(toks) < 2:240 toks = line.split(';')241 # Now go for whitespace242 if len(toks) < 2:243 toks = line.split()244 return toks -
src/sas/sascalc/dataloader/readers/cansas_reader.py
r654e8e0 r5f26aa4 62 62 type_name = "canSAS" 63 63 invalid = True 64 frm = ""65 64 ## Log messages and errors 66 65 logging = None … … 139 138 for entry in entry_list: 140 139 # Create a new DataInfo object for every <SASentry> 140 141 141 142 142 # Set the file name and then parse the entry. … … 183 183 return self.output 184 184 185 def _parse_entry(self, dom , recurse=False):185 def _parse_entry(self, dom): 186 186 """ 187 187 Parse a SASEntry - new recursive method for parsing the dom of … … 192 192 """ 193 193 194 if not self._is_call_local() and not recurse: 194 frm = inspect.stack()[1] 195 if not self._is_call_local(frm): 195 196 self.reset_state() 196 197 self.add_data_set() … … 200 201 self.base_ns = "{0}{1}{2}".format("{", \ 201 202 CANSAS_NS.get(self.cansas_version).get("ns"), "}") 203 tagname = '' 204 tagname_original = '' 202 205 203 206 # Go through each child in the parent element … … 222 225 self._initialize_new_data_set() 223 226 ## Recursion step to access data within the group 224 self._parse_entry(node , True)227 self._parse_entry(node) 225 228 if tagname == "SASsample": 226 229 self.current_datainfo.sample.name = name … … 434 437 length = len(self.names) - 1 435 438 self.parent_class = self.names[length] 436 if not self._is_call_local() and not recurse: 437 self.frm = "" 439 if not self._is_call_local(frm): 438 440 self.add_data_set() 439 441 empty = None … … 446 448 447 449 448 def _is_call_local(self ):449 """ 450 451 """452 if self.frm == "":453 inter = inspect.stack()454 self.frm = inter[2]455 mod_name = self.frm[1].replace("\\", "/").replace(".pyc", "")450 def _is_call_local(self, frm=""): 451 """ 452 453 :return: 454 """ 455 if frm == "": 456 frm = inspect.stack()[1] 457 mod_name = frm[1].replace("\\", "/").replace(".pyc", "") 456 458 mod_name = mod_name.replace(".py", "") 457 459 mod = mod_name.split("sas/") … … 834 836 # If the calling function was not the cansas reader, return a minidom 835 837 # object rather than an lxml object. 836 self.frm = inspect.stack()[1]837 doc, entry_node = self._check_origin(entry_node, doc )838 frm = inspect.stack()[1] 839 doc, entry_node = self._check_origin(entry_node, doc, frm) 838 840 return doc, entry_node 839 841 … … 1230 1232 self.append(node, entry_node) 1231 1233 1232 def _check_origin(self, entry_node, doc ):1234 def _check_origin(self, entry_node, doc, frm): 1233 1235 """ 1234 1236 Return the document, and the SASentry node associated with … … 1240 1242 :param doc: entire xml tree 1241 1243 """ 1242 if not self.frm:1243 self.frm = inspect.stack()[1]1244 mod_name = self.frm[1].replace("\\", "/").replace(".pyc", "")1244 if not frm: 1245 frm = inspect.stack()[1] 1246 mod_name = frm[1].replace("\\", "/").replace(".pyc", "") 1245 1247 mod_name = mod_name.replace(".py", "") 1246 1248 mod = mod_name.split("sas/") -
src/sas/sascalc/dataloader/readers/xml_reader.py
ra235f715 rb699768 70 70 self.xmldoc = etree.parse(self.xml, parser=PARSER) 71 71 self.xmlroot = self.xmldoc.getroot() 72 except etree.XMLSyntaxError as xml_error:73 logging.info(xml_error)74 except Exception:75 self.xml = None76 self.xmldoc = None77 self.xmlroot = None78 79 def set_xml_string(self, tag_soup):80 """81 Set an XML string as the working XML.82 83 :param tag_soup: XML formatted string84 """85 try:86 self.xml = tag_soup87 self.xmldoc = tag_soup88 self.xmlroot = etree.fromstring(tag_soup)89 72 except etree.XMLSyntaxError as xml_error: 90 73 logging.info(xml_error) -
src/sas/sascalc/pr/invertor.py
r2c60f304 rb699768 154 154 return self.set_err(value2) 155 155 elif name == 'd_max': 156 if value <= 0.0:157 msg = "Invertor: d_max must be greater than zero."158 msg += "Correct that entry before proceeding"159 raise ValueError, msg160 156 return self.set_dmax(value) 161 157 elif name == 'q_min': -
src/sas/sasgui/guiframe/aboutbox.py
re0f28e6 rd85c194 106 106 self.bitmap_button_nist = wx.BitmapButton(self, -1, wx.NullBitmap) 107 107 self.bitmap_button_umd = wx.BitmapButton(self, -1, wx.NullBitmap) 108 self.bitmap_button_ornl = wx.BitmapButton(self, -1, wx.NullBitmap) 109 #self.bitmap_button_sns = wx.BitmapButton(self, -1, wx.NullBitmap) 108 self.bitmap_button_sns = wx.BitmapButton(self, -1, wx.NullBitmap) 110 109 #self.bitmap_button_nsf = wx.BitmapButton(self, -1, 111 110 # wx.NullBitmap) … … 116 115 self.bitmap_button_ess = wx.BitmapButton(self, -1, wx.NullBitmap) 117 116 self.bitmap_button_ill = wx.BitmapButton(self, -1, wx.NullBitmap) 118 self.bitmap_button_ansto = wx.BitmapButton(self, -1, wx.NullBitmap)119 117 120 118 self.static_line_3 = wx.StaticLine(self, -1) … … 126 124 self.Bind(wx.EVT_BUTTON, self.onNistLogo, self.bitmap_button_nist) 127 125 self.Bind(wx.EVT_BUTTON, self.onUmdLogo, self.bitmap_button_umd) 128 #self.Bind(wx.EVT_BUTTON, self.onSnsLogo, self.bitmap_button_sns) 129 self.Bind(wx.EVT_BUTTON, self.onOrnlLogo, self.bitmap_button_ornl) 126 self.Bind(wx.EVT_BUTTON, self.onSnsLogo, self.bitmap_button_sns) 130 127 #self.Bind(wx.EVT_BUTTON, self.onNsfLogo, self.bitmap_button_nsf) 131 128 #self.Bind(wx.EVT_BUTTON, self.onDanseLogo, self.bitmap_button_danse) … … 134 131 self.Bind(wx.EVT_BUTTON, self.onEssLogo, self.bitmap_button_ess) 135 132 self.Bind(wx.EVT_BUTTON, self.onIllLogo, self.bitmap_button_ill) 136 self.Bind(wx.EVT_BUTTON, self.onAnstoLogo, self.bitmap_button_ansto)137 133 # end wxGlade 138 134 # fill in acknowledgements … … 167 163 self.bitmap_button_umd.SetBitmapLabel(logo) 168 164 169 image = file_dir + "/images/ornl_logo.png" 170 if os.path.isfile(config._ornl_logo): 171 image = config._ornl_logo 172 logo = wx.Bitmap(image) 173 self.bitmap_button_ornl.SetBitmapLabel(logo) 174 175 """ 165 176 166 image = file_dir + "/images/sns_logo.png" 177 167 if os.path.isfile(config._sns_logo): … … 180 170 self.bitmap_button_sns.SetBitmapLabel(logo) 181 171 172 """ 182 173 image = file_dir + "/images/nsf_logo.png" 183 174 if os.path.isfile(config._nsf_logo): … … 215 206 logo = wx.Bitmap(image) 216 207 self.bitmap_button_ill.SetBitmapLabel(logo) 217 218 image = file_dir + "/images/ansto_logo.png"219 if os.path.isfile(config._ansto_logo):220 image = config._ansto_logo221 logo = wx.Bitmap(image)222 self.bitmap_button_ansto.SetBitmapLabel(logo)223 208 224 209 # resize dialog window to fit version number nicely … … 242 227 self.bitmap_button_nist.SetSize(self.bitmap_button_nist.GetBestSize()) 243 228 self.bitmap_button_umd.SetSize(self.bitmap_button_umd.GetBestSize()) 244 self.bitmap_button_ornl.SetSize(self.bitmap_button_ornl.GetBestSize()) 245 #self.bitmap_button_sns.SetSize(self.bitmap_button_sns.GetBestSize()) 229 self.bitmap_button_sns.SetSize(self.bitmap_button_sns.GetBestSize()) 246 230 #self.bitmap_button_nsf.SetSize(self.bitmap_button_nsf.GetBestSize()) 247 231 #self.bitmap_button_danse.SetSize(self.bitmap_button_danse.GetBestSize()) … … 250 234 self.bitmap_button_ess.SetSize(self.bitmap_button_ess.GetBestSize()) 251 235 self.bitmap_button_ill.SetSize(self.bitmap_button_ill.GetBestSize()) 252 self.bitmap_button_ansto.SetSize(self.bitmap_button_ansto.GetBestSize())253 236 # end wxGlade 254 237 … … 302 285 sizer_logos.Add(self.bitmap_button_nist, 0, 303 286 wx.LEFT|wx.ADJUST_MINSIZE, 2) 304 #sizer_logos.Add(self.bitmap_button_sns, 0, 305 # wx.LEFT|wx.ADJUST_MINSIZE, 2) 306 sizer_logos.Add(self.bitmap_button_ornl, 0, 287 sizer_logos.Add(self.bitmap_button_sns, 0, 307 288 wx.LEFT|wx.ADJUST_MINSIZE, 2) 308 289 sizer_logos.Add(self.bitmap_button_isis, 0, … … 311 292 wx.LEFT|wx.ADJUST_MINSIZE, 2) 312 293 sizer_logos.Add(self.bitmap_button_ill, 0, 313 wx.LEFT|wx.ADJUST_MINSIZE, 2)314 sizer_logos.Add(self.bitmap_button_ansto, 0,315 294 wx.LEFT|wx.ADJUST_MINSIZE, 2) 316 295 … … 342 321 event.Skip() 343 322 344 def onOrnlLogo(self, event):345 """346 """347 # wxGlade: DialogAbout.<event_handler>348 launchBrowser(config._ornl_url)349 event.Skip()350 351 323 def onSnsLogo(self, event): 352 324 """ … … 396 368 # wxGlade: DialogAbout.<event_handler> 397 369 launchBrowser(config._ill_url) 398 event.Skip()399 400 def onAnstoLogo(self, event):401 """402 """403 # wxGlade: DialogAbout.<event_handler>404 launchBrowser(config._ansto_url)405 370 event.Skip() 406 371 -
src/sas/sasgui/guiframe/acknowledgebox.py
rc1fdf84 rd85c194 68 68 self.preamble.SetFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "")) 69 69 self.SetTitle("Acknowledging SasView") 70 #Increased size of box from (525, 225), SMK, 04/10/16 71 self.SetSize((600, 300)) 70 self.SetSize((525, 225)) 72 71 # end wxGlade 73 72 -
src/sas/sasgui/guiframe/gui_manager.py
r3fac0df rc8a641e8 1345 1345 self._help_menu.Append(wx_id, '&Documentation', '') 1346 1346 wx.EVT_MENU(self, wx_id, self._onSphinxDocs) 1347 self._help_menu.AppendSeparator()1348 1347 1349 1348 if config._do_tutorial and (IS_WIN or sys.platform == 'darwin'): 1349 self._help_menu.AppendSeparator() 1350 1350 wx_id = wx.NewId() 1351 1351 self._help_menu.Append(wx_id, '&Tutorial', 'Software tutorial') 1352 1352 wx.EVT_MENU(self, wx_id, self._onTutorial) 1353 1354 if config._do_acknowledge: 1353 1355 self._help_menu.AppendSeparator() 1354 1355 1356 if config._do_acknowledge:1357 1356 wx_id = wx.NewId() 1358 1357 self._help_menu.Append(wx_id, '&Acknowledge', 'Acknowledging SasView') 1359 1358 wx.EVT_MENU(self, wx_id, self._onAcknowledge) 1359 1360 if config._do_aboutbox: 1360 1361 self._help_menu.AppendSeparator() 1361 1362 1363 if config._do_aboutbox: 1364 logging.info("Doing help menu") 1365 wx_id = wx.NewId() 1366 self._help_menu.Append(wx_id, '&About', 'Software information') 1367 wx.EVT_MENU(self, wx_id, self._onAbout) 1368 self._help_menu.AppendSeparator() 1369 1362 self._help_menu.Append(wx.ID_ABOUT, '&About', 'Software information') 1363 wx.EVT_MENU(self, wx.ID_ABOUT, self._onAbout) 1370 1364 1371 1365 # Checking for updates -
src/sas/sasgui/guiframe/gui_statusbar.py
r3a22ce7 rd85c194 6 6 import sys 7 7 import logging 8 import datetime9 8 from wx import StatusBar as wxStatusB 10 9 from wx.lib import newevent … … 47 46 48 47 self.msg_txt.SetEditable(False) 49 timestamp = datetime.datetime.now() 50 status = '{:%Y-%m-%d %H:%M:%S} : No message available'.format(timestamp) 51 self.msg_txt.SetValue(status) 48 self.msg_txt.SetValue('No message available') 52 49 self.sizer.Add(self.msg_txt, 1, wx.EXPAND|wx.ALL, 10) 53 50 self.SetSizer(self.sizer) … … 63 60 if status.strip() == "": 64 61 return 65 # Add timestamp66 timestamp = datetime.datetime.now()67 status = '{:%Y-%m-%d %H:%M:%S} : '.format(timestamp) + status68 62 color = (0, 0, 0) #black 69 63 icon_bmp = wx.ArtProvider.GetBitmap(wx.ART_INFORMATION, wx.ART_TOOLBAR) -
src/sas/sasgui/guiframe/media/data_formats_help.rst
r280f929 rd85c194 3 3 .. This is a port of the original SasView html help file to ReSTructured text 4 4 .. by S King, ISIS, during SasView CodeCamp-III in Feb 2015. 5 .. WG Bouwman, DUT, added during CodeCamp-V in Oct 2016 the SESANS data format6 5 7 6 .. _Formats: … … 10 9 ============ 11 10 12 SasView reads several different 1D (I(Q) vs Q), 2D SANS(I(Qx,Qy) vs (Qx,Qy)) 13 and SESANS (P(z) vs z) 11 SasView reads several different 1D (I(Q) vs Q) and 2D (I(Qx,Qy) vs (Qx,Qy)) 14 12 data files. But please note that SasView does not at present load data where 15 13 the Q and I(Q) data are in separate files. 16 14 17 1D Formats SANS18 ---------- -----15 1D Formats 16 ---------- 19 17 20 18 SasView will read files with 2 to 4 columns of numbers in the following order: … … 48 46 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 49 47 50 2D Formats SANS51 ---------- -----48 2D Formats 49 ---------- 52 50 53 51 SasView will only read files in the NIST 2D format with the extensions … … 62 60 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 63 61 64 SESANS Format 65 ------------- 66 67 The current file extension is .ses or .sesans (not case sensitive). 68 69 The file format is to have a list of name-value pairs as a header at the top of the file, detailing general experimental parameters necessary for fitting and analyzing data. This list should contain all information necessary for the file to be 'portable' between users. 70 71 Following that is a 6 column list of instrument experimental variables: 72 73 - Spin echo length (z, in Angstroms) 74 - Spin echo length error (:math:`\Delta` z, in Angstroms) (experimental resolution) 75 - neutron wavelength (:math:`\lambda`, in Angstroms) (essential for ToF instruments) 76 - neutron wavelength error (:math:`\Delta \lambda`, in Angstroms) 77 - Normalized polarization (:math:`P/P_0`, unitless) 78 - Normalized polarization error (:math:`\Delta(P/P_0)`, unitless) (measurement error) 79 80 81 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 82 83 .. note:: This help document was last changed by Wim Bouwman, 05Oct2016 62 .. note:: This help document was last changed by Steve King, 01May2015 -
src/sas/sasgui/guiframe/media/graph_help.rst
rf9b0c81 re68c9bf 42 42 plot window. 43 43 44 .. note:: 45 *If a residuals graph (when fitting data) is hidden, it will not show up 46 after computation.* 44 *NOTE! If a residuals graph (when fitting data) is hidden, it will not show up 45 after computation.* 47 46 48 47 Dragging a plot … … 68 67 After zooming in on a a region, the *left arrow* or *right arrow* buttons on 69 68 the toolbar will switch between recent views. 70 71 The axis range can also be specified manually. To do so go to the *Graph Menu*72 (see Invoking_the_graph_menu_ for further details), choose the *Set Graph Range*73 option and enter the limits in the pop box.74 69 75 70 *NOTE! If a wheel mouse is available scrolling the wheel will zoom in/out … … 121 116 ^^^^^^^^^^^^^^^^^^^ 122 117 123 It is possible to make custom modifications to plots including: 118 From the *Graph Menu* (see Invoking_the_graph_menu_) it is also possible to 119 make some custom modifications to plots, including: 124 120 125 121 * changing the plot window title 126 * changing the default legend location and toggling it on/off127 * changing the axis l abel text128 * changing the axis l abel units129 * changing the axis l abel font & font colour122 * changing the axis legend locations 123 * changing the axis legend label text 124 * changing the axis legend label units 125 * changing the axis legend label font & font colour 130 126 * adding/removing a text string 131 127 * adding a grid overlay 132 133 The legend and text strings can be drag and dropped around the plot134 135 These options are accessed through the *Graph Menu* (see Invoking_the_graph_menu_)136 and selecting *Modify Graph Appearance* (for axis labels, grid overlay and137 legend position) or *Add Text* to add textual annotations, selecting font, color,138 style and size. *Remove Text* will remove the last annotation added. To change139 the legend. *Window Title* allows a custom title to be entered instead of Graph140 x.141 128 142 129 Changing scales … … 247 234 selected data will be removed from the plot. 248 235 249 .. note:: 250 The Remove data set action cannot be undone. 236 *NOTE! This action cannot be undone.* 251 237 252 238 Show-Hide error bars … … 262 248 In the *Dataset Menu* (see Invoking_the_dataset_menu_), select *Modify Plot 263 249 Property* to change the size, color, or shape of the displayed marker for the 264 chosen dataset, or to change the dataset label that appears in the plot legend 265 box. 250 chosen dataset, or to change the dataset label that appears on the plot. 266 251 267 252 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ … … 307 292 average. 308 293 309 .. note:: 310 The displayed average only updates when input focus is moved back to 311 that window; ie, when the mouse pointer is moved onto that plot. 294 *NOTE! The displayed average only updates when input focus is moved back to 295 that window; ie, when the mouse pointer is moved onto that plot.* 312 296 313 297 Selecting *Box Sum* automatically brings up the 'Slicer Parameters' dialog in … … 375 359 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 376 360 377 .. note:: This help document was last modified by Paul Butler, 05 September, 2016361 .. note:: This help document was last changed by Steve King, 01May2015 -
src/sas/sasgui/guiframe/utils.py
ra0373d5 rd85c194 46 46 return flag 47 47 48 49 def check_int(item): 50 """ 51 :param item: txtcrtl containing a value 52 """ 53 flag = True 54 try: 55 mini = int(item.GetValue()) 56 item.SetBackgroundColour(wx.WHITE) 57 item.Refresh() 58 except: 59 flag = False 60 item.SetBackgroundColour("pink") 61 item.Refresh() 62 return flag 63 64 48 65 49 class PanelMenu(wx.Menu): 66 50 """ -
src/sas/sasgui/perspectives/fitting/basepage.py
rc65a265 re4c897b 17 17 from wx.lib.scrolledpanel import ScrolledPanel 18 18 19 from sasmodels.weights import MODELS as POLYDISPERSITY_MODELS 20 19 import sasmodels.sasview_model 21 20 from sas.sasgui.guiframe.panel_base import PanelBase 22 from sas.sasgui.guiframe.utils import format_number, check_float, IdList , check_int21 from sas.sasgui.guiframe.utils import format_number, check_float, IdList 23 22 from sas.sasgui.guiframe.events import PanelOnFocusEvent 24 23 from sas.sasgui.guiframe.events import StatusEvent … … 627 626 self.disp_help_bt.Bind(wx.EVT_BUTTON, self.on_pd_help_clicked, 628 627 id=self.disp_help_bt.GetId()) 629 self.disp_help_bt.SetToolTipString("Help for polydispersion.")628 self.disp_help_bt.SetToolTipString("Helps for Polydispersion.") 630 629 631 630 self.Bind(wx.EVT_RADIOBUTTON, self._set_dipers_Param, … … 933 932 if len(self._disp_obj_dict) > 0: 934 933 for k, v in self._disp_obj_dict.iteritems(): 935 self.state._disp_obj_dict[k] = v .type934 self.state._disp_obj_dict[k] = v 936 935 937 936 self.state.values = copy.deepcopy(self.values) … … 1010 1009 if len(self._disp_obj_dict) > 0: 1011 1010 for k, v in self._disp_obj_dict.iteritems(): 1012 self.state._disp_obj_dict[k] = v .type1011 self.state._disp_obj_dict[k] = v 1013 1012 1014 1013 self.state.values = copy.deepcopy(self.values) … … 1124 1123 state.disp_cb_dict[item]) 1125 1124 # Create the dispersion objects 1126 disp_model = POLYDISPERSITY_MODELS['array']() 1125 from sas.models.dispersion_models import ArrayDispersion 1126 disp_model = ArrayDispersion() 1127 1127 if hasattr(state, "values") and \ 1128 1128 self.disp_cb_dict[item].GetValue() == True: … … 1379 1379 self.weights = copy.deepcopy(state.weights) 1380 1380 1381 for key, disp_type in state._disp_obj_dict.iteritems(): 1382 #disp_model = disp 1383 disp_model = POLYDISPERSITY_MODELS[disp_type]() 1381 for key, disp in state._disp_obj_dict.iteritems(): 1382 # From saved file, disp_model can not be sent in model obj. 1383 # it will be sent as a string here, then converted to model object. 1384 if disp.__class__.__name__ == 'str': 1385 disp_model = None 1386 com_str = "from sasmodels.weights " 1387 com_str += "import %s as disp_func \ndisp_model = disp_func()" 1388 exec com_str % disp 1389 else: 1390 disp_model = disp 1384 1391 self._disp_obj_dict[key] = disp_model 1385 1392 param_name = key.split('.')[0] … … 1497 1504 is_2Ddata = True 1498 1505 if self.model != None: 1499 is_modified = (self._check_value_enter(self.fittable_param) 1500 or self._check_value_enter(self.fixed_param) 1501 or self._check_value_enter(self.parameters)) 1506 try: 1507 is_modified = self._check_value_enter(self.fittable_param, 1508 is_modified) 1509 is_modified = self._check_value_enter(self.fixed_param, 1510 is_modified) 1511 is_modified = self._check_value_enter(self.parameters, 1512 is_modified) 1513 except Exception: 1514 logging.error(traceback.format_exc()) 1502 1515 1503 1516 # Here we should check whether the boundaries have been modified. … … 1520 1533 else: 1521 1534 self.fitrange = False 1535 1536 if not self.data.is_data: 1537 is_modified = True 1522 1538 1523 1539 ## if any value is modify draw model with new value … … 1536 1552 self._draw_model() 1537 1553 self.Refresh() 1538 1539 logging.info("is_modified flag set to %g",is_modified)1540 1554 return is_modified 1541 1555 … … 1547 1561 flag = True 1548 1562 self.fitrange = True 1563 is_modified = False 1549 1564 1550 1565 #wx.PostEvent(self._manager.parent, StatusEvent(status=" \ … … 1559 1574 [self.data]) 1560 1575 ##Check the values 1561 self._check_value_enter(self.fittable_param )1562 self._check_value_enter(self.fixed_param )1563 self._check_value_enter(self.parameters )1576 self._check_value_enter(self.fittable_param, is_modified) 1577 self._check_value_enter(self.fixed_param, is_modified) 1578 self._check_value_enter(self.parameters, is_modified) 1564 1579 1565 1580 # If qmin and qmax have been modified, update qmin and qmax and … … 1645 1660 return flag 1646 1661 1662 def _is_modified(self, is_modified): 1663 """ 1664 return to self._is_modified 1665 """ 1666 return is_modified 1667 1647 1668 def _reset_parameters_state(self, listtorestore, statelist): 1648 1669 """ … … 1943 1964 wx.PostEvent(self.parent, StatusEvent(status=msg)) 1944 1965 # Flag to register when a parameter has changed. 1966 #is_modified = False 1945 1967 if tcrtl.GetValue().lstrip().rstrip() != "": 1946 1968 try: … … 1972 1994 if temp_npts != self.num_points: 1973 1995 self.num_points = temp_npts 1996 #is_modified = True 1974 1997 else: 1975 1998 msg = "Cannot plot: No points in Q range!!! " … … 2147 2170 self.Layout() 2148 2171 2149 2150 2172 def _validate_qrange(self, qmin_ctrl, qmax_ctrl): 2151 2173 """ … … 2254 2276 return flag 2255 2277 2256 def _check_value_enter(self, list ):2278 def _check_value_enter(self, list, modified): 2257 2279 """ 2258 2280 :param list: model parameter and panel info … … 2264 2286 parameter's maximum value , 2265 2287 parameter's units] 2266 2267 Returns True if the model parameters have changed.2268 """2269 is_modified = False2288 """ 2289 is_modified = modified 2290 if len(list) == 0: 2291 return is_modified 2270 2292 for item in list: 2271 2293 #skip angle parameters for 1D 2272 if not self.enable2D and item in self.orientation_params: 2273 continue 2274 2275 value_ctrl = item[2] 2276 if not value_ctrl.IsEnabled(): 2277 # ArrayDispersion disables PD, Min, Max, Npts, Nsigs 2278 continue 2279 2280 name = item[1] 2281 value_str = value_ctrl.GetValue().strip() 2282 if name.endswith(".npts"): 2283 validity = check_int(value_ctrl) 2284 if not validity: 2294 if not self.enable2D: 2295 if item in self.orientation_params: 2285 2296 continue 2286 value = int(value_str) 2287 2288 elif name.endswith(".nsigmas"): 2289 validity = check_float(value_ctrl) 2290 if not validity: 2291 continue 2292 value = float(value_str) 2293 2294 else: # value or polydispersity 2295 2296 # Check that min, max and value are floats 2297 min_ctrl, max_ctrl = item[5], item[6] 2298 min_str = min_ctrl.GetValue().strip() 2299 max_str = max_ctrl.GetValue().strip() 2300 validity = check_float(value_ctrl) 2301 if min_str != "": 2302 validity = validity and check_float(min_ctrl) 2303 if max_str != "": 2304 validity = validity and check_float(max_ctrl) 2305 if not validity: 2306 continue 2307 2308 # Check that min is less than max 2309 low = -numpy.inf if min_str == "" else float(min_str) 2310 high = numpy.inf if max_str == "" else float(max_str) 2311 if high < low: 2312 min_ctrl.SetBackgroundColour("pink") 2313 min_ctrl.Refresh() 2314 max_ctrl.SetBackgroundColour("pink") 2315 max_ctrl.Refresh() 2316 #msg = "Invalid fit range for %s: min must be smaller than max"%name 2317 #wx.PostEvent(self._manager.parent, StatusEvent(status=msg)) 2318 continue 2319 2320 # Force value between min and max 2321 value = float(value_str) 2322 if value < low: 2323 value = low 2324 value_ctrl.SetValue(format_number(value)) 2325 elif value > high: 2326 value = high 2327 value_ctrl.SetValue(format_number(value)) 2328 2329 if name not in self.model.details.keys(): 2330 self.model.details[name] = ["", None, None] 2331 old_low, old_high = self.model.details[name][1:3] 2332 if old_low != low or old_high != high: 2333 # The configuration has changed but it won't change the 2334 # computed curve so no need to set is_modified to True 2335 #is_modified = True 2336 self.model.details[name][1:3] = low, high 2337 2338 # Update value in model if it has changed 2339 if value != self.model.getParam(name): 2340 self.model.setParam(name, value) 2341 is_modified = True 2297 #try: 2298 name = str(item[1]) 2299 2300 if string.find(name, ".npts") == -1 and \ 2301 string.find(name, ".nsigmas") == -1: 2302 ## check model parameters range 2303 param_min = None 2304 param_max = None 2305 2306 ## check minimun value 2307 if item[5] != None and item[5] != "": 2308 if item[5].GetValue().lstrip().rstrip() != "": 2309 try: 2310 param_min = float(item[5].GetValue()) 2311 if not self._validate_qrange(item[5], item[2]): 2312 if numpy.isfinite(param_min): 2313 item[2].SetValue(format_number(param_min)) 2314 2315 item[5].SetBackgroundColour(wx.WHITE) 2316 item[2].SetBackgroundColour(wx.WHITE) 2317 2318 except: 2319 msg = "Wrong fit parameter range entered" 2320 wx.PostEvent(self._manager.parent, 2321 StatusEvent(status=msg)) 2322 raise ValueError, msg 2323 is_modified = True 2324 ## check maximum value 2325 if item[6] != None and item[6] != "": 2326 if item[6].GetValue().lstrip().rstrip() != "": 2327 try: 2328 param_max = float(item[6].GetValue()) 2329 if not self._validate_qrange(item[2], item[6]): 2330 if numpy.isfinite(param_max): 2331 item[2].SetValue(format_number(param_max)) 2332 2333 item[6].SetBackgroundColour(wx.WHITE) 2334 item[2].SetBackgroundColour(wx.WHITE) 2335 except: 2336 msg = "Wrong Fit parameter range entered " 2337 wx.PostEvent(self._manager.parent, 2338 StatusEvent(status=msg)) 2339 raise ValueError, msg 2340 is_modified = True 2341 2342 if param_min != None and param_max != None: 2343 if not self._validate_qrange(item[5], item[6]): 2344 msg = "Wrong Fit range entered for parameter " 2345 msg += "name %s of model %s " % (name, self.model.name) 2346 wx.PostEvent(self._manager.parent, 2347 StatusEvent(status=msg)) 2348 2349 if name in self.model.details.keys(): 2350 self.model.details[name][1:3] = param_min, param_max 2351 is_modified = True 2352 else: 2353 self.model.details[name] = ["", param_min, param_max] 2354 is_modified = True 2355 try: 2356 # Check if the textctr is enabled 2357 if item[2].IsEnabled(): 2358 value = float(item[2].GetValue()) 2359 item[2].SetBackgroundColour("white") 2360 # If the value of the parameter has changed, 2361 # +update the model and set the is_modified flag 2362 if value != self.model.getParam(name) and \ 2363 numpy.isfinite(value): 2364 self.model.setParam(name, value) 2365 except: 2366 item[2].SetBackgroundColour("pink") 2367 msg = "Wrong Fit parameter value entered " 2368 wx.PostEvent(self._manager.parent, StatusEvent(status=msg)) 2342 2369 2343 2370 return is_modified … … 2512 2539 self._disp_obj_dict[name1] = disp_model 2513 2540 self.model.set_dispersion(param_name, disp_model) 2514 self.state._disp_obj_dict[name1] = disp_model .type2541 self.state._disp_obj_dict[name1] = disp_model 2515 2542 2516 2543 value1 = str(format_number(self.model.getParam(name1), True)) … … 2535 2562 item[0].Enable() 2536 2563 item[2].Enable() 2537 item[3].Show(True)2538 item[4].Show(True)2539 2564 item[5].Enable() 2540 2565 item[6].Enable() … … 2629 2654 self._disp_obj_dict[name] = disp 2630 2655 self.model.set_dispersion(name.split('.')[0], disp) 2631 self.state._disp_obj_dict[name] = disp .type2656 self.state._disp_obj_dict[name] = disp 2632 2657 self.values[name] = values 2633 2658 self.weights[name] = weights … … 2697 2722 :param disp_function: dispersion distr. function 2698 2723 """ 2724 # List of the poly_model name in the combobox 2725 list = ["RectangleDispersion", "ArrayDispersion", 2726 "LogNormalDispersion", "GaussianDispersion", 2727 "SchulzDispersion"] 2728 2699 2729 # Find the selection 2700 if disp_func is not None: 2701 try: 2702 return POLYDISPERSITY_MODELS.values().index(disp_func.__class__) 2703 except ValueError: 2704 pass # Fall through to default class 2705 return POLYDISPERSITY_MODELS.keys().index('gaussian') 2730 try: 2731 selection = list.index(disp_func.__class__.__name__) 2732 return selection 2733 except: 2734 return 3 2706 2735 2707 2736 def on_reset_clicked(self, event): … … 3290 3319 pd = content[name][1] 3291 3320 if name.count('.') > 0: 3292 # If this is parameter.width, then pd may be a floating3293 # point value or it may be an array distribution.3294 # Nothing to do for parameter.npts or parameter.nsigmas.3295 3321 try: 3296 3322 float(pd) 3297 if name.endswith('.npts'): 3298 pd = int(pd) 3299 except Exception: 3323 except: 3300 3324 #continue 3301 3325 if not pd and pd != '': … … 3305 3329 # Only array func has pd == '' case. 3306 3330 item[2].Enable(False) 3307 else:3308 item[2].Enable(True)3309 3331 if item[2].__class__.__name__ == "ComboBox": 3310 3332 if content[name][1] in self.model.fun_list: … … 3333 3355 pd = value[0] 3334 3356 if name.count('.') > 0: 3335 # If this is parameter.width, then pd may be a floating3336 # point value or it may be an array distribution.3337 # Nothing to do for parameter.npts or parameter.nsigmas.3338 3357 try: 3339 3358 pd = float(pd) 3340 if name.endswith('.npts'):3341 pd = int(pd)3342 3359 except: 3343 3360 #continue … … 3348 3365 # Only array func has pd == '' case. 3349 3366 item[2].Enable(False) 3350 else:3351 item[2].Enable(True)3352 3367 if item[2].__class__.__name__ == "ComboBox": 3353 3368 if value[0] in self.model.fun_list: … … 3369 3384 Helps get paste for poly function 3370 3385 3371 *item* is the parameter name 3372 3373 *value* depends on which parameter is being processed, and whether it 3374 has array polydispersity. 3375 3376 For parameters without array polydispersity: 3377 3378 parameter => ['FLOAT', ''] 3379 parameter.width => ['FLOAT', 'DISTRIBUTION', ''] 3380 parameter.npts => ['FLOAT', ''] 3381 parameter.nsigmas => ['FLOAT', ''] 3382 3383 For parameters with array polydispersity: 3384 3385 parameter => ['FLOAT', ''] 3386 parameter.width => ['FILENAME', 'array', [x1, ...], [w1, ...]] 3387 parameter.npts => ['FLOAT', ''] 3388 parameter.nsigmas => ['FLOAT', ''] 3389 """ 3390 # Do nothing if not setting polydispersity 3391 if len(value[1]) == 0: 3392 return 3393 3394 try: 3395 name = item[7].Name 3396 param_name = name.split('.')[0] 3397 item[7].SetValue(value[1]) 3398 selection = item[7].GetCurrentSelection() 3399 dispersity = item[7].GetClientData(selection) 3400 disp_model = dispersity() 3401 3402 if value[1] == 'array': 3403 pd_vals = numpy.array(value[2]) 3404 pd_weights = numpy.array(value[3]) 3405 if len(pd_vals) == 0 or len(pd_vals) != len(pd_weights): 3406 msg = ("bad array distribution parameters for %s" 3407 % param_name) 3408 raise ValueError(msg) 3409 self._set_disp_cb(True, item=item) 3410 self._set_array_disp_model(name=name, 3411 disp=disp_model, 3412 values=pd_vals, 3413 weights=pd_weights) 3414 else: 3415 self._set_disp_cb(False, item=item) 3416 self._disp_obj_dict[name] = disp_model 3417 self.model.set_dispersion(param_name, disp_model) 3418 self.state._disp_obj_dict[name] = disp_model.type 3419 # TODO: It's not an array, why update values and weights? 3420 self.model._persistency_dict[param_name] = \ 3421 [self.values, self.weights] 3422 self.state.values = self.values 3423 self.state.weights = self.weights 3424 3425 except Exception: 3426 logging.error(traceback.format_exc()) 3427 print "Error in BasePage._paste_poly_help: %s" % \ 3428 sys.exc_info()[1] 3429 3430 def _set_disp_cb(self, isarray, item): 3386 :param item: Gui param items 3387 :param value: the values for parameter ctrols 3388 """ 3389 is_array = False 3390 if len(value[1]) > 0: 3391 # Only for dispersion func.s 3392 try: 3393 item[7].SetValue(value[1]) 3394 selection = item[7].GetCurrentSelection() 3395 name = item[7].Name 3396 param_name = name.split('.')[0] 3397 dispersity = item[7].GetClientData(selection) 3398 disp_model = dispersity() 3399 # Only for array disp 3400 try: 3401 pd_vals = numpy.array(value[2]) 3402 pd_weights = numpy.array(value[3]) 3403 if len(pd_vals) > 0 and len(pd_vals) > 0: 3404 if len(pd_vals) == len(pd_weights): 3405 self._set_disp_array_cb(item=item) 3406 self._set_array_disp_model(name=name, 3407 disp=disp_model, 3408 values=pd_vals, 3409 weights=pd_weights) 3410 is_array = True 3411 except Exception: 3412 logging.error(traceback.format_exc()) 3413 if not is_array: 3414 self._disp_obj_dict[name] = disp_model 3415 self.model.set_dispersion(name, 3416 disp_model) 3417 self.state._disp_obj_dict[name] = \ 3418 disp_model 3419 self.model.set_dispersion(param_name, disp_model) 3420 self.state.values = self.values 3421 self.state.weights = self.weights 3422 self.model._persistency_dict[param_name] = \ 3423 [self.state.values, 3424 self.state.weights] 3425 3426 except Exception: 3427 logging.error(traceback.format_exc()) 3428 print "Error in BasePage._paste_poly_help: %s" % \ 3429 sys.exc_info()[1] 3430 3431 def _set_disp_array_cb(self, item): 3431 3432 """ 3432 3433 Set cb for array disp 3433 3434 """ 3434 if isarray: 3435 item[0].SetValue(False) 3436 item[0].Enable(False) 3437 item[2].Enable(False) 3438 item[3].Show(False) 3439 item[4].Show(False) 3440 item[5].SetValue('') 3441 item[5].Enable(False) 3442 item[6].SetValue('') 3443 item[6].Enable(False) 3444 else: 3445 item[0].Enable() 3446 item[2].Enable() 3447 item[3].Show(True) 3448 item[4].Show(True) 3449 item[5].Enable() 3450 item[6].Enable() 3435 item[0].SetValue(False) 3436 item[0].Enable(False) 3437 item[2].Enable(False) 3438 item[3].Show(False) 3439 item[4].Show(False) 3440 item[5].SetValue('') 3441 item[5].Enable(False) 3442 item[6].SetValue('') 3443 item[6].Enable(False) 3451 3444 3452 3445 def update_pinhole_smear(self): -
src/sas/sasgui/perspectives/fitting/batchfitpage.py
ree4b3cb rfc18690 256 256 # if self.model != None: 257 257 # ##Check the values 258 # self._check_value_enter( self.fittable_param )259 # self._check_value_enter( self.fixed_param )260 # self._check_value_enter( self.parameters )258 # self._check_value_enter( self.fittable_param, is_modified) 259 # self._check_value_enter( self.fixed_param, is_modified) 260 # self._check_value_enter( self.parameters, is_modified) 261 261 # 262 262 # # If qmin and qmax have been modified, update qmin and qmax and -
src/sas/sasgui/perspectives/fitting/fitpage.py
r6c382da r934ce649 10 10 import math 11 11 import time 12 import traceback13 12 14 13 from sasmodels.weights import MODELS as POLYDISPERSITY_MODELS … … 1366 1365 try: 1367 1366 tcrtl.SetBackgroundColour(wx.WHITE) 1368 self._check_value_enter(self.fittable_param )1369 self._check_value_enter(self.parameters )1367 self._check_value_enter(self.fittable_param, is_modified) 1368 self._check_value_enter(self.parameters, is_modified) 1370 1369 except: 1371 1370 tcrtl.SetBackgroundColour("pink") … … 2059 2058 msg = "Error: This model state has missing or outdated " 2060 2059 msg += "information.\n" 2061 msg += traceback.format_exc()2060 msg += "%s" % (sys.exc_value) 2062 2061 wx.PostEvent(self._manager.parent, 2063 2062 StatusEvent(status=msg, info="error")) -
src/sas/sasgui/perspectives/fitting/fitting.py
rca4d985 r7673ecd 313 313 """ 314 314 event_id = event.GetId() 315 self.update_custom_combo() 315 self.update_custom_combo() 316 316 317 317 def update_custom_combo(self): … … 342 342 page.formfactorbox.SetLabel(current_val) 343 343 except: 344 logging.error("update_custom_combo: %s", sys.exc_value) 344 pass 345 345 346 346 347 def set_edit_menu(self, owner): … … 1665 1666 wx.PostEvent(self.parent, StatusEvent(status=msg, type="update")) 1666 1667 1667 def create_theory_1D(self, x, y, page_id, model, data, state,1668 data_description, data_id, dy=None):1669 """1670 Create a theory object associate with an existing Data1D1671 and add it to the data manager.1672 @param x: x-values of the data1673 @param y: y_values of the data1674 @param page_id: fit page ID1675 @param model: model used for fitting1676 @param data: Data1D object to create the theory for1677 @param state: model state1678 @param data_description: title to use in the data manager1679 @param data_id: unique data ID1680 """1681 new_plot = Data1D(x=x, y=y)1682 if dy is None:1683 new_plot.is_data = False1684 new_plot.dy = numpy.zeros(len(y))1685 # If this is a theory curve, pick the proper symbol to make it a curve1686 new_plot.symbol = GUIFRAME_ID.CURVE_SYMBOL_NUM1687 else:1688 new_plot.is_data = True1689 new_plot.dy = dy1690 new_plot.interactive = True1691 new_plot.dx = None1692 new_plot.dxl = None1693 new_plot.dxw = None1694 _yaxis, _yunit = data.get_yaxis()1695 _xaxis, _xunit = data.get_xaxis()1696 new_plot.title = data.name1697 new_plot.group_id = data.group_id1698 if new_plot.group_id == None:1699 new_plot.group_id = data.group_id1700 new_plot.id = data_id1701 # Find if this theory was already plotted and replace that plot given1702 # the same id1703 self.page_finder[page_id].get_theory_data(fid=data.id)1704 1705 if data.is_data:1706 data_name = str(data.name)1707 else:1708 data_name = str(model.__class__.__name__)1709 1710 new_plot.name = data_description + " [" + data_name + "]"1711 new_plot.xaxis(_xaxis, _xunit)1712 new_plot.yaxis(_yaxis, _yunit)1713 self.page_finder[page_id].set_theory_data(data=new_plot,1714 fid=data.id)1715 self.parent.update_theory(data_id=data.id, theory=new_plot,1716 state=state)1717 return new_plot1718 1719 1668 def _complete1D(self, x, y, page_id, elapsed, index, model, 1720 1669 weight=None, fid=None, 1721 1670 toggle_mode_on=False, state=None, 1722 1671 data=None, update_chisqr=True, 1723 source='model', plot_result=True, 1724 unsmeared_model=None, unsmeared_data=None, 1725 unsmeared_error=None, sq_model=None, pq_model=None): 1726 """ 1727 Complete plotting 1D data 1728 @param unsmeared_model: fit model, without smearing 1729 @param unsmeared_data: data, rescaled to unsmeared model 1730 @param unsmeared_error: data error, rescaled to unsmeared model 1672 source='model', plot_result=True): 1673 """ 1674 Complete plotting 1D data 1731 1675 """ 1732 1676 try: 1733 1677 numpy.nan_to_num(y) 1734 new_plot = self.create_theory_1D(x, y, page_id, model, data, state, 1735 data_description=model.name, 1736 data_id=str(page_id) + " " + data.name) 1737 if unsmeared_model is not None: 1738 self.create_theory_1D(x, unsmeared_model, page_id, model, data, state, 1739 data_description=model.name + " unsmeared", 1740 data_id=str(page_id) + " " + data.name + " unsmeared") 1741 1742 self.create_theory_1D(x, unsmeared_data, page_id, model, data, state, 1743 data_description="Data unsmeared", 1744 data_id="Data " + data.name + " unsmeared", 1745 dy=unsmeared_error) 1746 1747 if sq_model is not None and pq_model is not None: 1748 self.create_theory_1D(x, sq_model, page_id, model, data, state, 1749 data_description=model.name + " S(q)", 1750 data_id=str(page_id) + " " + data.name + " S(q)") 1751 self.create_theory_1D(x, pq_model, page_id, model, data, state, 1752 data_description=model.name + " P(q)", 1753 data_id=str(page_id) + " " + data.name + " P(q)") 1754 1755 1678 1679 new_plot = Data1D(x=x, y=y) 1680 new_plot.is_data = False 1681 new_plot.dy = numpy.zeros(len(y)) 1682 new_plot.symbol = GUIFRAME_ID.CURVE_SYMBOL_NUM 1683 _yaxis, _yunit = data.get_yaxis() 1684 _xaxis, _xunit = data.get_xaxis() 1685 new_plot.title = data.name 1686 1687 new_plot.group_id = data.group_id 1688 if new_plot.group_id == None: 1689 new_plot.group_id = data.group_id 1690 new_plot.id = str(page_id) + " " + data.name 1691 #if new_plot.id in self.color_dict: 1692 # new_plot.custom_color = self.color_dict[new_plot.id] 1693 #find if this theory was already plotted and replace that plot given 1694 #the same id 1695 self.page_finder[page_id].get_theory_data(fid=data.id) 1696 1697 if data.is_data: 1698 data_name = str(data.name) 1699 else: 1700 data_name = str(model.__class__.__name__) 1701 1702 new_plot.name = model.name + " [" + data_name + "]" 1703 new_plot.xaxis(_xaxis, _xunit) 1704 new_plot.yaxis(_yaxis, _yunit) 1705 self.page_finder[page_id].set_theory_data(data=new_plot, 1706 fid=data.id) 1707 self.parent.update_theory(data_id=data.id, theory=new_plot, 1708 state=state) 1756 1709 current_pg = self.fit_panel.get_page_by_id(page_id) 1757 1710 title = new_plot.title -
src/sas/sasgui/perspectives/fitting/media/fitting.rst
r05829fb rd85c194 18 18 19 19 Information on the SasView Optimisers <optimizer.rst> 20 21 Writing a Plugin <plugin.rst> 20 -
src/sas/sasgui/perspectives/fitting/media/fitting_help.rst
r05829fb rb64b87c 132 132 * By :ref:`Writing_a_Plugin` 133 133 134 *NB: Because of the way these options are implemented, it is not possible for them* 135 *to use the polydispersity algorithms in SasView. Only models in the model library* 136 *can do this. At the time of writing (Release 3.1.0) work is in hand to make it* 137 *easier to add new models to the model library.* 138 134 139 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 135 140 … … 158 163 the :ref:`Advanced` option. 159 164 160 *NB: "Fit Parameters" has been split into two sections, those which can be161 polydisperse (shape and orientation parameters) and those which are not162 (scattering length densities, for example).*163 164 165 Sum|Multi(p1,p2) 165 166 ^^^^^^^^^^^^^^^^ … … 191 192 *Advanced Custom Model Editor*. 192 193 193 See :ref:`Writing_a_Plugin` for details on the plugin format. 194 195 *NB: Sum/Product models are still using the SasView 3.x model format. Unless 196 you are confident about what you are doing, it is recommended that you 197 only modify lines denoted with the ## <----- comments!* 194 *NB: Unless you are confident about what you are doing, it is recommended that you* 195 *only modify lines denoted with the ## <----- comments!* 198 196 199 197 When editing is complete, select *Run -> Compile* from the *Model Editor* menu bar. An … … 213 211 214 212 *NB: Custom models shipped with SasView cannot be removed in this way.* 213 214 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 215 216 .. _Writing_a_Plugin: 217 218 Writing a Plugin 219 ---------------- 220 221 Advanced users can write their own model in Python and save it to the the SasView 222 *plugin_models* folder 223 224 *C:\\Users\\[username]\\.sasview\\plugin_models* - (on Windows) 225 226 in .py format. The next time SasView is started it will compile the plugin and add 227 it to the list of *Customized Models*. 228 229 It is recommended that existing plugin models be used as templates. 215 230 216 231 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ -
src/sas/sasgui/perspectives/fitting/model_thread.py
rca4d985 r934ce649 7 7 import math 8 8 from sas.sascalc.data_util.calcthread import CalcThread 9 from sas.sascalc.fit.MultiplicationModel import MultiplicationModel10 9 11 10 class Calc2D(CalcThread): … … 167 166 index = (self.qmin <= self.data.x) & (self.data.x <= self.qmax) 168 167 169 # If we use a smearer, also return the unsmeared model170 unsmeared_output = None171 unsmeared_data = None172 unsmeared_error = None173 168 ##smearer the ouput of the plot 174 169 if self.smearer is not None: … … 176 171 self.qmax) 177 172 mask = self.data.x[first_bin:last_bin+1] 178 unsmeared_output = numpy.zeros((len(self.data.x))) 179 unsmeared_output[first_bin:last_bin+1] = self.model.evalDistribution(mask) 180 output = self.smearer(unsmeared_output, first_bin, last_bin) 181 182 # Rescale data to unsmeared model 183 unsmeared_data = numpy.zeros((len(self.data.x))) 184 unsmeared_error = numpy.zeros((len(self.data.x))) 185 unsmeared_data[first_bin:last_bin+1] = self.data.y[first_bin:last_bin+1]\ 186 * unsmeared_output[first_bin:last_bin+1]\ 187 / output[first_bin:last_bin+1] 188 unsmeared_error[first_bin:last_bin+1] = self.data.dy[first_bin:last_bin+1]\ 189 * unsmeared_output[first_bin:last_bin+1]\ 190 / output[first_bin:last_bin+1] 191 unsmeared_output=unsmeared_output[index] 192 unsmeared_data=unsmeared_data[index] 193 unsmeared_error=unsmeared_error 173 output[first_bin:last_bin+1] = self.model.evalDistribution(mask) 174 output = self.smearer(output, first_bin, last_bin) 194 175 else: 195 176 output[index] = self.model.evalDistribution(self.data.x[index]) 196 197 sq_model = None198 pq_model = None199 if isinstance(self.model, MultiplicationModel):200 sq_model = numpy.zeros((len(self.data.x)))201 pq_model = numpy.zeros((len(self.data.x)))202 sq_model[index] = self.model.s_model.evalDistribution(self.data.x[index])203 pq_model[index] = self.model.p_model.evalDistribution(self.data.x[index])204 177 205 178 elapsed = time.time() - self.starttime … … 214 187 data=self.data, 215 188 update_chisqr=self.update_chisqr, 216 source=self.source, 217 unsmeared_model=unsmeared_output, 218 unsmeared_data=unsmeared_data, 219 unsmeared_error=unsmeared_error, 220 pq_model=pq_model, 221 sq_model=sq_model) 189 source=self.source) 222 190 223 191 def results(self): -
src/sas/sasgui/perspectives/fitting/pagestate.py
r6c382da r7673ecd 24 24 from xml.dom.minidom import parseString 25 25 from lxml import etree 26 27 import sasmodels.weights28 26 29 27 import sas.sascalc.dataloader … … 476 474 value = content[1] 477 475 except Exception: 478 msg = "Report string expected 'name: value' but got %r"%line 479 logging.error(msg) 476 logging.error(traceback.format_exc()) 480 477 if name.count("State created"): 481 478 repo_time = "" + value … … 519 516 title_name = HEADER % title 520 517 except Exception: 521 msg = "While parsing 'data: ...'\n" 522 logging.error(msg + traceback.format_exc()) 518 logging.error(traceback.format_exc()) 523 519 if name == "model name ": 524 520 try: … … 535 531 q_range = CENTRE % q_name 536 532 except Exception: 537 msg = "While parsing 'Plotting Range: ...'\n" 538 logging.error(msg + traceback.format_exc()) 533 logging.error(traceback.format_exc()) 539 534 paramval = "" 540 535 for lines in param_string.split(":"): … … 716 711 # For self.values ={ disp_param_name: [vals,...],...} 717 712 # and for self.weights ={ disp_param_name: [weights,...],...} 713 value_list = {} 718 714 for item in LIST_OF_MODEL_ATTRIBUTES: 719 715 element = newdoc.createElement(item[0]) … … 729 725 730 726 # Create doc for the dictionary of self._disp_obj_dic 731 for tagname, varname, tagtype in DISPERSION_LIST: 732 element = newdoc.createElement(tagname) 733 value_list = getattr(self, varname) 734 for key, value in value_list.iteritems(): 727 for item in DISPERSION_LIST: 728 element = newdoc.createElement(item[0]) 729 value_list = getattr(self, item[1]) 730 for key, val in value_list.iteritems(): 731 value = repr(val) 735 732 sub_element = newdoc.createElement(key) 736 733 sub_element.setAttribute('name', str(key)) … … 850 847 # Recover _disp_obj_dict from xml file 851 848 self._disp_obj_dict = {} 852 for tagname, varname, tagtype in DISPERSION_LIST: 853 node = get_content("ns:%s" % tagname, entry) 849 for item in DISPERSION_LIST: 850 # Get node 851 node = get_content("ns:%s" % item[0], entry) 854 852 for attr in node: 855 parameter = str(attr.get('name')) 856 value = attr.get('value') 857 if value.startswith("<"): 858 try: 859 # <path.to.NamedDistribution object/instance...> 860 cls_name = value[1:].split()[0].split('.')[-1] 861 cls = getattr(sasmodels.weights, cls_name) 862 value = cls.type 863 except Exception: 864 logging.error("unable to load distribution %r for %s" 865 % (value, parameter)) 866 continue 867 _disp_obj_dict = getattr(self, varname) 868 _disp_obj_dict[parameter] = value 853 name = str(attr.get('name')) 854 val = attr.get('value') 855 value = val.split(" instance")[0] 856 disp_name = value.split("<")[1] 857 try: 858 # Try to recover disp_model object from strings 859 com = "from sas.models.dispersion_models " 860 com += "import %s as disp" 861 com_name = disp_name.split(".")[3] 862 exec com % com_name 863 disp_model = disp() 864 attribute = getattr(self, item[1]) 865 attribute[name] = com_name 866 except Exception: 867 logging.error(traceback.format_exc()) 869 868 870 869 # get self.values and self.weights dic. if exists 871 for tagname, varnamein LIST_OF_MODEL_ATTRIBUTES:872 node = get_content("ns:%s" % tagname, entry)870 for item in LIST_OF_MODEL_ATTRIBUTES: 871 node = get_content("ns:%s" % item[0], entry) 873 872 dic = {} 874 873 value_list = [] 875 874 for par in node: 876 875 name = par.get('name') 877 values = par.text.split( )876 values = par.text.split('\n') 878 877 # Get lines only with numbers 879 878 for line in values: … … 883 882 except Exception: 884 883 # pass if line is empty (it happens) 885 msg = ("Error reading %r from %s %s\n" 886 % (line, tagname, name)) 887 logging.error(msg + traceback.format_exc()) 884 logging.error(traceback.format_exc()) 888 885 dic[name] = numpy.array(value_list) 889 setattr(self, varname, dic)886 setattr(self, item[1], dic) 890 887 891 888 def set_plot_state(self, figs, canvases): … … 1234 1231 1235 1232 except: 1236 logging.info("XML document does not contain fitting information.\n" 1237 + traceback.format_exc()) 1233 logging.info("XML document does not contain fitting information.\n %s" % sys.exc_value) 1238 1234 1239 1235 return state … … 1573 1569 if output[ind].run_name is not None\ 1574 1570 and len(output[ind].run_name) != 0: 1575 if isinstance(output[ind].run_name, dict): 1576 name = output[ind].run_name.keys()[0] 1577 else: 1578 name = output[ind].run_name 1571 name = output[ind].run_name 1579 1572 else: 1580 1573 name = original_fname -
src/sas/sasgui/perspectives/invariant/invariant_panel.py
r654e8e0 rc12f9b4 250 250 251 251 num = self.state.saved_state['state_num'] 252 if int(num)> 0:252 if num > 0: 253 253 self._set_undo_flag(True) 254 if int(num)< len(state.state_list) - 1:254 if num < len(state.state_list) - 1: 255 255 self._set_redo_flag(True) 256 256 … … 830 830 """ 831 831 try: 832 if key in ['compute_num', 'file', 'is_time_machine', 'state_num']: 833 return 834 else: 835 attr = getattr(self, key) 832 attr = getattr(self, key) 836 833 if attr.__class__.__name__ == "StaticText": 837 834 return 838 if value in ["True", "False", True, False]: 839 value = bool(value) 840 else: 835 if type(value) is not bool: 841 836 value = str(value) 842 837 attr.SetValue(value) … … 1865 1860 (self.button_calculate, 0, 1866 1861 wx.RIGHT | wx.TOP | wx.BOTTOM, 10), 1867 (self.button_help, 0, 1862 (self.button_help, 0, 1868 1863 wx.RIGHT | wx.TOP | wx.BOTTOM, 10),]) 1869 1864 def _do_layout(self): … … 1887 1882 self.SetSizer(self.main_sizer) 1888 1883 self.SetAutoLayout(True) 1889 1884 1890 1885 def on_help(self, event): 1891 1886 """ 1892 Bring up the Invariant Documentation whenever the HELP button is 1887 Bring up the Invariant Documentation whenever the HELP button is 1893 1888 clicked. 1894 1889 -
src/sas/sasgui/perspectives/invariant/invariant_state.py
rcb93b40 rc10d9d6c 426 426 if input_field is not None: 427 427 temp_state[item] = val 428 self.state_list[ str(ind)] = temp_state428 self.state_list[ind] = temp_state 429 429 430 430 # Parse current state (ie, saved_state) … … 790 790 doc = state.toXML(datainfo.name, doc=doc, entry_node=sasentry) 791 791 return doc 792 -
src/sas/sasgui/perspectives/pr/media/pr_help.rst
r0391dae rb64b87c 15 15 *P(r)* is set to be equal to an expansion of base functions of the type 16 16 17 .. math:: 18 \Phi_{n(r)} = 2 r sin(\frac{\pi n r}{D_{max}}) 17 |bigphi|\_n(r) = 2.r.sin(|pi|\ .n.r/D_max) 19 18 20 The coefficient of each base function in the expansion is found by performing 19 The coefficient of each base function in the expansion is found by performing 21 20 a least square fit with the following fit function 22 21 23 .. math:: 22 |chi|\ :sup:`2` = |bigsigma|\ :sub:`i` [ I\ :sub:`meas`\ (Q\ :sub:`i`\ ) - I\ :sub:`th`\ (Q\ :sub:`i`\ ) ] :sup:`2` / (Error) :sup:`2` + Reg_term 24 23 25 \chi^2=\frac{\sum_i (I_{meas}(Q_i)-I_{th}(Q_i))^2}{error^2}+Reg\_term 26 24 where I\ :sub:`meas`\ (Q) is the measured scattering intensity and 25 I\ :sub:`th`\ (Q) is the prediction from the Fourier transform of the *P(r)* 26 expansion. 27 27 28 where $I_{meas}(Q_i)$ is the measured scattering intensity and $I_{th}(Q_i)$ is 29 the prediction from the Fourier transform of the *P(r)* expansion. 30 31 The $Reg\_term$ term is a regularization term set to the second derivative 32 $d^2P(r)/d^2r$ integrated over $r$. It is used to produce a smooth *P(r)* output. 28 The *Reg_term* term is a regularization term set to the second derivative 29 d\ :sup:`2`\ *P(r)* / dr\ :sup:`2` integrated over *r*. It is used to produce a 30 smooth *P(r)* output. 33 31 34 32 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ … … 47 45 system. 48 46 49 P(r) inversion requires that the background be perfectly subtracted. This is50 often difficult to do well and thus many data sets will include a background.51 For those cases, the user should check the "estimate background" box and the52 module will do its best to estimate it.53 54 The P(r) module is constantly computing in the background what the optimum55 *number of terms* should be as well as the optimum *regularization constant*.56 These are constantly updated in the buttons next to the entry boxes on the GUI.57 These are almost always close and unless the user has a good reason to choose58 differently they should just click on the buttons to accept both. {D_max} must59 still be set by the user. However, besides looking at the output, the user can60 click the explore button which will bring up a graph of chi^2 vs Dmax over a61 range around the current Dmax. The user can change the range and the number of62 points to explore in that range. They can also choose to plot several other63 parameters as a function of Dmax including: I0, Rg, Oscillation parameter,64 background, positive fraction, and 1-sigma positive fraction.65 66 47 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 67 48 … … 74 55 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 75 56 76 .. note:: This help document was last modified by Paul Butler, 05 September, 201657 .. note:: This help document was last changed by Steve King, 01May2015 -
test/sasdataloader/test/utest_ascii.py
r7d94915 rb699768 94 94 f = self.loader.load("ascii_test_6.txt") 95 95 # The length of the data is 5 96 self.assertEqual(f, None) 96 self.assertEqual(len(f.x), 4) 97 self.assertEqual(f.x[0],0.013534) 98 self.assertEqual(f.x[3],0.022254) 97 99 98 100 if __name__ == '__main__':
Note: See TracChangeset
for help on using the changeset viewer.