westpa 2022.12__cp312-cp312-macosx_10_13_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-312-darwin.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-312-darwin.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-312-darwin.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-312-darwin.so +0 -0
  75. westpa/mclib/__init__.py +271 -0
  76. westpa/mclib/__main__.py +28 -0
  77. westpa/mclib/_mclib.cpython-312-darwin.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-312-darwin.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,14 @@
1
+ '''
2
+ Function(s) for the postanalysis toolkit
3
+ '''
4
+
5
+ import logging
6
+
7
+ from . import _reweight
8
+ from ._reweight import stats_process, reweight_for_c
9
+ from .matrix import FluxMatrix
10
+
11
+ __all__ = ['_reweight', 'stats_process', 'reweight_for_c', 'FluxMatrix']
12
+
13
+
14
+ log = logging.getLogger(__name__)
@@ -0,0 +1,126 @@
1
+ import warnings
2
+
3
+ import numpy as np
4
+ import scipy.sparse as sp
5
+
6
+ from westpa.core.data_manager import weight_dtype
7
+ from westpa.core import h5io
8
+
9
+ # From postanalysis matrix
10
+ from westpa.core.binning import index_dtype
11
+ from westpa.core.reweight import stats_process
12
+
13
+
14
+ warnings.filterwarnings('ignore', category=DeprecationWarning)
15
+ warnings.filterwarnings('ignore', category=RuntimeWarning)
16
+ warnings.filterwarnings('ignore', category=FutureWarning)
17
+
18
+
19
+ def calc_stats(bin_assignments, weights, fluxes, populations, trans, mask, sampling_frequency):
20
+ fluxes.fill(0.0)
21
+ populations.fill(0.0)
22
+ trans.fill(0)
23
+
24
+ stats_process(bin_assignments, weights, fluxes, populations, trans, mask, interval=sampling_frequency)
25
+
26
+
27
+ class FluxMatrix:
28
+ def w_postanalysis_matrix(self):
29
+ pi = self.progress.indicator
30
+ pi.new_operation('Initializing')
31
+
32
+ self.data_reader.open('r')
33
+ nbins = self.assignments_file.attrs['nbins']
34
+
35
+ state_labels = self.assignments_file['state_labels'][...]
36
+ # state_map = self.assignments_file['state_map'][...]
37
+ nstates = len(state_labels)
38
+
39
+ start_iter, stop_iter = self.iter_range.iter_start, self.iter_range.iter_stop # h5io.get_iter_range(self.assignments_file)
40
+ iter_count = stop_iter - start_iter
41
+
42
+ nfbins = nbins * nstates
43
+
44
+ flux_shape = (iter_count, nfbins, nfbins)
45
+ pop_shape = (iter_count, nfbins)
46
+
47
+ h5io.stamp_iter_range(self.output_file, start_iter, stop_iter)
48
+
49
+ bin_populations_ds = self.output_file.create_dataset('bin_populations', shape=pop_shape, dtype=weight_dtype)
50
+ h5io.stamp_iter_range(bin_populations_ds, start_iter, stop_iter)
51
+ h5io.label_axes(bin_populations_ds, ['iteration', 'bin'])
52
+
53
+ flux_grp = self.output_file.create_group('iterations')
54
+ self.output_file.attrs['nrows'] = nfbins
55
+ self.output_file.attrs['ncols'] = nfbins
56
+
57
+ fluxes = np.empty(flux_shape[1:], weight_dtype)
58
+ populations = np.empty(pop_shape[1:], weight_dtype)
59
+ trans = np.empty(flux_shape[1:], np.int64)
60
+
61
+ # Check to make sure this isn't a data set with target states
62
+ # tstates = self.data_reader.data_manager.get_target_states(0)
63
+ # if len(tstates) > 0:
64
+ # raise ValueError('Postanalysis reweighting analysis does not support WE simulation run under recycling conditions')
65
+
66
+ pi.new_operation('Calculating flux matrices', iter_count)
67
+ # Calculate instantaneous statistics
68
+ for iiter, n_iter in enumerate(range(start_iter, stop_iter)):
69
+ # Get data from the main HDF5 file
70
+ iter_group = self.data_reader.get_iter_group(n_iter)
71
+ seg_index = iter_group['seg_index']
72
+ nsegs, npts = iter_group['pcoord'].shape[0:2]
73
+ weights = seg_index['weight']
74
+
75
+ # Get bin and traj. ensemble assignments from the previously-generated assignments file
76
+ assignment_iiter = h5io.get_iteration_entry(self.assignments_file, n_iter)
77
+ bin_assignments = np.require(
78
+ self.assignments_file['assignments'][assignment_iiter + np.s_[:nsegs, :npts]], dtype=index_dtype
79
+ )
80
+
81
+ mask_unknown = np.zeros_like(bin_assignments, dtype=np.uint16)
82
+
83
+ macrostate_iiter = h5io.get_iteration_entry(self.assignments_file, n_iter)
84
+ macrostate_assignments = np.require(
85
+ self.assignments_file['trajlabels'][macrostate_iiter + np.s_[:nsegs, :npts]], dtype=index_dtype
86
+ )
87
+
88
+ # Transform bin_assignments to take macrostate membership into account
89
+ bin_assignments = nstates * bin_assignments + macrostate_assignments
90
+
91
+ mask_indx = np.where(macrostate_assignments == nstates)
92
+ mask_unknown[mask_indx] = 1
93
+
94
+ # Calculate bin-to-bin fluxes, bin populations and number of obs transitions
95
+ calc_stats(bin_assignments, weights, fluxes, populations, trans, mask_unknown, self.sampling_frequency)
96
+
97
+ # Store bin-based kinetics data
98
+ bin_populations_ds[iiter] = populations
99
+
100
+ # Setup sparse data structures for flux and obs
101
+ fluxes_sp = sp.coo_matrix(fluxes)
102
+ trans_sp = sp.coo_matrix(trans)
103
+
104
+ assert fluxes_sp.nnz == trans_sp.nnz
105
+
106
+ flux_iter_grp = flux_grp.create_group('iter_{:08d}'.format(n_iter))
107
+ flux_iter_grp.create_dataset('flux', data=fluxes_sp.data, dtype=weight_dtype)
108
+ flux_iter_grp.create_dataset('obs', data=trans_sp.data, dtype=np.int32)
109
+ flux_iter_grp.create_dataset('rows', data=fluxes_sp.row, dtype=np.int32)
110
+ flux_iter_grp.create_dataset('cols', data=fluxes_sp.col, dtype=np.int32)
111
+ flux_iter_grp.attrs['nrows'] = nfbins
112
+ flux_iter_grp.attrs['ncols'] = nfbins
113
+
114
+ # Do a little manual clean-up to prevent memory explosion
115
+ del iter_group, weights, bin_assignments
116
+ del macrostate_assignments
117
+
118
+ pi.progress += 1
119
+
120
+ # Check and save the number of intermediate time points; this will be used to normalize the
121
+ # flux and kinetics to tau in w_postanalysis_reweight.
122
+ if self.assignments_file.attrs['subsampled'] is True or self.sampling_frequency == 'iteration':
123
+ self.output_file.attrs['npts'] = 2
124
+ else:
125
+ # self.output_file.attrs['npts'] = npts if self.sampling_frequency == 'timepoint' else 2
126
+ self.output_file.attrs['npts'] = npts
westpa/core/segment.py ADDED
@@ -0,0 +1,119 @@
1
+ import math
2
+
3
+ import numpy as np
4
+
5
+
6
+ class Segment:
7
+ '''A class wrapping segment data that must be passed through the work manager or data manager.
8
+ Most fields are self-explanatory. One item worth noting is that a negative parent ID means that
9
+ the segment starts from the initial state with ID -(segment.parent_id+1)
10
+ '''
11
+
12
+ SEG_STATUS_UNSET = 0
13
+ SEG_STATUS_PREPARED = 1
14
+ SEG_STATUS_COMPLETE = 2
15
+ SEG_STATUS_FAILED = 3
16
+
17
+ SEG_INITPOINT_UNSET = 0
18
+ SEG_INITPOINT_CONTINUES = 1
19
+ SEG_INITPOINT_NEWTRAJ = 2
20
+
21
+ SEG_ENDPOINT_UNSET = 0
22
+ SEG_ENDPOINT_CONTINUES = 1
23
+ SEG_ENDPOINT_MERGED = 2
24
+ SEG_ENDPOINT_RECYCLED = 3
25
+
26
+ statuses = {}
27
+ initpoint_types = {}
28
+ endpoint_types = {}
29
+
30
+ status_names = {}
31
+ initpoint_type_names = {}
32
+ endpoint_type_names = {}
33
+
34
+ # convenience functions for binning
35
+ @staticmethod
36
+ def initial_pcoord(segment):
37
+ 'Return the initial progress coordinate point of this segment.'
38
+ return segment.pcoord[0]
39
+
40
+ @staticmethod
41
+ def final_pcoord(segment):
42
+ 'Return the final progress coordinate point of this segment.'
43
+ return segment.pcoord[-1]
44
+
45
+ def __init__(
46
+ self,
47
+ n_iter=None,
48
+ seg_id=None,
49
+ weight=None,
50
+ endpoint_type=None,
51
+ parent_id=None,
52
+ wtg_parent_ids=None,
53
+ pcoord=None,
54
+ status=None,
55
+ walltime=None,
56
+ cputime=None,
57
+ data=None,
58
+ ):
59
+ # NaNs appear sometimes if a WEST program is terminated unexpectedly; replace with zero
60
+ walltime = 0.0 if walltime is None or math.isnan(walltime) else walltime
61
+ cputime = 0.0 if cputime is None or math.isnan(cputime) else cputime
62
+
63
+ # the int() and float() calls are required so that new-style string formatting doesn't barf
64
+ # assuming that the respective fields are actually strings, probably after implicitly
65
+ # calling __str__() on them. Not sure if this is a numpy, h5py, or python problem
66
+ self.n_iter = int(n_iter) if n_iter is not None else None
67
+ self.seg_id = int(seg_id) if seg_id is not None else None
68
+ self.status = int(status) if status is not None else None
69
+ self.parent_id = int(parent_id) if parent_id is not None else None
70
+ self.endpoint_type = int(endpoint_type) if endpoint_type else self.SEG_ENDPOINT_UNSET
71
+
72
+ self.weight = float(weight) if weight is not None else None
73
+ self.wtg_parent_ids = set(wtg_parent_ids or ())
74
+
75
+ self.pcoord = np.asarray(pcoord) if pcoord is not None else None
76
+ self.walltime = walltime
77
+ self.cputime = cputime
78
+ self.data = data if data else {}
79
+
80
+ def __repr__(self):
81
+ return '<%s(%s) n_iter=%r seg_id=%r weight=%r parent_id=%r wtg_parent_ids=%r pcoord[0]=%r pcoord[-1]=%r>' % (
82
+ self.__class__.__name__,
83
+ hex(id(self)),
84
+ self.n_iter,
85
+ self.seg_id,
86
+ self.weight,
87
+ self.parent_id,
88
+ tuple(self.wtg_parent_ids or ()),
89
+ self.pcoord[0] if self.pcoord is not None else None,
90
+ self.pcoord[-1] if self.pcoord is not None else None,
91
+ )
92
+
93
+ @property
94
+ def initpoint_type(self):
95
+ if self.parent_id < 0:
96
+ return Segment.SEG_INITPOINT_NEWTRAJ
97
+ else:
98
+ return Segment.SEG_INITPOINT_CONTINUES
99
+
100
+ @property
101
+ def initial_state_id(self):
102
+ if self.parent_id < 0:
103
+ return -(self.parent_id + 1)
104
+ else:
105
+ return None
106
+
107
+ status_text = property((lambda s: s.status_names[s.status]))
108
+ endpoint_type_text = property((lambda s: s.endpoint_type_names[s.endpoint_type]))
109
+
110
+
111
+ Segment.statuses.update({_attr: getattr(Segment, _attr) for _attr in dir(Segment) if _attr.startswith('SEG_STATUS_')})
112
+ Segment.initpoint_types.update({_attr: getattr(Segment, _attr) for _attr in dir(Segment) if _attr.startswith('SEG_INITPOINT_')})
113
+ Segment.endpoint_types.update({_attr: getattr(Segment, _attr) for _attr in dir(Segment) if _attr.startswith('SEG_ENDPOINT_')})
114
+
115
+ Segment.status_names.update({getattr(Segment, _attr): _attr for _attr in dir(Segment) if _attr.startswith('SEG_STATUS_')})
116
+ Segment.initpoint_type_names.update(
117
+ {getattr(Segment, _attr): _attr for _attr in dir(Segment) if _attr.startswith('SEG_INITPOINT_')}
118
+ )
119
+ Segment.endpoint_type_names.update({getattr(Segment, _attr): _attr for _attr in dir(Segment) if _attr.startswith('SEG_ENDPOINT_')})