Ticket #6090 (closed: fixed)

Opened 8 years ago

Last modified 5 years ago

Add ability to read neutron weights from Event Nexus files

Reported by: Stuart Campbell Owned by: Michael Reuter
Priority: major Milestone: Release 2.4
Component: Mantid Keywords:
Cc: linjiao@… Blocked By:
Blocking: Tester: Stuart Campbell

Description

If we produce an event nexus file from a simulation, then this file will need to contain a list of neutron 'weights'. The obvious name for such a field would be event_weight.

Can we alter LoadEventNexus to load the weights field, if it exists, and return an EventWorkspace with weighted events ?

Attachments

sim_test.py (607 bytes) - added by Michael Reuter 8 years ago.
Reduction script for simulation file

Change History

comment:1 Changed 8 years ago by Russell Taylor

A few thoughts on this, partly arrived at via discussion with Michael....

I think it's critical here that we don't slow down loading for people loading actual data event nexus files (as the ratio of those loading real to simulated data will be high number). (Actually, if we implement this very poorly we could slow things down for people loading any kind of file.)

Arguably, it's also undesirable to pollute the main LoadEventNexus algorithm with this if it's going to be very specific kind of file. If we can agree on a standard way of representing simulated data in event nexus files then this is less of a concern. Otherwise, we could have essentially a wrapper algorithm that first calls LoadEventNexus to load the file and then re-parses the events in the file to obtain and add the weights. This will certainly be slower than doing it in one shot, but see my comment about the ratio of users. Having said all this, a first look at the code does suggest the complexity of the two-step approach may not be low.

If we follow the separate algorithms approach, adding access via the generic Load algorithm could be a later step. In that situation it might be desirable for filenames of simulated data to carry a different extension for quick identification. Michael also mentioned that we could make use of the 'definition' field in the nexus file to flag it as containing simulated data, which would be simpler than digging into the actual data groups to check for a field.

comment:2 Changed 8 years ago by Nick Draper

I agree with Russell on this one, Our LoadEventNexus is written for RAW data straight for the instruments and is optimised that way.

I'm happy for us to add another algorithm to support this, and it can hapily share code with LoadEventNexus, or event inherit from it, but we should not alter what is arguably our most used algorithm in any way that could slow things down.

comment:3 Changed 8 years ago by Stuart Campbell

I think that keeping it separate is a good idea. As long as (for the user) it is easy to load the data I don't think it matters to the user how we do it internally.

I think that we can either modify the definition field, or leave it the same as it would be for a 'real' data file and just add an attribute to it (e.g. simulated = true ?). There is also a field for the program name that generated the data file, this could be used as a secondary check as well - so we don't need to dig into the actual data groups.

comment:4 Changed 8 years ago by Stuart Campbell

  • Owner set to Michael Reuter
  • Status changed from new to assigned

comment:5 Changed 8 years ago by Michael Reuter

  • Status changed from assigned to accepted

comment:6 Changed 8 years ago by Michael Reuter

Refs #6090. Add ability to read simulated data.

It turns out that adding the code alongside produced no dramatic changes in the performance of the loader, at least in all the tests that I've run (about 40 or so on two difference machines). Being able to do this simplified the code necessary to achieve this capability.

Changeset: 8ea3af487b2b13de422cbb52d5cddbd785f51623

comment:7 Changed 8 years ago by Michael Reuter

Refs #6090. Correcting the value of the weight.

Changeset: 3c4f70463a5cae8a114b7a60a5e2dbd19e334a45

comment:8 Changed 8 years ago by Michael Reuter

The last check-in was actually correcting the value for the error squared.

comment:9 Changed 8 years ago by Michael Reuter

Refs #6090. Typo in comment.

Changeset: 3c4a7e5014b39672672aa9194e55f7b82e3e7b9d

comment:10 Changed 8 years ago by Michael Reuter

Refs #6090. Adding unit test for simulated file.

Changeset: bc756b4a292be47d692ae324b5edd8dc6defad1b

Changed 8 years ago by Michael Reuter

Reduction script for simulation file

comment:11 Changed 8 years ago by Michael Reuter

  • Status changed from accepted to verify
  • Resolution set to fixed

TESTING: Make sure that the unit test for LoadEventNexus is running. Also, run the attached reduction script to see that data does actually come out. There should be a peak of data at deltaE ~ 770 meV in the 1D plot.

comment:12 Changed 8 years ago by Michael Reuter

Refs #6090. Add ability to read simulated data.

It turns out that adding the code alongside produced no dramatic changes in the performance of the loader, at least in all the tests that I've run (about 40 or so on two difference machines). Being able to do this simplified the code necessary to achieve this capability.

Changeset: 8ea3af487b2b13de422cbb52d5cddbd785f51623

comment:13 Changed 8 years ago by Michael Reuter

Refs #6090. Correcting the value of the weight.

Changeset: 3c4f70463a5cae8a114b7a60a5e2dbd19e334a45

comment:14 Changed 8 years ago by Michael Reuter

Refs #6090. Typo in comment.

Changeset: 3c4a7e5014b39672672aa9194e55f7b82e3e7b9d

comment:15 Changed 8 years ago by Michael Reuter

Refs #6090. Adding unit test for simulated file.

Changeset: bc756b4a292be47d692ae324b5edd8dc6defad1b

comment:16 Changed 8 years ago by Stuart Campbell

  • Status changed from verify to verifying
  • Tester set to Stuart Campbell

comment:17 Changed 8 years ago by Stuart Campbell

  • Status changed from verifying to closed

Tested using the ARCS_sim_event.nxs file. Loads with no problems either calling LoadEventNexus() directly or using Load().

comment:18 Changed 5 years ago by Stuart Campbell

This ticket has been transferred to github issue 6936

Note: See TracTickets for help on using tickets.