Package pymontecarlo.util.hdf5

Examples of pymontecarlo.util.hdf5.HDF5FileWriter


    @Override
    public void saveResults(HDF5Group root, String key) throws IOException {
        super.saveResults(root, key);

        HDF5Group group = root.requireSubgroup(key);

        String transitionName;
        double[][] gnf, gt, enf, et;
        HDF5Group transitionGroup;
        for (XRayTransition trans : przCharac.getTransitions()) {
            if (!trans.isWellKnown())
                continue;

            transitionName = trans.getIUPACName();
            transitionGroup = group.createSubgroup(transitionName);

            gnf = new double[2][channels];
            gt = new double[2][channels];
            enf = new double[2][channels];
            et = new double[2][channels];

            gnf[0] = zs;
            gnf[1] = przCharac.getGenerated(trans);

            gt[0] = zs;
            gt[1] = gnf[1].clone();

            enf[0] = zs;
            enf[1] = przCharac.getEmitted(trans);

            et[0] = zs;
            et[1] = enf[1].clone();

            transitionGroup.createDataset("gnf", transpose(gnf));
            transitionGroup.createDataset("gt", transpose(gt));
            transitionGroup.createDataset("enf", transpose(enf));
            transitionGroup.createDataset("et", transpose(et));
        }
    }
View Full Code Here


    @Override
    public void saveResults(HDF5Group root, String key) throws IOException {
        super.saveResults(root, key);

        HDF5Group group = root.requireSubgroup(key);

        Trajectory trajectory;
        String name;
        double[][] data;
        int interactionsSize;
        Double[] interaction;
        HDF5Dataset dataset;
        for (int i = 0; i < trajectories.size(); i++) {
            trajectory = trajectories.get(i);

            name = "trajectory" + i;

            interactionsSize = trajectory.interactions.size();
            data = new double[interactionsSize][6];
            for (int j = 0; j < interactionsSize; j++) {
                interaction = trajectory.interactions.get(j);
                data[j][0] = interaction[0];
                data[j][1] = interaction[1];
                data[j][2] = interaction[2];
                data[j][3] = interaction[3];
                data[j][4] = interaction[4];
                data[j][5] = interaction[5];
            }

            dataset = group.createDataset(name, data);

            dataset.setAttribute("primary", trajectory.primary ? 1 : 0);
            dataset.setAttribute("particle", 1); // Electron
            dataset.setAttribute("collision", trajectory.collision);
            dataset.setAttribute("exit_state", trajectory.exitState);
View Full Code Here



    @Test
    public void testSaveResults() throws Exception {
        HDF5Group root = HDF5Group.createRoot();
        det.saveResults(root, "det1");
        HDF5FileWriter.write(root, resultsFile, true);
    }
View Full Code Here



    @Test
    public void testSaveResults() throws Exception {
        HDF5Group root = HDF5Group.createRoot();
        det.saveResults(root, "det1");
        HDF5FileWriter.write(root, resultsFile, true);
    }
View Full Code Here

    @Override
    public void saveResults(HDF5Group root, String key) throws IOException {
        super.saveResults(root, key);

        HDF5Group group = root.requireSubgroup(key);

        long elapsedTime = System.currentTimeMillis() - startSimulationTime;
        group.setAttribute("simulation_time_s", elapsedTime / 1000.0);

        double mean = sum / count;
        double std = Math.sqrt(sumSquare / count - Math.pow(mean, 2.0));
        group.setAttribute("simulation_speed_s", mean / 1000.0, std / 1000.0);
    }
View Full Code Here



    @Test
    public void testSaveResults() throws Exception {
        HDF5Group root = HDF5Group.createRoot();
        det.saveResults(root, "det1");
        HDF5FileWriter.write(root, resultsFile, true);
    }
View Full Code Here

    @Override
    public void saveResults(HDF5Group root, String key) throws IOException {
        super.saveResults(root, key);

        HDF5Group group = root.requireSubgroup(key);

        String transitionName;
        double[][][] gnf, gt, enf, et;
        HDF5Group transitionGroup;
        for (XRayTransition trans : mapTotal.getTransitions()) {
            if (!trans.isWellKnown())
                continue;

            transitionName = trans.getIUPACName();
            transitionGroup = group.createSubgroup(transitionName);

            gnf = mapCharac.getGeneratedDistribution(trans).getArray();
            gt = mapTotal.getGeneratedDistribution(trans).getArray();
            enf = mapCharac.getEmittedDistribution(trans).getArray();
            et = mapTotal.getGeneratedDistribution(trans).getArray();

            transitionGroup.createDataset("gnf", gnf);
            transitionGroup.createDataset("gt", gt);
            transitionGroup.createDataset("enf", enf);
            transitionGroup.createDataset("et", et);
        }
    }
View Full Code Here

    @Override
    public void saveResults(HDF5Group root, String key) throws IOException {
        super.saveResults(root, key);

        HDF5Group group = root.requireSubgroup(key);

        String transitionName;
        double[][] gnf, enf;
        HDF5Group transitionGroup;
        for (XRayTransition trans : transitions) {
            transitionName = trans.getIUPACName();
            transitionGroup = group.createSubgroup(transitionName);

            gnf = new double[2][channels];
            enf = new double[2][channels];

            gnf[0] = zPZS.get(trans);
            gnf[1] = gnfPZs.get(trans);

            enf[0] = zPZS.get(trans);
            enf[1] = enfPZs.get(trans);

            transitionGroup.createDataset("gnf", transpose(gnf));
            transitionGroup.createDataset("enf", transpose(enf));
        }
    }
View Full Code Here

            detector.run();
        }

        // Save results
        report(1.0, "Saving results");
        HDF5Group rootGroup =
                createHDF5Group(props, detectors, rootElement, name);
        File resultsH5 = new File(resultsDir, name + ".h5");
        HDF5FileWriter.write(rootGroup, resultsH5, true);
        report(1.0, "Complete");
    }
View Full Code Here


    private HDF5Group createHDF5Group(SpectrumProperties props,
            Map<String, Detector> detectors,
            Element rootElement, String name) throws IOException {
        HDF5Group rootGroup = HDF5Group.createRoot();

        // Save version, class
        rootGroup.setAttribute("version", VERSION);
        rootGroup.setAttribute("_class", "Results");

        // Create results group
        String identifier = rootElement.getAttributeValue("uuid");
        rootGroup.setAttribute("identifiers", new String[] { identifier });

        HDF5Group resultsGroup =
                rootGroup.createSubgroup("result-" + identifier);

        // Save results from detectors
        String key;
        Detector detector;
        for (Entry<String, Detector> entry : detectors.entrySet()) {
            key = entry.getKey();
            detector = entry.getValue();
            detector.saveResults(resultsGroup, key);
        }

        // Save overall log
        Properties logProps = new Properties();
        logProps.putAll(props.getPropertyMap());
        createLog(logProps);
        resultsGroup.setAttribute("log", props.toString());

        // Save options
        XMLOutputter outputter = new XMLOutputter(Format.getCompactFormat());
        String optionsStr = outputter.outputString(rootElement);
        resultsGroup.setAttribute("options", optionsStr);
        rootGroup.setAttribute("options", optionsStr);

        return rootGroup;
    }
View Full Code Here

TOP

Related Classes of pymontecarlo.util.hdf5.HDF5FileWriter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.