Changeset 729198e in sasview for src/sas/sasgui/perspectives
- Timestamp:
- Sep 11, 2017 6:55:51 AM (7 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.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- ff65d02
- Parents:
- 2d9526d (diff), e2b2473 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - Location:
- src/sas/sasgui/perspectives
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/perspectives/file_converter/converter_panel.py
red9f872 r19296dc 24 24 from sas.sascalc.file_converter.otoko_loader import OTOKOLoader 25 25 from sas.sascalc.file_converter.bsl_loader import BSLLoader 26 from sas.sascalc.file_converter.ascii2d_loader import ASCII2DLoader 26 27 from sas.sascalc.file_converter.nxcansas_writer import NXcanSASWriter 27 28 from sas.sascalc.dataloader.data_info import Detector … … 35 36 _STATICBOX_WIDTH = 410 36 37 _BOX_WIDTH = 200 37 PANEL_SIZE = 48038 PANEL_SIZE = 520 38 39 FONT_VARIANT = 0 39 40 else: … … 41 42 _STATICBOX_WIDTH = 430 42 43 _BOX_WIDTH = 200 43 PANEL_SIZE = 5 0044 PANEL_SIZE = 540 44 45 FONT_VARIANT = 1 45 46 … … 352 353 w.write(frame_data, output_path) 353 354 355 def convert_2d_data(self, dataset): 356 metadata = self.get_metadata() 357 for key, value in metadata.iteritems(): 358 setattr(dataset[0], key, value) 359 360 w = NXcanSASWriter() 361 w.write(dataset, self.output.GetPath()) 362 354 363 def on_convert(self, event): 355 364 """Called when the Convert button is clicked""" … … 367 376 qdata, iqdata = self.extract_otoko_data(self.q_input.GetPath()) 368 377 self.convert_1d_data(qdata, iqdata) 378 elif self.data_type == 'ascii2d': 379 loader = ASCII2DLoader(self.iq_input.GetPath()) 380 data = loader.load() 381 dataset = [data] # ASCII 2D only ever contains 1 frame 382 self.convert_2d_data(dataset) 369 383 else: # self.data_type == 'bsl' 370 384 dataset = self.extract_bsl_data(self.iq_input.GetPath()) … … 372 386 # Cancelled by user 373 387 return 374 375 metadata = self.get_metadata() 376 for key, value in metadata.iteritems(): 377 setattr(dataset[0], key, value) 378 379 w = NXcanSASWriter() 380 w.write(dataset, self.output.GetPath()) 388 self.convert_2d_data(dataset) 389 381 390 except Exception as ex: 382 391 msg = str(ex) … … 399 408 def validate_inputs(self): 400 409 msg = "You must select a" 401 if self.q_input.GetPath() == '' and self.data_type != 'bsl': 410 if self.q_input.GetPath() == '' and self.data_type != 'bsl' \ 411 and self.data_type != 'ascii2d': 402 412 msg += " Q Axis input file." 403 413 elif self.iq_input.GetPath() == '': … … 472 482 dtype = event.GetEventObject().GetName() 473 483 self.data_type = dtype 474 if dtype == 'bsl' :484 if dtype == 'bsl' or dtype == 'ascii2d': 475 485 self.q_input.SetPath("") 476 486 self.q_input.Disable() … … 500 510 501 511 instructions = ( 502 "Select linked single column 1D ASCII files containing the Q-axis and " 503 "Intensity-axis data, or 1D BSL/OTOKO files, or a 2D BSL/OTOKO file, " 504 "then choose where to save the converted file, and click Convert.\n" 505 "1D ASCII and BSL/OTOKO files can be converted to CanSAS (XML) or " 506 "NXcanSAS (HDF5) formats. 2D BSL/OTOKO files can only be converted to " 507 "the NXcanSAS format.\n" 508 "Metadata can be optionally added for the CanSAS XML format." 512 "If converting a 1D dataset, select linked single-column ASCII files " 513 "containing the Q-axis and intensity-axis data, or a 1D BSL/OTOKO file." 514 " If converting 2D data, select an ASCII file in the ISIS 2D file " 515 "format, or a 2D BSL/OTOKO file. Choose where to save the converted " 516 "file and click convert.\n" 517 "One dimensional ASCII and BSL/OTOKO files can be converted to CanSAS " 518 "(XML) or NXcanSAS (HDF5) formats. Two dimensional datasets can only be" 519 " converted to the NXcanSAS format.\n" 520 "Metadata can also be optionally added to the output file." 509 521 ) 510 522 … … 526 538 wx.ALIGN_CENTER_VERTICAL, 5) 527 539 radio_sizer = wx.BoxSizer(wx.HORIZONTAL) 528 ascii_btn = wx.RadioButton(self, -1, "ASCII ", name="ascii",540 ascii_btn = wx.RadioButton(self, -1, "ASCII 1D", name="ascii", 529 541 style=wx.RB_GROUP) 530 542 ascii_btn.Bind(wx.EVT_RADIOBUTTON, self.datatype_changed) 531 543 radio_sizer.Add(ascii_btn) 544 ascii2d_btn = wx.RadioButton(self, -1, "ASCII 2D", name="ascii2d") 545 ascii2d_btn.Bind(wx.EVT_RADIOBUTTON, self.datatype_changed) 546 radio_sizer.Add(ascii2d_btn) 532 547 otoko_btn = wx.RadioButton(self, -1, "BSL 1D", name="otoko") 533 548 otoko_btn.Bind(wx.EVT_RADIOBUTTON, self.datatype_changed) 534 549 radio_sizer.Add(otoko_btn) 535 input_grid.Add(radio_sizer, (y,1), (1,1), wx.ALL, 5)536 550 bsl_btn = wx.RadioButton(self, -1, "BSL 2D", name="bsl") 537 551 bsl_btn.Bind(wx.EVT_RADIOBUTTON, self.datatype_changed) 538 552 radio_sizer.Add(bsl_btn) 553 input_grid.Add(radio_sizer, (y,1), (1,1), wx.ALL, 5) 539 554 y += 1 540 555 … … 549 564 y += 1 550 565 551 iq_label = wx.StaticText(self, -1, "Intensity -AxisData: ")566 iq_label = wx.StaticText(self, -1, "Intensity Data: ") 552 567 input_grid.Add(iq_label, (y,0), (1,1), wx.ALIGN_CENTER_VERTICAL, 5) 553 568 … … 647 662 648 663 def __init__(self, parent=None, title='File Converter', base=None, 649 manager=None, size=(PANEL_SIZE * 1.05, PANEL_SIZE / 1.1),664 manager=None, size=(PANEL_SIZE * 0.96, PANEL_SIZE * 0.9), 650 665 *args, **kwargs): 651 666 kwargs['title'] = title -
src/sas/sasgui/perspectives/file_converter/file_converter.py
r463e7ffc r94e3572 25 25 Returns a set of menu entries 26 26 """ 27 help_txt = "Convert single column ASCII data to CanSAS format"27 help_txt = "Convert ASCII or BSL/OTOKO data to CanSAS or NXcanSAS formats" 28 28 return [("File Converter", help_txt, self.on_file_converter)] 29 29 -
src/sas/sasgui/perspectives/file_converter/media/file_converter_help.rst
rd73998c r59decb81 18 18 * Single-column ASCII data, with lines that end without any delimiter, 19 19 or with a comma or semi-colon delimiter 20 * 2D `ISIS ASCII formatted 21 <http://www.isis.stfc.ac.uk/instruments/loq/software/ 22 colette-ascii-file-format-descriptions9808.pdf>`_ data 20 23 * `1D BSL/OTOKO format 21 24 <http://www.diamond.ac.uk/Beamlines/Soft-Condensed-Matter/small-angle/ … … 36 39 37 40 1) Select the files containing your Q-axis and Intensity-axis data 38 2) Choose whether the files are in ASCII , 1D BSL/OTOKO or 2D BSL/OTOKO format41 2) Choose whether the files are in ASCII 1D, ASCII 2D, 1D BSL/OTOKO or 2D BSL/OTOKO format 39 42 3) Choose where you would like to save the converted file 40 43 4) Optionally, input some metadata such as sample size, detector name, etc … … 47 50 file, a dialog will appear asking which frames you would like converted. You 48 51 may enter a start frame, end frame & increment, and all frames in that subset 49 will be converted. For example, entering 0, 50 and 10 will convert frames 0, 52 will be converted. For example, entering 0, 50 and 10 will convert frames 0, 50 53 10, 20, 30, 40 & 50. 51 54 … … 56 59 single file, so there is an option in the *Select Frame* dialog to output each 57 60 frame to its own file. The single file option will produce one file with 58 multiple `<SASdata>` elements. The multiple file option will output a separate 59 file with one `<SASdata>` element for each frame. The frame number will also be 61 multiple `<SASdata>` elements. The multiple file option will output a separate 62 file with one `<SASdata>` element for each frame. The frame number will also be 60 63 appended to the file name. 61 64 62 The multiple file option is not available when exporting to NXcanSAS because 65 The multiple file option is not available when exporting to NXcanSAS because 63 66 the HDF5 format is more efficient at handling large amounts of data. 64 67 -
src/sas/sasgui/perspectives/fitting/fitting.py
r489f53a r2d9526d 1742 1742 @param unsmeared_error: data error, rescaled to unsmeared model 1743 1743 """ 1744 1745 1744 number_finite = np.count_nonzero(np.isfinite(y)) 1746 1745 np.nan_to_num(y) … … 1748 1747 data_description=model.name, 1749 1748 data_id=str(page_id) + " " + data.name) 1749 plots_to_update = [] # List of plottables that have changed since last calculation 1750 # Create the new theories 1750 1751 if unsmeared_model is not None: 1751 self.create_theory_1D(x, unsmeared_model, page_id, model, data, state, 1752 unsmeared_model_plot = self.create_theory_1D(x, unsmeared_model, 1753 page_id, model, data, state, 1752 1754 data_description=model.name + " unsmeared", 1753 1755 data_id=str(page_id) + " " + data.name + " unsmeared") 1756 plots_to_update.append(unsmeared_model_plot) 1754 1757 1755 1758 if unsmeared_data is not None and unsmeared_error is not None: 1756 self.create_theory_1D(x, unsmeared_data, page_id, model, data, state, 1759 unsmeared_data_plot = self.create_theory_1D(x, unsmeared_data, 1760 page_id, model, data, state, 1757 1761 data_description="Data unsmeared", 1758 1762 data_id="Data " + data.name + " unsmeared", 1759 1763 dy=unsmeared_error) 1760 # Comment this out until we can get P*S models with correctly populated parameters 1761 #if sq_model is not None and pq_model is not None: 1762 # self.create_theory_1D(x, sq_model, page_id, model, data, state, 1763 # data_description=model.name + " S(q)", 1764 # data_id=str(page_id) + " " + data.name + " S(q)") 1765 # self.create_theory_1D(x, pq_model, page_id, model, data, state, 1766 # data_description=model.name + " P(q)", 1767 # data_id=str(page_id) + " " + data.name + " P(q)") 1764 plots_to_update.append(unsmeared_data_plot) 1765 if sq_model is not None and pq_model is not None: 1766 sq_id = str(page_id) + " " + data.name + " S(q)" 1767 sq_plot = self.create_theory_1D(x, sq_model, page_id, model, data, state, 1768 data_description=model.name + " S(q)", 1769 data_id=sq_id) 1770 plots_to_update.append(sq_plot) 1771 pq_id = str(page_id) + " " + data.name + " P(q)" 1772 pq_plot = self.create_theory_1D(x, pq_model, page_id, model, data, state, 1773 data_description=model.name + " P(q)", 1774 data_id=pq_id) 1775 plots_to_update.append(pq_plot) 1776 # Update the P(Q), S(Q) and unsmeared theory plots if they exist 1777 wx.PostEvent(self.parent, NewPlotEvent(plots=plots_to_update, 1778 action='update')) 1768 1779 1769 1780 current_pg = self.fit_panel.get_page_by_id(page_id) -
src/sas/sasgui/perspectives/fitting/model_thread.py
r7432acb r0f9ea1c 71 71 (self.data.qy_data * self.data.qy_data)) 72 72 73 # For theory, qmax is based on 1d qmax 73 # For theory, qmax is based on 1d qmax 74 74 # so that must be mulitified by sqrt(2) to get actual max for 2d 75 75 index_model = (self.qmin <= radius) & (radius <= self.qmax) … … 91 91 self.data.qy_data[index_model] 92 92 ]) 93 output = np.zeros(len(self.data.qx_data)) 93 # Initialize output to NaN so masked elements do not get plotted. 94 output = np.empty_like(self.data.qx_data) 94 95 # output default is None 95 96 # This method is to distinguish between masked 96 97 #point(nan) and data point = 0. 97 output = output / output98 output[:] = np.NaN 98 99 # set value for self.mask==True, else still None to Plottools 99 100 output[index_model] = value … … 198 199 output[index] = self.model.evalDistribution(self.data.x[index]) 199 200 201 x=self.data.x[index] 202 y=output[index] 200 203 sq_values = None 201 204 pq_values = None 202 s_model = None203 p_model = None204 205 if isinstance(self.model, MultiplicationModel): 205 206 s_model = self.model.s_model 206 207 p_model = self.model.p_model 207 elif hasattr(self.model, "get_composition_models"): 208 p_model, s_model = self.model.get_composition_models() 209 210 if p_model is not None and s_model is not None: 211 sq_values = np.zeros((len(self.data.x))) 212 pq_values = np.zeros((len(self.data.x))) 213 sq_values[index] = s_model.evalDistribution(self.data.x[index]) 214 pq_values[index] = p_model.evalDistribution(self.data.x[index]) 208 sq_values = s_model.evalDistribution(x) 209 pq_values = p_model.evalDistribution(x) 210 elif hasattr(self.model, "calc_composition_models"): 211 results = self.model.calc_composition_models(x) 212 if results is not None: 213 pq_values, sq_values = results 214 215 215 216 216 elapsed = time.time() - self.starttime 217 217 218 self.complete(x= self.data.x[index], y=output[index],218 self.complete(x=x, y=y, 219 219 page_id=self.page_id, 220 220 state=self.state,
Note: See TracChangeset
for help on using the changeset viewer.