How to save(persist) array data at one time. #5017
-
|
I have some array data like x = np.linspace(0, 10, 100)
y = np.linspace(20, 30, 50)
z = np.random.random((100, 50))And actually I can get these data at one time for some reason, without need to iterate over axis And, saving data like the simplest way context = qcodes.Measurement(experiment, name="demo")
x_param = Parameter("x")
y_param = Parameter("y")
z_param = Parameter("z")
context.register_parameter(x_param)
context.register_parameter(y_param)
context.register_parameter(z_param, setpoints=(x_param, y_param))
with context.run() as datasaver:
for i, _x in enumerate(x):
for j, _y in enumerate(y):
datasaver.add_result(
(x_param, _x),
(y_param, _y),
(z_param, z[i, j]),
)is intolerably slow. My question is that it there any way to save these data at one time without iteration. I found there was a discussion before #3330, but it seems not help to meet my needs. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
|
@littlebaker
i guess that's just how your instruments work, right? :) now moving to answering your question:
let us know if this helps :) |
Beta Was this translation helpful? Give feedback.
-
yes :) this is why I highly recommend to check documentation is linked in the point 2 of the answer ;) this will make storing the x/y/z arrays noticably faster (also you'll notice improvement when reading/loading the data) |
Beta Was this translation helpful? Give feedback.
@littlebaker
i guess that's just how your instruments work, right? :)
now moving to answering your question:
add_resultssupports taking arrays of values, so you can pass a grid made ofxandyand thezvalues directly toadd_resultslike this.add_results((x_param, x_gridd), (y_param, y_grid), (z_param, z))wherex_grid, y_grid = numpy.meshgrid(x, y)(i might be wrong with the exact use of meshgrid, please look in numpy docs for details of how to create a grid from vectors) and qcodes internally will store them as(x_grid[1], y_grid[1], z[1]), (x_grid[2], y_g…