Skip to content

Commit

Permalink
Merge pull request #44 from DUNE-DAQ/aeo/style-update
Browse files Browse the repository at this point in the history
Plotting Style Update
  • Loading branch information
aeoranday authored Jul 3, 2024
2 parents a2ea4ed + 8a2cfa3 commit 830a432
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 12 deletions.
11 changes: 11 additions & 0 deletions python/trgtools/plot/PDFPlotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,17 @@ def plot_histogram(
ax.patch.set_visible(False)
ax2.set_zorder(1)

linear_color = plot_details_dict.get('linear_style', self._DEFAULT_HIST_STYLE).get('color', self._DEFAULT_HIST_STYLE['linear_style']['color'])
# Set axis and tick colors.
ax.spines['left'].set_color(linear_color)
ax.yaxis.label.set_color(linear_color)
ax.tick_params('y', colors=linear_color)

log_color = plot_details_dict.get('log_style', self._DEFAULT_HIST_STYLE).get('color', self._DEFAULT_HIST_STYLE['log_style']['color'])
ax.spines['right'].set_color(log_color) # Actually belongs to ax and not ax2.
ax2.yaxis.label.set_color(log_color)
ax2.tick_params('y', colors=log_color)

handles, labels = ax.get_legend_handles_labels()
handles2, labels2 = ax2.get_legend_handles_labels()
handles = handles + handles2
Expand Down
13 changes: 10 additions & 3 deletions scripts/ta_dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def parse():
Parses CLI input arguments.
"""
parser = argparse.ArgumentParser(
description="Display diagnostic information for TAs for a given tpstream file."
description="Display diagnostic information for TAs for a given HDF5 file."
)
parser.add_argument(
"filename",
Expand Down Expand Up @@ -290,6 +290,11 @@ def main():

data = trgtools.TAReader(filename, verbosity)

# Check that there are TA fragments.
if len(data.get_fragment_paths()) == 0:
print("File doesn't contain any TriggerActivity fragments.")
return 1

# Load all case.
if start_frag == 0 and end_frag == -1:
data.read_all_fragments() # Has extra debug/warning info
Expand Down Expand Up @@ -339,7 +344,7 @@ def main():
'log_style': dict(color='#EE442F', alpha=0.6, label='Log')
},
'algorithm': {
'bins': np.arange(-0.5, np.max(ALGORITHM_TICKS) + 1, 1),
'bins': np.sort(np.array([(tick-0.45, tick+0.45) for tick in ALGORITHM_TICKS]).flatten()),
'title': "Algorithm Histogram",
'xlabel': 'Algorithm Type',
'ylabel': "Count",
Expand All @@ -349,6 +354,7 @@ def main():
'xticks': {
'labels': ALGORITHM_LABELS,
'ticks': ALGORITHM_TICKS,
'fontsize': 6,
'rotation': 60,
'ha': 'right' # Horizontal alignment
}
Expand Down Expand Up @@ -439,7 +445,7 @@ def main():
'log_style': dict(color='#EE442F', alpha=0.6, label='Log')
},
'type': {
'bins': np.arange(-0.5, np.max(TYPE_TICKS) + 1, 1),
'bins': np.sort(np.array([(tick-0.45, tick+0.45) for tick in TYPE_TICKS]).flatten()),
'title': "Type Histogram",
'xlabel': "Type",
'ylabel': "Count",
Expand All @@ -449,6 +455,7 @@ def main():
'xticks': {
'labels': TYPE_LABELS,
'ticks': TYPE_TICKS,
'fontsize': 6,
'rotation': 60,
'ha': 'right' # Horizontal alignment
}
Expand Down
13 changes: 10 additions & 3 deletions scripts/tc_dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ def parse():
Parses CLI input arguments.
"""
parser = argparse.ArgumentParser(
description="Display diagnostic information for TCs for a given tpstream file."
description="Display diagnostic information for TCs for a given HDF5 file."
)
parser.add_argument(
"filename",
Expand Down Expand Up @@ -283,6 +283,11 @@ def main():

data = trgtools.TCReader(filename, verbosity)

# Check that there are TC fragments.
if len(data.get_fragment_paths()) == 0:
print("File doesn't contain any TriggerCandidate fragments.")
return 1

# Load all case.
if start_frag == 0 and end_frag == -1:
data.read_all_fragments() # Has extra debug/warning info
Expand Down Expand Up @@ -315,7 +320,7 @@ def main():
# Dictionary containing unique title, xlabel, and xticks (only some)
plot_hist_dict = {
'algorithm': {
'bins': np.arange(-0.5, np.max(ALGORITHM_TICKS) + 1, 1),
'bins': np.sort(np.array([(tick-0.45, tick+0.45) for tick in ALGORITHM_TICKS]).flatten()),
'title': "Algorithm",
'xlabel': 'Algorithm Type',
'ylabel': "Count",
Expand All @@ -325,6 +330,7 @@ def main():
'xticks': {
'labels': ALGORITHM_LABELS,
'ticks': ALGORITHM_TICKS,
'fontsize': 6,
'rotation': 60,
'ha': 'right' # Horizontal alignment
}
Expand Down Expand Up @@ -384,7 +390,7 @@ def main():
'log_style': dict(color='#EE442F', alpha=0.6, label='Log')
},
'type': {
'bins': np.arange(-0.5, np.max(TYPE_TICKS) + 1, 1),
'bins': np.sort(np.array([(tick-0.45, tick+0.45) for tick in TYPE_TICKS]).flatten()),
'title': "Type",
'xlabel': "Type",
'ylabel': "Count",
Expand All @@ -394,6 +400,7 @@ def main():
'xticks': {
'labels': TYPE_LABELS,
'ticks': TYPE_TICKS,
'fontsize': 6,
'rotation': 60,
'ha': 'right' # Horizontal alignment
}
Expand Down
33 changes: 27 additions & 6 deletions scripts/tp_dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,20 @@ def plot_pdf_adc_integral_vs_peak(tp_data: np.ndarray, pdf: PdfPages, verbosity:
)
print("Total number of TPs:", len(tp_data['adc_peak']))
high_integral_locs = np.where(tp_data['adc_integral'] == np.power(2, 15)-1)
unity = (np.min(tp_data['adc_peak']), np.max(tp_data['adc_peak']))

plt.figure(figsize=(6, 4), dpi=200)

plt.scatter(
plt.plot(
tp_data['adc_peak'],
tp_data['adc_integral'],
c='k',
s=2,
c="#00000055",
ms=2,
ls='none',
marker='o',
mew=0,
label='TP',
zorder=2,
rasterized=True
)
plt.scatter(
Expand All @@ -117,8 +122,17 @@ def plot_pdf_adc_integral_vs_peak(tp_data: np.ndarray, pdf: PdfPages, verbosity:
c='#63ACBE',
s=2, marker='+',
label=r'$2^{15}-1$',
zorder=3,
rasterized=True
)
plt.plot(
unity,
unity,
color='#EE442F',
label="Unity",
lw=2,
zorder=1
)

plt.title("ADC Integral vs ADC Peak")
plt.xlabel("ADC Peak")
Expand Down Expand Up @@ -170,7 +184,7 @@ def write_summary_stats(data: np.ndarray, filename: str, title: str) -> None:

def parse():
parser = argparse.ArgumentParser(
description="Display diagnostic information for TAs for a given tpstream file."
description="Display diagnostic information for TPs for a given HDF5 file."
)
parser.add_argument(
"filename",
Expand Down Expand Up @@ -248,6 +262,11 @@ def main():

data = trgtools.TPReader(filename, verbosity)

# Check that there are TP fragments.
if len(data.get_fragment_paths()) == 0:
print("File doesn't contain any TriggerPrimitive fragments.")
return 1

# Load all case
if start_frag == 0 and end_frag == -1:
data.read_all_fragments() # Has extra debug/warning info
Expand Down Expand Up @@ -298,7 +317,7 @@ def main():
'log_style': dict(color='#EE442F', alpha=0.6, label='Log')
},
'algorithm': {
'bins': np.arange(-0.5, np.max(ALGORITHM_TICKS) + 1, 1),
'bins': np.sort(np.array([(tick-0.45, tick+0.45) for tick in ALGORITHM_TICKS]).flatten()),
'title': "Algorithm Histogram",
'xlabel': 'Algorithm Type',
'ylabel': "Count",
Expand All @@ -308,6 +327,7 @@ def main():
'xticks': {
'labels': ALGORITHM_LABELS,
'ticks': ALGORITHM_TICKS,
'fontsize': 6,
'rotation': 60,
'ha': 'right' # Horizontal alignment
}
Expand Down Expand Up @@ -371,7 +391,7 @@ def main():
'log_style': dict(color='#EE442F', alpha=0.6, label='Log')
},
'type': {
'bins': np.arange(-0.5, np.max(TYPE_TICKS) + 1, 1),
'bins': np.sort(np.array([(tick-0.45, tick+0.45) for tick in TYPE_TICKS]).flatten()),
'title': "Type Histogram",
'xlabel': "Type",
'ylabel': "Count",
Expand All @@ -381,6 +401,7 @@ def main():
'xticks': {
'labels': TYPE_LABELS,
'ticks': TYPE_TICKS,
'fontsize': 6,
'rotation': 60,
'ha': 'right' # Horizontal alignment
}
Expand Down

0 comments on commit 830a432

Please sign in to comment.