westpa 2022.12__cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.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.

Potentially problematic release.


This version of westpa might be problematic. Click here for more details.

Files changed (149) 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 +746 -0
  5. westpa/analysis/statistics.py +27 -0
  6. westpa/analysis/trajectories.py +360 -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 +596 -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 +547 -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 +833 -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_trace.py +599 -0
  38. westpa/core/__init__.py +0 -0
  39. westpa/core/_rc.py +673 -0
  40. westpa/core/binning/__init__.py +55 -0
  41. westpa/core/binning/_assign.cpython-313-x86_64-linux-gnu.so +0 -0
  42. westpa/core/binning/assign.py +455 -0
  43. westpa/core/binning/binless.py +96 -0
  44. westpa/core/binning/binless_driver.py +54 -0
  45. westpa/core/binning/binless_manager.py +190 -0
  46. westpa/core/binning/bins.py +47 -0
  47. westpa/core/binning/mab.py +506 -0
  48. westpa/core/binning/mab_driver.py +54 -0
  49. westpa/core/binning/mab_manager.py +198 -0
  50. westpa/core/data_manager.py +1694 -0
  51. westpa/core/extloader.py +74 -0
  52. westpa/core/h5io.py +995 -0
  53. westpa/core/kinetics/__init__.py +24 -0
  54. westpa/core/kinetics/_kinetics.cpython-313-x86_64-linux-gnu.so +0 -0
  55. westpa/core/kinetics/events.py +147 -0
  56. westpa/core/kinetics/matrates.py +156 -0
  57. westpa/core/kinetics/rate_averaging.py +266 -0
  58. westpa/core/progress.py +218 -0
  59. westpa/core/propagators/__init__.py +54 -0
  60. westpa/core/propagators/executable.py +719 -0
  61. westpa/core/reweight/__init__.py +14 -0
  62. westpa/core/reweight/_reweight.cpython-313-x86_64-linux-gnu.so +0 -0
  63. westpa/core/reweight/matrix.py +126 -0
  64. westpa/core/segment.py +119 -0
  65. westpa/core/sim_manager.py +835 -0
  66. westpa/core/states.py +359 -0
  67. westpa/core/systems.py +93 -0
  68. westpa/core/textio.py +74 -0
  69. westpa/core/trajectory.py +330 -0
  70. westpa/core/we_driver.py +910 -0
  71. westpa/core/wm_ops.py +43 -0
  72. westpa/core/yamlcfg.py +391 -0
  73. westpa/fasthist/__init__.py +34 -0
  74. westpa/fasthist/_fasthist.cpython-313-x86_64-linux-gnu.so +0 -0
  75. westpa/mclib/__init__.py +271 -0
  76. westpa/mclib/__main__.py +28 -0
  77. westpa/mclib/_mclib.cpython-313-x86_64-linux-gnu.so +0 -0
  78. westpa/oldtools/__init__.py +4 -0
  79. westpa/oldtools/aframe/__init__.py +35 -0
  80. westpa/oldtools/aframe/atool.py +75 -0
  81. westpa/oldtools/aframe/base_mixin.py +26 -0
  82. westpa/oldtools/aframe/binning.py +178 -0
  83. westpa/oldtools/aframe/data_reader.py +560 -0
  84. westpa/oldtools/aframe/iter_range.py +200 -0
  85. westpa/oldtools/aframe/kinetics.py +117 -0
  86. westpa/oldtools/aframe/mcbs.py +153 -0
  87. westpa/oldtools/aframe/output.py +39 -0
  88. westpa/oldtools/aframe/plotting.py +90 -0
  89. westpa/oldtools/aframe/trajwalker.py +126 -0
  90. westpa/oldtools/aframe/transitions.py +469 -0
  91. westpa/oldtools/cmds/__init__.py +0 -0
  92. westpa/oldtools/cmds/w_ttimes.py +361 -0
  93. westpa/oldtools/files.py +34 -0
  94. westpa/oldtools/miscfn.py +23 -0
  95. westpa/oldtools/stats/__init__.py +4 -0
  96. westpa/oldtools/stats/accumulator.py +35 -0
  97. westpa/oldtools/stats/edfs.py +129 -0
  98. westpa/oldtools/stats/mcbs.py +96 -0
  99. westpa/tools/__init__.py +33 -0
  100. westpa/tools/binning.py +472 -0
  101. westpa/tools/core.py +340 -0
  102. westpa/tools/data_reader.py +159 -0
  103. westpa/tools/dtypes.py +31 -0
  104. westpa/tools/iter_range.py +198 -0
  105. westpa/tools/kinetics_tool.py +340 -0
  106. westpa/tools/plot.py +283 -0
  107. westpa/tools/progress.py +17 -0
  108. westpa/tools/selected_segs.py +154 -0
  109. westpa/tools/wipi.py +751 -0
  110. westpa/trajtree/__init__.py +4 -0
  111. westpa/trajtree/_trajtree.cpython-313-x86_64-linux-gnu.so +0 -0
  112. westpa/trajtree/trajtree.py +117 -0
  113. westpa/westext/__init__.py +0 -0
  114. westpa/westext/adaptvoronoi/__init__.py +3 -0
  115. westpa/westext/adaptvoronoi/adaptVor_driver.py +214 -0
  116. westpa/westext/hamsm_restarting/__init__.py +3 -0
  117. westpa/westext/hamsm_restarting/example_overrides.py +35 -0
  118. westpa/westext/hamsm_restarting/restart_driver.py +1165 -0
  119. westpa/westext/stringmethod/__init__.py +11 -0
  120. westpa/westext/stringmethod/fourier_fitting.py +69 -0
  121. westpa/westext/stringmethod/string_driver.py +253 -0
  122. westpa/westext/stringmethod/string_method.py +306 -0
  123. westpa/westext/weed/BinCluster.py +180 -0
  124. westpa/westext/weed/ProbAdjustEquil.py +100 -0
  125. westpa/westext/weed/UncertMath.py +247 -0
  126. westpa/westext/weed/__init__.py +10 -0
  127. westpa/westext/weed/weed_driver.py +192 -0
  128. westpa/westext/wess/ProbAdjust.py +101 -0
  129. westpa/westext/wess/__init__.py +6 -0
  130. westpa/westext/wess/wess_driver.py +217 -0
  131. westpa/work_managers/__init__.py +57 -0
  132. westpa/work_managers/core.py +396 -0
  133. westpa/work_managers/environment.py +134 -0
  134. westpa/work_managers/mpi.py +318 -0
  135. westpa/work_managers/processes.py +187 -0
  136. westpa/work_managers/serial.py +28 -0
  137. westpa/work_managers/threads.py +79 -0
  138. westpa/work_managers/zeromq/__init__.py +20 -0
  139. westpa/work_managers/zeromq/core.py +641 -0
  140. westpa/work_managers/zeromq/node.py +131 -0
  141. westpa/work_managers/zeromq/work_manager.py +526 -0
  142. westpa/work_managers/zeromq/worker.py +320 -0
  143. westpa-2022.12.dist-info/AUTHORS +22 -0
  144. westpa-2022.12.dist-info/LICENSE +21 -0
  145. westpa-2022.12.dist-info/METADATA +193 -0
  146. westpa-2022.12.dist-info/RECORD +149 -0
  147. westpa-2022.12.dist-info/WHEEL +6 -0
  148. westpa-2022.12.dist-info/entry_points.txt +29 -0
  149. westpa-2022.12.dist-info/top_level.txt +1 -0
@@ -0,0 +1,166 @@
1
+ import logging
2
+ import sys
3
+
4
+ import numpy as np
5
+
6
+ from westpa.tools import WESTTool, WESTDataReader, BinMappingComponent
7
+ import westpa
8
+
9
+ from westpa.tools.binning import write_bin_info
10
+
11
+
12
+ log = logging.getLogger('w_bins')
13
+
14
+
15
+ class WBinTool(WESTTool):
16
+ prog = 'w_bins'
17
+ description = '''\
18
+ Display information and statistics about binning in a WEST simulation, or
19
+ modify the binning for the current iteration of a WEST simulation.
20
+ -------------------------------------------------------------------------------
21
+ '''
22
+
23
+ def __init__(self):
24
+ super().__init__()
25
+ self.subcommand = None
26
+ self.data_reader = WESTDataReader()
27
+ self.binning = BinMappingComponent()
28
+ self.args = None
29
+ self.n_iter = None
30
+
31
+ # Interface for command-line tools
32
+ def add_args(self, parser):
33
+ self.data_reader.add_args(parser)
34
+
35
+ subparsers = parser.add_subparsers(help='available commands')
36
+
37
+ info_parser = subparsers.add_parser('info', help='Display information about binning.')
38
+ info_parser.add_argument(
39
+ '-n', '--n-iter', type=int, help='''Consider initial points of segment N_ITER (default: current iteration).'''
40
+ )
41
+ info_parser.add_argument(
42
+ '--detail',
43
+ action='store_true',
44
+ help='''Display detailed per-bin information in addition to summary
45
+ information.''',
46
+ )
47
+ self.binning.add_args(info_parser)
48
+ info_parser.set_defaults(func=self.cmd_info)
49
+
50
+ rebin_parser = subparsers.add_parser('rebin', help='Rebuild current iteration with new binning.')
51
+ rebin_parser.add_argument(
52
+ '--confirm',
53
+ action='store_true',
54
+ help='''Commit the revised iteration to HDF5; without this option, the effects of the
55
+ new binning are only calculated and printed.''',
56
+ )
57
+ rebin_parser.add_argument(
58
+ '--detail',
59
+ action='store_true',
60
+ help='''Display detailed per-bin information in addition to summary
61
+ information.''',
62
+ )
63
+ rebin_parser.add_argument(
64
+ '-n', '--n-iter', type=int, help='''Consider initial points of segment N_ITER (default: current iteration).'''
65
+ )
66
+ self.binning.add_args(rebin_parser, suppress=['--bins-from-file'])
67
+ self.binning.add_target_count_args(rebin_parser)
68
+ rebin_parser.set_defaults(func=self.cmd_rebin)
69
+
70
+ def process_args(self, args):
71
+ self.data_reader.process_args(args)
72
+ self.data_reader.open(mode='r+')
73
+ self.n_iter = getattr(args, 'n_iter', None) or self.data_reader.current_iteration
74
+
75
+ # we cannot read bin information during rebins
76
+ # interesting note: '==' is required here; 'is' fails
77
+ if args.func == self.cmd_rebin:
78
+ self.binning.target_counts_required = True
79
+ else:
80
+ self.binning.set_we_h5file_info(self.n_iter, self.data_reader)
81
+
82
+ self.binning.process_args(args)
83
+
84
+ self.args = args
85
+ self.subcommand = args.func
86
+
87
+ def go(self):
88
+ self.subcommand()
89
+
90
+ def cmd_info(self):
91
+ mapper = self.binning.mapper
92
+
93
+ # Get target states and their assignments
94
+ target_states = self.data_reader.get_target_states(self.n_iter)
95
+ n_target_states = len(target_states)
96
+
97
+ iter_group = self.data_reader.get_iter_group(self.n_iter)
98
+
99
+ # bin initial pcoords for iteration n_iter
100
+ initial_pcoords = iter_group['pcoord'][:, 0, :]
101
+ assignments = mapper.assign(initial_pcoords)
102
+ del initial_pcoords
103
+
104
+ print('Bin information for iteration {:d}'.format(self.n_iter))
105
+
106
+ # Get bin counts and weights
107
+ weights = iter_group['seg_index']['weight']
108
+
109
+ write_bin_info(mapper, assignments, weights, n_target_states, detailed=self.args.detail)
110
+
111
+ def cmd_rebin(self):
112
+ mapper = self.binning.mapper
113
+ assert mapper is not None
114
+ if self.n_iter == 1:
115
+ sys.stderr.write('rebin is not supported for the first iteration; reinitialize with w_init instead\n')
116
+ sys.exit(1)
117
+ n_target_states = len(self.data_reader.get_target_states(self.n_iter))
118
+ we_driver = westpa.rc.get_we_driver()
119
+ data_manager = self.data_reader.data_manager
120
+
121
+ segments = data_manager.get_segments(self.n_iter, load_pcoords=True)
122
+ last_iter_segments = data_manager.get_segments(self.n_iter - 1, load_pcoords=False)
123
+
124
+ # Bin on this iteration's initial points
125
+ # We don't have to worry about recycling because we are binning on
126
+ # initial points rather than final points, so recycling has already
127
+ # occurred for this iteration.
128
+ # We do need initial states, in case we merge a newly-created walker out of existence
129
+ # avail_initial_states = {state.state_id: state
130
+ # for state in data_manager.get_unused_initial_states(n_iter = self.n_iter)}
131
+ avail_initial_states = data_manager.get_unused_initial_states(n_iter=self.n_iter)
132
+ used_initial_states = data_manager.get_segment_initial_states(segments)
133
+ we_driver.new_iteration(
134
+ initial_states=avail_initial_states, bin_mapper=mapper, bin_target_counts=self.binning.bin_target_counts
135
+ )
136
+ we_driver.used_initial_states = {state.state_id: state for state in used_initial_states}
137
+ we_driver.assign(segments, initializing=True)
138
+ we_driver.rebin_current(parent_segments=last_iter_segments)
139
+
140
+ weights = np.array([segment.weight for segment in we_driver.next_iter_segments])
141
+ assignments = np.fromiter(we_driver.next_iter_assignments, dtype=int, count=len(weights))
142
+ write_bin_info(mapper, assignments, weights, n_target_states, detailed=self.args.detail)
143
+
144
+ if self.args.confirm:
145
+ data_manager.prepare_iteration(self.n_iter, list(we_driver.next_iter_segments))
146
+
147
+ # manually update endpoint statuses only
148
+ endpoint_types = sorted([(segment.seg_id, segment.endpoint_type) for segment in last_iter_segments])
149
+ last_iter_group = data_manager.get_iter_group(self.n_iter - 1)
150
+ last_iter_index = last_iter_group['seg_index'][...]
151
+ last_iter_index['endpoint_type'] = [pair[1] for pair in endpoint_types]
152
+ last_iter_group['seg_index'][...] = last_iter_index
153
+
154
+ data_manager.save_iter_binning(
155
+ self.n_iter, self.binning.mapper_hash, self.binning.mapper_pickle, we_driver.bin_target_counts
156
+ )
157
+ data_manager.update_initial_states(we_driver.all_initial_states)
158
+ data_manager.flush_backing()
159
+
160
+
161
+ def entry_point():
162
+ WBinTool().main()
163
+
164
+
165
+ if __name__ == '__main__':
166
+ entry_point()
@@ -0,0 +1,119 @@
1
+ import logging
2
+
3
+ from westpa.tools import WESTParallelTool, WESTDataReader, IterRangeSelection, ProgressIndicatorComponent
4
+ import westpa
5
+ from westpa.core.extloader import get_object
6
+
7
+ log = logging.getLogger('w_crawl')
8
+
9
+
10
+ class WESTPACrawler:
11
+ '''Base class for general crawling execution. This class
12
+ only exists on the master.'''
13
+
14
+ def initialize(self, iter_start, iter_stop):
15
+ '''Initialize this crawling process.'''
16
+ pass
17
+
18
+ def finalize(self):
19
+ '''Finalize this crawling process.'''
20
+ pass
21
+
22
+ def process_iter_result(self, n_iter, result):
23
+ '''Process the result of a per-iteration task.'''
24
+ pass
25
+
26
+
27
+ def _remote_task(n_iter, taskfn):
28
+ data_manager = westpa.rc.get_data_manager() # gaahhh...globals
29
+ data_manager.open_backing(mode='r')
30
+ return n_iter, taskfn(n_iter, data_manager.get_iter_group(n_iter))
31
+
32
+
33
+ class WCrawl(WESTParallelTool):
34
+ prog = 'w_crawl'
35
+ description = '''\
36
+ Crawl a weighted ensemble dataset, executing a function for each iteration.
37
+ This can be used for postprocessing of trajectories, cleanup of datasets,
38
+ or anything else that can be expressed as "do X for iteration N, then do
39
+ something with the result". Tasks are parallelized by iteration, and
40
+ no guarantees are made about evaluation order.
41
+
42
+
43
+ -----------------------------------------------------------------------------
44
+ Command-line options
45
+ -----------------------------------------------------------------------------
46
+
47
+ '''
48
+
49
+ def __init__(self):
50
+ super().__init__()
51
+
52
+ # These are used throughout
53
+ self.progress = ProgressIndicatorComponent()
54
+ self.data_reader = WESTDataReader()
55
+ self.iter_range = IterRangeSelection(self.data_reader)
56
+
57
+ self.crawler = None
58
+ self.task_callable = None
59
+
60
+ def add_args(self, parser):
61
+ self.data_reader.add_args(parser)
62
+ self.iter_range.add_args(parser)
63
+
64
+ tgroup = parser.add_argument_group('task options')
65
+ tgroup.add_argument(
66
+ '-c',
67
+ '--crawler-instance',
68
+ help='''Use CRAWLER_INSTANCE (specified as module.instance) as an instance of
69
+ WESTPACrawler to coordinate the calculation. Required only if initialization,
70
+ finalization, or task result processing is required.''',
71
+ )
72
+ tgroup.add_argument(
73
+ 'task_callable',
74
+ help='''Run TASK_CALLABLE (specified as module.function) on each iteration.
75
+ Required.''',
76
+ )
77
+ self.progress.add_args(parser)
78
+
79
+ def process_args(self, args):
80
+ self.progress.process_args(args)
81
+ self.data_reader.process_args(args)
82
+ with self.data_reader:
83
+ self.iter_range.process_args(args)
84
+
85
+ self.task_callable = get_object(args.task_callable, path=['.'])
86
+ if args.crawler_instance is not None:
87
+ self.crawler = get_object(args.crawler_instance, path=['.'])
88
+ else:
89
+ self.crawler = WESTPACrawler()
90
+
91
+ def go(self):
92
+ iter_start = self.iter_range.iter_start
93
+ iter_stop = self.iter_range.iter_stop
94
+ iter_count = iter_stop - iter_start
95
+ self.data_reader.open('r')
96
+ pi = self.progress.indicator
97
+ with pi:
98
+ pi.operation = 'Initializing'
99
+ self.crawler.initialize(iter_start, iter_stop)
100
+
101
+ try:
102
+ pi.new_operation('Dispatching tasks & processing results', iter_count)
103
+ task_gen = ((_remote_task, (n_iter, self.task_callable), {}) for n_iter in range(iter_start, iter_stop))
104
+ for future in self.work_manager.submit_as_completed(task_gen, self.max_queue_len):
105
+ n_iter, result = future.get_result(discard=True)
106
+ if self.crawler is not None:
107
+ self.crawler.process_iter_result(n_iter, result)
108
+ pi.progress += 1
109
+ finally:
110
+ pi.new_operation('Finalizing')
111
+ self.crawler.finalize()
112
+
113
+
114
+ def entry_point():
115
+ WCrawl().main()
116
+
117
+
118
+ if __name__ == '__main__':
119
+ entry_point()