mirror of
https://github.com/pim-n/pg-rad
synced 2026-04-24 17:58:11 +02:00
improve plotting functionality
This commit is contained in:
@ -58,12 +58,7 @@ class LandscapeSlicePlotter:
|
||||
ax.set_xlim(right=max(width, .5*height))
|
||||
|
||||
# if the road is very flat, we center it vertically (looks better)
|
||||
if median(landscape.path.y_list) == 0:
|
||||
h = max(height, .5*width)
|
||||
ax.set_ylim(bottom=-h//2,
|
||||
top=h//2)
|
||||
else:
|
||||
ax.set_ylim(top=max(height, .5*width))
|
||||
ax.set_ylim(bottom=-.5*width, top=.5*width)
|
||||
|
||||
ax.set_xlabel("X [m]")
|
||||
ax.set_ylabel("Y [m]")
|
||||
|
||||
@ -37,7 +37,7 @@ class ResultPlotter:
|
||||
self._draw_cps(ax_cps)
|
||||
|
||||
ax_counts = fig.add_subplot(gs[0, 1])
|
||||
self._draw_count_rate(ax_counts)
|
||||
self._draw_counts(ax_counts)
|
||||
|
||||
ax_landscape = fig.add_subplot(gs[1, :])
|
||||
self._plot_landscape(ax_landscape, landscape_z)
|
||||
@ -77,15 +77,20 @@ class ResultPlotter:
|
||||
def _draw_cps(self, ax):
|
||||
x = self.count_rate_res.sub_points
|
||||
y = self.count_rate_res.cps
|
||||
ax.plot(x, y, color='b')
|
||||
ax.plot(x, y, color='b', label=f'max(CPS) = {y.max():.2f}')
|
||||
ax.legend(handlelength=0, handletextpad=0, fancybox=True)
|
||||
ax.set_title('Counts per second (CPS)')
|
||||
ax.set_xlabel('Arc length s [m]')
|
||||
ax.set_ylabel('CPS [s$^{-1}$]')
|
||||
|
||||
def _draw_count_rate(self, ax):
|
||||
x = self.count_rate_res.acquisition_points
|
||||
y = self.count_rate_res.integrated_counts
|
||||
ax.plot(x, y, color='r', linestyle='--', alpha=0.2)
|
||||
def _draw_counts(self, ax):
|
||||
x = self.count_rate_res.acquisition_points[1:]
|
||||
y = self.count_rate_res.integrated_counts[1:]
|
||||
ax.plot(
|
||||
x, y, color='r', linestyle='--',
|
||||
alpha=0.2, label=f'max(counts) = {y.max():.2f}'
|
||||
)
|
||||
ax.legend(handlelength=0, handletextpad=0, fancybox=True)
|
||||
ax.scatter(x, y, color='r', marker='x')
|
||||
ax.set_title('Integrated counts')
|
||||
ax.set_xlabel('Arc length s [m]')
|
||||
@ -99,6 +104,7 @@ class ResultPlotter:
|
||||
["Air density (kg/m^3)", round(self.landscape.air_density, 3)],
|
||||
["Total path length (m)", round(self.landscape.path.length, 3)],
|
||||
["Readout points", len(self.count_rate_res.integrated_counts)],
|
||||
["Mean background cps", round(self.count_rate_res.mean_bkg_cps, 3)]
|
||||
]
|
||||
|
||||
ax.table(
|
||||
@ -124,7 +130,7 @@ class ResultPlotter:
|
||||
# list field efficiencies for each primary gamma in the landscape
|
||||
effs = {e: det.get_efficiency(e) for e in source_energies}
|
||||
formatted_effs = ", ".join(
|
||||
f"{value:.3f} @ {key:.1f} keV"
|
||||
f"{value:.5f} @ {key:.1f} keV"
|
||||
for key, value in effs.items()
|
||||
)
|
||||
ax.set_axis_off()
|
||||
@ -201,6 +207,5 @@ class ResultPlotter:
|
||||
|
||||
theta_rad = np.radians(theta_deg)
|
||||
|
||||
print(theta_rad)
|
||||
ax.plot(theta_rad, eff)
|
||||
ax.set_title(f"Rel. angular efficiency @ {energy_keV:.1f} keV")
|
||||
|
||||
Reference in New Issue
Block a user