‘Farming’ with Harvester Example#

This examples demonstrates ‘farming’ runs, that is, using a Harvester to perform and combine succesive, disjoint sets of runs.

First we define a simple trig function to explore and label with a Runner:

[1]:
import xyzpy as xyz
import numpy as np

def trig(f, x, amp, phi):

    trig_fn = getattr(np, f)
    err = 0.2 + 0.1 * np.random.randn()

    return amp * trig_fn(x - phi), err

r = xyz.Runner(trig, ['f(x)', 'ef(x)'])

The harvester is composed of this Runner and logic for merging for saving each new set of runs.

[2]:
h = xyz.Harvester(r, data_name='trig.h5')

We perform one set of runs first:

[3]:
combos_1 = {
    'f': ['sin', 'cos'],
    'x': np.linspace(-5, 5, 101),
    'amp': [1, 2, 3],
    'phi': [0.4, 0.8],
}
[4]:
h.harvest_combos(combos_1)
100%|##########| 1212/1212 [00:00<00:00, 198993.83it/s]

Which we can plot:

[5]:
h.full_ds.xyz.ilineplot(x='x', y='f(x)', z='f', col='amp', row='phi', y_err='ef(x)')
Loading BokehJS ...