Source code for SimEx.Calculators.IdealPhotonDetector

""":module IdealPhotonDetector: Module that holds the IdealPhotonDetector class.  """
##########################################################################
#                                                                        #
# Copyright (C) 2015 Carsten Fortmann-Grote                              #
# Contact: Carsten Fortmann-Grote <carsten.grote@xfel.eu>                #
#                                                                        #
# This file is part of simex_platform.                                   #
# simex_platform 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.                                    #
#                                                                        #
# simex_platform 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/>.  #
# Include needed directories in sys.path.                                #
#                                                                        #
##########################################################################

import os

from SimEx.Calculators.AbstractPhotonDetector import AbstractPhotonDetector

[docs]class IdealPhotonDetector(AbstractPhotonDetector): """ :class IdealPhotonDetector: Class representing an ideal photon detector. This is just a dummy calculator that copies input data to output data. """ def __init__(self, parameters=None, input_path=None, output_path=None): """ :param parameters: Parameters for the Detector simulation. :type parameters: dict :param input_path: Path to input files for the detector simulation. :type input_path: str :param output_path: Path where output is stored. :type output_path: str """ # Initialize base class. super(IdealPhotonDetector, self).__init__(parameters,input_path,output_path) self.__provided_data = [ '/data/data', '/data/diffr', '/data/angle', '/history/parent/detail', '/history/parent/parent', '/info/package_version', '/info/contact', '/info/data_description', '/info/method_description', '/params/geom/detectorDist', '/params/geom/pixelWidth', '/params/geom/pixelHeight', '/params/geom/mask', '/params/beam/photonEnergy', '/params/beam/photons', '/params/beam/focusArea', '/params/info', ] self.__expected_data = [ '/data/data', '/data/diffr', '/data/angle', '/history/parent/detail', '/history/parent/parent', '/info/package_version', '/info/contact', '/info/data_description', '/info/method_description', '/params/geom/detectorDist', '/params/geom/pixelWidth', '/params/geom/pixelHeight', '/params/geom/mask', '/params/beam/photonEnergy', '/params/beam/photons', '/params/beam/focusArea', '/params/info', ]
[docs] def expectedData(self): """ Query for the data expected by the Interactor. """ return self.__expected_data
[docs] def providedData(self): """ Query for the data provided by the Interactor. """ return self.__provided_data
[docs] def backengine(self): """ This method drives the backengine code.""" # Simply link input to output and we're fine. os.symlink(self.input_path, self.output_path)
@property def data(self): """ Query for the field data. """ return self.__data def _readH5(self): """ """ """ Private method for reading the hdf5 input and extracting the parameters and data relevant to initialize the object. """ pass # Nothing to be done since IO happens in backengine. ## Read the file. #file_handle = h5py.File(self.input_path, 'r') ## Setup empty dictionary. #parameters = {} ## Get photon energy. ##parameters['photon_energy'] = file_handle['params/photonEnergy'].value ## Read the electric field data and convert to numpy array. #Ehor = numpy.array(file_handle['/data/arrEhor'][:]) #Ever = numpy.array(file_handle['/data/arrEver'][:]) ## Store on object. #self.__e_field = numpy.array([Ehor, Ever]) #super(IdealPhotonDetector, self).__init__(parameters,self.input_path,self.output_path) #file_handle.close()
[docs] def saveH5(self): """ """ """ Private method to save the object to a file. :param output_path: The file where to save the object's data. :type output_path: str """ pass