essreduce 25.1.0__py3-none-any.whl → 25.1.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,8 +6,9 @@ Utilities for computing real neutron time-of-flight from chopper settings and
6
6
  neutron time-of-arrival at the detectors.
7
7
  """
8
8
 
9
- from .toa_to_tof import default_parameters, resample_tof_data, providers, TofWorkflow
10
9
  from .simulation import simulate_beamline
10
+ from .toa_to_tof import default_parameters, resample_tof_data, providers, TofWorkflow
11
+ from .to_events import to_events
11
12
  from .types import (
12
13
  DistanceResolution,
13
14
  FrameFoldedTimeOfArrival,
@@ -56,4 +57,5 @@ __all__ = [
56
57
  "providers",
57
58
  "resample_tof_data",
58
59
  "simulate_beamline",
60
+ "to_events",
59
61
  ]
@@ -45,19 +45,21 @@ def to_events(
45
45
  edge_sizes = {dim: da.sizes[dim] for dim in edge_dims}
46
46
  for dim in edge_dims:
47
47
  coord = da.coords[dim]
48
- low = sc.broadcast(coord[dim, :-1], sizes=edge_sizes).values
49
- high = sc.broadcast(coord[dim, 1:], sizes=edge_sizes).values
48
+ left = sc.broadcast(coord[dim, :-1], sizes=edge_sizes).values
49
+ right = sc.broadcast(coord[dim, 1:], sizes=edge_sizes).values
50
50
 
51
51
  # The numpy.random.uniform function below does not support NaNs, so we need to
52
52
  # replace them with zeros, and then replace them back after the random numbers
53
53
  # have been generated.
54
- nans = np.isnan(low) | np.isnan(high)
55
- low = np.where(nans, 0.0, low)
56
- high = np.where(nans, 0.0, high)
54
+ nans = np.isnan(left) | np.isnan(right)
55
+ left = np.where(nans, 0.0, left)
56
+ right = np.where(nans, 0.0, right)
57
+ # Ensure left <= right
58
+ left, right = np.minimum(left, right), np.maximum(left, right)
57
59
 
58
60
  # In each bin, we generate a number of events with a uniform distribution.
59
61
  events = rng.uniform(
60
- low, high, size=(events_per_bin, *list(edge_sizes.values()))
62
+ left, right, size=(events_per_bin, *list(edge_sizes.values()))
61
63
  )
62
64
  events[..., nans] = np.nan
63
65
  event_coords[dim] = sc.array(
@@ -77,20 +79,20 @@ def to_events(
77
79
  data = da.data
78
80
  if event_masks:
79
81
  inv_mask = (~reduce(lambda a, b: a | b, event_masks.values())).to(dtype=int)
80
- inv_mask.unit = ''
82
+ inv_mask.unit = ""
81
83
  data = data * inv_mask
82
84
 
83
85
  # Create the data counts, which are the original counts divided by the number of
84
86
  # events per bin
85
87
  sizes = {event_dim: events_per_bin} | da.sizes
86
88
  val = sc.broadcast(sc.values(data) / float(events_per_bin), sizes=sizes)
87
- kwargs = {'dims': sizes.keys(), 'values': val.values, 'unit': data.unit}
89
+ kwargs = {"dims": sizes.keys(), "values": val.values, "unit": data.unit}
88
90
  if data.variances is not None:
89
91
  # Note here that all the events are correlated.
90
92
  # If we later histogram the events with different edges than the original
91
93
  # histogram, then neighboring bins will be correlated, and the error obtained
92
94
  # will be too small. It is however not clear what can be done to improve this.
93
- kwargs['variances'] = sc.broadcast(
95
+ kwargs["variances"] = sc.broadcast(
94
96
  sc.variances(data) / float(events_per_bin), sizes=sizes
95
97
  ).values
96
98
  new_data = sc.array(**kwargs)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: essreduce
3
- Version: 25.1.0
3
+ Version: 25.1.1
4
4
  Summary: Common data reduction tools for the ESS facility
5
5
  Author: Scipp contributors
6
6
  License: BSD 3-Clause License
@@ -17,10 +17,10 @@ ess/reduce/nexus/json_nexus.py,sha256=QrVc0p424nZ5dHX9gebAJppTw6lGZq9404P_OFl1gi
17
17
  ess/reduce/nexus/types.py,sha256=Az_pZtaTIlEAA4Po_YOLabez8w4HeHcr0asY3rS6BXg,9676
18
18
  ess/reduce/nexus/workflow.py,sha256=jzdh0ubp9Mmb98a04KIeM8Xo9bpAqpnsfwFWz2VllnQ,23676
19
19
  ess/reduce/scripts/grow_nexus.py,sha256=hET3h06M0xlJd62E3palNLFvJMyNax2kK4XyJcOhl-I,3387
20
- ess/reduce/time_of_flight/__init__.py,sha256=Qbu0y9fHBoib1GIftmA77iEW1CaxLUmgb6aGvCoyTls,1496
20
+ ess/reduce/time_of_flight/__init__.py,sha256=buqd_rvHvdeO3BTZLf_rKGAFwfJgd6ixAAsxRU_-kik,1546
21
21
  ess/reduce/time_of_flight/fakes.py,sha256=cyo6eYn0nOy3Dt1iDge7utkUrSGU-OpZ5g73-DGJsyw,7583
22
22
  ess/reduce/time_of_flight/simulation.py,sha256=Tn4kRkXisWjA4ss4AXVshfa9gga0GFOXqtABjRru2MI,2488
23
- ess/reduce/time_of_flight/to_events.py,sha256=BNBv6gT9KkJDJ2UWSw-V2YkOyPf_kYv_xVU6-K-sngE,4003
23
+ ess/reduce/time_of_flight/to_events.py,sha256=hXTyc_o6qQc2KDurUM55Kb-5VS-VrB9lE5H_R6vAfYM,4115
24
24
  ess/reduce/time_of_flight/toa_to_tof.py,sha256=_aQiXqO5LeeBePZcZv_f5VhkreH9NDwFQfDsbe275xI,19505
25
25
  ess/reduce/time_of_flight/types.py,sha256=JIAvdBF61wESKoxl1vHmks_udNfT2dlrOxHKOBjFCzg,5888
26
26
  ess/reduce/widgets/__init__.py,sha256=wk5ihxvtZHqkp2EYVtbJr1Es0lw69KQpyTSaizNgWjU,5326
@@ -35,9 +35,9 @@ ess/reduce/widgets/_spinner.py,sha256=2VY4Fhfa7HMXox2O7UbofcdKsYG-AJGrsgGJB85nDX
35
35
  ess/reduce/widgets/_string_widget.py,sha256=iPAdfANyXHf-nkfhgkyH6gQDklia0LebLTmwi3m-iYQ,1482
36
36
  ess/reduce/widgets/_switchable_widget.py,sha256=fjKz99SKLhIF1BLgGVBSKKn3Lu_jYBwDYGeAjbJY3Q8,2390
37
37
  ess/reduce/widgets/_vector_widget.py,sha256=aTaBqCFHZQhrIoX6-sSqFWCPePEW8HQt5kUio8jP1t8,1203
38
- essreduce-25.1.0.dist-info/LICENSE,sha256=nVEiume4Qj6jMYfSRjHTM2jtJ4FGu0g-5Sdh7osfEYw,1553
39
- essreduce-25.1.0.dist-info/METADATA,sha256=JQTRg0pPoWtR1wBHbFJiqPsFxvlV4Xq8tezxsut92Ls,3708
40
- essreduce-25.1.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
41
- essreduce-25.1.0.dist-info/entry_points.txt,sha256=PMZOIYzCifHMTe4pK3HbhxUwxjFaZizYlLD0td4Isb0,66
42
- essreduce-25.1.0.dist-info/top_level.txt,sha256=0JxTCgMKPLKtp14wb1-RKisQPQWX7i96innZNvHBr-s,4
43
- essreduce-25.1.0.dist-info/RECORD,,
38
+ essreduce-25.1.1.dist-info/LICENSE,sha256=nVEiume4Qj6jMYfSRjHTM2jtJ4FGu0g-5Sdh7osfEYw,1553
39
+ essreduce-25.1.1.dist-info/METADATA,sha256=mjZuI2PH5ONZej_X6h-FCcEUOu70Qh8sxwaWLUL5gH0,3708
40
+ essreduce-25.1.1.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
41
+ essreduce-25.1.1.dist-info/entry_points.txt,sha256=PMZOIYzCifHMTe4pK3HbhxUwxjFaZizYlLD0td4Isb0,66
42
+ essreduce-25.1.1.dist-info/top_level.txt,sha256=0JxTCgMKPLKtp14wb1-RKisQPQWX7i96innZNvHBr-s,4
43
+ essreduce-25.1.1.dist-info/RECORD,,