holodeck.librarian.params

Parameters and parameter spaces for holodeck libraries.

class holodeck.librarian.params.PD_Lin_Log(lo, hi, crit, lofrac, **kwargs)[source]
class holodeck.librarian.params.PD_Log_Lin(lo, hi, crit, lofrac, **kwargs)[source]
class holodeck.librarian.params.PD_Normal(mean, stdev, clip=None, **kwargs)[source]

NOTE: use clip parameter to avoid extreme values.

class holodeck.librarian.params.PD_Piecewise_Uniform_Density(edges, densities, **kwargs)[source]
class holodeck.librarian.params.PD_Piecewise_Uniform_Mass(edges, weights, **kwargs)[source]
class holodeck.librarian.params.PD_Uniform(lo, hi, **kwargs)[source]
class holodeck.librarian.params.PD_Uniform_Log(lo, hi, **kwargs)[source]
class holodeck.librarian.params._Param_Dist(clip=None)[source]

Parameter Distribution base-class for use in Latin HyperCube sampling.

These classes are passed uniform random variables between [0.0, 1.0], and return parameters from the desired distribution.

Subclasses are required to implement the _dist_func() function which accepts a float value from [0.0, 1.0] and returns the appropriate corresponding parameter, drawn from the desired distribution. In practice, _dist_func() is usually the inverse cumulative-distribution for the desired distribution function.

class holodeck.librarian.params._Param_Space(log, nsamples=None, sam_shape=None, seed=None, random_state=None, **param_kwargs)[source]

Base class for generating holodeck libraries. Defines the parameter space and settings.

Libraries are generated over some parameter space defined by which parameters are being varied.

_normalized_params(vals)[source]

Convert input values (uniform/linear) into parameters from the stored distributions.

For example, if this parameter space has 2 dimensions, where the distributions are:

  1. ‘value_a’ is a uniform parameter from [-1.0, 1.0], and

  2. ‘value_b’ normal with mean 10.0 and stdev 1.0

Then input values of [0.75, 0.5] are mapped to parameters [0.5, 10.0], which will be returned as {value_a: 0.5, value_b: 10.0}.

Parameters:

vals ((P,) iterable of float,) – A list/iterable of P float values, matching the number of parameters (i.e. dimensions) in this parameter space. Each value is passed to the corresponding distribution for that parameter.

Returns:

params – The resulting parameters in the form of key-value pairs where the keys are the parameter names, and the values are drawn from the correspinding distributions.

Return type:

dict,

classmethod from_save(fname, log)[source]

Create a new _Param_Space instance loaded from the given file.

Parameters:

fname (str) – Filename containing parameter-space save information, generated form _Param_Space.save.

Returns:

space

Return type:

_Param_Space instance

classmethod model_for_params(params, sam_shape=None)[source]

Construct a model (SAM and hardening instances) from the given parameters.

Parameters:
  • params (dict) – Key-value pairs for sam/hardening parameters. Each item much match expected parameters that are set in the defaults dictionary.

  • sam_shape (None or int or (3,) int) –

Returns:

  • sam (holodeck.sam.Semi_Analytic_Model instance)

  • hard (holodeck.hardening._Hardening instance)

save(path_output)[source]

Save the generated samples and parameter-space info from this instance to an output file.

This data can then be loaded using the _Param_Space.from_save method.

Parameters:

path_output (str) – Path in which to save file. This must be an existing directory.

Returns:

fname – Output path including filename in which this parameter-space was saved.

Return type:

str