Beispiel #1
0
    def _import_phi_z(self, options, name, detector, path):
        wxrresult = CharateristicPhirhoz(path)

        def _extract(data, absorption):
            distributions = {}

            for z in data:
                for xrayline in data[z]:
                    transition = from_string(symbol(z) + " " + xrayline)

                    dist = np.array(data[z][xrayline]).T

                    # Convert z values in meters
                    dist[:, 0] *= -1e-9

                    # WinXRay starts from the bottom to the top
                    # The order must be reversed
                    dist = dist[::-1]

                    key = PhotonKey(transition, absorption, PhotonKey.P)
                    distributions[key] = dist

            return distributions

        distributions = {}
        distributions.update(_extract(wxrresult.getPhirhozs('Generated'), False))
        distributions.update(_extract(wxrresult.getPhirhozs('Emitted'), True))

        return PhiZResult(distributions)
Beispiel #2
0
    def _import_phi_z(self, options, name, detector, jobdir):
        prz_filepath = os.path.join(jobdir, 'phi_%s.csv' % name)
        if not os.path.exists(prz_filepath):
            raise ImporterException('Result file "phi_%s.csv" not found in job directory (%s)' % \
                                    (name, jobdir))

        with open(prz_filepath, 'r') as fp:
            reader = csv.reader(fp, delimiter=';')
            header = next(reader)

            data = {}
            for row in reader:
                for i, val in enumerate(row):
                    data.setdefault(header[i], []).append(float(val.replace(',', '.'))) # FIXME: Hack to handle locale problem

        rzs = np.array(data.pop('rho z'))

        distributions = {}
        for transition, values in data.items():
            transition = from_string(transition.strip())
            enf = np.array([rzs, values]).transpose()
            distributions[PhotonKey(transition, True, PhotonKey.P)] = enf

        return PhiZResult(distributions)