Changeset 4b862c4 in sasview for src/sas/sasgui/perspectives/file_converter
- Timestamp:
- Jul 19, 2016 7:09:53 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:
- a027549
- Parents:
- 3a9801f
- Location:
- src/sas/sasgui/perspectives/file_converter
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/perspectives/file_converter/converter_panel.py
r9318c4e r4b862c4 17 17 from sas.sasgui.guiframe.utils import check_float 18 18 from sas.sascalc.dataloader.readers.cansas_reader import Reader as CansasReader 19 from sas.sasgui.perspectives.file_converter.bsl_loader import BSLLoader 19 20 from sas.sascalc.dataloader.data_info import Detector 20 21 from sas.sascalc.dataloader.data_info import Sample … … 50 51 self.iq_input = None 51 52 self.output = None 53 self.data_type = "ascii" 52 54 53 55 self.metadata = { … … 59 61 'sample': Sample() 60 62 } 63 64 self.metadata['detector'][0].name = '' 61 65 62 66 self._do_layout() … … 98 102 99 103 try: 100 qdata = self.extract_data(self.q_input.GetPath()) 101 iqdata = self.extract_data(self.iq_input.GetPath()) 104 if self.data_type == 'ascii': 105 qdata = self.extract_data(self.q_input.GetPath()) 106 iqdata = self.extract_data(self.iq_input.GetPath()) 107 else: # self.data_type == 'bsl' 108 loader = BSLLoader(self.q_input.GetPath(), 109 self.iq_input.GetPath()) 110 bsl_data = loader.load_bsl_data() 111 qdata = bsl_data.q_axis.data[0] 112 iqdata = bsl_data.data_axis.data[0] 102 113 except Exception as ex: 103 114 msg = str(ex) … … 175 186 sample_frame.Show(True) 176 187 188 def datatype_changed(self, event): 189 event.Skip() 190 dtype = event.GetEventObject().GetName() 191 self.data_type = dtype 192 177 193 def metadata_changed(self, event): 178 194 event.Skip() … … 190 206 vbox = wx.BoxSizer(wx.VERTICAL) 191 207 192 instructions = ("Select the 1 column ASCII files containing the Q Axis"193 " and Intensity data, chose where to save the converted file, then"194 " click Convert to convert them to CanSAS XML format. If required,"195 " metadata can also be input below.")208 instructions = ("Select either 1 column ASCII files or BSL files " 209 "containing the Q Axis and Intensity data, chose where to save " 210 "the converted file, then click Convert to convert them to CanSAS " 211 "XML format. If required, metadata can also be input below.") 196 212 instruction_label = wx.StaticText(self, -1, instructions, 197 213 size=(_STATICBOX_WIDTH+40, -1)) … … 205 221 input_grid = wx.GridBagSizer(5, 5) 206 222 223 y = 0 224 207 225 q_label = wx.StaticText(self, -1, "Q Axis: ") 208 input_grid.Add(q_label, ( 0,0), (1,1), wx.ALIGN_CENTER_VERTICAL, 5)226 input_grid.Add(q_label, (y,0), (1,1), wx.ALIGN_CENTER_VERTICAL, 5) 209 227 210 228 self.q_input = wx.FilePickerCtrl(self, -1, 211 229 size=(_STATICBOX_WIDTH-80, -1), 212 230 message="Chose the Q Axis data file.") 213 input_grid.Add(self.q_input, (0,1), (1,1), wx.ALL, 5) 231 input_grid.Add(self.q_input, (y,1), (1,1), wx.ALL, 5) 232 y += 1 214 233 215 234 iq_label = wx.StaticText(self, -1, "Intensity Data: ") 216 input_grid.Add(iq_label, ( 1,0), (1,1), wx.ALIGN_CENTER_VERTICAL, 5)235 input_grid.Add(iq_label, (y,0), (1,1), wx.ALIGN_CENTER_VERTICAL, 5) 217 236 218 237 self.iq_input = wx.FilePickerCtrl(self, -1, 219 238 size=(_STATICBOX_WIDTH-80, -1), 220 239 message="Chose the Intensity data file.") 221 input_grid.Add(self.iq_input, (1,1), (1,1), wx.ALL, 5) 240 input_grid.Add(self.iq_input, (y,1), (1,1), wx.ALL, 5) 241 y += 1 242 243 data_type_label = wx.StaticText(self, -1, "Input Format: ") 244 input_grid.Add(data_type_label, (y,0), (1,1), 245 wx.ALIGN_CENTER_VERTICAL, 5) 246 radio_sizer = wx.BoxSizer(wx.HORIZONTAL) 247 ascii_btn = wx.RadioButton(self, -1, "ASCII", name="ascii", 248 style=wx.RB_GROUP) 249 ascii_btn.Bind(wx.EVT_RADIOBUTTON, self.datatype_changed) 250 radio_sizer.Add(ascii_btn) 251 bsl_btn = wx.RadioButton(self, -1, "BSL", name="bsl") 252 bsl_btn.Bind(wx.EVT_RADIOBUTTON, self.datatype_changed) 253 radio_sizer.Add(bsl_btn) 254 input_grid.Add(radio_sizer, (y,1), (1,1), wx.ALL, 5) 255 y += 1 222 256 223 257 output_label = wx.StaticText(self, -1, "Output File: ") 224 input_grid.Add(output_label, ( 2,0), (1,1), wx.ALIGN_CENTER_VERTICAL, 5)258 input_grid.Add(output_label, (y,0), (1,1), wx.ALIGN_CENTER_VERTICAL, 5) 225 259 226 260 self.output = wx.FilePickerCtrl(self, -1, … … 229 263 style=wx.FLP_SAVE | wx.FLP_OVERWRITE_PROMPT | wx.FLP_USE_TEXTCTRL, 230 264 wildcard="*.xml") 231 input_grid.Add(self.output, (2,1), (1,1), wx.ALL, 5) 265 input_grid.Add(self.output, (y,1), (1,1), wx.ALL, 5) 266 y += 1 232 267 233 268 convert_btn = wx.Button(self, wx.ID_OK, "Convert") 234 input_grid.Add(convert_btn, ( 3,0), (1,1), wx.ALL, 5)269 input_grid.Add(convert_btn, (y,0), (1,1), wx.ALL, 5) 235 270 convert_btn.Bind(wx.EVT_BUTTON, self.on_convert) 236 271
Note: See TracChangeset
for help on using the changeset viewer.