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,213 @@
1
+ import h5py
2
+ import numpy as np
3
+
4
+ from westpa.tools import WESTTool, WESTDataReader, IterRangeSelection, ProgressIndicatorComponent
5
+
6
+ import westpa
7
+ from westpa.core import h5io
8
+ from westpa.core.data_manager import seg_id_dtype, n_iter_dtype, weight_dtype
9
+ from westpa.core.binning import assignments_list_to_table
10
+
11
+
12
+ class WNTopTool(WESTTool):
13
+ prog = 'w_ntop'
14
+ description = '''\
15
+ Select walkers from bins . An assignment file mapping walkers to
16
+ bins at each timepoint is required (see``w_assign --help`` for further
17
+ information on generating this file). By default, high-weight walkers are
18
+ selected (hence the name ``w_ntop``: select the N top-weighted walkers from
19
+ each bin); however, minimum weight walkers and randomly-selected walkers
20
+ may be selected instead.
21
+
22
+
23
+ -----------------------------------------------------------------------------
24
+ Output format
25
+ -----------------------------------------------------------------------------
26
+
27
+ The output file (-o/--output, by default "ntop.h5") contains the following
28
+ datasets:
29
+
30
+ ``/n_iter`` [iteration]
31
+ *(Integer)* Iteration numbers for each entry in other datasets.
32
+
33
+ ``/n_segs`` [iteration][bin]
34
+ *(Integer)* Number of segments in each bin/state in the given iteration.
35
+ This will generally be the same as the number requested with
36
+ ``--n/--count`` but may be smaller if the requested number of walkers
37
+ does not exist.
38
+
39
+ ``/seg_ids`` [iteration][bin][segment]
40
+ *(Integer)* Matching segments in each iteration for each bin.
41
+ For an iteration ``n_iter``, only the first ``n_iter`` entries are
42
+ valid. For example, the full list of matching seg_ids in bin 0 in the
43
+ first stored iteration is ``seg_ids[0][0][:n_segs[0]]``.
44
+
45
+ ``/weights`` [iteration][bin][segment]
46
+ *(Floating-point)* Weights for each matching segment in ``/seg_ids``.
47
+
48
+
49
+ -----------------------------------------------------------------------------
50
+ Command-line arguments
51
+ -----------------------------------------------------------------------------
52
+ '''
53
+
54
+ def __init__(self):
55
+ super().__init__()
56
+
57
+ self.data_reader = WESTDataReader()
58
+ self.iter_range = IterRangeSelection()
59
+ self.progress = ProgressIndicatorComponent()
60
+ self.output_file = None
61
+ self.assignments_filename = None
62
+ self.output_filename = None
63
+ self.what = None
64
+ self.timepoint = None
65
+ self.count = None
66
+
67
+ def add_args(self, parser):
68
+ self.data_reader.add_args(parser)
69
+ self.iter_range.add_args(parser)
70
+
71
+ igroup = parser.add_argument_group('input options')
72
+ igroup.add_argument(
73
+ '-a',
74
+ '--assignments',
75
+ default='assign.h5',
76
+ help='''Use assignments from the given ASSIGNMENTS file (default: %(default)s).''',
77
+ )
78
+
79
+ sgroup = parser.add_argument_group('selection options')
80
+ sgroup.add_argument(
81
+ '-n',
82
+ '--count',
83
+ type=int,
84
+ default=1,
85
+ help='''Select COUNT walkers from each iteration for each bin (default: %(default)s).''',
86
+ )
87
+ sgroup.add_argument(
88
+ '-t',
89
+ '--timepoint',
90
+ type=int,
91
+ default=-1,
92
+ help='''Base selection on the given TIMEPOINT within each iteration. Default (-1)
93
+ corresponds to the last timepoint.''',
94
+ )
95
+ cgroup = parser.add_mutually_exclusive_group()
96
+ cgroup.add_argument(
97
+ '--highweight',
98
+ dest='select_what',
99
+ action='store_const',
100
+ const='highweight',
101
+ help='''Select COUNT highest-weight walkers from each bin.''',
102
+ )
103
+ cgroup.add_argument(
104
+ '--lowweight',
105
+ dest='select_what',
106
+ action='store_const',
107
+ const='lowweight',
108
+ help='''Select COUNT lowest-weight walkers from each bin.''',
109
+ )
110
+ cgroup.add_argument(
111
+ '--random',
112
+ dest='select_what',
113
+ action='store_const',
114
+ const='random',
115
+ help='''Select COUNT walkers randomly from each bin.''',
116
+ )
117
+ parser.set_defaults(select_what='highweight')
118
+
119
+ ogroup = parser.add_argument_group('output options')
120
+ ogroup.add_argument('-o', '--output', default='ntop.h5', help='''Write output to OUTPUT (default: %(default)s).''')
121
+ self.progress.add_args(parser)
122
+
123
+ def process_args(self, args):
124
+ self.progress.process_args(args)
125
+ self.data_reader.process_args(args)
126
+ with self.data_reader:
127
+ self.iter_range.process_args(args)
128
+ self.what = args.select_what
129
+ self.output_filename = args.output
130
+ self.assignments_filename = args.assignments
131
+ self.count = args.count
132
+ self.timepoint = args.timepoint
133
+
134
+ def go(self):
135
+ self.data_reader.open('r')
136
+ assignments_file = h5py.File(self.assignments_filename, mode='r')
137
+ output_file = h5io.WESTPAH5File(self.output_filename, mode='w')
138
+ pi = self.progress.indicator
139
+ count = self.count
140
+ timepoint = self.timepoint
141
+
142
+ nbins = assignments_file.attrs['nbins'] + 1
143
+ assignments_ds = assignments_file['assignments']
144
+
145
+ iter_start, iter_stop = self.iter_range.iter_start, self.iter_range.iter_stop
146
+ iter_count = iter_stop - iter_start
147
+ h5io.check_iter_range_least(assignments_ds, iter_start, iter_stop)
148
+ nsegs = assignments_file['nsegs'][h5io.get_iteration_slice(assignments_file['nsegs'], iter_start, iter_stop)]
149
+
150
+ output_file.create_dataset('n_iter', dtype=n_iter_dtype, data=list(range(iter_start, iter_stop)))
151
+
152
+ seg_count_ds = output_file.create_dataset('nsegs', dtype=np.uint, shape=(iter_count, nbins))
153
+ matching_segs_ds = output_file.create_dataset(
154
+ 'seg_ids',
155
+ shape=(iter_count, nbins, count),
156
+ dtype=seg_id_dtype,
157
+ chunks=h5io.calc_chunksize((iter_count, nbins, count), seg_id_dtype),
158
+ shuffle=True,
159
+ compression=9,
160
+ )
161
+ weights_ds = output_file.create_dataset(
162
+ 'weights',
163
+ shape=(iter_count, nbins, count),
164
+ dtype=weight_dtype,
165
+ chunks=h5io.calc_chunksize((iter_count, nbins, count), weight_dtype),
166
+ shuffle=True,
167
+ compression=9,
168
+ )
169
+ what = self.what
170
+
171
+ with pi:
172
+ pi.new_operation('Finding matching segments', extent=iter_count)
173
+ for iiter, n_iter in enumerate(range(iter_start, iter_stop)):
174
+ assignments = np.require(
175
+ assignments_ds[h5io.get_iteration_entry(assignments_ds, n_iter) + np.index_exp[:, timepoint]],
176
+ dtype=westpa.core.binning.index_dtype,
177
+ )
178
+ all_weights = self.data_reader.get_iter_group(n_iter)['seg_index']['weight']
179
+
180
+ # the following Cython function just executes this loop:
181
+ # for iseg in xrange(nsegs[iiter]):
182
+ # segs_by_bin[iseg,assignments[iseg]] = True
183
+ segs_by_bin = assignments_list_to_table(nsegs[iiter], nbins, assignments)
184
+ for ibin in range(nbins):
185
+ segs = np.nonzero(segs_by_bin[:, ibin])[0]
186
+
187
+ seg_count_ds[iiter, ibin] = min(len(segs), count)
188
+
189
+ if len(segs):
190
+ weights = all_weights.take(segs)
191
+
192
+ if what == 'lowweight':
193
+ indices = np.argsort(weights, kind='stable')[:count]
194
+ elif what == 'highweight':
195
+ indices = np.argsort(weights, kind='stable')[::-1][:count]
196
+ else:
197
+ assert what == 'random'
198
+ indices = np.random.permutation(len(weights))
199
+
200
+ matching_segs_ds[iiter, ibin, : len(segs)] = segs.take(indices)
201
+ weights_ds[iiter, ibin, : len(segs)] = weights.take(indices)
202
+ del segs, weights
203
+
204
+ del assignments, segs_by_bin, all_weights
205
+ pi.progress += 1
206
+
207
+
208
+ def entry_point():
209
+ WNTopTool().main()
210
+
211
+
212
+ if __name__ == '__main__':
213
+ entry_point()