Changeset b35d3d1 in sasview for guiframe/data_loader.py


Ignore:
Timestamp:
Aug 6, 2010 7:36:07 PM (14 years ago)
Author:
Jae Cho <jhjcho@…>
Branches:
master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
028a0e8
Parents:
a93f525
Message:

save state file: working, but more work to do

File:
1 edited

Legend:

Unmodified
Added
Removed
  • guiframe/data_loader.py

    raf47c8d rb35d3d1  
    150150                                                type="stop")) 
    151151     
    152 def plot_data(parent, path): 
     152def plot_data(parent, path, format=None): 
    153153    """ 
    154154    Use the DataLoader loader to created data to plot. 
    155155     
    156156    :param path: the path of the data to load 
    157      
     157    : param format: file format (as file extension) 
    158158    """ 
    159159    from sans.guicomm.events import NewPlotEvent, StatusEvent 
     
    165165    # Load data  
    166166    try: 
    167         output = L.load(path) 
     167        output = L.load(path, format) 
    168168    except: 
    169169        load_error(sys.exc_value) 
     
    235235        i=1 
    236236        for item in output: 
    237             msg = "Loading 1D data: %s"%str(item.run[0]) 
    238             wx.PostEvent(parent, StatusEvent(status=msg, info="info", type="stop")) 
    239237            try: 
    240                 dx = item.dx 
    241                 dxl = item.dxl 
    242                 dxw = item.dxw 
     238                msg = "Loading 1D data: %s"%str(item.run[0]) 
     239                wx.PostEvent(parent, StatusEvent(status=msg, info="info", type="stop")) 
     240                try: 
     241                    dx = item.dx 
     242                    dxl = item.dxl 
     243                    dxw = item.dxw 
     244                except: 
     245                    dx = None 
     246                    dxl = None 
     247                    dxw = None 
     248     
     249                new_plot = Data1D(x=item.x,y=item.y,dx=dx,dy=item.dy) 
     250                new_plot.copy_from_datainfo(item) 
     251                item.clone_without_data(clone=new_plot) 
     252                new_plot.dxl = dxl 
     253                new_plot.dxw = dxw 
     254                 
     255                name = parse_name(name=str(item.run[0]), expression="_") 
     256                #if not name in parent.indice_load_data.keys(): 
     257                #    parent.indice_load_data[name] = 0 
     258                #else: 
     259                    ## create a copy of the loaded data 
     260                     
     261                    #TODO: this is a very annoying feature. We should make this 
     262                    # an option. Excel doesn't do this. Why should we? 
     263                    # What is the requirement for this feature, and are the 
     264                    # counter arguments stronger? Is this feature developed 
     265                    # to please at least 80% of the users or a special few? 
     266                    #parent.indice_load_data[name] += 1 
     267                    #name = name + "(copy %i)"%parent.indice_load_data[name] 
     268                     
     269                new_plot.name = name 
     270                new_plot.interactive = True 
     271                new_plot.group_id = name 
     272                new_plot.id = name 
     273                new_plot.is_data = True 
     274             
     275                if hasattr(item,"title"): 
     276                    title = item.title.lstrip().rstrip() 
     277                    if title == "": 
     278                        title = str(name) 
     279                else: 
     280                    title = name 
     281                if hasattr(parent, "panel_on_focus") and not(parent.panel_on_focus is None): 
     282                    existing_panel  = parent.panel_on_focus 
     283                    panel_name = existing_panel.window_caption 
     284                    data_name = new_plot.name 
     285                    if enable_add_data(existing_panel, new_plot): 
     286                        if open_dialog_append_data(panel_name, data_name): 
     287                            #add this plot the an existing panel 
     288                            new_plot.group_id = existing_panel.group_id 
     289                wx.PostEvent(parent, NewPlotEvent(plot=new_plot, title=str(title))) 
     290                i+=1 
    243291            except: 
    244                 dx = None 
    245                 dxl = None 
    246                 dxw = None 
    247  
    248             new_plot = Data1D(x=item.x,y=item.y,dx=dx,dy=item.dy) 
    249             new_plot.copy_from_datainfo(item) 
    250             item.clone_without_data(clone=new_plot) 
    251             new_plot.dxl = dxl 
    252             new_plot.dxw = dxw 
    253             
    254             name = parse_name(name=str(item.run[0]), expression="_") 
    255             #if not name in parent.indice_load_data.keys(): 
    256             #    parent.indice_load_data[name] = 0 
    257             #else: 
    258                 ## create a copy of the loaded data 
    259                  
    260                 #TODO: this is a very annoying feature. We should make this 
    261                 # an option. Excel doesn't do this. Why should we? 
    262                 # What is the requirement for this feature, and are the 
    263                 # counter arguments stronger? Is this feature developed 
    264                 # to please at least 80% of the users or a special few? 
    265                 #parent.indice_load_data[name] += 1 
    266                 #name = name + "(copy %i)"%parent.indice_load_data[name] 
    267                  
    268             new_plot.name = name 
    269             new_plot.interactive = True 
    270             new_plot.group_id = name 
    271             new_plot.id = name 
    272             new_plot.is_data = True 
    273          
    274             if hasattr(item,"title"): 
    275                 title = item.title.lstrip().rstrip() 
    276                 if title == "": 
    277                     title = str(name) 
    278             else: 
    279                 title = name 
    280             if hasattr(parent, "panel_on_focus") and not(parent.panel_on_focus is None): 
    281                 existing_panel  = parent.panel_on_focus 
    282                 panel_name = existing_panel.window_caption 
    283                 data_name = new_plot.name 
    284                 if enable_add_data(existing_panel, new_plot): 
    285                     if open_dialog_append_data(panel_name, data_name): 
    286                         #add this plot the an existing panel 
    287                         new_plot.group_id = existing_panel.group_id 
    288             wx.PostEvent(parent, NewPlotEvent(plot=new_plot, title=str(title))) 
    289             i+=1 
    290           
     292                raise 
Note: See TracChangeset for help on using the changeset viewer.