From 998327540111c7be25502f4e65f9453f92af958f Mon Sep 17 00:00:00 2001 From: Aaron Brewster Date: Wed, 3 Jan 2024 16:00:57 -0800 Subject: [PATCH] Auto-save cluster file in XFEL GUI Also bump sleep time to 15s for the uc plot Co-authored-by: Nicholas Sauter --- xfel/ui/components/xfel_gui_init.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/xfel/ui/components/xfel_gui_init.py b/xfel/ui/components/xfel_gui_init.py index 108c706594..92dbc18265 100644 --- a/xfel/ui/components/xfel_gui_init.py +++ b/xfel/ui/components/xfel_gui_init.py @@ -846,12 +846,25 @@ def run(self): plots = dbscan_plot_manager(params) plots.wrap_3D_features(fig = figure, embedded = True) figure.canvas.draw_idle() + cluster_dir = os.path.join(self.parent.params.output_folder, "cluster") + if not os.path.isdir(cluster_dir): + os.makedirs(cluster_dir) + cluster_file = os.path.join(cluster_dir,"cluster_%s.pickle"%(plots.FV.sample_name.strip().replace(" ", "_"))) + print("Writing cluster to", cluster_file) + import pickle + with open(cluster_file,"wb") as FF: + pickle.dump( + dict(populations=plots.pop, + features=plots.FV.features_, + info=plots.FV.output_info, + sample=plots.FV.sample_name),FF + ) else: print("Unsupported crystal system", cs) self.post_refresh() self.parent.run_window.unitcell_light.change_status('on') - time.sleep(5) + time.sleep(15) except Exception as e: print(e) self.parent.run_window.unitcell_light.change_status('alert')