Exemplo n.º 1
0
    def _import_photon_depth(self, options, key, detector, path,
                             phdets_key_index, phdets_index_keys, *args):
        distributions = {}

        for filepath in glob.glob(os.path.join(path, 'pe-map-*-depth.dat')):
            # Create photon key
            with open(filepath, 'r') as fp:
                next(fp)  # Skip first line
                text = next(fp).split(':')[1].strip()
                match = re.match(
                    'Z = ([ \d]+),([ \w]+)-([ \w]+), detector = ([ \d]+)',
                    text)
                z, dest, src, detector_index = match.groups()

                z = int(z)
                src = Subshell(z, iupac=src.strip())
                dest = Subshell(z, iupac=dest.strip())
                transition = Transition(z, src, dest)

                detector_index = int(detector_index)
                if detector_index == 0:
                    photonkey = PhotonKey(transition, False, PhotonKey.T)
                else:
                    assert detector_index == phdets_key_index[key] + 1
                    photonkey = PhotonKey(transition, True, PhotonKey.T)

            # Read values
            datum = np.genfromtxt(filepath, skip_header=6)
            datum *= 1e-2  # cm to m

            distributions[photonkey] = datum

        return PhotonDepthResult(distributions)