magnetic_scattrelease-4.2.2ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change
on this file since 66285f5 was
959eb01,
checked in by ajj, 8 years ago
|
normalising line endings
|
-
Property mode set to
100644
|
File size:
660 bytes
|
Rev | Line | |
---|
[959eb01] | 1 | """ |
---|
| 2 | Module contains functions frequently used in this package |
---|
| 3 | """ |
---|
| 4 | import numpy as np |
---|
| 5 | |
---|
| 6 | |
---|
| 7 | def get_weight(data, is2d, flag=None): |
---|
| 8 | """ |
---|
| 9 | Received flag and compute error on data. |
---|
| 10 | :param flag: flag to transform error of data. |
---|
| 11 | :param is2d: flag to distinguish 1D to 2D Data |
---|
| 12 | """ |
---|
| 13 | weight = None |
---|
| 14 | if is2d: |
---|
| 15 | dy_data = data.err_data |
---|
| 16 | data = data.data |
---|
| 17 | else: |
---|
| 18 | dy_data = data.dy |
---|
| 19 | data = data.y |
---|
| 20 | if flag == 0: |
---|
| 21 | weight = np.ones_like(data) |
---|
| 22 | elif flag == 1: |
---|
| 23 | weight = dy_data |
---|
| 24 | elif flag == 2: |
---|
| 25 | weight = np.sqrt(np.abs(data)) |
---|
| 26 | elif flag == 3: |
---|
| 27 | weight = np.abs(data) |
---|
| 28 | return weight |
---|
Note: See
TracBrowser
for help on using the repository browser.