w_bins
w_bins
deals with binning modification and statistics
Overview
Usage:
w_bins [-h] [-r RCFILE] [--quiet | --verbose | --debug] [--version]
[-W WEST_H5FILE]
{info,rebin} ...
Display information and statistics about binning in a WEST simulation, or modify the binning for the current iteration of a WEST simulation.
Command-Line Options
See the general command-line tool reference for more information on the general options.
Options Under ‘info’
Usage:
w_bins info [-h] [-n N_ITER] [--detail]
[--bins-from-system | --bins-from-expr BINS_FROM_EXPR | --bins-from-function BINS_FROM_FUNCTION | --bins-from-file]
Positional options:
info
Display information about binning.
Options for ‘info’:
-n N_ITER, --n-iter N_ITER
Consider initial points of segment N_ITER (default: current
iteration).
--detail
Display detailed per-bin information in addition to summary
information.
Binning options for ‘info’:
--bins-from-system
Bins are constructed by the system driver specified in the WEST
configuration file (default where stored bin definitions not
available).
--bins-from-expr BINS_FROM_EXPR, --binbounds BINS_FROM_EXPR
Construct bins on a rectilinear grid according to the given BINEXPR.
This must be a list of lists of bin boundaries (one list of bin
boundaries for each dimension of the progress coordinate), formatted
as a Python expression. E.g. "[[0,1,2,4,inf],[-inf,0,inf]]". The
numpy module and the special symbol "inf" (for floating-point
infinity) are available for use within BINEXPR.
--bins-from-function BINS_FROM_FUNCTION, --binfunc BINS_FROM_FUNCTION
Supply an external function which, when called, returns a properly
constructed bin mapper which will then be used for bin assignments.
This should be formatted as "[PATH:]MODULE.FUNC", where the function
FUNC in module MODULE will be used; the optional PATH will be
prepended to the module search path when loading MODULE.
--bins-from-file
Load bin specification from the data file being examined (default
where stored bin definitions available).
Options Under ‘rebin’
Usage:
w_bins rebin [-h] [--confirm] [--detail]
[--bins-from-system | --bins-from-expr BINS_FROM_EXPR | --bins-from-function BINS_FROM_FUNCTION]
[--target-counts TARGET_COUNTS | --target-counts-from FILENAME]
Positional option:
rebin
Rebuild current iteration with new binning.
Options for ‘rebin’:
--confirm
Commit the revised iteration to HDF5; without this option, the
effects of the new binning are only calculated and printed.
--detail
Display detailed per-bin information in addition to summary
information.
Binning options for ‘rebin’;
Same as the binning options for ‘info’.
Bin target count options for ‘rebin’;:
--target-counts TARGET_COUNTS
Use TARGET_COUNTS instead of stored or system driver target counts.
TARGET_COUNTS is a comma-separated list of integers. As a special
case, a single integer is acceptable, in which case the same target
count is used for all bins.
--target-counts-from FILENAME
Read target counts from the text file FILENAME instead of using
stored or system driver target counts. FILENAME must contain a list
of integers, separated by arbitrary whitespace (including newlines).
Input Options
-W WEST_H5FILE, --west_data WEST_H5FILE
Take WEST data from WEST_H5FILE (default: read from the HDF5 file
specified in west.cfg).
Examples
(TODO: Write up an example)
westpa.cli.tools.w_bins module
- class westpa.cli.tools.w_bins.WESTTool
Bases:
WESTToolComponent
Base class for WEST command line tools
- prog = None
- usage = None
- description = None
- epilog = None
- add_args(parser)
Add arguments specific to this tool to the given argparse parser.
- process_args(args)
Take argparse-processed arguments associated with this tool and deal with them appropriately (setting instance variables, etc)
- make_parser(prog=None, usage=None, description=None, epilog=None, args=None)
- make_parser_and_process(prog=None, usage=None, description=None, epilog=None, args=None)
A convenience function to create a parser, call add_all_args(), and then call process_all_args(). The argument namespace is returned.
- go()
Perform the analysis associated with this tool.
- main()
A convenience function to make a parser, parse and process arguments, then call self.go()
- class westpa.cli.tools.w_bins.WESTDataReader
Bases:
WESTToolComponent
Tool for reading data from WEST-related HDF5 files. Coordinates finding the main HDF5 file from west.cfg or command line arguments, caching of certain kinds of data (eventually), and retrieving auxiliary data sets from various places.
- add_args(parser)
Add arguments specific to this component to the given argparse parser.
- process_args(args)
Take argparse-processed arguments associated with this component and deal with them appropriately (setting instance variables, etc)
- open(mode='r')
- close()
- property weight_dsspec
- property parent_id_dsspec
- class westpa.cli.tools.w_bins.BinMappingComponent
Bases:
WESTToolComponent
Component for obtaining a bin mapper from one of several places based on command-line arguments. Such locations include an HDF5 file that contains pickled mappers (including the primary WEST HDF5 file), the system object, an external function, or (in the common case of rectilinear bins) a list of lists of bin boundaries.
Some configuration is necessary prior to calling process_args() if loading a mapper from HDF5. Specifically, either set_we_h5file_info() or set_other_h5file_info() must be called to describe where to find the appropriate mapper. In the case of set_we_h5file_info(), the mapper used for WE at the end of a given iteration will be loaded. In the case of set_other_h5file_info(), an arbitrary group and hash value are specified; the mapper corresponding to that hash in the given group will be returned.
In the absence of arguments, the mapper contained in an existing HDF5 file is preferred; if that is not available, the mapper from the system driver is used.
This component adds the following arguments to argument parsers:
- --bins-from-system
Obtain bins from the system driver
—bins-from-expr=EXPR Construct rectilinear bins by parsing EXPR and calling RectilinearBinMapper() with the result. EXPR must therefore be a list of lists.
- –bins-from-function=[PATH:]MODULE.FUNC
Call an external function FUNC in module MODULE (optionally adding PATH to the search path when loading MODULE) which, when called, returns a fully-constructed bin mapper.
—bins-from-file Load bin definitions from a YAML configuration file.
- --bins-from-h5file
Load bins from the file being considered; this is intended to mean the master WEST HDF5 file or results of other binning calculations, as appropriate.
- add_args(parser, description='binning options', suppress=[])
Add arguments specific to this component to the given argparse parser.
- add_target_count_args(parser, description='bin target count options')
Add options to the given parser corresponding to target counts.
- process_args(args)
Take argparse-processed arguments associated with this component and deal with them appropriately (setting instance variables, etc)
- set_we_h5file_info(n_iter=None, data_manager=None, required=False)
Set up to load a bin mapper from the master WEST HDF5 file. The mapper is actually loaded from the file when self.load_bin_mapper() is called, if and only if command line arguments direct this. If
required
is true, then a mapper must be available at iterationn_iter
, or else an exception will be raised.
- set_other_h5file_info(topology_group, hashval)
Set up to load a bin mapper from (any) open HDF5 file, where bin topologies are stored in
topology_group
(an h5py Group object) and the desired mapper has hash valuehashval
. The mapper itself is loaded when self.load_bin_mapper() is called.
- westpa.cli.tools.w_bins.write_bin_info(mapper, assignments, weights, n_target_states, outfile=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>, detailed=False)
Write information about binning to
outfile
, given a mapper (mapper
) and the weights (weights
) and bin assignments (assignments
) of a set of segments, along with a target state count (n_target_states
). Ifdetailed
is true, then per-bin information is written as well as summary information about all bins.
- class westpa.cli.tools.w_bins.WBinTool
Bases:
WESTTool
- prog = 'w_bins'
- description = 'Display information and statistics about binning in a WEST simulation, or\nmodify the binning for the current iteration of a WEST simulation.\n-------------------------------------------------------------------------------\n'
- add_args(parser)
Add arguments specific to this tool to the given argparse parser.
- process_args(args)
Take argparse-processed arguments associated with this tool and deal with them appropriately (setting instance variables, etc)
- go()
Perform the analysis associated with this tool.
- cmd_info()
- cmd_rebin()
- westpa.cli.tools.w_bins.entry_point()