Changeset 299edd2 in sasmodels
- Timestamp:
- Jan 29, 2016 9:49:36 AM (9 years ago)
- Branches:
- master, core_shell_microgels, costrafo411, magnetic_model, release_v0.94, release_v0.95, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
- Children:
- d07c883
- Parents:
- 2c1bb7b0
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/data.py
r2c1bb7b0 r299edd2 87 87 88 88 class Data1D(object): 89 """ 90 1D data object. 91 92 Note that this definition matches the attributes from sasview, with 93 some generic 1D data vectors and some SAS specific definitions. Some 94 refactoring to allow consistent naming conventions between 1D, 2D and 95 SESANS data would be helpful. 96 97 **Attributes** 98 99 *x*, *dx*: $q$ vector and gaussian resolution 100 101 *y*, *dy*: $I(q)$ vector and measurement uncertainty 102 103 *mask*: values to include in plotting/analysis 104 105 *dxl*: slit widths for slit smeared data, with *dx* ignored 106 107 *qmin*, *qmax*: range of $q$ values in *x* 108 109 *filename*: label for the data line 110 111 *_xaxis*, *_xunit*: label and units for the *x* axis 112 113 *_yaxis*, *_yunit*: label and units for the *y* axis 114 """ 89 115 def __init__(self, x=None, y=None, dx=None, dy=None): 90 116 self.x, self.y, self.dx, self.dy = x, y, dx, dy … … 117 143 118 144 class Data2D(object): 145 """ 146 2D data object. 147 148 Note that this definition matches the attributes from sasview. Some 149 refactoring to allow consistent naming conventions between 1D, 2D and 150 SESANS data would be helpful. 151 152 **Attributes** 153 154 *qx_data*, *dqx_data*: $q_x$ matrix and gaussian resolution 155 156 *qy_data*, *dqy_data*: $q_y$ matrix and gaussian resolution 157 158 *data*, *err_data*: $I(q)$ matrix and measurement uncertainty 159 160 *mask*: values to exclude from plotting/analysis 161 162 *qmin*, *qmax*: range of $q$ values in *x* 163 164 *filename*: label for the data line 165 166 *_xaxis*, *_xunit*: label and units for the *x* axis 167 168 *_yaxis*, *_yunit*: label and units for the *y* axis 169 170 *_zaxis*, *_zunit*: label and units for the *y* axis 171 172 *Q_unit*, *I_unit*: units for Q and intensity 173 174 *x_bins*, *y_bins*: grid steps in *x* and *y* directions 175 """ 119 176 def __init__(self, x=None, y=None, z=None, dx=None, dy=None, dz=None): 120 177 self.qx_data, self.dqx_data = x, dx … … 131 188 self.Q_unit = "1/A" 132 189 self.I_unit = "1/cm" 133 self.xaxis("Q_x", " A^{-1}")134 self.yaxis("Q_y", " A^{-1}")135 self.zaxis("Intensity", r"\text{cm}^{-1}")190 self.xaxis("Q_x", "1/A") 191 self.yaxis("Q_y", "1/A") 192 self.zaxis("Intensity", "1/cm") 136 193 self._xaxis, self._xunit = "x", "" 137 194 self._yaxis, self._yunit = "y", "" … … 162 219 163 220 class Vector(object): 221 """ 222 3-space vector of *x*, *y*, *z* 223 """ 164 224 def __init__(self, x=None, y=None, z=None): 165 225 self.x, self.y, self.z = x, y, z … … 240 300 """ 241 301 Plot data loaded by the sasview loader. 302 303 *data* is a sasview data object, either 1D, 2D or SESANS. 304 305 *view* is log or linear. 306 307 *limits* sets the intensity limits on the plot; if None then the limits 308 are inferred from the data. 242 309 """ 243 310 # Note: kind of weird using the plot result functions to plot just the … … 254 321 def plot_theory(data, theory, resid=None, view='log', 255 322 use_data=True, limits=None): 323 """ 324 Plot theory calculation. 325 326 *data* is needed to define the graph properties such as labels and 327 units, and to define the data mask. 328 329 *theory* is a matrix of the same shape as the data. 330 331 *view* is log or linear 332 333 *use_data* is True if the data should be plotted as well as the theory. 334 335 *limits* sets the intensity limits on the plot; if None then the limits 336 are inferred from the data. 337 """ 256 338 if hasattr(data, 'lam'): 257 339 _plot_result_sesans(data, theory, resid, use_data=True, limits=limits) … … 263 345 264 346 def protect(fn): 347 """ 348 Decorator to wrap calls in an exception trapper which prints the 349 exception and continues. Keyboard interrupts are ignored. 350 """ 265 351 def wrapper(*args, **kw): 266 352 try: 267 353 return fn(*args, **kw) 354 except KeyboardInterrupt: 355 raise 268 356 except: 269 357 traceback.print_exc() … … 337 425 @protect 338 426 def _plot_result_sesans(data, theory, resid, use_data, limits=None): 427 """ 428 Plot SESANS results. 429 """ 339 430 import matplotlib.pyplot as plt 340 431 use_data = use_data and data.y is not None … … 464 555 465 556 def demo(): 557 """ 558 Load and plot a SAS dataset. 559 """ 466 560 data = load_data('DEC07086.DAT') 467 561 set_beam_stop(data, 0.004)
Note: See TracChangeset
for help on using the changeset viewer.