From b70a3b3e87b27abd1c39bf9c8205fcb2e16a969f Mon Sep 17 00:00:00 2001 From: Thomas Baumann <39156931+brownbaerchen@users.noreply.github.com> Date: Mon, 7 Sep 2026 13:49:29 +0200 Subject: [PATCH 1/2] Improve plot slightly --- scripts/astrodendro_example_comparisions.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/astrodendro_example_comparisions.py b/scripts/astrodendro_example_comparisions.py index de9021d..f625c62 100644 --- a/scripts/astrodendro_example_comparisions.py +++ b/scripts/astrodendro_example_comparisions.py @@ -34,7 +34,7 @@ def compare_examples(ntasks=4): ntasks=ntasks, **params, min_npix_loc=5 ) d_fast = DistributedDendrogram.compute_pseudo_parallel( - ntasks=ntasks, **params, min_npix_loc=params["min_npix"] + ntasks=ntasks, **params, min_npix_loc=params["min_npix"], min_delta_loc=0.6 ) compare_dendrograms(d_astrodendro, d_exact) @@ -69,7 +69,10 @@ def compare_examples(ntasks=4): ax, structure=structure.idx, colors=[colors.get(j, "green")] ) - ax.set_title(titles[i]) + if hasattr(dendrogram, "_iterations"): + ax.set_title(f"{titles[i]}\n{dendrogram._iterations} merge iter") + else: + ax.set_title(f"{titles[i]}") fig.tight_layout() fig.savefig("compare_astrodendro_example_v3.pdf", dpi=300, bbox_inches="tight") From 53d95b25289d65960c678ceb8713e4ee1edf9814 Mon Sep 17 00:00:00 2001 From: Thomas Baumann <39156931+brownbaerchen@users.noreply.github.com> Date: Mon, 7 Sep 2026 16:12:01 +0200 Subject: [PATCH 2/2] Add OGHRES comparison plots --- scripts/OGHRES_comparison.py | 60 ++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 scripts/OGHRES_comparison.py diff --git a/scripts/OGHRES_comparison.py b/scripts/OGHRES_comparison.py new file mode 100644 index 0000000..06bab67 --- /dev/null +++ b/scripts/OGHRES_comparison.py @@ -0,0 +1,60 @@ +import matplotlib.pyplot as plt +from dendro.analysis import compare_dendrograms + + +def compare_OGHRES(): + from astrodendro import Dendrogram + + d_v3 = Dendrogram.load_from( + "/Users/thomasbaumann/Documents/repositories/dendrogram/speedup_studies//timing_data/OGHRES-dendrogram-v3-4tasks.fits" + ) + d_astrodendro = Dendrogram.load_from( + "/Users/thomasbaumann/Documents/repositories/dendrogram/speedup_studies//timing_data/OGHRES-dendrogram-astrodendro-1tasks.fits" + ) + import matplotlib.pyplot as plt + + fig, axs = plt.subplots(1, 2, sharex=True, sharey=True) + overlap_fig, overlap_ax = plt.subplots() + # d_astrodendro.plotter().plot_tree(axs[0]) + # d_v3.plotter().plot_tree(axs[1]) + + titles = ["astrodrendro", "distributed"] + for j in [0, 4, 8]: + for i, dendrogram in enumerate([d_astrodendro, d_v3]): + ax = axs[i] + # ax.imshow( + # params["data"], + # origin="lower", + # interpolation="nearest", + # cmap=plt.cm.Blues, + # vmax=4.0, + # rasterized=True, + # ) + + if j == 0 and dendrogram is not d_astrodendro: # plot overlap + overlap = compare_dendrograms(d_astrodendro, dendrogram) + overlap_ax.plot(overlap.keys(), overlap.values(), label=f"{titles[i]}") + + plotter = dendrogram.plotter() + + structures = [structure for structure in dendrogram if structure.level == j] + colors = {0: "black", 4: "yellow", 8: "red"} + + for structure in structures: + plotter.plot_contour( + ax, structure=structure.idx, colors=[colors.get(j, "green")] + ) + + ax.set_title(titles[i]) + fig.tight_layout() + fig.savefig("compare_OGHRES_v3.pdf", dpi=300, bbox_inches="tight") + + overlap_ax.set_xlabel("level") + overlap_ax.set_ylabel("overlap") + overlap_ax.legend(frameon=False) + overlap_fig.savefig("compare_OGHRES_v3_overlap.pdf", dpi=300, bbox_inches="tight") + + +if __name__ == "__main__": + compare_OGHRES() + plt.show()