Package pymontecarlo.util.hdf5

Examples of pymontecarlo.util.hdf5.HDF5Attribute


        super.saveResults(root, key);

        HDF5Group group = root.requireSubgroup(key);

        String transitionName;
        HDF5Dataset ds;
        int[][] emptyData = new int[][] { { 0 } };
        for (XRayTransition transition : transitions) {
            transitionName = transition.getIUPACName();

            ds = group.createDataset(transitionName, emptyData);

            ds.setAttribute("gnf", gnfIntensities.get(transition), 0.0);
            ds.setAttribute("enf", enfIntensities.get(transition), 0.0);
            ds.setAttribute("et", etIntensities.get(transition), 0.0);
        }
    }
View Full Code Here


        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

        HDF5Group group = root.requireSubgroup(key);

        double normFactor = (double) trajectoryCount;

        String transitionName;
        HDF5Dataset ds;
        double gcf, gbf, gnf;
        double ecf, ebf, enf;
        int[][] emptyData = new int[][] { { 0 } };
        for (XRayTransition transition : accumCharac.getTransitions()) {
            transitionName = transition.getIUPACName();

            ds = group.createDataset(transitionName, emptyData);

            gnf = accumCharac.getGenerated(transition) / normFactor;
            enf = accumCharac.getEmitted(transition) / normFactor;

            gcf = ecf = 0.0;
            if (accumCharacFluo != null) {
                gcf = accumCharacFluo.getGenerated(transition) / normFactor;
                ecf = accumCharacFluo.getEmitted(transition) / normFactor;
            }

            gbf = ebf = 0.0;
            if (accumBremssFluo != null) {
                gbf = accumBremssFluo.getGenerated(transition) / normFactor;
                ebf = accumBremssFluo.getEmitted(transition) / normFactor;
            }

            ds.setAttribute("gcf", gcf, 0.0);
            ds.setAttribute("gbf", gbf, 0.0);
            ds.setAttribute("gnf", gnf, 0.0);
            ds.setAttribute("gt", gnf + gcf + gbf, 0.0);

            ds.setAttribute("ecf", ecf, 0.0);
            ds.setAttribute("ebf", ebf, 0.0);
            ds.setAttribute("enf", enf, 0.0);
            ds.setAttribute("et", enf + ecf + ebf, 0.0);
        }
    }
View Full Code Here



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

        // Set Python class
        group.setAttribute("_class", getPythonResultClass());

        // Save log
        Properties props = new Properties();
        createLog(props);
        group.setAttribute("log", props.toString());
    }
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;
        HDF5Dataset ds;
        int[][] emptyData = new int[][] { { 0 } };
        for (XRayTransition transition : transitions) {
            transitionName = transition.getIUPACName();

            ds = group.createDataset(transitionName, emptyData);

            ds.setAttribute("gnf", gnfIntensities.get(transition), 0.0);
            ds.setAttribute("enf", enfIntensities.get(transition), 0.0);
            ds.setAttribute("et", etIntensities.get(transition), 0.0);
        }
View Full Code Here

            mcss.runTrajectory();
        }

        // Save results
        report(1.0, "Saving results");
        HDF5Group rootGroup =
                createHDF5Group(mcss, 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(MonteCarloSS mcss,
            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 props = new Properties();
        createLog(props, mcss);
        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



    @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 IOException {
        HDF5Group root = HDF5Group.createRoot();
        det.saveResults(root, "det1");
        HDF5FileWriter.write(root, resultsFile, true);
    }
View Full Code Here

        double[][] spectrumTotal =
                arrayFromSpectrum(detectorTotal.getSpectrum(1.0));
        double[][] spectrumBackground =
                arrayFromSpectrum(detectorBackground.getSpectrum(1.0));

        HDF5Group group = root.requireSubgroup(key);

        group.createDataset("total", spectrumTotal);
        group.createDataset("background", spectrumBackground);
    }
View Full Code Here

TOP

Related Classes of pymontecarlo.util.hdf5.HDF5Attribute

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.