Skip to content

Commit

Permalink
added no-reweight option to w_multi_west (westpa#190)
Browse files Browse the repository at this point in the history
* added no-reweight option to w_multi_west

* fixed multi_west test

* w_multi_west documentation update
  • Loading branch information
jeremyleung521 authored Oct 27, 2021
1 parent 0885211 commit db1b30b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions doc/documentation/cli/w_multi_west.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ Both input and output files are *hdf5* format::
-aa, --auxall
Combine all auxiliary datsets as labeled in ``west.h5`` in folder 01. (Default: False)

-nr, --no-reweight
Do not perform reweighting. (Default: False)

Examples
--------
If you have five simulations, set up your directory such that you
Expand Down
7 changes: 6 additions & 1 deletion src/westpa/cli/tools/w_multi_west.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ def add_args(self, parser):
)
iogroup.add_argument('-a', '--aux', action='append', help='''Names of additional auxiliary datasets to be combined''')
iogroup.add_argument('-aa', '--auxall', action='store_true', help='''Combine all auxiliary datasets. Default: False''')
iogroup.add_argument('-nr', '--no-reweight', action='store_true', help='''Do not reweight. Default: False''')

def open_files(self):
self.output_file = h5io.WESTPAH5File(self.output_file, 'w', creating_program=True)
Expand All @@ -148,6 +149,7 @@ def process_args(self, args):
self.sims = args.sims
self.aux = args.aux
self.auxall = args.auxall
self.reweight = args.no_reweight

def total_number_of_walkers(self):
self.total_walkers = [0] * self.niters
Expand Down Expand Up @@ -308,7 +310,10 @@ def go(self):
# This is... maybe wrong, actually? Or at least, it's not ALL that is required for normalizing things.
# We need to weight everything by 1/N, then just normalize if that normalization was wrong. Keep the relative weights sane.
# ... or actually, no, that's fine, nevermind, what's wrong with me? But we'll leave it in for now.
mseg['weight'] /= mseg['weight'].sum()

if not self.reweight:
mseg['weight'] /= mseg['weight'].sum()

summary['n_particles'][iter - 1] = mseg.shape[0]
summary['norm'][iter - 1] = mseg['weight'].sum()
summary['min_seg_prob'][iter - 1] = min(mseg['weight'])
Expand Down
1 change: 1 addition & 0 deletions tests/test_tools/test_w_multi_west.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def test_run_w_multi_west(self, ref_multi):
sims='3',
aux=None,
auxall=True,
no_reweight=False,
),
):
entry_point()
Expand Down

0 comments on commit db1b30b

Please sign in to comment.