# 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, sys, numpy, types, pickle, time, math
import condor.utils.icosahedron as icosahedron
import condor.utils.linalg as linalg
import logging
from .log import log_and_raise_error,log_warning,log_info,log_debug
    t1 = time.time()
    log_debug(logger, "Built map within %f seconds." % (t1-t0))
    return icomap

def make_icosahedron_map_slow(N,nRmax,extrinsic_rotation=None):
    """
    Generate map of a uniform icosahedron (density = 1) on a regular grid (*slow python implementation*)

    Orientation: The cartesian grid axis all lie parallel to 2-fold symmetry axes of the icosahedron.

    Args:
      :N (int): Edge length of the grid in unit pixels

      :nRmax (float): Outer radius of the icosahedron in unit pixels

    Kwargs:
    
      :rotation (:class:`condor.utils.rotation.Rotation`): Rotation instance for extrinsic rotation of the icosahedron. 
    """
    na = nRmax/numpy.sqrt(10.0+2*numpy.sqrt(5))*4.
    nRmin = numpy.sqrt(3)/12*(3.0+numpy.sqrt(5))*na # radius at faces
    log_debug(logger, "Building icosahedral geometry")
    n_list = get_icosahedron_normal_vectors()
    # Rotate
    if extrinsic_rotation is not None:
        n_list = extrinsic_rotation.rotate_vectors(numpy.array(n_list))
    X,Y,Z = 1.0*numpy.mgrid[0:N,0:N,0:N]
    X = X - (N-1)/2.
    Y = Y - (N-1)/2.
    Z = Z - (N-1)/2.

# 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/bodies.py
import numpy, sys, numpy, types, pickle, time, math
import condor.utils.icosahedron as icosahedron
import condor.utils.linalg as linalg
import logging
from .log import log_and_raise_error,log_warning,log_info,log_debug

    t1 = time.time()
    log_debug(logger, "Built map within %f seconds." % (t1-t0))
    return icomap

def make_icosahedron_map_slow(N,nRmax,extrinsic_rotation=None):
    """
    Generate map of a uniform icosahedron (density = 1) on a regular grid (*slow python implementation*)

    Orientation: The cartesian grid axis all lie parallel to 2-fold symmetry axes of the icosahedron.

    Args:
      :N (int): Edge length of the grid in unit pixels

      :nRmax (float): Outer radius of the icosahedron in unit pixels

    Kwargs:
    
      :rotation (:class:`condor.utils.rotation.Rotation`): Rotation instance for extrinsic rotation of the icosahedron. 
    """
    na = nRmax/numpy.sqrt(10.0+2*numpy.sqrt(5))*4.
    nRmin = numpy.sqrt(3)/12*(3.0+numpy.sqrt(5))*na # radius at faces
    log_debug(logger, "Building icosahedral geometry")
    n_list = get_icosahedron_normal_vectors()
    # Rotate
    if extrinsic_rotation is not None:
        n_list = extrinsic_rotation.rotate_vectors(numpy.array(n_list))
    X,Y,Z = 1.0*numpy.mgrid[0:N,0:N,0:N]
    X = X - (N-1)/2.
    Y = Y - (N-1)/2.
    Z = Z - (N-1)/2.

    log_debug(logger, "Grid: %i x %i x %i (%i voxels)" % (N,N,N,N**3))