Adding a unit to a sample log entry

Hello, I am trying to use the elwin option on a Mantid Workspace. The problem is that the associated temperature is recorded in the sample log but without a unit. Is there any way to add this retrospectively?

Thank you

Hi Mona, thanks for getting in touch. One option would be to use the AddSampleLog algorithm, with the LogUnit argument set to 'K' (or whatever unit you want). You can get the existing data with e.g. ws.getRun().getLogData('TempData'). You could then either overwrite the original value in the log, or create a new entry with the unit attached. Any problems or questions, please let us know.

https://docs.mantidproject.org/nightly/algorithms/AddSampleLog-v1.html

Best wishes,
James

Another option is to call ws.getRun().getProperty("TempData").units = 'K', probably easier but that will edit the original property.

Best wishes,
James