Changeset ca2bdae in sasview for fittingview
- Timestamp:
- Sep 13, 2011 5:17:52 PM (13 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, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- fba201a0
- Parents:
- 05325ec4
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fittingview/src/sans/perspectives/fitting/fitting.py
rcfcb7197 rca2bdae 1498 1498 instead of calling expansive CalcChisqr in guithread 1499 1499 """ 1500 data = deepcopy(data)1500 data_copy = deepcopy(data) 1501 1501 1502 1502 # default chisqr … … 1504 1504 #to compute chisq make sure data has valid data 1505 1505 # return None if data == None 1506 if not check_data_validity(data ):1506 if not check_data_validity(data_copy): 1507 1507 return chisqr 1508 1508 1509 1509 # Get data: data I, theory I, and data dI in order 1510 if data .__class__.__name__ == "Data2D":1510 if data_copy.__class__.__name__ == "Data2D": 1511 1511 if index == None: 1512 index = numpy.ones(len(data .data),ntype=bool)1512 index = numpy.ones(len(data_copy.data),ntype=bool) 1513 1513 if self.weight != None: 1514 data .err_data = self.weight1514 data_copy.err_data = self.weight 1515 1515 # get rid of zero error points 1516 index = index & (data .err_data != 0)1517 index = index & (numpy.isfinite(data .data))1518 fn = data .data[index]1519 theory_data = self.page_finder[page_id].get_theory_data(fid=data .id)1516 index = index & (data_copy.err_data != 0) 1517 index = index & (numpy.isfinite(data_copy.data)) 1518 fn = data_copy.data[index] 1519 theory_data = self.page_finder[page_id].get_theory_data(fid=data_copy.id) 1520 1520 gn = theory_data.data[index] 1521 en = data .err_data[index]1521 en = data_copy.err_data[index] 1522 1522 else: 1523 1523 # 1 d theory from model_thread is only in the range of index 1524 1524 if index == None: 1525 index = numpy.ones(len(data .y), ntype=bool)1525 index = numpy.ones(len(data_copy.y), ntype=bool) 1526 1526 if self.weight != None: 1527 data .dy = self.weight1528 if data .dy == None or data.dy == []:1529 dy = numpy.ones(len(data .y))1527 data_copy.dy = self.weight 1528 if data_copy.dy == None or data_copy.dy == []: 1529 dy = numpy.ones(len(data_copy.y)) 1530 1530 else: 1531 1531 ## Set consitently w/AbstractFitengine: 1532 1532 # But this should be corrected later. 1533 dy = deepcopy(data .dy)1533 dy = deepcopy(data_copy.dy) 1534 1534 dy[dy==0] = 1 1535 fn = data .y[index]1536 theory_data = self.page_finder[page_id].get_theory_data(fid=data .id)1535 fn = data_copy.y[index] 1536 theory_data = self.page_finder[page_id].get_theory_data(fid=data_copy.id) 1537 1537 gn = theory_data.y 1538 1538 en = dy[index] … … 1542 1542 # get chisqr only w/finite 1543 1543 chisqr = numpy.average(residuals * residuals) 1544 self._plot_residuals(page_id, data, index) 1545 #reset weight 1546 self.weight = None 1544 self._plot_residuals(page_id, data_copy, index) 1545 1547 1546 return chisqr 1548 1547 … … 1555 1554 : Note: this is different from the residuals in cal_chisqr() 1556 1555 """ 1556 data_copy = deepcopy(data) 1557 1557 # Get data: data I, theory I, and data dI in order 1558 if data .__class__.__name__ == "Data2D":1558 if data_copy.__class__.__name__ == "Data2D": 1559 1559 # build residuals 1560 1560 residuals = Data2D() 1561 1561 #residuals.copy_from_datainfo(data) 1562 1562 # Not for trunk the line below, instead use the line above 1563 data .clone_without_data(len(data.data), residuals)1563 data_copy.clone_without_data(len(data_copy.data), residuals) 1564 1564 residuals.data = None 1565 fn = data .data#[index]1566 theory_data = self.page_finder[page_id].get_theory_data(fid=data .id)1565 fn = data_copy.data#[index] 1566 theory_data = self.page_finder[page_id].get_theory_data(fid=data_copy.id) 1567 1567 gn = theory_data.data#[index] 1568 en = data.err_data#[index]1568 en = self.weight#data_copy.err_data#[index] 1569 1569 residuals.data = (fn - gn) / en 1570 residuals.qx_data = data .qx_data#[index]1571 residuals.qy_data = data .qy_data #[index]1572 residuals.q_data = data .q_data#[index]1570 residuals.qx_data = data_copy.qx_data#[index] 1571 residuals.qy_data = data_copy.qy_data #[index] 1572 residuals.q_data = data_copy.q_data#[index] 1573 1573 residuals.err_data = numpy.ones(len(residuals.data))#[index] 1574 1574 residuals.xmin = min(residuals.qx_data) … … 1576 1576 residuals.ymin = min(residuals.qy_data) 1577 1577 residuals.ymax = max(residuals.qy_data) 1578 residuals.q_data = data .q_data#[index]1579 residuals.mask = data .mask1578 residuals.q_data = data_copy.q_data#[index] 1579 residuals.mask = data_copy.mask 1580 1580 residuals.scale = 'linear' 1581 1581 # check the lengths … … 1584 1584 else: 1585 1585 # 1 d theory from model_thread is only in the range of index 1586 if data .dy == None or data.dy == []:1587 dy = numpy.ones(len(data .y))1586 if data_copy.dy == None or data_copy.dy == []: 1587 dy = numpy.ones(len(data_copy.y)) 1588 1588 else: 1589 1589 ## Set consitently w/AbstractFitengine: 1590 1590 ## But this should be corrected later. 1591 dy = deepcopy(data.dy)1591 dy = self.weight#deepcopy(data_copy.dy) 1592 1592 dy[dy==0] = 1 1593 fn = data .y[index]1594 theory_data = self.page_finder[page_id].get_theory_data(fid=data .id)1593 fn = data_copy.y[index] 1594 theory_data = self.page_finder[page_id].get_theory_data(fid=data_copy.id) 1595 1595 gn = theory_data.y 1596 1596 en = dy[index] … … 1598 1598 residuals = Data1D() 1599 1599 residuals.y = (fn - gn) / en 1600 residuals.x = data .x[index]1600 residuals.x = data_copy.x[index] 1601 1601 residuals.dy = numpy.ones(len(residuals.y)) 1602 1602 residuals.dx = None … … 1620 1620 1621 1621 # plot data 1622 wx.PostEvent(self.parent, NewPlotEvent(plot=new_plot, title=title)) 1623 1622 wx.PostEvent(self.parent, NewPlotEvent(plot=new_plot, title=title)) 1623 #reset weight 1624 self.weight = None 1624 1625 #def profile(fn, *args, **kw): 1625 1626 # import cProfile, pstats, os
Note: See TracChangeset
for help on using the changeset viewer.