class do_mpc.sampling.datahandler.DataHandler(sampling_plan)[source]

Post-processing data created from a sampling plan. Data (individual samples) were created with do_mpc.sampling.sampler.Sampler. The list of all samples originates from do_mpc.sampling.samplingplanner.SamplingPlanner and is used to initiate this class (sampling_plan).

Configuration and retrieving processed data:

  1. Initiate the object with the sampling_plan originating from do_mpc.sampling.samplingplanner.SamplingPlanner.
  2. Set parameters with set_param(). Most importantly, the directory in which the individual samples are located should be passe with data_dir argument.
  3. (Optional) set one (or multiple) post-processing functions. These functions are applied to each loaded sample and can, e.g., extract or compile important information.
  4. Load and return samples either by indexing with the __getitem__() method or by filtering with filter().


sp = do_mpc.sampling.SamplingPlanner()

# Plan with two variables alpha and beta:
sp.set_sampling_var('alpha', np.random.randn)
sp.set_sampling_var('beta', lambda: np.random.randint(0,5))

plan = sp.gen_sampling_plan(n_samples=10)

sampler = do_mpc.sampling.Sampler(plan)

# Sampler computes the product of two variables alpha and beta
# that were created in the SamplingPlanner:

def sample_function(alpha, beta):
    return alpha*beta



# Create DataHandler object with same plan:
dh = do_mpc.sampling.DataHandler(plan)

# Assume you want to compute the square of the result of each sample
dh.set_post_processing('square', lambda res: res**2)

# As well as the value itself:
dh.set_post_processing('default', lambda res: res)

# Query all post-processed results with:


DataHandler.data_dir Set the directory where the results are stored.


DataHandler.filter Filter data from the DataHandler.
DataHandler.set_param Set the parameters of the DataHandler.
DataHandler.set_post_processing Set a post processing function.

This page is auto-generated. Page source is not available on Github.