mantidproject / mantid

Main repository for Mantid code
https://www.mantidproject.org
GNU General Public License v3.0
211 stars 123 forks source link

run_number in nxspe files #37654

Closed abuts closed 1 month ago

abuts commented 3 months ago

Is your feature request related to a problem? Please describe.

Horace package uses nxspe files produced by Mantid as its primary source of data about neutron scattering. Currently we are enabling the possibility to combine information from different experients and differnet instruments so the information in nxspe files should be easy identifiable. It currently contains information about instrument (unique insturment name) while information about experiment is not there and should be extracted using various different means.

Facilities have long developed unique vay of identifying experiments and this way is run numbers, so these numbers can be used for identifying experiments in Horace too.

Describe the solution you'd like

Alongside with instrument name, I want to add run_number field, which would contain the run number taken from processed workspace. E.g. Current state of nxspe file:

ws_name->instrument->name

Suggested change:

ws_name->instrument->name
ws_name->instrument->run_number

Additional context Additional hdf field should not affect any software not interested in it (so Mantid loader should not be changed unless Mantid wants to recover this information.

It looks like the nxspe format version from

ws_name->definition(attribute)->version

should be also changed from 1.2 to 1.3 but this is optional (to maintain logics of nxspe file format versions) and can be rejected if causes any problem.

SpencerHowells commented 3 months ago

@abuts Could you also add a line to set efixed=Ei so that several of our programs can run without having to do it manually, thanks.

abuts commented 3 months ago

you mean duplicate fixed_energy field from

 ws_name->NXSPE_info->fixed_energy

with additional field:

 ws_name->NXSPE_info->efixed

? Do not see problem with this though SNS was not very happy with such changes in a past. But if there are no objections from the community -- why not.

But would not it be easier to modify the soft to read existing field? All previous nexpe files contain fixed_energy field, and efixed will be only in the latest one.

SpencerHowells commented 3 months ago

@abuts We have to use SetInstrumentParameter so it's an instrument parameter together with emode whcih should be Direct.

abuts commented 3 months ago

@SpencerHowells -- I do not understand. SaveNXSPE currently saves EI for direct spectrometers as field

 ws_name->NXSPE_info->fixed_energy

It takes it from instrument parameters set in reduction script as far as I remember.

I also believe it writes the same field for indirect instruments and if it does not save it correctly, it is a bug. (it was writing it correctly I believe)

You want different NXSPE file field (efixed) or something else?

SpencerHowells commented 3 months ago

@abuts According to the SaveNXSPE info there is an input Efixed which is optoinal - this can br Ei. All the Direct instruments we use for QENS use efixed. At ISIS the script we use to ceate Sqw has option of NXSPE or NXS for oiutput and Duc Le now recommends we always use NXS. ILL and Munich now also use efixed.

abuts commented 3 months ago

ok, so efix on reduced workspace for indirect instruments is named differently and saveNXSPE does not pick it up to save as fixed_energy. Makes sence to fix it indeed.

I am sure nobody would object this.

I will also talk to Duc about this

mducle commented 3 months ago

@SpencerHowells There is already a fixed_energy field in the NXSPE specification. I think the main problem is that some Mantid algorithms don't save this information, but rather create a log entry with the Efix value instead - and the log is discarded when saving to .nxspe because logs are not in the NXSPE specs.

In any case we would recommend to use .nxs (or _red.nxs) to QENS users instead of .nxspe and as far as I know the regular reduction script will generate _red.nxs files compatible with the QENS data analysis GUIs and we just need to update the polarised reduction files used on LET.

SilkeSchomann commented 3 months ago

@mducle I've added the run number to nxspe (https://github.com/mantidproject/mantid/pull/37673), but still need to test this change. What would be the best way to do this? LoadNXSPE from Mantid does not read the run number and DAVE cannot read nxspe files as far as I know.

mducle commented 3 months ago

@SilkeSchomann DAVE does read .nxspe files - you have to select the "Data Reduction" menu option, then "NCNR" -> "DCS Reduction (Mslice)" then a new window will pop up, and then in this new window, click on the "File" menu option, then "File type" -> "nxspe", then .nxspe files will show up in the file tree view on the upper left side, you can then select an nxspe file and click "Load Data" on the left side, then "Calculate Projections" then "Plot Slice".

However, DAVE won't read the run number - but we should check that files with run numbers will still load in DAVE.

Horace will be the only program which uses the run number so it's fine not to check for them.

abuts commented 2 months ago

see further discussion on this in PR https://github.com/mantidproject/mantid/pull/37673