Ticket #5624 (closed: fixed)

Opened 8 years ago

Last modified 5 years ago

Expose UnitFactory to Python & add methods for conversion between two units

Reported by: Martyn Gigg Owned by: Martyn Gigg
Priority: major Milestone: Release 2.2
Component: Mantid Keywords:
Cc: Blocked By:
Blocking: Tester: Wenduo Zhou

Description

A new tool for converting units for single values is being created. It requires that the unit factory is exposed to Python along with the addition of simple calls to be able to convert from one unit to another another without explicitly having to create each unit.

Change History

comment:1 Changed 8 years ago by Martyn Gigg

Improve VectorToNumpy return policy. Refs #5624

There are now two: VectorRefToNumpy & VectorToNumpy. The latter only allows clones as the return could be a return by value.

Changeset: d9eb9e1cadc50c8aa865a5c47c424321d5751423

comment:2 Changed 8 years ago by Martyn Gigg

Export the UnitFactory to the new Python API. Refs #5624

Changeset: cce51cb4460ce3d6b8a3e270c37c12c854c3f288

comment:3 Changed 8 years ago by Martyn Gigg

Add a simple UnitConversion class. Refs #5624

Allows conversion between units using a single call.

Changeset: 078cb1fa60254dacdd071f7ae468bd1f1bde1477

comment:4 Changed 8 years ago by Martyn Gigg

Export UnitConversion class to new python API. Refs #5624

Changeset: e7dabb9030579c4a913d02e38717fb6da280208f

comment:5 Changed 8 years ago by Martyn Gigg

Remove constness of Unit in UnitConversion. Refs #5624

Makes it explicit that the object is modified.

Changeset: 80b98689a71ab4181555f3c824207b679c3cae12

comment:6 Changed 8 years ago by Martyn Gigg

Improve VectorToNumpy return policy. Refs #5624

There are now two: VectorRefToNumpy & VectorToNumpy. The latter only allows clones as the return could be a return by value.

Changeset: d9eb9e1cadc50c8aa865a5c47c424321d5751423

comment:7 Changed 8 years ago by Martyn Gigg

Export the UnitFactory to the new Python API. Refs #5624

Changeset: cce51cb4460ce3d6b8a3e270c37c12c854c3f288

comment:8 Changed 8 years ago by Martyn Gigg

Add a simple UnitConversion class. Refs #5624

Allows conversion between units using a single call.

Changeset: 078cb1fa60254dacdd071f7ae468bd1f1bde1477

comment:9 Changed 8 years ago by Martyn Gigg

Export UnitConversion class to new python API. Refs #5624

Changeset: e7dabb9030579c4a913d02e38717fb6da280208f

comment:10 Changed 8 years ago by Martyn Gigg

Remove constness of Unit in UnitConversion. Refs #5624

Makes it explicit that the object is modified.

Changeset: 80b98689a71ab4181555f3c824207b679c3cae12

comment:11 Changed 8 years ago by Martyn Gigg

  • Status changed from new to accepted

comment:12 Changed 8 years ago by Martyn Gigg

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

This was done to allow some work by some work experience students but was not used.

Example usage:

from mantid.kernel import UnitConversion, DeltaEModeType
src_unit = "Wavelength"
src_value = 1.5
dest_unit = "Momentum"
        
l1 = l2 = twoTheta = efixed = 0.0
emode = DeltaEModeType.Indirect;
expected = 2.0*math.pi/src_value
   
result = UnitConversion.run(src_unit, dest_unit, src_value, l1, l2, twoTheta, emode, efixed)

comment:13 Changed 8 years ago by Wenduo Zhou

  • Status changed from verify to verifying
  • Tester set to Wenduo Zhou

comment:14 Changed 8 years ago by Wenduo Zhou

  • Status changed from verifying to closed

comment:15 Changed 5 years ago by Stuart Campbell

This ticket has been transferred to github issue 6470

Note: See TracTickets for help on using tickets.