atompy.load_2d_from_root#

atompy.load_2d_from_root(fname, hname, output_format='pcolormesh')[source]#

Load 2D data stored in a ROOT file.

Parameters:
fnamestr

Filename, e.g., "my_root_file.root".

hnamestr

Histogram name in the root file, e.g., "path/to/histogram".

output_format{"imshow", "pcolormesh", "Hist2d" }, default "pcolormesh"

Change output format. See Returns.

Returns:
outputPcolormeshData, ImshowData or Hist2d

Depends on output_format.

Examples

Load data such that it can be plotted using matplotlib.pyplot.pcolormesh().

data = ap.load_2d_from_txt("rootfile.root", "path/to/hist",
                           output_format="pcolormesh")
plt.pcolormesh(data.x, data.y, data.z)

Load data such that it can be plotted using matplotlib.pyplot.imshow().

data = ap.load_2d_from_txt("rootfile.root", "path/to/hist",
                           output_format="imshow")
plt.imshow(data.image, extent=data.extent)

Alternatively, immediately unpack the loaded data into their respective numpy.ndarray.

x, y, z = ap.load_2d_from_txt("rootfile.root", "path/to/hist",
                              output_format="pcolormesh")
plt.pcolormesh(x, y, z)

image, extent = ap.load_2d_from_txt("rootfile.root", "path/to/hist",
                                    output_format="imshow")
plt.imshow(image, extent=extent)

Load data as a Hist2d".

data = ap.load_2d_from_txt("rootfile.root", "path/to/hist",
                           output_format="Hist2d")
data = hist.column_normalized_to_sum.for_pcolormesh
plt.pcolormesh(data.x, data.y, data.z)