Changeset f265927 in sasview
- Timestamp:
- Apr 14, 2010 12:10:48 PM (15 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:
- c5874f2
- Parents:
- 1f811dd
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
DataLoader/manipulations.py
rdde2d44 rf265927 85 85 q_data = numpy.sqrt(qx_data*qx_data+qy_data*qy_data) 86 86 if data2d.err_data == None or numpy.any(data2d.err_data<=0): 87 new_err_data = numpy.sqrt(numpy. fabs(new_data))87 new_err_data = numpy.sqrt(numpy.abs(new_data)) 88 88 else: 89 89 new_err_data = data2d.err_data.flatten() … … 827 827 return self._agv(data2D, 'q2') 828 828 829 class Ringcut(object): 830 """ 831 Defines a ring on a 2D data set. 832 The ring is defined by r_min, r_max, and 833 the position of the center of the ring. 834 835 The data returned is the region inside the ring 836 837 Phi_min and phi_max should be defined between 0 and 2*pi 838 in anti-clockwise starting from the x- axis on the left-hand side 839 """ 840 def __init__(self, r_min=0, r_max=0, center_x=0, center_y=0 ): 841 # Minimum radius 842 self.r_min = r_min 843 # Maximum radius 844 self.r_max = r_max 845 # Center of the ring in x 846 self.center_x = center_x 847 # Center of the ring in y 848 self.center_y = center_y 849 850 851 def __call__(self, data2D): 852 """ 853 Apply the ring to the data set. 854 Returns the angular distribution for a given q range 855 856 @param data2D: Data2D object 857 @return: index array in the range 858 """ 859 if data2D.__class__.__name__ not in ["Data2D", "plottable_2D"]: 860 raise RuntimeError, "Ring cut only take plottable_2D objects" 861 862 # Get data 863 qx_data = data2D.qx_data 864 qy_data = data2D.qy_data 865 mask = data2D.mask 866 q_data = numpy.sqrt(qx_data*qx_data+qy_data*qy_data) 867 #q_data_max = numpy.max(q_data) 868 869 # check whether or not the data point is inside ROI 870 out = (self.r_min <= q_data) & (self.r_max >= q_data) 871 872 return (out) 873 874 829 875 class Boxcut(object): 830 876 """ … … 865 911 qx_data = data2D.qx_data 866 912 qy_data = data2D.qy_data 913 mask = data2D.mask 867 914 868 915 # check whether or not the data point is inside ROI 869 outx = [self.x_min <= qx_data & self.x_max > qx_data]870 outy = [self.y_min <= qy_data & self.y_max > qy_data]916 outx = (self.x_min <= qx_data) & (self.x_max > qx_data) 917 outy = (self.y_min <= qy_data) & (self.y_max > qy_data) 871 918 872 919 return (outx & outy) … … 887 934 def __call__(self, data2D): 888 935 """ 889 Perform sector averaging.936 Find a rectangular 2D region of interest. 890 937 891 938 @param data2D: Data2D object … … 913 960 914 961 # get phi from data 915 phi_data = numpy.arctan2(qy_data, qy_data) 962 phi_data = numpy.arctan2(qy_data, qx_data) 963 964 # Get the min and max into the region: -pi <= phi < Pi 965 phi_min_major = flip_phi(self.phi_min+Pi)-Pi 966 phi_max_major = flip_phi(self.phi_max+Pi)-Pi 916 967 # check for major sector 917 if self.phi_min > self.phi_max:918 out_major = ( self.phi_min <= phi_data) or (self.phi_max> phi_data)968 if phi_min_major > phi_max_major: 969 out_major = (phi_min_major <= phi_data) + (phi_max_major > phi_data) 919 970 else: 920 out_major = ( self.phi_min <= phi_data) & (self.phi_max> phi_data)921 971 out_major = (phi_min_major <= phi_data) & (phi_max_major > phi_data) 972 922 973 # minor sector 923 974 # Get the min and max into the region: -pi <= phi < Pi … … 927 978 # check for minor sector 928 979 if phi_min_minor > phi_max_minor: 929 out_minor= (phi_min_minor <= phi_data) or (phi_max_minor>phi_data)980 out_minor= (phi_min_minor <= phi_data) + (phi_max_minor>= phi_data) 930 981 else: 931 out_minor = (phi_min_minor <= phi_data) & (phi_max_minor > phi_data)982 out_minor = (phi_min_minor <= phi_data) & (phi_max_minor >= phi_data) 932 983 out = out_major + out_minor 933 984 934 985 return out 935 986
Note: See TracChangeset
for help on using the changeset viewer.