Changeset b7c21a7 in sasview
- Timestamp:
- Aug 9, 2016 5:16:48 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:
- 9c500ab
- Parents:
- 3a38a8b
- git-author:
- Lewis O'Driscoll <lewis.o'driscoll@…> (08/09/16 05:15:42)
- git-committer:
- Lewis O'Driscoll <lewis.o'driscoll@…> (08/09/16 05:16:48)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/perspectives/file_converter/converter_panel.py
r5451a78 rb7c21a7 116 116 sasentry_attrs=entry_attrs) 117 117 118 def convert_to_red2d(self, filepath, x, y, frame_data): 119 """ 120 Writes Data2D objects to Red2D .dat files. If more than one frame is 121 provided, the frame number will be appended to the filename of each 122 file written. 123 124 :param filepath: The filepath to write to 125 :param x: The x column of the data 126 :param y: The y column of the data 127 :param frame_data: A dictionary of the form frame_number: data, where 128 data is a 2D numpy array containing the intensity data 129 """ 130 filename = os.path.split(filepath)[-1] 131 filepath = os.path.split(filepath)[0] 132 writer = Red2DWriter() 133 134 for i, frame in frame_data.iteritems(): 135 # If more than 1 frame is being exported, append the frame 136 # number to the filename 137 if len(frame_data) > 1: 138 frame_filename = filename.split('.') 139 frame_filename[0] += str(i+1) 140 frame_filename = '.'.join(frame_filename) 141 else: 142 frame_filename = filename 143 144 data_i = frame.reshape((len(x),1)) 145 data_info = Data2D(data=data_i, qx_data=x, qy_data=y) 146 writer.write(os.path.join(filepath, frame_filename), data_info) 147 118 148 def extract_ascii_data(self, filename): 119 149 """ … … 169 199 170 200 return qdata, iqdata 201 202 def extract_bsl_data(self, filename): 203 """ 204 Extracts data from a 2D BSL file 205 206 :param filename: The header file to extract the data from 207 :return x_data: A 1D array containing all the x coordinates of the data 208 :return y_data: A 1D array containing all the y coordinates of the data 209 :return frame_data: A dictionary of the form frame_number: data, where 210 data is a 2D numpy array containing the intensity data 211 """ 212 loader = BSLLoader(filename) 213 frames = [0] 214 if loader.n_frames > 1: 215 params = self.ask_frame_range(loader.n_frames) 216 frames = params['frames'] 217 frame_data = {} 218 219 for frame in frames: 220 loader.frame = frame 221 frame_data[frame] = loader.load_data() 222 223 # TODO: Tidy this up 224 # Prepare axes values (arbitrary scale) 225 x_data = [] 226 y_data = range(loader.n_pixels) * loader.n_rasters 227 for i in range(loader.n_rasters): 228 x_data += [i] * loader.n_pixels 229 230 return x_data, y_data, frame_data 171 231 172 232 def ask_frame_range(self, n_frames): … … 231 291 qdata, iqdata = self.extract_otoko_data(self.q_input.GetPath()) 232 292 else: # self.data_type == 'bsl' 233 # TODO: Refactor this into an extract_bsl_data method 234 loader = BSLLoader(self.iq_input.GetPath()) 235 frames = [0] 236 if loader.n_frames > 1: 237 params = self.ask_frame_range(loader.n_frames) 238 frames = params['frames'] 239 data = {} 240 241 for frame in frames: 242 loader.frame = frame 243 data[frame] = loader.load_data() 244 245 # TODO: Tidy this up 246 # Prepare axes values (arbitrary scale) 247 data_x = [] 248 data_y = range(loader.n_pixels) * loader.n_rasters 249 for i in range(loader.n_rasters): 250 data_x += [i] * loader.n_pixels 293 x_data, y_data, frame_data = self.extract_bsl_data( 294 self.iq_input.GetPath()) 251 295 252 296 file_path = self.output.GetPath() 253 filename = os.path.split(file_path)[-1] 254 file_path = os.path.split(file_path)[0] 255 for i, frame in data.iteritems(): 256 # If more than 1 frame is being exported, append the frame 257 # number to the filename 258 if len(data) > 1: 259 frame_filename = filename.split('.') 260 frame_filename[0] += str(i+1) 261 frame_filename = '.'.join(frame_filename) 262 else: 263 frame_filename = filename 264 265 data_i = frame.reshape((loader.n_pixels*loader.n_rasters,1)) 266 data_info = Data2D(data=data_i, qx_data=data_x, qy_data=data_y) 267 writer = Red2DWriter() 268 writer.write(os.path.join(file_path, frame_filename), data_info) 297 self.convert_to_red2d(file_path, x_data, y_data, frame_data) 269 298 270 299 wx.PostEvent(self.parent.manager.parent, … … 363 392 def show_detector_window(self, event): 364 393 """ 365 Show the window for inputting :class:`~sas.sascalc.dataloader.data_info.Detector~`metadata394 Show the window for inputting Detector metadata 366 395 """ 367 396 if self.meta_frames != []: … … 377 406 def show_sample_window(self, event): 378 407 """ 379 Show the window for inputting :class:`~sas.sascalc.dataloader.data_info.Sample~`metadata408 Show the window for inputting Sample metadata 380 409 """ 381 410 if self.meta_frames != []: … … 391 420 def show_source_window(self, event): 392 421 """ 393 Show the window for inputting :class:`~sas.sascalc.dataloader.data_info.Source~`metadata422 Show the window for inputting Source metadata 394 423 """ 395 424 if self.meta_frames != []:
Note: See TracChangeset
for help on using the changeset viewer.