Ticket #4649 (closed: fixed)

Opened 9 years ago

Last modified 5 years ago

Set/get MDHistoWorkspace contents as numpy arrays

Reported by: Janik Zikovsky Owned by: Martyn Gigg
Priority: major Milestone: Release 2.3
Component: Mantid Keywords:
Cc: owen.arnold@… Blocked By:
Blocking: Tester: Andrei Savici

Description

  • Expose methods to get or set the signal and error data of MDHistoWorkspaces as numpy array.

Note from Martyn:

At the moment anything that implements the MatrixWorkspace interface can have a numpy array created from the data. There a several methods that allow you to either create a read-only wrapper, a writeable wrapper and then another for extracting the data out into a 2D array.

PyhonInterface/mantid/api/MatrixWorkspace.cpp shows the export to Python of MatrixWorkspace, which gives you the list of methods there are available there. These use some helper code in the file PythonInterface/mantid/api/WorkspaceToNumpy.cpp in order to actually produce the arrays from our data. I would say that this file could be renamed to MatrixWorkspaceToNumpy.cpp and then you could create another file MDWorkspaceToNumpy and implement the required helpers there. Does that make sense?

I suggest that this should go into the new API only, as we would like to phase the old one out and also for the next iteration.

Cheers,

Martyn

Change History

comment:1 Changed 8 years ago by Nick Draper

  • Milestone changed from Release 2.1 to Release 2.2

Moved at end of release 2.1

comment:2 Changed 8 years ago by Janik Zikovsky

  • Status changed from new to assigned
  • Owner changed from Janik Zikovsky to Martyn Gigg

comment:3 Changed 8 years ago by Nick Draper

  • Milestone changed from Release 2.2 to Release 2.3

Moved at the end of release 2.2

comment:4 Changed 8 years ago by Martyn Gigg

  • Status changed from assigned to accepted

comment:5 Changed 8 years ago by Martyn Gigg

Refactor numpy converters to work through C arrays. Refs #4649

This should simplify the numpy converter code so that everything just funnels it through the C array interface. Future converters should no only have to implement the top level portion an pass c arrays on.

Changeset: e57703a22350472d144eeb3d58fd371977f09931

comment:6 Changed 8 years ago by Martyn Gigg

Rename header NumpyWrapMode to WrapWithNumpy. Refs #4649

Changeset: 38539608054608dfa1cb260815d38c499f5cd71b

comment:7 Changed 8 years ago by Martyn Gigg

Wrap signal/error arrays from MDHistoWS with numpy. Refs #4649

Changeset: 10f9186f7caa859078e0668f4b9ce26d4db92f57

comment:8 Changed 8 years ago by Martyn Gigg

Add setters from numpy array for MDHistoWS from python. Refs #4649

Changeset: 5492e586a830f20da0f2f69c19b4d42a8fff2acc

comment:9 Changed 8 years ago by Martyn Gigg

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

comment:10 Changed 8 years ago by Martyn Gigg

Refactor numpy converters to work through C arrays. Refs #4649

This should simplify the numpy converter code so that everything just funnels it through the C array interface. Future converters should no only have to implement the top level portion an pass c arrays on.

Changeset: e57703a22350472d144eeb3d58fd371977f09931

comment:11 Changed 8 years ago by Martyn Gigg

Rename header NumpyWrapMode to WrapWithNumpy. Refs #4649

Changeset: 38539608054608dfa1cb260815d38c499f5cd71b

comment:12 Changed 8 years ago by Martyn Gigg

Wrap signal/error arrays from MDHistoWS with numpy. Refs #4649

Changeset: 10f9186f7caa859078e0668f4b9ce26d4db92f57

comment:13 Changed 8 years ago by Martyn Gigg

Add setters from numpy array for MDHistoWS from python. Refs #4649

Changeset: 5492e586a830f20da0f2f69c19b4d42a8fff2acc

comment:14 Changed 8 years ago by Andrei Savici

  • Status changed from verify to verifying
  • Tester set to Andrei Savici

comment:15 Changed 8 years ago by Andrei Savici

  • Status changed from verifying to closed
Load(Filename='CNCS_7860_event.nxs',OutputWorkspace='CNCS_7860_event')
ConvertUnits(InputWorkspace='CNCS_7860_event',OutputWorkspace='CNCS_7860_event',Target='DeltaE',EMode='Direct',EFixed='3')
ConvertToMD(InputWorkspace='CNCS_7860_event',OutputWorkspace='MD',QDimensions='|Q|',QConversionScales='HKL',MinValues='0,-3',MaxValues='3,3')
BinToMDHistoWorkspace(InputWorkspace='MD',AlignedDim0='|Q|,0,3,30',AlignedDim1='DeltaE,-3,3,30',OutputWorkspace='MDH')

w=mtd['MDH']
w.setSignalArray(-2*w.getSignalArray())

comment:16 Changed 5 years ago by Stuart Campbell

This ticket has been transferred to github issue 5496

Note: See TracTickets for help on using tickets.