OxfordIonTrapGroup / oitg

Python package of helper routines (result loading, fitting, etc) for the Oxford Ion-Trap Group (OITG).
https://oxfordiontrapgroup.github.io/oitg/
13 stars 9 forks source link

Convenience functions for loading and sorting ndscan experiments #45

Closed AVB25 closed 6 months ago

AVB25 commented 11 months ago

Some simple convenience functions that have been helpful to me, and I think may be helpful to others. They parse the results dictionary yielded by load_results to translate all PYON into python objects and make data more accessible. There are also functions to sort a multi-dimensional scan, possibly with missing entries (only tested for 2-D scans so far).

Demo usage for loading and directly plotting a 2D scan with missing entries:

scan_results, scan_axes, args = load_ndscan(day=day, rid=rid, experiment="abaqus")

data = scan_results["measurement_camera_readout_p_0"]["data"]
axis_0 = scan_axes[0]["data"] / scan_axes[0]["spec"]["scale"]
axis_1 = scan_axes[1]["data"] / scan_axes[1]["spec"]["scale"]

plt.pcolormesh(axis_0, axis_1, data)
plt.xlabel(f"{scan_axes[0]['description']} ({scan_axes[0]['spec']['unit']})")
plt.ylabel(f"{scan_axes[1]['description']} ({scan_axes[1]['spec']['unit']})")
dnadlinger commented 11 months ago

Centralising our analysis tools is definitely a promising direction!

I think the best place for these to go would be in ndscan.results, as ndscan depends on oitg, not the other way round. That package already has functions for just quickly getting a matplotlib plot on the screen for a results file, but hasn't seen much love yet.

Now that we are no longer stuck on Python 3.5, we might want to use dataclasses (or at least named tuples) to make the API easier to use.