Qcodes icon indicating copy to clipboard operation
Qcodes copied to clipboard

Bug: _add_metadata_to_xarray does not add completed_timestamp_raw and run_timestamp_raw if those are None which is inconsistent and confusing

Open astafan8 opened this issue 5 months ago • 1 comments

There is an inconsistency between the export and load methods. _add_metadata_to_xarray simply does not add two attributes completed_timestamp_raw and run_timestamp_raw if they were None in the original dataset, but it does add empty placeholders for completed_timestamp and run_timestamp even if they are None.

This is the function: https://github.com/microsoft/Qcodes/blob/40da9d9331b9c3cd5bb61757dc5c640f43333c61/src/qcodes/dataset/exporters/export_to_xarray.py#L156

So the solution should be to always add the *_raw timestamps as attrbiutes upon export. If they are None, set them on xarray dataset as None as well. And when loading from a netcdf file, perform a correct handling on None value for those. And for datasets that were exported to netcdf before this change, apply the following logic: if those attributes are not present, then try to calculate them from the non-raw versions of these timestamp attributes.

astafan8 avatar Jul 25 '25 08:07 astafan8

@astafan8 This was fixed in #7333 right?

jenshnielsen avatar Sep 25 '25 09:09 jenshnielsen

Correct! #7333 fixed this!

astafan8 avatar Dec 15 '25 09:12 astafan8