Changeset fa4af76 in sasview for src/sas/sascalc/dataloader
- Timestamp:
- Apr 7, 2017 9:51:47 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.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- 168d359
- Parents:
- ccc7192
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sascalc/dataloader/manipulations.py
rccc7192 rfa4af76 1 from __future__ import division 1 2 """ 2 3 Data manipulations for 2D data sets. … … 560 561 561 562 dq_data = None 562 if data2D.dqx_data != None and data2D.dqy_data !=None:563 if data2D.dqx_data is not None and data2D.dqy_data is not None: 563 564 dq_data = get_dq_data(data2D) 564 565 565 566 #q_data_max = np.max(q_data) 566 if len(data2D.q_data) ==None:567 if len(data2D.q_data) is None: 567 568 msg = "Circular averaging: invalid q_data: %g" % data2D.q_data 568 569 raise RuntimeError(msg) … … 610 611 else: 611 612 err_y[i_q] += frac * frac * err_data[npt] * err_data[npt] 612 if dq_data !=None:613 if dq_data is not None: 613 614 # To be consistent with dq calculation in 1d reduction, 614 615 # we need just the averages (not quadratures) because … … 625 626 err_y[n] = -err_y[n] 626 627 err_y[n] = math.sqrt(err_y[n]) 627 # if err_x !=None:628 # if err_x is not None: 628 629 # err_x[n] = math.sqrt(err_x[n]) 629 630 … … 634 635 idx = (np.isfinite(y)) & (np.isfinite(x)) 635 636 636 if err_x !=None:637 if err_x is not None: 637 638 d_x = err_x[idx] / y_counts[idx] 638 639 else: … … 791 792 792 793 dq_data = None 793 if data2D.dqx_data != None and data2D.dqy_data !=None:794 if data2D.dqx_data is not None and data2D.dqy_data is not None: 794 795 dq_data = get_dq_data(data2D) 795 796 … … 799 800 y_err = np.zeros(self.nbins) 800 801 x_err = np.zeros(self.nbins) 801 y_counts = np.zeros(self.nbins) 802 y_counts = np.zeros(self.nbins) # Cycle counts (for the mean) 802 803 803 804 # Get the min and max into the region: 0 <= phi < 2Pi … … 817 818 phi_value = math.atan2(qy_data[n], qx_data[n]) + math.pi 818 819 819 # No need to calculate the frac when all data are within range820 # No need to calculate: data outside of the radius 820 821 if self.r_min > q_value or q_value > self.r_max: 821 822 continue … … 844 845 phi_value < phi_max) 845 846 847 # data oustide of the phi range 846 848 if not is_in: 847 849 continue 850 848 851 # Check which type of averaging we need 849 852 if run.lower() == 'phi': 850 853 temp_x = (self.nbins) * (phi_value - self.phi_min) 851 854 temp_y = (self.phi_max - self.phi_min) 852 i_bin = int(math.floor(temp_x / temp_y))853 855 else: 854 856 temp_x = (self.nbins) * (q_value - self.r_min) 855 857 temp_y = (self.r_max - self.r_min) 856 i_bin = int(math.floor(temp_x / temp_y)) 858 # Bin index calulation 859 i_bin = int(math.floor(temp_x / temp_y)) 857 860 858 861 # Take care of the edge case at phi = 2pi. … … 863 866 y[i_bin] += data_n 864 867 x[i_bin] += q_value 865 if err_data[n] ==None or err_data[n] == 0.0:868 if err_data[n] is None or err_data[n] == 0.0: 866 869 if data_n < 0: 867 870 data_n = -data_n 868 y_err[i_bin] += 871 y_err[i_bin] += data_n 869 872 else: 870 y_err[i_bin] += err_data[n] * err_data[n]871 872 if dq_data !=None:873 y_err[i_bin] += err_data[n]**2 874 875 if dq_data is not None: 873 876 # To be consistent with dq calculation in 1d reduction, 874 877 # we need just the averages (not quadratures) because … … 900 903 y_err[y_err == 0] = np.average(y_err) 901 904 idx = (np.isfinite(y) & np.isfinite(y_err)) 902 if x_err !=None:905 if x_err is not None: 903 906 d_x = x_err[idx] / y_counts[idx] 904 907 else:
Note: See TracChangeset
for help on using the changeset viewer.