In [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.
In [2]:
h = xyz.Harvester(r, data_name='trig.h5')
We perform one set of runs first:
In [3]:
combos_1 = {
'f': ['sin', 'cos'],
'x': np.linspace(-5, 5, 101),
'amp': [1, 2, 3],
'phi': [0.4, 0.8],
}
In [4]:
h.harvest_combos(combos_1)
Which we can plot:
In [5]:
h.full_ds.xyz.ilineplot(x='x', y='f(x)', z='f', col='amp', row='phi', y_err='ef(x)')
Then we can define and run a completely disjoint set of runs:
In [6]:
combos_2 = {
'f': ['sin', 'cos'],
'x': np.linspace(-5, 5, 101),
'amp': [4, 5],
'phi': [1.2, 1.6],
}
In [7]:
h.harvest_combos(combos_2)
If we plot the current full_ds we’ll see both sets of runs are present, but there are also blank spaces:
In [8]:
h.full_ds.xyz.ilineplot(x='x', y='f(x)', z='f', col='amp', row='phi', y_err='ef(x)')
Finally let’s add tan into the mix, but only for the central combinations:
In [9]:
combos_3 = {
'f': ['tan'],
'x': np.linspace(-5, 5, 101),
'amp': [2, 3, 4],
'phi': [0.8, 1.2],
}
In [10]:
h.harvest_combos(combos_3)
We’ll specify some plotting limits to avoid the infinities as well:
In [11]:
h.full_ds.xyz.ilineplot(
x='x', y='f(x)', z='f',
col='amp', row='phi', y_err='ef(x)',
ylims=(-4, 4),
)
All runs have also been accumulated into the on-disk:
In [12]:
ls *.h5
In [13]:
xyz.load_ds('trig.h5')
Out[13]:
For now just clean this up.
In [14]:
h.delete_ds()