Create GUI unit for scattering vector

This commit is contained in:
Valentin Valls 2019-05-16 14:09:10 +02:00
parent 6253e670ad
commit 490ae9bbfc
1 changed files with 10 additions and 1 deletions

View File

@ -24,7 +24,7 @@
__authors__ = ["V. Valls"]
__license__ = "MIT"
__date__ = "10/05/2019"
__date__ = "16/05/2019"
import numpy
@ -41,6 +41,8 @@ class Dimentionality(enum.Enum):
WAVELENGTH = "Wavelength"
SCATTERING_VECTOR = "Scattering vector"
PIXEL = "Pixel"
@property
@ -68,6 +70,10 @@ class Unit(enum.Enum):
PIXEL = ("Pixel", u"px", Dimentionality.PIXEL, 1),
INV_ANGSTROM = (u"Inverse Ångström", u"Å⁻¹", Dimentionality.SCATTERING_VECTOR, 1),
INV_NANOMETER = (u"Inverse nanometer", u"nm⁻¹", Dimentionality.SCATTERING_VECTOR, 1),
@property
def fullname(self):
return self.value[0][0]
@ -116,6 +122,9 @@ def _initConverters():
_converters[(Unit.MILLIMETER, Unit.METER)] = lambda v: v * 1e-3
_converters[(Unit.MILLIMETER, Unit.CENTIMETER)] = lambda v: v * 1e-1
_converters[(Unit.INV_ANGSTROM, Unit.INV_NANOMETER)] = lambda v: v * 10.0
_converters[(Unit.INV_NANOMETER, Unit.INV_ANGSTROM)] = lambda v: v * 0.1
def convert(value, inputUnit, outputUnit):
if inputUnit is outputUnit: