Changeset 5d63ea0 in sasview for src/sas/dataloader
- Timestamp:
- Feb 17, 2015 8:45:34 AM (9 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:
- 54b9ad2
- Parents:
- 66e579f (diff), 400155b (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - Location:
- src/sas/dataloader
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/dataloader/data_info.py
rb3efb7d r7eaf9f2 25 25 import numpy 26 26 import math 27 28 29 class plottable_sesans1D: 30 """ 31 SESANS is a place holder for 1D SESANS plottables. 32 33 #TODO: This was directly copied from the plottables_1D. 34 #TODO: The class has not been updated from there. 35 """ 36 # The presence of these should be mutually 37 # exclusive with the presence of Qdev (dx) 38 x = None 39 y = None 40 dx = None 41 dy = None 42 ## Slit smearing length 43 dxl = None 44 ## Slit smearing width 45 dxw = None 46 47 # Units 48 _xaxis = '' 49 _xunit = '' 50 _yaxis = '' 51 _yunit = '' 52 53 def __init__(self, x, y, dx=None, dy=None, dxl=None, dxw=None): 54 self.x = numpy.asarray(x) 55 self.y = numpy.asarray(y) 56 if dx is not None: 57 self.dx = numpy.asarray(dx) 58 if dy is not None: 59 self.dy = numpy.asarray(dy) 60 if dxl is not None: 61 self.dxl = numpy.asarray(dxl) 62 if dxw is not None: 63 self.dxw = numpy.asarray(dxw) 64 65 def xaxis(self, label, unit): 66 """ 67 set the x axis label and unit 68 """ 69 self._xaxis = label 70 self._xunit = unit 71 72 def yaxis(self, label, unit): 73 """ 74 set the y axis label and unit 75 """ 76 self._yaxis = label 77 self._yunit = unit 27 78 28 79 … … 940 991 941 992 993 class SESANSData1D(plottable_sesans1D, DataInfo): 994 """ 995 SESANS 1D data class 996 """ 997 x_unit = '1/A' 998 y_unit = '1/cm' 999 1000 def __init__(self, x, y, dx=None, dy=None): 1001 DataInfo.__init__(self) 1002 plottable_sesans1D.__init__(self, x, y, dx, dy) 1003 1004 def __str__(self): 1005 """ 1006 Nice printout 1007 """ 1008 _str = "%s\n" % DataInfo.__str__(self) 1009 1010 _str += "Data:\n" 1011 _str += " Type: %s\n" % self.__class__.__name__ 1012 _str += " X-axis: %s\t[%s]\n" % (self._xaxis, self._xunit) 1013 _str += " Y-axis: %s\t[%s]\n" % (self._yaxis, self._yunit) 1014 _str += " Length: %g\n" % len(self.x) 1015 1016 return _str 1017 1018 def is_slit_smeared(self): 1019 """ 1020 Check whether the data has slit smearing information 1021 1022 :return: True is slit smearing info is present, False otherwise 1023 1024 """ 1025 def _check(v): 1026 if (v.__class__ == list or v.__class__ == numpy.ndarray) \ 1027 and len(v) > 0 and min(v) > 0: 1028 return True 1029 1030 return False 1031 1032 return _check(self.dxl) or _check(self.dxw) 1033 1034 def clone_without_data(self, length=0, clone=None): 1035 """ 1036 Clone the current object, without copying the data (which 1037 will be filled out by a subsequent operation). 1038 The data arrays will be initialized to zero. 1039 1040 :param length: length of the data array to be initialized 1041 :param clone: if provided, the data will be copied to clone 1042 """ 1043 from copy import deepcopy 1044 1045 if clone is None or not issubclass(clone.__class__, Data1D): 1046 x = numpy.zeros(length) 1047 dx = numpy.zeros(length) 1048 y = numpy.zeros(length) 1049 dy = numpy.zeros(length) 1050 clone = Data1D(x, y, dx=dx, dy=dy) 1051 1052 clone.title = self.title 1053 clone.run = self.run 1054 clone.filename = self.filename 1055 clone.instrument = self.instrument 1056 clone.notes = deepcopy(self.notes) 1057 clone.process = deepcopy(self.process) 1058 clone.detector = deepcopy(self.detector) 1059 clone.sample = deepcopy(self.sample) 1060 clone.source = deepcopy(self.source) 1061 clone.collimation = deepcopy(self.collimation) 1062 clone.trans_spectrum = deepcopy(self.trans_spectrum) 1063 clone.meta_data = deepcopy(self.meta_data) 1064 clone.errors = deepcopy(self.errors) 1065 1066 return clone 1067 1068 942 1069 class Data2D(plottable_2D, DataInfo): 943 1070 """ -
src/sas/dataloader/manipulations.py
r79492222 r400155b 582 582 """ 583 583 #Todo: remove center. 584 def __init__(self, r_min=0, r_max=0, center_x=0, center_y=0, nbins= 20):584 def __init__(self, r_min=0, r_max=0, center_x=0, center_y=0, nbins=36): 585 585 # Minimum radius 586 586 self.r_min = r_min … … 593 593 # Number of angular bins 594 594 self.nbins_phi = nbins 595 595 596 596 597 def __call__(self, data2D): … … 622 623 phi_values = numpy.zeros(self.nbins_phi) 623 624 phi_err = numpy.zeros(self.nbins_phi) 624 625 626 # Shift to apply to calculated phi values in order to center first bin at zero 627 phi_shift = Pi / self.nbins_phi 628 625 629 for npt in range(len(data)): 626 630 frac = 0 … … 637 641 continue 638 642 # binning 639 i_phi = int(math.floor((self.nbins_phi) * phi_value/ (2 * Pi)))643 i_phi = int(math.floor((self.nbins_phi) * (phi_value+phi_shift) / (2 * Pi))) 640 644 641 645 # Take care of the edge case at phi = 2pi. 642 if i_phi == self.nbins_phi:643 i_phi = self.nbins_phi - 1646 if i_phi >= self.nbins_phi: 647 i_phi = 0 644 648 phi_bins[i_phi] += frac * data[npt] 645 649 … … 655 659 phi_bins[i] = phi_bins[i] / phi_counts[i] 656 660 phi_err[i] = math.sqrt(phi_err[i]) / phi_counts[i] 657 phi_values[i] = 2.0 * math.pi / self.nbins_phi * (1.0 * i + 0.5)661 phi_values[i] = 2.0 * math.pi / self.nbins_phi * (1.0 * i) 658 662 659 663 idx = (numpy.isfinite(phi_bins))
Note: See TracChangeset
for help on using the changeset viewer.