xp_launch⚓︎
Tools (notably xpList) for setup and running of experiments (known as xps).
See da_methods.da_method for the strict definition of xps.
Modules:
| Name | Description |
|---|---|
dapper |
Root package of DAPPER |
pb |
Make |
xpList
⚓︎
Bases: list
Subclass of list specialized for experiment ("xp") objects.
Main use: administrate experiment launches.
Modifications to list:
xpList.appendsupportsuniqueto enable lazyxpdeclaration.__iadd__(+=) supports adding singlexps. this is hackey, but convenience is king.__getitem__supports lists, similar tonp.ndarray__repr__: prints the list as rows of a table, where the columns represent attributes whose value is not shared among allxps. Refer toxpList.prep_tablefor more information.
Add-ons:
xpList.launch: run the experiments in current list.xpList.prep_table: find all attributes of thexps in the list; classify as distinct, redundant, or common.xpList.gen_names: usexpList.prep_tableto generate a short & unique name for eachxpin the list.xpList.tabulate_avrgs: tabulate time-averaged results.xpList.indsto search by kw-attrs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
args
|
entries
|
Nothing, or a list of |
()
|
unique
|
bool
|
Duplicates won't get appended. Makes |
False
|
Also see
- Examples:
docs/examples/basic_2,docs/examples/basic_3 xp_process.xpSpace, which is used for experient result presentation, as opposed to this class (xpList), which handles launching experiments.
da_methods
⚓︎
List da_method attributes in this list.
__getitem__(keys)
⚓︎
Indexing, also by a list
append(xp)
⚓︎
Append if not self.unique & present.
gen_names(abbrev=6, tab=False)
⚓︎
Similiar to self.__repr__(), but:
- returns list of names
- tabulation is optional
- attaches (abbreviated) labels to each attribute
inds(strict=True, missingval='NONSENSE', **kws)
⚓︎
Find (all) indices of xps whose attributes match kws.
If strict, then xps lacking a requested attr. will not match,
unless the missingval matches the required value.
launch(HMM, save_as='noname', mp=False, fail_gently=None, **kwargs)
⚓︎
Essentially: for xp in self: run_experiment(xp, ..., **kwargs).
See run_experiment for documentation on the kwargs and fail_gently.
See tools.datafiles.create_run_dir for documentation save_as.
Depending on mp, run_experiment is delegated as follows:
False: caller process (no parallelisation)Trueor"MP"or anint: multiprocessing on this host"GCP"or"Google"ordict(server="GCP"): the DAPPER server (Google Cloud Computing with HTCondor).- Specify a list of files as
mp["files"]to include them in working directory of the server workers. - In order to use absolute paths, the list should cosist of tuples, where the first item is relative to the second (which is an absolute path). The root is then not included in the working directory of the server.
- If this dict field is empty, then all python files
in
sys.path[0]are uploaded.
- Specify a list of files as
See docs/examples/basic_2.py and docs/examples/basic_3.py for example use.
prep_table(nomerge=())
⚓︎
Classify all attrs. of all xps as distinct, redundant, or common.
An attribute of the xps is inserted in one of the 3 dicts as follows:
The attribute names become dict keys. If the values of an attribute
(collected from all of the xps) are all equal, then the attribute
is inserted in common, but only with a single value.
If they are all the same or missing, then it is inserted in redundant
with a single value. Otherwise, it is inserted in distinct,
with its full list of values (filling with None where the attribute
was missing in the corresponding xp).
The attrs in distinct are sufficient to (but not generally necessary,
since there might exist a subset of attributes that) uniquely identify each xp
in the list (the redundant and common can be "squeezed" out).
Thus, a table of the xps does not need to list all of the attributes.
This function also does the heavy lifting for xp_process.xpSpace.squeeze.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
nomerge
|
list
|
Attributes that should always be seen as distinct. |
()
|
combinator(param_dict, **glob_dict)
⚓︎
Mass creation of xp's by combining the value lists in the param_dict.
Returns a function (for_params) that creates all possible combinations
of parameters (from their value list) for a given da_methods.da_method.
This is a good deal more efficient than relying on xpList's unique. Parameters
- not found among the args of the given DA method are ignored by
for_params. - specified as keywords to the
for_paramsfix the value preventing using the corresponding (if any) value list in theparam_dict.
Warning
Beware! If, eg., infl or rot are in param_dict, aimed at the EnKF,
but you forget that they are also attributes some method where you don't
actually want to use them (eg. SVGDF),
then you'll create many more than you intend.
run_experiment(xp, label, savedir, HMM, setup=seed_and_simulate, free=True, statkeys=False, fail_gently=False, **stat_kwargs)
⚓︎
Used by xp_launch.xpList.launch to run each single (DA) experiment ("xp").
This involves steps similar to docs/examples/basic_1.py, i.e.:
setup: Initialize experiment.xp.assimilate: run DA, pass on exception if fail_gentlyxp.stats.average_in_time: result averagingxp.avrgs.tabulate: result printingdill.dump: result storage
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
xp
|
object
|
Type: a |
required |
label
|
str
|
Name attached to progressbar during assimilation. |
required |
savedir
|
str
|
Path of folder wherein to store the experiment data. |
required |
HMM
|
HiddenMarkovModel
|
Container defining the system. |
required |
free
|
bool
|
Whether (or not) to |
True
|
statkeys
|
list
|
A list of names (possibly in the form of abbreviations) of the statistical averages that should be printed immediately afther this xp. |
False
|
fail_gently
|
bool
|
Whether (or not) to propagate exceptions. |
False
|
setup
|
function
|
This function must take two arguments: This gives you the ability to customize almost any aspect of the individual
experiments within a batch launch of experiments (i.e. not just the parameters
of the DA. method). Typically you will grab one or more parameter values stored
in the
|
seed_and_simulate
|
seed_and_simulate(HMM, xp)
⚓︎
Default experiment setup (sets seed and simulates truth and obs).
Used by xp_launch.xpList.launch via xp_launch.run_experiment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
HMM
|
HiddenMarkovModel
|
Container defining the system. |
required |
xp
|
object
|
Type: a
Without |
required |
Returns:
| Type | Description |
|---|---|
tuple(xx, yy)
|
The simulated truth and observations. |