# 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 sys
import numpy
import logging
import condor
import condor.utils.log
import condor.utils.spheroid_diffraction
import condor.utils.diffraction
import condor.utils.bodies
import condor.utils.emdio
        import h5py
from condor.utils.log import log_and_raise_error,log_warning,log_info,log_debug
from condor.utils.variation import Variation
from .particle_abstract import AbstractContinuousParticle
                                            position=position, position_variation=position_variation, position_spread=position_spread, position_variation_n=position_variation_n,
                                            material_type=material_type, massdensity=massdensity, atomic_composition=atomic_composition, electron_density=electron_density)
        
        # Check for valid geometry
        if geometry not in ["icosahedron", "cube", "sphere", "spheroid", "custom"]:
            log_and_raise_error(logger, "Cannot initialize %s because \'%s\' is not a valid argument for \'geometry\'." % (kwargs["geometry"], self.__class__.__name__))
            sys.exit(1)
        self.geometry = geometry
        
        # Has effect only for spheroids
        self.flattening = flattening

        # Init chache
        self._cache = {}
        self._dx_orig                = None
        self._map3d_orig             = None

        if geometry == "custom":
            if map3d is not None:
                if dx is None:
                    log_and_raise_error(logger, "Cannot initialize custom geometry with \'map3d\' without known grid spacing (\'dx\').")
                    sys.exit(1)
                else:
                    log_debug(logger, "Attempting to initialise custom geometry with \'map3d\'.")
                    if map3d_filename is not None or map3d_dataset is not None or emd_id is not None:
                        log_and_raise_error(logger, "Cannot initialize custom geometry because of ambiguous keyword arguments.")
                        sys.exit(1)
                    self.set_custom_geometry_by_array(map3d, dx)
            elif map3d_filename is not None and map3d_dataset is not None:
                if dx is None:

# 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/particle/particle_map.py
import sys
import numpy
import logging
import condor
import condor.utils.log
import condor.utils.spheroid_diffraction
import condor.utils.diffraction
import condor.utils.bodies
import condor.utils.emdio
        import h5py
from condor.utils.log import log_and_raise_error,log_warning,log_info,log_debug
from condor.utils.variation import Variation
from .particle_abstract import AbstractContinuousParticle

                                            position=position, position_variation=position_variation, position_spread=position_spread, position_variation_n=position_variation_n,
                                            material_type=material_type, massdensity=massdensity, atomic_composition=atomic_composition, electron_density=electron_density)
        
        # Check for valid geometry
        if geometry not in ["icosahedron", "cube", "sphere", "spheroid", "custom"]:
            log_and_raise_error(logger, "Cannot initialize %s because \'%s\' is not a valid argument for \'geometry\'." % (kwargs["geometry"], self.__class__.__name__))
            sys.exit(1)
        self.geometry = geometry
        
        # Has effect only for spheroids
        self.flattening = flattening

        # Init chache
        self._cache = {}
        self._dx_orig                = None
        self._map3d_orig             = None

        if geometry == "custom":
            if map3d is not None:
                if dx is None:
                    log_and_raise_error(logger, "Cannot initialize custom geometry with \'map3d\' without known grid spacing (\'dx\').")
                    sys.exit(1)
                else:
                    log_debug(logger, "Attempting to initialise custom geometry with \'map3d\'.")
                    if map3d_filename is not None or map3d_dataset is not None or emd_id is not None:
                        log_and_raise_error(logger, "Cannot initialize custom geometry because of ambiguous keyword arguments.")
                        sys.exit(1)
                    self.set_custom_geometry_by_array(map3d, dx)
            elif map3d_filename is not None and map3d_dataset is not None:
                if dx is None:

                    log_and_raise_error(logger, "You are trying to initialise the map with an HDF5 file. You also need to provide the grid spacing \'dx\'")