def GetEnergyDimension(Dim):
    """ Return an energy value in eV.  """
    unit = Dim.units
    if str(unit) == 'eV':
        scalefac = 1
    elif str(unit) == str('keV'):
        scalefac = 1000.0
    elif unit == 'MeV':
        scalefac = 1000000.0
    else:
        print('Unrecognized energy dimension unit in Bruker file: ' + unit)
        scalefac = 1
    Axis = Dim.index2value(range(Dim.size))
    return Axis * scalefac
