Take the following situation, where two ParameterWithSetpointss share the same setpoints, but one has control of the other. This could be the case if one is a physically measured parameter with time points as setpoints and the other is a meta-parameter that describes some instrument ramp sampled at the time points. Since only the first is actually measured, having it take control of the second parameter simplifies defining the measurement.
import tempfile
import numpy as np
from qcodes.validators import Arrays
from qcodes.parameters import ManualParameter, ParameterWithSetpoints
from qcodes.dataset import Measurement, new_experiment, initialise_or_create_database_at
class MySp(ParameterWithSetpoints):
def unpack_self(self, vals):
res = super().unpack_self(vals)
res.append((p1, p1()))
return res
mp = ManualParameter('mp', vals=Arrays(shape=(10,)), initial_value=np.arange(10))
p1 = ParameterWithSetpoints('p1', vals=Arrays(shape=(10,)), setpoints=(mp,), set_cmd=None)
p2 = MySp('p2', vals=Arrays(shape=(10,)), setpoints=(mp,), set_cmd=None)
p2.has_control_of.add(p1)
p1(np.linspace(-1, 1, 10))
p2(np.random.randn(10))
initialise_or_create_database_at(tempfile.mkdtemp() + '/baz.db')
new_experiment('foo', 'bar')
meas = Measurement()
meas.register_parameter(p2)
with meas.run() as ds:
ds.add_result((p2, p2()))
xds = ds.dataset.to_xarray_dataset() # does not unravel to grid
Since both p1 and p2 share the same setpoints, I'd expect the exported data to be a DataSet with p1 and p2 as data variables and mp as coordinates. But the data is actually not gridded and instead returned as a ravelled array.
Take the following situation, where two
ParameterWithSetpointss share the samesetpoints, but one has control of the other. This could be the case if one is a physically measured parameter with time points as setpoints and the other is a meta-parameter that describes some instrument ramp sampled at the time points. Since only the first is actually measured, having it take control of the second parameter simplifies defining the measurement.Since both
p1andp2share the same setpoints, I'd expect the exported data to be aDataSetwithp1andp2as data variables andmpas coordinates. But the data is actually not gridded and instead returned as a ravelled array.