# Path: condor/utils/log.py
# def log(logger, message, lvl, exception=None, rollback=1):
# def log_execution_time(logger):
#     def st_time(func):
#         def st_func(*args, **keyArgs):


import numpy, copy
import logging
import condor.utils.linalg
from .log import log_and_raise_error,log_warning,log_info,log_debug

from __future__ import print_function, absolute_import # Compatibility with python 2 and 3

logger = logging.getLogger(__name__)

#import rotation


def q_from_p(p, wavelength):
    r"""
    Return scattering vector from pixel position vector and photon wavelength.

    Args:
      :p (array): Pixel position vector :math:`\vec{p}=(p_x,p_y,p_z)` with respect to the interaction point in unit meter

      :wavelength (float): Photon wavelength in unit meter
    """
    p0 = p / condor.utils.linalg.length(p)
    R_Ewald = 2*numpy.pi / wavelength
    k0 = R_Ewald * numpy.array([0.,0.,1.])
    k1 = R_Ewald * p0
    q = k0 - k1
    return q


def generate_qmap(X,Y,pixel_size,detector_distance,wavelength,extrinsic_rotation=None, order="xyz"):
    r"""
    Generate scattering vector map from experimental parameters

    Args:

# Path: condor/utils/log.py
# def log(logger, message, lvl, exception=None, rollback=1):
# def log_execution_time(logger):
#     def st_time(func):
#         def st_func(*args, **keyArgs):


# Path: condor/utils/scattering_vector.py
import numpy, copy
import logging
import condor.utils.linalg
from .log import log_and_raise_error,log_warning,log_info,log_debug


from __future__ import print_function, absolute_import # Compatibility with python 2 and 3

logger = logging.getLogger(__name__)

#import rotation


def q_from_p(p, wavelength):
    r"""
    Return scattering vector from pixel position vector and photon wavelength.

    Args:
      :p (array): Pixel position vector :math:`\vec{p}=(p_x,p_y,p_z)` with respect to the interaction point in unit meter

      :wavelength (float): Photon wavelength in unit meter
    """
    p0 = p / condor.utils.linalg.length(p)
    R_Ewald = 2*numpy.pi / wavelength
    k0 = R_Ewald * numpy.array([0.,0.,1.])
    k1 = R_Ewald * p0
    q = k0 - k1
    return q


def generate_qmap(X,Y,pixel_size,detector_distance,wavelength,extrinsic_rotation=None, order="xyz"):
    r"""
    Generate scattering vector map from experimental parameters

    Args:

      :X (array): :math:`x`-coordinates of pixels in unit meter