Changeset a4a1ac9 in sasview


Ignore:
Timestamp:
Sep 10, 2018 1:26:03 PM (2 months ago)
Author:
GitHub <noreply@…>
Branches:
master, config-error, py37-all, py37-sascalc, py37-sasgui, pytest, simplify-c-build, ticket-1015-quick-fix, ticket-1094-headless, ticket-1111, ticket-1205-fit-weights, unittest-saveload
Children:
17cccd0
Parents:
6015eee (diff), 44e8f48 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
git-author:
Paul Kienzle <pkienzle@…> (09/10/18 13:26:03)
git-committer:
GitHub <noreply@…> (09/10/18 13:26:03)
Message:

Merge pull request #172 from SasView?/ticket-1166

Fix for report generation issue. Refs #1166.

Files:
4 added
14 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sasgui/guiframe/report_dialog.py

    r91552b5 rd0ce666f  
    77import sys 
    88import wx.html as html 
     9from sas.sasgui.guiframe.report_image_handler import ReportImageHandler 
    910 
    1011logger = logging.getLogger(__name__) 
     
    7071        button_close = wx.Button(self, wx.ID_OK, "Close") 
    7172        button_close.SetToolTipString("Close this report window.") 
     73        button_close.Bind(wx.EVT_BUTTON, self.onClose, 
     74                          id=button_close.GetId()) 
    7275        hbox.Add(button_close) 
    7376        button_close.SetFocus() 
     
    117120 
    118121 
    119     def OnClose(self, event=None): 
     122    def onClose(self, event=None): 
    120123        """ 
    121124        Close the Dialog 
     
    123126        """ 
    124127        for fig in self.fig_urls: 
    125             self.imgRAM.RemoveFile(fig) 
     128            ReportImageHandler.remove_figure(fig) 
    126129 
    127         self.Close() 
     130        self.Destroy() 
    128131 
    129132    def HTML2PDF(self, data, filename): 
  • src/sas/sasgui/perspectives/fitting/basepage.py

    rb4398819 ra4a1ac9  
    3131 
    3232from sas.sasgui.guiframe.panel_base import PanelBase 
     33from sas.sasgui.guiframe.report_image_handler import ReportImageHandler 
    3334from sas.sasgui.guiframe.utils import format_number, check_float, IdList, \ 
    3435    check_int 
     
    651652        by plotting, putting it into wx.FileSystem image object 
    652653        """ 
    653         images = [] 
    654         refs = [] 
    655  
    656         # For no figures in the list, prepare empty plot 
    657         if figs is None or len(figs) == 0: 
    658             figs = [None] 
    659  
    660         # Loop over the list of figures 
    661         # use wx.MemoryFSHandler 
    662         imgRAM = wx.MemoryFSHandler() 
    663         for fig in figs: 
    664             if fig is not None: 
    665                 ind = figs.index(fig) 
    666                 canvas = canvases[ind] 
    667  
    668             # store the image in wx.FileSystem Object 
    669             wx.FileSystem.AddHandler(wx.MemoryFSHandler()) 
    670  
    671             # index of the fig 
    672             ind = figs.index(fig) 
    673  
    674             # AddFile, image can be retrieved with 'memory:filename' 
    675             name = 'img_fit%s.png' % ind 
    676             refs.append('memory:' + name) 
    677             imgRAM.AddFile(name, canvas.bitmap, wx.BITMAP_TYPE_PNG) 
    678             # append figs 
    679             images.append(fig) 
    680  
    681         return imgRAM, images, refs 
    682  
     654        bitmaps = [] 
     655        for canvas in canvases: 
     656            bitmaps.append(canvas.bitmap) 
     657        imgs, refs = ReportImageHandler.set_figs(figs, bitmaps, 'fit') 
     658 
     659        return ReportImageHandler.instance, imgs, refs 
    683660 
    684661    def on_save(self, event): 
  • src/sas/sasgui/perspectives/fitting/report_dialog.py

    r69a6897 r44e8f48  
    7272        filename = basename + ext 
    7373 
    74         # save figures 
    75         pictures = [] 
    76         for num in range(self.nimages): 
    77             pic_name = basename + '_img%s.png' % num 
    78             # save the image for use with pdf writer 
    79             self.report_list[2][num].savefig(pic_name) 
    80             pictures.append(pic_name) 
     74        # save the images for use with pdf writer 
     75        pictures = [ 
     76            '_'.join((basename, url.split(':')[1])) for url in self.fig_urls] 
     77        for i, pic in enumerate(pictures): 
     78            self.report_list[2][i].savefig(pic) 
    8179 
    8280        # translate png references int html from in-memory name to on-disk name 
    83         html = self.report_html.replace("memory:img_fit", basename+'_img') 
     81        html = self.report_html.replace("memory:", basename+'_') 
    8482 
    8583        #set file extensions 
  • src/sas/sasgui/perspectives/invariant/invariant_panel.py

    r2469df7 r44e8f48  
    2424from sas.sasgui.guiframe.panel_base import PanelBase 
    2525from sas.sasgui.guiframe.documentation_window import DocumentationWindow 
     26from sas.sasgui.guiframe.report_image_handler import ReportImageHandler 
    2627 
    2728logger = logging.getLogger(__name__) 
     
    783784        report_img = self.state.image 
    784785        report_list = [report_html_str, report_text_str, report_img] 
    785         dialog = ReportDialog(report_list, None, -1, "") 
     786        ReportImageHandler.check_for_empty_instance() 
     787        imgRAM = ReportImageHandler.instance.img_holder 
     788        refs = [self.state.wximgbmp] 
     789        dialog = ReportDialog(report_list, imgRAM, refs, None, wx.ID_ANY, "") 
    786790        dialog.Show() 
    787791 
  • src/sas/sasgui/perspectives/invariant/invariant_state.py

    r2469df7 rfa412df  
    1212from lxml import etree 
    1313from sas.sascalc.dataloader.readers.cansas_reader import Reader as CansasReader 
     14from sas.sasgui.guiframe.report_image_handler import ReportImageHandler 
    1415from sas.sascalc.dataloader.readers.cansas_reader import get_content 
    1516from sas.sasgui.guiframe.utils import format_number 
     
    611612        wximgbmp = wx.BitmapFromImage(wximg) 
    612613        # store the image in wx.FileSystem Object 
    613         wx.FileSystem.AddHandler(wx.MemoryFSHandler()) 
    614         # use wx.MemoryFSHandler 
    615         self.imgRAM = wx.MemoryFSHandler() 
    616         # AddFile, image can be retrieved with 'memory:filename' 
    617         self.imgRAM.AddFile('img_inv.png', wximgbmp, wx.BITMAP_TYPE_PNG) 
    618  
    619         self.wximgbmp = 'memory:img_inv.png' 
    620         self.image = fig 
     614        imgs, refs = ReportImageHandler.set_figs([fig], [wximgbmp], 'inv') 
     615 
     616        self.wximgbmp = refs[0] 
     617        self.image = imgs[0] 
    621618 
    622619class Reader(CansasReader): 
  • src/sas/sasgui/perspectives/invariant/report_dialog.py

    r959eb01 rd0ce666f  
    4141 
    4242        # put image path in the report string 
    43         self.report_html = self.report_list[0] % "memory:img_inv.png" 
     43        self.report_html = self.report_list[0] % self.fig_urls[0] 
    4444        # layout 
    4545        self._setup_layout() 
  • .gitignore

    r1b605fb r153b75a  
    3434/docs/sphinx-docs/build 
    3535/docs/sphinx-docs/source-temp 
    36 /docs/sphinx-docs/source/dev/api 
    37 /docs/sphinx-docs/source/user/guiframe 
    38 /docs/sphinx-docs/source/user/models 
    39 /docs/sphinx-docs/source/user/sasview 
    40 /docs/sphinx-docs/source/user/perspectives 
    4136/docs/sphinx-docs/katex*.zip 
    4237/docs/sphinx-docs/node_modules 
  • docs/sphinx-docs/build_sphinx.py

    rdf72475 r153b75a  
    88from __future__ import print_function 
    99 
    10 import subprocess 
     10import sys 
    1111import os 
    1212from os.path import join as joinpath, abspath, dirname, isdir, exists, relpath 
    13 import sys 
    14 import fnmatch 
    1513import shutil 
     14import subprocess 
    1615import imp 
    17  
    1816from glob import glob 
    1917from distutils.dir_util import copy_tree 
     
    2119from distutils.spawn import find_executable 
    2220 
    23 from shutil import copy 
    24 from os import listdir 
    25  
    26 platform = '.%s-%s'%(get_platform(),sys.version[:3]) 
     21PLATFORM = '.%s-%s'%(get_platform(), sys.version[:3]) 
    2722 
    2823# sphinx paths 
     
    3530SASVIEW_ROOT = joinpath(SPHINX_ROOT, '..', '..') 
    3631SASVIEW_DOCS = joinpath(SPHINX_ROOT, "source") 
    37 SASVIEW_BUILD = abspath(joinpath(SASVIEW_ROOT, "build", "lib"+platform)) 
     32SASVIEW_BUILD = abspath(joinpath(SASVIEW_ROOT, "build", "lib"+PLATFORM)) 
    3833SASVIEW_MEDIA_SOURCE = joinpath(SASVIEW_ROOT, "src", "sas") 
    3934SASVIEW_DOC_TARGET = joinpath(SASVIEW_BUILD, "doc") 
     
    6560 
    6661def inplace_change(filename, old_string, new_string): 
    67 # Thanks to http://stackoverflow.com/questions/4128144/replace-string-within-file-contents 
    68         s=open(filename).read() 
    69         if old_string in s: 
    70                 print('Changing "{old_string}" to "{new_string}"'.format(**locals())) 
    71                 s=s.replace(old_string, new_string) 
    72                 f=open(filename, 'w') 
    73                 f.write(s) 
    74                 f.flush() 
    75                 f.close() 
    76         else: 
    77                 print('No occurences of "{old_string}" found.'.format(**locals())) 
     62    # Thanks to http://stackoverflow.com/questions/4128144/replace-string-within-file-contents 
     63    s = open(filename).read() 
     64    if old_string in s: 
     65        print('Changing "{old_string}" to "{new_string}"'.format(**locals())) 
     66        s = s.replace(old_string, new_string) 
     67        with open(filename, 'w') as f: 
     68            f.write(s) 
     69    else: 
     70        print('No occurences of "{old_string}" found.'.format(**locals())) 
    7871 
    7972def _remove_dir(dir_path): 
     
    241234        finally: 
    242235            fd_in.close() 
    243     with ZipFile(cache_path) as zip: 
    244         zip.extractall(destination) 
     236    with ZipFile(cache_path) as archive: 
     237        archive.extractall(destination) 
    245238 
    246239def convert_katex(): 
  • docs/sphinx-docs/source/conf.py

    ra8bbba2 rb229a3b  
    1111# All configuration values have a default; values that are commented out 
    1212# serve to show the default. 
     13from __future__ import print_function 
    1314 
    1415import sys, os, collections 
     
    2223sys.path.insert(0, build_lib) 
    2324sys.path.insert(0, os.path.abspath('_extensions')) # for sphinx extensions 
    24 print "-- path --" 
    25 print "\n".join(sys.path) 
     25print("-- path --") 
     26print("\n".join(sys.path)) 
    2627 
    2728# -- General configuration ----------------------------------------------------- 
     
    8081version = '4.2' 
    8182# The full version, including alpha/beta/rc tags. 
    82 release = '4.2.0-beta' 
     83release = '4.2.0' 
    8384 
    8485# The language for content autogenerated by Sphinx. Refer to documentation 
  • docs/sphinx-docs/source/rst_prolog

    r1659f54 r153b75a  
     1.. TODO: This file is ignored!  Prolog comes from sasmodels/doc/rst_prolog. 
     2 
    13.. Set up some substitutions to make life easier... 
    24 
  • docs/sphinx-docs/source/user/tutorial.rst

    r3bd677b re873408  
    1010:download:`Getting Started with Sasview <sasview/getting_started_with_sasview.pdf>` 
    1111 
     12:download:`Basic 1D Fitting in Sasview <sasview/basic_1d_fitting_in_sasview_v3x_4x.pdf>` 
     13 
     14:download:`Simultaneous 1D Fitting in Sasview <sasview/simultaneous_1d_fitting_in_sasview_v3x_4x.pdf>` 
     15 
    1216:download:`Old Tutorial <sasview/Tutorial.pdf>` 
  • src/sas/sasgui/perspectives/calculator/media/slit_calculator_help.rst

    r643efb5 r346745a  
    1111----------- 
    1212 
    13 This tool enables X-ray users to calculate the slit size (FWHM/2) for smearing 
    14 based on their half beam profile data. 
     13This tool enables X-ray users to calculate the slit size (FWHM/2) for resolution  
     14smearing purposes based on their half beam profile data (as Q vs Intensity; any  
     15other data fields are ignored). 
    1516 
    16 *NOTE! Whilst it may have some more generic applicability, the calculator has 
    17 only been tested with beam profile data from Anton-Paar SAXSess\ :sup:`TM` software.* 
     17Method 
     18------ 
     19 
     20The tool works by sequentially summing 10 or more intensity values until a  
     21maximum value is attained. It then locates the Q values for the points just before,  
     22and just after, **half** of this maximum value and interpolates between them to get  
     23an accurate value for the Q value for the half maximum. 
     24 
     25NOTE! Whilst it may have some more generic applicability, the calculator has 
     26only been tested with beam profile data from Anton-Paar SAXSess\ :sup:`TM`\  software. 
     27The beam profile file does not carry any information about the units of the  
     28Q data. It is probably |nm^-1| but the resolution calculations assume the slit  
     29height/width has units of |Ang^-1|. If the beam profile data is not in these  
     30units then it, or the result, must be manually converted. 
    1831 
    1932.. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 
     
    2740 
    2841   *NOTE! To see an example of the beam profile file format, visit the file 
    29    beam profile.DAT in your {installation_directory}/SasView/test folder.* 
     42   beam profile.DAT in your {installation_directory}/SasView/test_1d folder.* 
    3043 
    31443) Once a data is loaded, the slit size is automatically computed and displayed 
    3245   in the tool window. 
    3346 
    34 *NOTE! The beam profile file does not carry any information about the units of 
    35 the Q data. This calculator assumes the data has units of 1/\ |Ang|\ . If the 
    36 data is not in these units it must be manually converted beforehand.* 
    37  
    3847.. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 
    3948 
    40 .. note::  This help document was last changed by Steve King, 01May2015 
     49.. note::  This help document was last changed by Steve King, 09Sep2018 
  • src/sas/sasview/__init__.py

    ra8bbba2 rb229a3b  
    1 __version__ = "4.2.0-beta" 
     1__version__ = "4.2.0" 
    22__build__ = "GIT_COMMIT" 
  • src/sas/sasview/local_config.py

    rb963b20 rb229a3b  
    4848'''This work benefited from the use of the SasView application, originally developed under NSF Award DMR-0520547. SasView also contains code developed with funding from the EU Horizon 2020 programme under the SINE2020 project Grant No 654000.''' 
    4949_acknowledgement_citation = \ 
    50 '''M. Doucet et al. SasView Version 4.1.2, Zenodo, 10.5281/zenodo.825675''' 
     50'''M. Doucet et al. SasView Version 4.2, Zenodo, 10.5281/zenodo.1412041''' 
    5151 
    5252_acknowledgement =  \ 
Note: See TracChangeset for help on using the changeset viewer.