Closed abehersan closed 2 years ago
below is a minimal reproducible example of what i was trying to attempt in the first place - i believe with the recent pull req. the issue is fixed
"""
file name:
mjolnirErrMinimal.py
program function:
minimal reproducible example of MJOLNIR's exception passed when
giving a custom plt axis to plotting functions - fixed now
"""
import matplotlib.pyplot as plt
from MJOLNIR import _tools
from MJOLNIR.Data import DataSet
import numpy as np
# dset object generation
numor_path_year = "956-959", "./CAMEAData/", 2021
dfiles = _tools.fileListGenerator(*numor_path_year)
dset = DataSet.DataSet(dfiles)
dset.convertDataFile(binning=5,saveFile=False)
# parameter definition for plots
cutqe_params = {
"q1":np.array([-1,2,0], float),
"q2":np.array([0,2,0], float),
"EMin":0.0, "EMax":1.3, "dE":0.1, "width":0.1, "minPixel":0.05,
"rlu":True, "smoothing":0.0, "vmin":0.0, "vmax":4e-02
}
# custom axes generation
fig, axes = plt.subplots(2,1) # two axes stacked on top of each other in same fig
ax_direction1, ax_direction2 = axes.flatten()
# plotting and cutting with MJOLNIR - fixed now for QE cuts
q2 = [1,1,0]
cutqe_params.update({"q2":q2, "ax":ax_direction1})
ax_direction1, data_dir1, bins_dir1 = dset.plotCutQE(**cutqe_params)
q2 = np.array([0.5,2,0],float)
cutqe_params.update({"q2":q2, "ax":ax_direction2})
ax_direction2, data_dir2, bins_dir2 = dset.plotCutQE(**cutqe_params)
# apply tight layout for cutQE plot
plt.tight_layout()
plt.show()
hopefully it's something to go by(? cheers and thanks again Jakob! BW, Abraham
Hi Abraham
I have taken your code as a test case for the four plotcut functions (c1d4fb1442a2ed1a38bdd3ac023b842047b00436). I adjusted the calculation in the plotting routines such that they allow custom axis. For all but the QELine this solves the issue by calculating the distance from the original point to the data point and uses this as the x coordinate.
by simply extending the
generate1DAxis
method, any axes can be safely passed as an argument to the plotting methods of theDataSet
objecttested on
plotCut1DE
plotCutQE
plotCutQELine