Changeset c2a8523 in sasview
- Timestamp:
- Jan 15, 2009 2:44:25 PM (16 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:
- 4853c04
- Parents:
- 3bae6c8
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
DataLoader/manipulations.py
rfb198a9 rc2a8523 633 633 return None 634 634 635 635 #This class can be removed. 636 636 class _Sectorold: 637 637 """ … … 804 804 y_err = numpy.zeros(self.nbins) 805 805 806 # This If finds qmax within ROI defined by sector lines 807 if run.lower()=='q2'or run.lower()=='q': 808 tempq=0 #to find qmax within ROI 809 for i in range(numpy.size(data,1)): 810 dx = pixel_width_x*(i+0.5 - center_x) 811 for j in range(numpy.size(data,0)): 812 813 dy = pixel_width_y*(j+0.5 - center_y) 814 q_value = get_q(dx, dy, det_dist, wavelength) 815 # Compute phi and check whether it's within the limits 816 phi_value=math.atan2(dy,dx)+math.pi 817 if self.phi_max>2*math.pi: 818 self.phi_max=self.phi_max-2*math.pi 819 if self.phi_min<0: 820 self.phi_max=self.phi_max+2*math.pi 821 822 #In case of two ROI (symmetric major and minor regions)(for 'q2') 823 if run.lower()=='q2': 824 if ((self.phi_max>=0 and self.phi_max<math.pi)and (self.phi_min>=0 and self.phi_min<math.pi)): 825 temp_max=self.phi_max+math.pi 826 temp_min=self.phi_min+math.pi 827 else: 828 temp_max=self.phi_max 829 temp_min=self.phi_min 830 831 if ((temp_max>=math.pi and temp_max<2*math.pi)and (temp_min>=math.pi and temp_min<2*math.pi)): 832 if (phi_value<temp_min or phi_value>temp_max): 833 if (phi_value<temp_min-math.pi or phi_value>temp_max-math.pi): 834 continue 835 if (self.phi_max<self.phi_min): 836 tmp_max=self.phi_max+math.pi 837 tmp_min=self.phi_min-math.pi 838 else: 839 tmp_max=self.phi_max 840 tmp_min=self.phi_min 841 if (tmp_min<math.pi and tmp_max>math.pi): 842 if((phi_value>tmp_max and phi_value<tmp_min+math.pi)or (phi_value>tmp_max-math.pi and phi_value<tmp_min)): 843 continue 844 #In case of one ROI (major only)(i.e.,for 'q' and 'phi') 845 else: 846 if (self.phi_max>=self.phi_min): 847 if (phi_value<self.phi_min or phi_value>self.phi_max): 848 continue 849 else: 850 if (phi_value<self.phi_min and phi_value>self.phi_max): 851 continue 852 if tempq<q_value: 853 tempq=q_value 854 qmax=tempq 855 print "qmax=",qmax 856 806 857 for i in range(numpy.size(data,1)): 807 858 dx = pixel_width_x*(i+0.5 - center_x) … … 827 878 q_11 = get_q(maxx, maxy, det_dist, wavelength) 828 879 829 # Look for intercept between each side of the pixel830 # and the constant-q ring for qmax831 frac_max = get_pixel_fraction(qmax, q_00, q_01, q_10, q_11)832 833 # Look for intercept between each side of the pixel834 # and the constant-q ring for qmin835 frac_min = get_pixel_fraction(qmin, q_00, q_01, q_10, q_11)836 837 # We are interested in the region between qmin and qmax838 # therefore the fraction of the surface of the pixel839 # that we will use to calculate the number of counts to840 # include is given by:841 842 frac = frac_max - frac_min843 844 880 # Compute phi and check whether it's within the limits 845 881 phi_value=math.atan2(dy,dx)+math.pi … … 848 884 if self.phi_min<0: 849 885 self.phi_max=self.phi_max+2*math.pi 850 851 #In case of two ROI (symetric major and minor regions)(for 'q2') 886 887 # Look for intercept between each side of the pixel 888 # and the constant-q ring for qmax 889 frac_max = get_pixel_fraction(qmax, q_00, q_01, q_10, q_11) 890 891 # Look for intercept between each side of the pixel 892 # and the constant-q ring for qmin 893 frac_min = get_pixel_fraction(qmin, q_00, q_01, q_10, q_11) 894 895 # We are interested in the region between qmin and qmax 896 # therefore the fraction of the surface of the pixel 897 # that we will use to calculate the number of counts to 898 # include is given by: 899 900 frac = frac_max - frac_min 901 902 #In case of two ROI (symmetric major and minor regions)(for 'q2') 852 903 if run.lower()=='q2': 853 904 if ((self.phi_max>=0 and self.phi_max<math.pi)and (self.phi_min>=0 and self.phi_min<math.pi)): … … 871 922 if((phi_value>tmp_max and phi_value<tmp_min+math.pi)or (phi_value>tmp_max-math.pi and phi_value<tmp_min)): 872 923 continue 873 #In case of one ROI (major only)( for 'q' and 'phi')924 #In case of one ROI (major only)(i.e.,for 'q' and 'phi') 874 925 else: 875 926 if (self.phi_max>=self.phi_min): … … 889 940 # the ring defined by q_min/q_max rather than the complete 890 941 # pixel 891 if q_value< self.r_min or q_value>self.r_max:942 if q_value<qmin or q_value>qmax: 892 943 continue 893 i_bin = int(math.ceil(self.nbins*(q_value- self.r_min)/(self.r_max-self.r_min))) - 1894 944 i_bin = int(math.ceil(self.nbins*(q_value-qmin)/(qmax-qmin))) - 1 945 895 946 try: 896 947 y[i_bin] += frac * data[j][i] … … 913 964 x[i] = (self.phi_max-self.phi_min)/self.nbins*(1.0*i + 0.5)+self.phi_min 914 965 else: 915 x[i] = ( self.r_max-self.r_min)/self.nbins*(1.0*i + 0.5)+self.r_min966 x[i] = (qmax-qmin)/self.nbins*(1.0*i + 0.5)+qmin 916 967 917 968 return Data1D(x=x, y=y, dy=y_err) … … 977 1028 978 1029 979 r = SectorQ(r_min=.00 5, r_max=.01, phi_min=0.0, phi_max=math.pi/2.0)1030 r = SectorQ(r_min=.000001, r_max=.01, phi_min=0.0, phi_max=math.pi/2.0) 980 1031 o = r(d) 981 1032
Note: See TracChangeset
for help on using the changeset viewer.