/usr/lib/python2.7/dist-packages/pyFAI/units.py is in pyfai 0.10.2-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Project: Azimuthal integration
# https://github.com/kif/pyFAI
#
# Copyright (C) European Synchrotron Radiation Facility, Grenoble, France
#
# Principal author: Picca Frédéric-Emmanuel <picca@synchrotron-soleil.fr>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
__authors__ = ["Picca Frédéric-Emmanuel", "Jérôme Kieffer"]
__contact__ = "picca@synchrotron-soleil.fr"
__license__ = "GPLv3+"
__copyright__ = "European Synchrotron Radiation Facility, Grenoble, France"
__date__ = "29/09/2014"
__status__ = "beta"
__docformat__ = 'restructuredtext'
import logging
logger = logging.getLogger("pyFAI.unit")
from numpy import pi
import types
hc = 12.398419292004204
class Enum(dict):
"""
Simple class half way between a dict and a class, behaving as an enum
"""
def __getattr__(self, name):
if name in self:
return self[name]
raise AttributeError
def __repr__(self, *args, **kwargs):
if "REPR" in self:
return self["REPR"]
else:
return dict.__repr__(self, *args, **kwargs)
UNDEFINED = Enum(REPR='?')
TTH_DEG = TTH = Enum(REPR="2th_deg",
corner="cornerArray",
center="twoThetaArray",
delta="delta2Theta",
scale=180.0 / pi)
TTH_RAD = Enum(REPR="2th_rad",
corner="cornerArray",
center="twoThetaArray",
delta="delta2Theta",
scale=1.0)
Q = Q_NM = Enum(REPR="q_nm^-1",
center="qArray",
corner="cornerQArray",
delta="deltaQ",
scale=1.0)
Q_A = Enum(REPR="q_A^-1",
center="qArray",
corner="cornerQArray",
delta="deltaQ",
scale=0.1)
R = R_MM = Enum(REPR="r_mm",
center="rArray",
corner="cornerRArray",
delta="deltaR",
scale=1000.0)
RADIAL_UNITS = (TTH_DEG, TTH_RAD, Q_NM, Q_A, R_MM)
def to_unit(obj):
rad_unit = None
if type(obj) in types.StringTypes:
for one_unit in RADIAL_UNITS:
if one_unit.REPR == obj:
rad_unit = one_unit
break
elif obj.__class__.__name__.split(".")[-1] == "Enum":
rad_unit = obj
if rad_unit is None:
logger.error("Unable to recognize this type unit '%s' of type %s. Valid units are 2th_deg, 2th_rad, q_nm^-1, q_A^-1 and r_mm" % (obj, type(obj)))
return rad_unit
|