westpa 2022.13__cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.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.
Files changed (162) hide show
  1. westpa/__init__.py +14 -0
  2. westpa/_version.py +21 -0
  3. westpa/analysis/__init__.py +5 -0
  4. westpa/analysis/core.py +749 -0
  5. westpa/analysis/statistics.py +27 -0
  6. westpa/analysis/trajectories.py +369 -0
  7. westpa/cli/__init__.py +0 -0
  8. westpa/cli/core/__init__.py +0 -0
  9. westpa/cli/core/w_fork.py +152 -0
  10. westpa/cli/core/w_init.py +230 -0
  11. westpa/cli/core/w_run.py +77 -0
  12. westpa/cli/core/w_states.py +212 -0
  13. westpa/cli/core/w_succ.py +99 -0
  14. westpa/cli/core/w_truncate.py +68 -0
  15. westpa/cli/tools/__init__.py +0 -0
  16. westpa/cli/tools/ploterr.py +506 -0
  17. westpa/cli/tools/plothist.py +706 -0
  18. westpa/cli/tools/w_assign.py +597 -0
  19. westpa/cli/tools/w_bins.py +166 -0
  20. westpa/cli/tools/w_crawl.py +119 -0
  21. westpa/cli/tools/w_direct.py +557 -0
  22. westpa/cli/tools/w_dumpsegs.py +94 -0
  23. westpa/cli/tools/w_eddist.py +506 -0
  24. westpa/cli/tools/w_fluxanl.py +376 -0
  25. westpa/cli/tools/w_ipa.py +832 -0
  26. westpa/cli/tools/w_kinavg.py +127 -0
  27. westpa/cli/tools/w_kinetics.py +96 -0
  28. westpa/cli/tools/w_multi_west.py +414 -0
  29. westpa/cli/tools/w_ntop.py +213 -0
  30. westpa/cli/tools/w_pdist.py +515 -0
  31. westpa/cli/tools/w_postanalysis_matrix.py +82 -0
  32. westpa/cli/tools/w_postanalysis_reweight.py +53 -0
  33. westpa/cli/tools/w_red.py +491 -0
  34. westpa/cli/tools/w_reweight.py +780 -0
  35. westpa/cli/tools/w_select.py +226 -0
  36. westpa/cli/tools/w_stateprobs.py +111 -0
  37. westpa/cli/tools/w_timings.py +113 -0
  38. westpa/cli/tools/w_trace.py +599 -0
  39. westpa/core/__init__.py +0 -0
  40. westpa/core/_rc.py +673 -0
  41. westpa/core/binning/__init__.py +55 -0
  42. westpa/core/binning/_assign.c +36018 -0
  43. westpa/core/binning/_assign.cpython-312-aarch64-linux-gnu.so +0 -0
  44. westpa/core/binning/_assign.pyx +370 -0
  45. westpa/core/binning/assign.py +454 -0
  46. westpa/core/binning/binless.py +96 -0
  47. westpa/core/binning/binless_driver.py +54 -0
  48. westpa/core/binning/binless_manager.py +189 -0
  49. westpa/core/binning/bins.py +47 -0
  50. westpa/core/binning/mab.py +506 -0
  51. westpa/core/binning/mab_driver.py +54 -0
  52. westpa/core/binning/mab_manager.py +197 -0
  53. westpa/core/data_manager.py +1761 -0
  54. westpa/core/extloader.py +74 -0
  55. westpa/core/h5io.py +1079 -0
  56. westpa/core/kinetics/__init__.py +24 -0
  57. westpa/core/kinetics/_kinetics.c +45174 -0
  58. westpa/core/kinetics/_kinetics.cpython-312-aarch64-linux-gnu.so +0 -0
  59. westpa/core/kinetics/_kinetics.pyx +815 -0
  60. westpa/core/kinetics/events.py +147 -0
  61. westpa/core/kinetics/matrates.py +156 -0
  62. westpa/core/kinetics/rate_averaging.py +266 -0
  63. westpa/core/progress.py +218 -0
  64. westpa/core/propagators/__init__.py +54 -0
  65. westpa/core/propagators/executable.py +592 -0
  66. westpa/core/propagators/loaders.py +196 -0
  67. westpa/core/reweight/__init__.py +14 -0
  68. westpa/core/reweight/_reweight.c +36899 -0
  69. westpa/core/reweight/_reweight.cpython-312-aarch64-linux-gnu.so +0 -0
  70. westpa/core/reweight/_reweight.pyx +439 -0
  71. westpa/core/reweight/matrix.py +126 -0
  72. westpa/core/segment.py +119 -0
  73. westpa/core/sim_manager.py +839 -0
  74. westpa/core/states.py +359 -0
  75. westpa/core/systems.py +93 -0
  76. westpa/core/textio.py +74 -0
  77. westpa/core/trajectory.py +603 -0
  78. westpa/core/we_driver.py +910 -0
  79. westpa/core/wm_ops.py +43 -0
  80. westpa/core/yamlcfg.py +298 -0
  81. westpa/fasthist/__init__.py +34 -0
  82. westpa/fasthist/_fasthist.c +38755 -0
  83. westpa/fasthist/_fasthist.cpython-312-aarch64-linux-gnu.so +0 -0
  84. westpa/fasthist/_fasthist.pyx +222 -0
  85. westpa/mclib/__init__.py +271 -0
  86. westpa/mclib/__main__.py +28 -0
  87. westpa/mclib/_mclib.c +34610 -0
  88. westpa/mclib/_mclib.cpython-312-aarch64-linux-gnu.so +0 -0
  89. westpa/mclib/_mclib.pyx +226 -0
  90. westpa/oldtools/__init__.py +4 -0
  91. westpa/oldtools/aframe/__init__.py +35 -0
  92. westpa/oldtools/aframe/atool.py +75 -0
  93. westpa/oldtools/aframe/base_mixin.py +26 -0
  94. westpa/oldtools/aframe/binning.py +178 -0
  95. westpa/oldtools/aframe/data_reader.py +560 -0
  96. westpa/oldtools/aframe/iter_range.py +200 -0
  97. westpa/oldtools/aframe/kinetics.py +117 -0
  98. westpa/oldtools/aframe/mcbs.py +153 -0
  99. westpa/oldtools/aframe/output.py +39 -0
  100. westpa/oldtools/aframe/plotting.py +88 -0
  101. westpa/oldtools/aframe/trajwalker.py +126 -0
  102. westpa/oldtools/aframe/transitions.py +469 -0
  103. westpa/oldtools/cmds/__init__.py +0 -0
  104. westpa/oldtools/cmds/w_ttimes.py +361 -0
  105. westpa/oldtools/files.py +34 -0
  106. westpa/oldtools/miscfn.py +23 -0
  107. westpa/oldtools/stats/__init__.py +4 -0
  108. westpa/oldtools/stats/accumulator.py +35 -0
  109. westpa/oldtools/stats/edfs.py +129 -0
  110. westpa/oldtools/stats/mcbs.py +96 -0
  111. westpa/tools/__init__.py +33 -0
  112. westpa/tools/binning.py +472 -0
  113. westpa/tools/core.py +340 -0
  114. westpa/tools/data_reader.py +159 -0
  115. westpa/tools/dtypes.py +31 -0
  116. westpa/tools/iter_range.py +198 -0
  117. westpa/tools/kinetics_tool.py +343 -0
  118. westpa/tools/plot.py +283 -0
  119. westpa/tools/progress.py +17 -0
  120. westpa/tools/selected_segs.py +154 -0
  121. westpa/tools/wipi.py +751 -0
  122. westpa/trajtree/__init__.py +4 -0
  123. westpa/trajtree/_trajtree.c +17829 -0
  124. westpa/trajtree/_trajtree.cpython-312-aarch64-linux-gnu.so +0 -0
  125. westpa/trajtree/_trajtree.pyx +130 -0
  126. westpa/trajtree/trajtree.py +117 -0
  127. westpa/westext/__init__.py +0 -0
  128. westpa/westext/adaptvoronoi/__init__.py +3 -0
  129. westpa/westext/adaptvoronoi/adaptVor_driver.py +214 -0
  130. westpa/westext/hamsm_restarting/__init__.py +3 -0
  131. westpa/westext/hamsm_restarting/example_overrides.py +35 -0
  132. westpa/westext/hamsm_restarting/restart_driver.py +1165 -0
  133. westpa/westext/stringmethod/__init__.py +11 -0
  134. westpa/westext/stringmethod/fourier_fitting.py +69 -0
  135. westpa/westext/stringmethod/string_driver.py +253 -0
  136. westpa/westext/stringmethod/string_method.py +306 -0
  137. westpa/westext/weed/BinCluster.py +180 -0
  138. westpa/westext/weed/ProbAdjustEquil.py +100 -0
  139. westpa/westext/weed/UncertMath.py +247 -0
  140. westpa/westext/weed/__init__.py +10 -0
  141. westpa/westext/weed/weed_driver.py +192 -0
  142. westpa/westext/wess/ProbAdjust.py +101 -0
  143. westpa/westext/wess/__init__.py +6 -0
  144. westpa/westext/wess/wess_driver.py +217 -0
  145. westpa/work_managers/__init__.py +57 -0
  146. westpa/work_managers/core.py +396 -0
  147. westpa/work_managers/environment.py +134 -0
  148. westpa/work_managers/mpi.py +318 -0
  149. westpa/work_managers/processes.py +201 -0
  150. westpa/work_managers/serial.py +28 -0
  151. westpa/work_managers/threads.py +79 -0
  152. westpa/work_managers/zeromq/__init__.py +20 -0
  153. westpa/work_managers/zeromq/core.py +635 -0
  154. westpa/work_managers/zeromq/node.py +131 -0
  155. westpa/work_managers/zeromq/work_manager.py +526 -0
  156. westpa/work_managers/zeromq/worker.py +320 -0
  157. westpa-2022.13.dist-info/METADATA +179 -0
  158. westpa-2022.13.dist-info/RECORD +162 -0
  159. westpa-2022.13.dist-info/WHEEL +7 -0
  160. westpa-2022.13.dist-info/entry_points.txt +30 -0
  161. westpa-2022.13.dist-info/licenses/LICENSE +21 -0
  162. westpa-2022.13.dist-info/top_level.txt +1 -0
@@ -0,0 +1,376 @@
1
+ import h5py
2
+ import numpy as np
3
+ from scipy.signal import fftconvolve
4
+
5
+ import westpa
6
+
7
+ from westpa.core.data_manager import weight_dtype, n_iter_dtype, vstr_dtype
8
+ from westpa.core.we_driver import NewWeightEntry
9
+ from westpa.core import h5io
10
+ from westpa.tools import WESTTool, WESTDataReader, IterRangeSelection
11
+ from westpa.tools.dtypes import iter_block_ci_dtype as ci_dtype
12
+ import westpa.mclib as mclib
13
+
14
+ fluxentry_dtype = np.dtype([('n_iter', n_iter_dtype), ('flux', weight_dtype), ('count', np.int32)])
15
+
16
+ target_index_dtype = np.dtype(
17
+ [
18
+ ('target_label', vstr_dtype),
19
+ ('mean_flux', weight_dtype),
20
+ ('mean_flux_ci_lb', weight_dtype),
21
+ ('mean_flux_ci_ub', weight_dtype),
22
+ ('mean_flux_correl_len', np.uintc),
23
+ ]
24
+ )
25
+
26
+
27
+ def _extract_fluxes_fileversion_lt_7(iter_start, iter_stop, data_manager):
28
+ '''Extract fluxes from old format, where groups for iterations where recyling
29
+ occurs contain a 'recycling' table.'''
30
+
31
+ assert data_manager.we_h5file_version < 7
32
+
33
+ iter_count = iter_stop - iter_start
34
+ target_count = data_manager.get_iter_group(iter_start)['recycling'].shape[0]
35
+ fluxdata = np.zeros((iter_count,), dtype=fluxentry_dtype)
36
+
37
+ if data_manager.we_h5file_version < 5:
38
+ flux_field = 'weight'
39
+ else:
40
+ flux_field = 'flux'
41
+
42
+ fluxdata = {itarget: np.zeros((iter_count,), dtype=fluxentry_dtype) for itarget in range(target_count)}
43
+
44
+ for iiter, n_iter in enumerate(range(iter_start, iter_stop)):
45
+ rdata = data_manager.get_iter_group(n_iter)['recycling']
46
+ for itarget in range(target_count):
47
+ fluxdata[itarget][iiter]['n_iter'] = n_iter
48
+ fluxdata[itarget][iiter]['flux'] = rdata[itarget][flux_field]
49
+ fluxdata[itarget][iiter]['count'] = rdata[itarget]['count']
50
+ del rdata
51
+
52
+ return fluxdata
53
+
54
+
55
+ def _extract_fluxes_fileversion_7(iter_start, iter_stop, data_manager):
56
+ '''Extract fluxes from HDF5 file version 7, where recycling information is
57
+ stored in the "new_weights" group of the iteration *following* recycling
58
+ events.'''
59
+
60
+ assert data_manager.we_h5file_version >= 7
61
+
62
+ iter_count = iter_stop - iter_start
63
+ iters = np.arange(iter_start, iter_stop, dtype=n_iter_dtype)
64
+
65
+ # for each target by name, collect the iterations, fluxes, and counts
66
+ # This is not the most foolproof way to do this, but it's good enough, and fast.
67
+ # The most correct way to do this is tracing trajectories,
68
+ # and warning if the boundary conditions change during the trace,
69
+ # but that's for another tool.
70
+ by_target = {}
71
+
72
+ for iiter, n_iter in enumerate(range(iter_start, iter_stop)):
73
+ target_states = data_manager.get_target_states(n_iter)
74
+ try:
75
+ new_weight_index = data_manager.get_iter_group(n_iter + 1)['new_weights']['index']
76
+ except KeyError:
77
+ # no recycling data available
78
+ continue
79
+
80
+ for tstate in target_states:
81
+ try:
82
+ target_info = by_target[tstate.label]
83
+ except KeyError:
84
+ # State not seen before
85
+ target_info = by_target[tstate.label] = np.zeros((iter_count,), dtype=fluxentry_dtype)
86
+ # If the target happens not to exist in an iteration (for whatever reason),
87
+ # store a count of -1 as a sentinel
88
+ target_info['count'][:] = -1
89
+ target_info['n_iter'][:] = iters[:]
90
+
91
+ recycled_from_tstate = (new_weight_index['source_type'] == NewWeightEntry.NW_SOURCE_RECYCLED) & (
92
+ new_weight_index['target_state_id'] == tstate.state_id
93
+ )
94
+
95
+ recycle_count = recycled_from_tstate.sum()
96
+ target_info['count'][iiter] = recycle_count
97
+ if recycle_count:
98
+ # flux is in units of per tau
99
+ target_info['flux'][iiter] = new_weight_index[recycled_from_tstate]['weight'].sum()
100
+
101
+ del new_weight_index, target_states
102
+
103
+ # Find the last contiguous run where target is available
104
+ for target_label in by_target:
105
+ fluxdata = by_target[target_label]
106
+ by_target[target_label] = fluxdata[np.searchsorted(fluxdata['count'], [0])[0] :]
107
+
108
+ return by_target
109
+
110
+
111
+ def extract_fluxes(iter_start=None, iter_stop=None, data_manager=None):
112
+ '''Extract flux values from the WEST HDF5 file for iterations >= iter_start
113
+ and < iter_stop, optionally using another data manager instance instead of the
114
+ global one returned by ``westpa.rc.get_data_manager()``.
115
+
116
+ Returns a dictionary mapping target names (if available, target index otherwise)
117
+ to a 1-D array of type ``fluxentry_dtype``, which contains columns for iteration
118
+ number, flux, and count.
119
+ '''
120
+
121
+ data_manager = data_manager or westpa.rc.get_data_manager()
122
+ iter_start = iter_start or 1
123
+ iter_stop = iter_stop or data_manager.current_iteration
124
+
125
+ if data_manager.we_h5file_version < 7:
126
+ return _extract_fluxes_fileversion_lt_7(iter_start, iter_stop, data_manager)
127
+ else:
128
+ return _extract_fluxes_fileversion_7(iter_start, iter_stop, data_manager)
129
+
130
+
131
+ class WFluxanlTool(WESTTool):
132
+ prog = 'w_fluxanl'
133
+ description = '''\
134
+ Extract fluxes into pre-defined target states from WEST data,
135
+ average, and construct confidence intervals. Monte Carlo bootstrapping
136
+ is used to account for the correlated and possibly non-Gaussian statistical
137
+ error in flux measurements.
138
+
139
+ All non-graphical output (including that to the terminal and HDF5) assumes that
140
+ the propagation/resampling period ``tau`` is equal to unity; to obtain results
141
+ in familiar units, divide all fluxes and multiply all correlation lengths by
142
+ the true value of ``tau``.
143
+ '''
144
+
145
+ output_format_version = 2
146
+
147
+ def __init__(self):
148
+ super().__init__()
149
+ self.data_reader = WESTDataReader()
150
+ self.iter_range = IterRangeSelection()
151
+ self.output_h5file = None
152
+ self.output_group = None
153
+ self.target_groups = {}
154
+
155
+ self.fluxdata = {}
156
+
157
+ self.alpha = None
158
+ self.autocorrel_alpha = None
159
+ self.n_sets = None
160
+ self.do_evol = False
161
+ self.evol_step = 1
162
+
163
+ def add_args(self, parser):
164
+ self.data_reader.add_args(parser)
165
+ self.iter_range.add_args(parser)
166
+ ogroup = parser.add_argument_group('output options')
167
+ ogroup.add_argument(
168
+ '-o',
169
+ '--output',
170
+ default='fluxanl.h5',
171
+ help='Store intermediate data and analysis results to OUTPUT (default: %(default)s).',
172
+ )
173
+ cgroup = parser.add_argument_group('calculation options')
174
+ cgroup.add_argument(
175
+ '--disable-bootstrap',
176
+ '-db',
177
+ dest='bootstrap',
178
+ action='store_const',
179
+ const=False,
180
+ help='''Enable the use of Monte Carlo Block Bootstrapping.''',
181
+ )
182
+ cgroup.add_argument(
183
+ '--disable-correl',
184
+ '-dc',
185
+ dest='correl',
186
+ action='store_const',
187
+ const=False,
188
+ help='''Disable the correlation analysis.''',
189
+ )
190
+ cgroup.add_argument(
191
+ '-a',
192
+ '--alpha',
193
+ type=float,
194
+ default=0.05,
195
+ help='''Calculate a (1-ALPHA) confidence interval on the average flux'
196
+ (default: %(default)s)''',
197
+ )
198
+ cgroup.add_argument(
199
+ '--autocorrel-alpha',
200
+ type=float,
201
+ dest='acalpha',
202
+ metavar='ACALPHA',
203
+ help='''Evaluate autocorrelation of flux to (1-ACALPHA) significance.
204
+ Note that too small an ACALPHA will result in failure to detect autocorrelation
205
+ in a noisy flux signal. (Default: same as ALPHA.)''',
206
+ )
207
+ cgroup.add_argument(
208
+ '-N', '--nsets', type=int, help='''Use NSETS samples for bootstrapping (default: chosen based on ALPHA)'''
209
+ )
210
+ cgroup.add_argument(
211
+ '--evol',
212
+ action='store_true',
213
+ dest='do_evol',
214
+ help='''Calculate time evolution of flux confidence intervals (expensive).''',
215
+ )
216
+ cgroup.add_argument(
217
+ '--evol-step',
218
+ type=int,
219
+ default=1,
220
+ metavar='ESTEP',
221
+ help='''Calculate time evolution of flux confidence intervals every ESTEP
222
+ iterations (default: %(default)s)''',
223
+ )
224
+
225
+ def process_args(self, args):
226
+ self.data_reader.process_args(args)
227
+ self.data_reader.open()
228
+ self.iter_range.data_manager = self.data_reader
229
+ self.iter_range.process_args(args)
230
+
231
+ self.output_h5file = h5py.File(args.output, 'w')
232
+
233
+ self.alpha = args.alpha
234
+ # Disable the bootstrap or the correlation analysis.
235
+ self.mcbs_enable = args.bootstrap if args.bootstrap is not None else True
236
+ self.do_correl = args.correl if args.correl is not None else True
237
+ self.autocorrel_alpha = args.acalpha or self.alpha
238
+ self.n_sets = args.nsets or mclib.get_bssize(self.alpha)
239
+
240
+ self.do_evol = args.do_evol
241
+ self.evol_step = args.evol_step or 1
242
+
243
+ def calc_store_flux_data(self):
244
+ westpa.rc.pstatus(
245
+ 'Calculating mean flux and confidence intervals for iterations [{},{})'.format(
246
+ self.iter_range.iter_start, self.iter_range.iter_stop
247
+ )
248
+ )
249
+
250
+ fluxdata = extract_fluxes(self.iter_range.iter_start, self.iter_range.iter_stop, self.data_reader)
251
+
252
+ # Create a group to store data in
253
+ output_group = h5io.create_hdf5_group(self.output_h5file, 'target_flux', replace=False, creating_program=self.prog)
254
+ self.output_group = output_group
255
+ output_group.attrs['version_code'] = self.output_format_version
256
+ self.iter_range.record_data_iter_range(output_group)
257
+
258
+ n_targets = len(fluxdata)
259
+ index = np.empty((len(fluxdata),), dtype=target_index_dtype)
260
+ avg_fluxdata = np.empty((n_targets,), dtype=ci_dtype)
261
+
262
+ for itarget, (target_label, target_fluxdata) in enumerate(fluxdata.items()):
263
+ # Create group and index entry
264
+ index[itarget]['target_label'] = str(target_label)
265
+ target_group = output_group.create_group('target_{}'.format(itarget))
266
+
267
+ self.target_groups[target_label] = target_group
268
+
269
+ # Store per-iteration values
270
+ target_group['n_iter'] = target_fluxdata['n_iter']
271
+ target_group['count'] = target_fluxdata['count']
272
+ target_group['flux'] = target_fluxdata['flux']
273
+ h5io.label_axes(target_group['flux'], ['n_iter'], units=['tau^-1'])
274
+
275
+ # Calculate flux autocorrelation
276
+ fluxes = target_fluxdata['flux']
277
+ mean_flux = fluxes.mean()
278
+ fmm = fluxes - mean_flux
279
+ acorr = fftconvolve(fmm, fmm[::-1])
280
+ acorr = acorr[len(acorr) // 2 :]
281
+ acorr /= acorr[0]
282
+ acorr_ds = target_group.create_dataset('flux_autocorrel', data=acorr)
283
+ h5io.label_axes(acorr_ds, ['lag'], ['tau'])
284
+
285
+ # Calculate overall averages and CIs
286
+ # avg, lb_ci, ub_ci, correl_len = mclib.mcbs_ci_correl(fluxes, np.mean, self.alpha, self.n_sets,
287
+ # autocorrel_alpha=self.autocorrel_alpha, subsample=np.mean)
288
+ avg, lb_ci, ub_ci, sterr, correl_len = mclib.mcbs_ci_correl(
289
+ {'dataset': fluxes},
290
+ estimator=(lambda stride, dataset: np.mean(dataset)),
291
+ alpha=self.alpha,
292
+ n_sets=self.n_sets,
293
+ autocorrel_alpha=self.autocorrel_alpha,
294
+ subsample=np.mean,
295
+ do_correl=self.do_correl,
296
+ mcbs_enable=self.mcbs_enable,
297
+ )
298
+ avg_fluxdata[itarget] = (self.iter_range.iter_start, self.iter_range.iter_stop, avg, lb_ci, ub_ci, sterr, correl_len)
299
+ westpa.rc.pstatus('target {!r}:'.format(target_label))
300
+ westpa.rc.pstatus(' correlation length = {} tau'.format(correl_len))
301
+ westpa.rc.pstatus(' mean flux and CI = {:e} ({:e},{:e}) tau^(-1)'.format(avg, lb_ci, ub_ci))
302
+ index[itarget]['mean_flux'] = avg
303
+ index[itarget]['mean_flux_ci_lb'] = lb_ci
304
+ index[itarget]['mean_flux_ci_ub'] = ub_ci
305
+ index[itarget]['mean_flux_correl_len'] = correl_len
306
+
307
+ # Write index and summary
308
+ index_ds = output_group.create_dataset('index', data=index)
309
+ index_ds.attrs['mcbs_alpha'] = self.alpha
310
+ index_ds.attrs['mcbs_autocorrel_alpha'] = self.autocorrel_alpha
311
+ index_ds.attrs['mcbs_n_sets'] = self.n_sets
312
+
313
+ self.fluxdata = fluxdata
314
+ self.output_h5file['avg_flux'] = avg_fluxdata
315
+
316
+ def calc_evol_flux(self):
317
+ westpa.rc.pstatus(
318
+ 'Calculating cumulative evolution of flux confidence intervals every {} iteration(s)'.format(self.evol_step)
319
+ )
320
+
321
+ for itarget, (target_label, target_fluxdata) in enumerate(self.fluxdata.items()):
322
+ fluxes = target_fluxdata['flux']
323
+ target_group = self.target_groups[target_label]
324
+ iter_start = target_group['n_iter'][0]
325
+ iter_stop = target_group['n_iter'][-1]
326
+ iter_count = iter_stop - iter_start
327
+ n_blocks = iter_count // self.evol_step
328
+ if iter_count % self.evol_step > 0:
329
+ n_blocks += 1
330
+
331
+ cis = np.empty((n_blocks,), dtype=ci_dtype)
332
+
333
+ for iblock in range(n_blocks):
334
+ block_iter_stop = min(iter_start + (iblock + 1) * self.evol_step, iter_stop)
335
+ istop = min((iblock + 1) * self.evol_step, len(target_fluxdata['flux']))
336
+ fluxes = target_fluxdata['flux'][:istop]
337
+
338
+ # avg, ci_lb, ci_ub, correl_len = mclib.mcbs_ci_correl(fluxes, np.mean, self.alpha, self.n_sets,
339
+ # autocorrel_alpha = self.autocorrel_alpha,
340
+ # subsample=np.mean)
341
+ avg, ci_lb, ci_ub, sterr, correl_len = mclib.mcbs_ci_correl(
342
+ {'dataset': fluxes},
343
+ estimator=(lambda stride, dataset: np.mean(dataset)),
344
+ alpha=self.alpha,
345
+ n_sets=self.n_sets,
346
+ autocorrel_alpha=self.autocorrel_alpha,
347
+ subsample=np.mean,
348
+ do_correl=self.do_correl,
349
+ mcbs_enable=self.mcbs_enable,
350
+ )
351
+ cis[iblock]['iter_start'] = iter_start
352
+ cis[iblock]['iter_stop'] = block_iter_stop
353
+ cis[iblock]['expected'], cis[iblock]['ci_lbound'], cis[iblock]['ci_ubound'] = avg, ci_lb, ci_ub
354
+ cis[iblock]['corr_len'] = correl_len
355
+ cis[iblock]['sterr'] = sterr
356
+
357
+ del fluxes
358
+
359
+ cis_ds = target_group.create_dataset('flux_evolution', data=cis)
360
+ cis_ds.attrs['iter_step'] = self.evol_step
361
+ cis_ds.attrs['mcbs_alpha'] = self.alpha
362
+ cis_ds.attrs['mcbs_autocorrel_alpha'] = self.autocorrel_alpha
363
+ cis_ds.attrs['mcbs_n_sets'] = self.n_sets
364
+
365
+ def go(self):
366
+ self.calc_store_flux_data()
367
+ if self.do_evol:
368
+ self.calc_evol_flux()
369
+
370
+
371
+ def entry_point():
372
+ WFluxanlTool().main()
373
+
374
+
375
+ if __name__ == '__main__':
376
+ entry_point()