Changeset 05595c4 in sasview for src/sas/sasgui/perspectives
- Timestamp:
- Aug 8, 2016 6:57:45 AM (8 years ago)
- 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, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- 489bb46
- Parents:
- 535e181
- Location:
- src/sas/sasgui/perspectives/file_converter
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/perspectives/file_converter/converter_panel.py
r535e181 r05595c4 5 5 import wx 6 6 import sys 7 import os 7 8 import numpy as np 8 9 from wx.lib.scrolledpanel import ScrolledPanel … … 21 22 from sas.sasgui.guiframe.utils import check_float 22 23 from sas.sasgui.perspectives.file_converter.cansas_writer import CansasWriter 24 from sas.sascalc.dataloader.readers.red2d_reader import Reader as Red2DWriter 23 25 from sas.sasgui.perspectives.file_converter.bsl_loader import BSLLoader as OTOKOLoader 24 26 from sas.sascalc.file_converter.bsl_loader import BSLLoader … … 136 138 def ask_frame_range(self, n_frames): 137 139 valid_input = False 138 dlg = FrameSelectDialog(n_frames) 140 is_bsl = (self.data_type == 'bsl') 141 dlg = FrameSelectDialog(n_frames, is_bsl) 139 142 frames = None 140 143 increment = None … … 147 150 last_frame = int(dlg.last_input.GetValue()) 148 151 increment = int(dlg.increment_input.GetValue()) 149 single_file = dlg.single_btn.GetValue() 152 if not is_bsl: 153 single_file = dlg.single_btn.GetValue() 154 150 155 if last_frame < 0 or first_frame < 0: 151 156 msg = "Frame values must be positive" … … 154 159 elif first_frame > last_frame: 155 160 msg = "First frame must be less than last frame" 156 elif last_frame > n_frames:161 elif last_frame >= n_frames: 157 162 msg = "Last frame must be less than {}".format(n_frames) 158 163 else: … … 189 194 params = self.ask_frame_range(loader.n_frames) 190 195 frames = params['frames'] 191 data = [] 196 data = {} 197 192 198 for frame in frames: 193 199 loader.frame = frame 194 data.append(loader.load_data()) 195 data = data[0] 200 data[frame] = loader.load_data() 201 202 # TODO: Tidy this up 203 # Prepare axes values (arbitrary scale) 196 204 data_x = [] 197 205 data_y = range(loader.n_pixels) * loader.n_rasters 198 data_i = data.reshape((loader.n_pixels*loader.n_rasters,1))199 206 for i in range(loader.n_rasters): 200 207 data_x += [i] * loader.n_pixels 201 import pdb; pdb.set_trace() 202 data_info = Data2D(data=data_i, qx_data=data_x, qy_data=data_y) 203 from sas.sascalc.dataloader.readers.red2d_reader import Reader as Writer2D 204 writer = Writer2D() 205 writer.write(self.output.GetPath(), data_info) 208 209 file_path = self.output.GetPath() 210 filename = os.path.split(file_path)[-1] 211 file_path = os.path.split(file_path)[0] 212 for i, frame in data.iteritems(): 213 # If more than 1 frame is being exported, append the frame 214 # number to the filename 215 if len(data) > 1: 216 frame_filename = filename.split('.') 217 frame_filename[0] += str(i+1) 218 frame_filename = '.'.join(frame_filename) 219 else: 220 frame_filename = filename 221 222 data_i = frame.reshape((loader.n_pixels*loader.n_rasters,1)) 223 data_info = Data2D(data=data_i, qx_data=data_x, qy_data=data_y) 224 writer = Red2DWriter() 225 writer.write(os.path.join(file_path, frame_filename), data_info) 226 206 227 wx.PostEvent(self.parent.manager.parent, 207 228 StatusEvent(status="Conversion completed.")) … … 217 238 increment = 1 218 239 single_file = True 240 n_frames = iqdata.shape[0] 219 241 # Standard file has 3 frames: SAS, calibration and WAS 220 if iqdata.shape[0]> 3:242 if n_frames > 3: 221 243 # File has multiple frames 222 params = self.ask_frame_range( frames[0])244 params = self.ask_frame_range(n_frames) 223 245 frames = params['frames'] 224 246 increment = params['inc'] … … 333 355 self.data_type = dtype 334 356 if dtype == 'bsl': 357 self.q_input.SetPath("") 335 358 self.q_input.Disable() 336 359 else: … … 425 448 message="Chose where to save the output file.", 426 449 style=wx.FLP_SAVE | wx.FLP_OVERWRITE_PROMPT | wx.FLP_USE_TEXTCTRL, 427 wildcard=" *.xml")450 wildcard="CanSAS 1D (*.xml)|*.xml|Red2D (*.dat)|*.dat") 428 451 input_grid.Add(self.output, (y,1), (1,1), wx.ALL, 5) 429 452 y += 1 -
src/sas/sasgui/perspectives/file_converter/frame_select_dialog.py
r94f4518 r05595c4 3 3 class FrameSelectDialog(wx.Dialog): 4 4 5 def __init__(self, n_frames ):5 def __init__(self, n_frames, is_bsl=False): 6 6 wx.Dialog.__init__(self, None, title="Select Frames") 7 7 … … 40 40 y += 1 41 41 42 export_label = wx.StaticText(self, -1, "Export each frame to:") 43 sizer.Add(export_label, (y,0), (1,1), wx.LEFT | wx.RIGHT | wx.TOP, 5) 44 y += 1 42 if not is_bsl: 43 export_label = wx.StaticText(self, -1, "Export each frame to:") 44 sizer.Add(export_label, (y,0), (1,1), wx.LEFT | wx.RIGHT | wx.TOP, 5) 45 y += 1 45 46 46 self.single_btn = wx.RadioButton(self, -1, label="The same file",47 style=wx.RB_GROUP)48 sizer.Add(self.single_btn, (y,0), (1,1),49 wx.LEFT | wx.RIGHT | wx.BOTTOM, 5)47 self.single_btn = wx.RadioButton(self, -1, label="The same file", 48 style=wx.RB_GROUP) 49 sizer.Add(self.single_btn, (y,0), (1,1), 50 wx.LEFT | wx.RIGHT | wx.BOTTOM, 5) 50 51 51 multiple_btn = wx.RadioButton(self, -1, label="Multiple files")52 sizer.Add(multiple_btn, (y,1), (1,1),53 wx.LEFT | wx.RIGHT | wx.BOTTOM, 5)54 y += 152 multiple_btn = wx.RadioButton(self, -1, label="Multiple files") 53 sizer.Add(multiple_btn, (y,1), (1,1), 54 wx.LEFT | wx.RIGHT | wx.BOTTOM, 5) 55 y += 1 55 56 56 57 done_btn = wx.Button(self, wx.ID_OK) … … 63 64 64 65 size = self.GetSize() 65 size.height += 35 66 if not is_bsl: 67 size.height += 35 66 68 self.SetSize(size)
Note: See TracChangeset
for help on using the changeset viewer.