# Path: utility/constants.py
# class Constants:
#     def __init__(self):
#         try:
#             import imas
#             self.__setup_imas_constants_db()
#         except ImportError:
#             self.__setup_standalone_constants_db()
# 
#     def __setup_standalone_constants_db(self):
#         self.charge_electron = c.elementary_charge
#         self.speed_of_light = c.speed_of_light
#         self.Boltzmann = c.Boltzmann
# 
#     def __setup_imas_constants_db(self):
#         pass
# 
# Path: utility/getdata.py
# DEFAULT_SETUP = 'getdata_setup.xml'
# class GetData(AccessData):
#     def __init__(self,
#                  data_path_name=None,
#                  data_key=[],
#                  data_format="pandas"):
#     def read_data(self):
#     def read_h5_to_pandas(self):
#     def read_h5_to_array(self):
#     def read_txt_to_str(self):
#     def read_txt_to_array(self):
#     def read_xml(self):
#     def get_data(self):
#     def download_private_data(self):
#     def download_public_data(self):
#     def ensure_dir(file_path):


from lxml import etree
from utility.constants import Constants
from utility import getdata
import pandas
import numpy
import warnings

                                                   new_resolution)
            self.observed_profile_int = numpy.interp(self.beamlet_grid_int, self.beamlet.profiles['beamlet grid'][
                'distance']['m'], self.beamlet.profiles[self.observed_level])
        else:
            self.beamlet_grid_int = self.beamlet.profiles['beamlet grid']['distance']['m']
            self.observed_profile_int = self.beamlet.profiles[self.observed_level]
        step_size = (max(self.beamlet_grid_int)-min(self.beamlet_grid_int))/len(self.beamlet_grid_int)
        for detector_index in range(len(self.obs_profile)):
            if self.obs_profile[0][detector_index] + self.detector_size / 2. < max(self.beamlet_grid_int):
                detector_steps = [i for i in range(self.beamlet_grid_int.size) if abs(
                    self.beamlet_grid_int[i] - self.obs_profile[0][detector_index])
                                       < (self.detector_size/2)]
                self.photon_emission_profile[detector_index] = sum([self.observed_profile_int[step]*step_size
                                                                    for step in detector_steps])
        observing_detectors = numpy.nonzero(self.photon_emission_profile)
        self.emission_profile = pandas.concat([self.obs_profile, pandas.DataFrame(self.photon_emission_profile)],
                                              axis=1, keys=['Location', 'Emission'])
        print('Only detectors completely inside the calculated region could observe the virtual beamlet, these detector'
              ' numbers are: ' + str(observing_detectors) + '.')
        return

    @staticmethod
    def read_observation_param(data_path):
        obs_param = getdata.GetData(data_path_name=data_path).data
        assert isinstance(obs_param, etree._ElementTree)
        print('obs_param read from file: ' + data_path)
        return obs_param

    @staticmethod
    def read_observation_profile(data_path):

# Path: utility/constants.py
# class Constants:
#     def __init__(self):
#         try:
#             import imas
#             self.__setup_imas_constants_db()
#         except ImportError:
#             self.__setup_standalone_constants_db()
# 
#     def __setup_standalone_constants_db(self):
#         self.charge_electron = c.elementary_charge
#         self.speed_of_light = c.speed_of_light
#         self.Boltzmann = c.Boltzmann
# 
#     def __setup_imas_constants_db(self):
#         pass
# 
# Path: utility/getdata.py
# DEFAULT_SETUP = 'getdata_setup.xml'
# class GetData(AccessData):
#     def __init__(self,
#                  data_path_name=None,
#                  data_key=[],
#                  data_format="pandas"):
#     def read_data(self):
#     def read_h5_to_pandas(self):
#     def read_h5_to_array(self):
#     def read_txt_to_str(self):
#     def read_txt_to_array(self):
#     def read_xml(self):
#     def get_data(self):
#     def download_private_data(self):
#     def download_public_data(self):
#     def ensure_dir(file_path):


# Path: observation/observation.py
from lxml import etree
from utility.constants import Constants
from utility import getdata
import pandas
import numpy
import warnings

                                                   new_resolution)
            self.observed_profile_int = numpy.interp(self.beamlet_grid_int, self.beamlet.profiles['beamlet grid'][
                'distance']['m'], self.beamlet.profiles[self.observed_level])
        else:
            self.beamlet_grid_int = self.beamlet.profiles['beamlet grid']['distance']['m']
            self.observed_profile_int = self.beamlet.profiles[self.observed_level]
        step_size = (max(self.beamlet_grid_int)-min(self.beamlet_grid_int))/len(self.beamlet_grid_int)
        for detector_index in range(len(self.obs_profile)):
            if self.obs_profile[0][detector_index] + self.detector_size / 2. < max(self.beamlet_grid_int):
                detector_steps = [i for i in range(self.beamlet_grid_int.size) if abs(
                    self.beamlet_grid_int[i] - self.obs_profile[0][detector_index])
                                       < (self.detector_size/2)]
                self.photon_emission_profile[detector_index] = sum([self.observed_profile_int[step]*step_size
                                                                    for step in detector_steps])
        observing_detectors = numpy.nonzero(self.photon_emission_profile)
        self.emission_profile = pandas.concat([self.obs_profile, pandas.DataFrame(self.photon_emission_profile)],
                                              axis=1, keys=['Location', 'Emission'])
        print('Only detectors completely inside the calculated region could observe the virtual beamlet, these detector'
              ' numbers are: ' + str(observing_detectors) + '.')
        return

    @staticmethod
    def read_observation_param(data_path):
        obs_param = getdata.GetData(data_path_name=data_path).data
        assert isinstance(obs_param, etree._ElementTree)
        print('obs_param read from file: ' + data_path)
        return obs_param

    @staticmethod
    def read_observation_profile(data_path):

        obs_profile = getdata.GetData(data_path_name=data_path).data
