Changeset 8db20a9 in sasview for src/sas/qtgui


Ignore:
Timestamp:
Jan 21, 2019 6:15:40 AM (5 years ago)
Author:
Piotr Rozyczko <piotr.rozyczko@…>
Branches:
ESS_GUI, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_opencl, ESS_GUI_sync_sascalc
Children:
d541324e
Parents:
3ca645bb
git-author:
Piotr Rozyczko <piotr.rozyczko@…> (01/21/19 06:12:08)
git-committer:
Piotr Rozyczko <piotr.rozyczko@…> (01/21/19 06:15:40)
Message:

Updated cansas read (cherrypicked and fixed from master).
Fixes: hdf5 returns byte strings so these need to be recasted properly.
https://github.com/h5py/h5py/issues/379

Location:
src/sas/qtgui
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/sas/qtgui/Plotting/Plotter2D.py

    r21e71f1 r8db20a9  
    468468        # check scale 
    469469        if self.scale == 'log_{10}': 
    470             try: 
    471                 if  self.zmin is None  and len(output[output > 0]) > 0: 
    472                     zmin_temp = self.zmin 
    473                     output[output > 0] = numpy.log10(output[output > 0]) 
    474                 elif self.zmin <= 0: 
    475                     zmin_temp = self.zmin 
    476                     output[output > 0] = numpy.zeros(len(output)) 
    477                     output[output <= 0] = MIN_Z 
    478                 else: 
    479                     zmin_temp = self.zmin 
    480                     output[output > 0] = numpy.log10(output[output > 0]) 
    481             except: 
    482                 #Too many problems in 2D plot with scale 
    483                 pass 
     470            with numpy.errstate(all='ignore'): 
     471                output = numpy.log10(output) 
     472            index = numpy.isfinite(output) 
     473            if not index.all(): 
     474                cutoff = (numpy.quantile(output[index], 0.05) - numpy.log10(2) if index.any() else 0.) 
     475                output[output < cutoff] = cutoff 
     476                output[~index] = cutoff 
     477        vmin, vmax = None, None 
    484478 
    485479        self.cmap = cmap 
  • src/sas/qtgui/Utilities/GuiUtils.py

    r10786bc2 r8db20a9  
    4444 
    4545from sas.sascalc.dataloader.loader import Loader 
     46from sas.sascalc.file_converter.nxcansas_writer import NXcanSASWriter 
     47 
    4648from sas.qtgui.Utilities import CustomDir 
    4749 
     
    793795 
    794796    wildcard = "Text files (*.txt);;"\ 
    795                 "CanSAS 1D files(*.xml)" 
     797                "CanSAS 1D files(*.xml);;"\ 
     798                "NXcanSAS files (*.h5)" 
    796799    kwargs = { 
    797800        'caption'   : 'Save As', 
     
    812815    if os.path.splitext(filename)[1].lower() == ".txt": 
    813816        onTXTSave(data, filename) 
    814     if os.path.splitext(filename)[1].lower() == ".xml": 
     817    elif os.path.splitext(filename)[1].lower() == ".xml": 
    815818        loader.save(filename, data, ".xml") 
     819    elif os.path.splitext(filename)[1].lower() == ".h5": 
     820        nxcansaswriter = NXcanSASWriter() 
     821        nxcansaswriter.write([data], filename) 
    816822 
    817823def saveData2D(data): 
     
    824830    default_name += "_out" + ext_format 
    825831 
    826     wildcard = "IGOR/DAT 2D file in Q_map (*.dat)" 
     832    wildcard = "IGOR/DAT 2D file in Q_map (*.dat);;"\ 
     833                "NXcanSAS files (*.h5)" 
    827834    kwargs = { 
    828835        'caption'   : 'Save As', 
     
    844851    if os.path.splitext(filename)[1].lower() == ext_format: 
    845852        loader.save(filename, data, ext_format) 
     853    elif os.path.splitext(filename)[1].lower() == ".h5": 
     854        nxcansaswriter = NXcanSASWriter() 
     855        nxcansaswriter.write([data], filename) 
     856 
    846857 
    847858class FormulaValidator(QtGui.QValidator): 
Note: See TracChangeset for help on using the changeset viewer.