Changeset 3c3a440 in sasview for src/sas/dataloader
- Timestamp:
- Mar 3, 2015 11:17:47 AM (10 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:
- 7425bcf
- Parents:
- c8a6c3d7
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/dataloader/manipulations.py
rc8a6c3d7 r3c3a440 206 206 207 207 #TODO: find better definition of x[i_q] based on q_data 208 x[i_q] += frac * q_value # min_value + (i_q + 1) * self.bin_width / 2.0 208 # min_value + (i_q + 1) * self.bin_width / 2.0 209 x[i_q] += frac * q_value 209 210 y[i_q] += frac * data[npts] 210 211 … … 573 574 Apply the ring to the data set. 574 575 Returns the angular distribution for a given q range 575 576 :param data2D: Data2D object 577 576 577 :param data2D: Data2D object 578 578 579 :return: Data1D object 579 580 """ … … 596 597 phi_err = numpy.zeros(self.nbins_phi) 597 598 598 # Shift to apply to calculated phi values in order to center first bin at zero 599 # Shift to apply to calculated phi values in order 600 # to center first bin at zero 599 601 phi_shift = Pi / self.nbins_phi 600 602 … … 612 614 if frac == 0: 613 615 continue 614 # binning 615 i_phi = int(math.floor((self.nbins_phi) * (phi_value + phi_shift) / (2 * Pi))) 616 # binning 617 i_phi = int(math.floor((self.nbins_phi) * \ 618 (phi_value + phi_shift) / (2 * Pi))) 616 619 617 620 # Take care of the edge case at phi = 2pi. … … 649 652 the four corners (q_00, q_01, q_10, q_11) that 650 653 has q < qmax.:: 651 654 652 655 q_01 q_11 653 656 y=1 +--------------+ … … 657 660 y=0 +--------------+ 658 661 q_00 q_10 659 662 660 663 x=0 x=1 661 664 662 665 """ 663 666 # y side for x = minx … … 714 717 The values returned is the fraction ON THE SIDE 715 718 OF THE LOWEST Q. :: 716 717 719 718 720 A B 719 721 +-----------+--------+ <--- pixel size … … 723 725 if Q_1 < Q_0, B is returned 724 726 if Q is outside the range of [Q_0, Q_1], None is returned 725 727 726 728 """ 727 729 if q_1 > q_0: 728 if (q > q_0 and q <= q_1):730 if q > q_0 and q <= q_1: 729 731 return (q - q_0) / (q_1 - q_0) 730 732 else: 731 if (q > q_1 and q <= q_0):733 if q > q_1 and q <= q_0: 732 734 return (q - q_1) / (q_0 - q_1) 733 735 return None 734 736 735 737 736 class _Sector :738 class _Sector(object): 737 739 """ 738 740 Defines a sector region on a 2D data set. … … 742 744 and left lines wrt central line 743 745 and phi_max could be less than phi_min. 744 746 745 747 Phi is defined between 0 and 2*pi in anti-clockwise 746 748 starting from the x- axis on the left-hand side … … 756 758 """ 757 759 Perform sector averaging. 758 760 759 761 :param data2D: Data2D object 760 762 :param run: define the varying parameter ('phi' , 'q' , or 'q2') 761 763 762 764 :return: Data1D object 763 765 """ … … 940 942 Sector average as a function of phi. 941 943 I(phi) is return and the data is averaged over Q. 942 944 943 945 A sector is defined by r_min, r_max, phi_min, phi_max. 944 946 The number of bin in phi also has to be defined. … … 947 949 """ 948 950 Perform sector average and return I(phi). 949 951 950 952 :param data2D: Data2D object 951 953 :return: Data1D object … … 958 960 Sector average as a function of Q for both symatric wings. 959 961 I(Q) is return and the data is averaged over phi. 960 962 961 963 A sector is defined by r_min, r_max, phi_min, phi_max. 962 964 r_min, r_max, phi_min, phi_max >0. … … 966 968 """ 967 969 Perform sector average and return I(Q). 968 969 :param data2D: Data2D object 970 970 971 :param data2D: Data2D object 972 971 973 :return: Data1D object 972 974 """ … … 979 981 The ring is defined by r_min, r_max, and 980 982 the position of the center of the ring. 981 983 982 984 The data returned is the region inside the ring 983 985 984 986 Phi_min and phi_max should be defined between 0 and 2*pi 985 987 in anti-clockwise starting from the x- axis on the left-hand side … … 999 1001 Apply the ring to the data set. 1000 1002 Returns the angular distribution for a given q range 1001 1002 :param data2D: Data2D object 1003 1003 1004 :param data2D: Data2D object 1005 1004 1006 :return: index array in the range 1005 1007 """ … … 1014 1016 # check whether or not the data point is inside ROI 1015 1017 out = (self.r_min <= q_data) & (self.r_max >= q_data) 1016 1017 return (out) 1018 return out 1018 1019 1019 1020 … … 1035 1036 """ 1036 1037 Find a rectangular 2D region of interest. 1037 1038 1038 1039 :param data2D: Data2D object 1039 1040 :return: mask, 1d array (len = len(data)) … … 1047 1048 """ 1048 1049 Find a rectangular 2D region of interest. 1049 1050 :param data2D: Data2D object 1051 1050 1051 :param data2D: Data2D object 1052 1052 1053 :return: out, 1d array (length = len(data)) 1053 1054 with Trues where the data points are inside ROI, otherwise Falses … … 1063 1064 outy = (self.y_min <= qy_data) & (self.y_max > qy_data) 1064 1065 1065 return (outx & outy)1066 return outx & outy 1066 1067 1067 1068 … … 1072 1073 where phi_min and phi_max are defined by the right 1073 1074 and left lines wrt central line. 1074 1075 1075 1076 Phi_min and phi_max are given in units of radian 1076 1077 and (phi_max-phi_min) should not be larger than pi … … 1083 1084 """ 1084 1085 Find a rectangular 2D region of interest. 1085 1086 :param data2D: Data2D object 1087 1086 1087 :param data2D: Data2D object 1088 1088 1089 :return: mask, 1d array (len = len(data)) 1089 1090 1090 1091 with Trues where the data points are inside ROI, otherwise False 1091 1092 """ … … 1097 1098 """ 1098 1099 Find a rectangular 2D region of interest. 1099 1100 :param data2D: Data2D object 1101 1100 1101 :param data2D: Data2D object 1102 1102 1103 :return: out, 1d array (length = len(data)) 1103 1104 1104 1105 with Trues where the data points are inside ROI, otherwise Falses 1105 1106 """ … … 1107 1108 raise RuntimeError, "Sectorcut take only plottable_2D objects" 1108 1109 Pi = math.pi 1109 # Get data 1110 # Get data 1110 1111 qx_data = data2D.qx_data 1111 1112 qy_data = data2D.qy_data
Note: See TracChangeset
for help on using the changeset viewer.