1############################################################################### 2# Copyright (c) Lawrence Livermore National Security, LLC and other Ascent 3# Project developers. See top-level LICENSE AND COPYRIGHT files for dates and 4# other details. No copyright assignment is required to contribute to Ascent. 5############################################################################### 6# 7# file: ascent_tutorial_python_extract_braid_histogram.py 8# 9############################################################################### 10 11import numpy as np 12 13# get published blueprint data from the ascent 14 15# python extract always consumes the multi-domain 16# flavor of the mesh blueprint, since we have a 17# single domain mesh, the data we want is the first child 18 19mesh = ascent_data().child(0) 20 21# fetch the numpy array for the braid field values 22e_vals = mesh["fields/braid/values"] 23 24# find the data extents of the braid field 25e_min, e_max = e_vals.min(), e_vals.max() 26 27# compute bins on extents 28bins = np.linspace(e_min, e_max) 29 30# get histogram counts 31hist, bin_edges = np.histogram(e_vals, bins = bins) 32 33print("\nEnergy extents: {} {}\n".format(e_min, e_max)) 34print("Histogram of Energy:\n") 35print("Counts:") 36print(hist) 37print("\nBin Edges:") 38print(bin_edges) 39print("") 40 41# save our results to a yaml file 42hist_results = conduit.Node() 43hist_results["hist"] = hist 44hist_results["bin_edges"] = bin_edges 45hist_results.save("out_py_extract_hist_results.yaml","yaml") 46