Skip to content

Commit

Permalink
Auto-save cluster file in XFEL GUI
Browse files Browse the repository at this point in the history
Also bump sleep time to 15s for the uc plot

Co-authored-by: Nicholas Sauter <[email protected]>
  • Loading branch information
phyy-nx and nksauter committed Jan 4, 2024
1 parent c7ef0f0 commit 9983275
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion xfel/ui/components/xfel_gui_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit 9983275

Please sign in to comment.