From 2f9798198b60301d87a70c575346508b4bfbb431 Mon Sep 17 00:00:00 2001 From: Kristjan Eimre Date: Thu, 20 Jan 2022 22:51:07 +0200 Subject: [PATCH 1/2] Include relevant info in export file names (#47) * default height 2.5 ang * export files: include all relevant data in filename --- nanoribbon/viewers/show_computed.py | 40 +++++++++++++++++++++++------ show.ipynb | 2 +- 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/nanoribbon/viewers/show_computed.py b/nanoribbon/viewers/show_computed.py index 1873829..4edc0aa 100644 --- a/nanoribbon/viewers/show_computed.py +++ b/nanoribbon/viewers/show_computed.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- """Viewers to display the results of the Nanoribbon work chain.""" # Base imports. @@ -387,6 +388,8 @@ def __init__(self, cmap='seismic', center0=True, show_cbar=True, export_label=No continuous_update=False, layout=layout) self.height_slider.observe(self.update_plot, names='value') + self.selected_height = 0.0 # angstrom + self.opacity_slider = ipw.FloatSlider(description="Opacity", value=0.5, max=1.0, @@ -454,14 +457,16 @@ def update_axis(self, _=None): geo_center = np.sum(self._current_structure.positions, axis=0) / len(self._current_structure) - z_arr = np.array([d_z * i - geo_center[2] for i in range(0, n_z, 1)]) - i_closest_to_1ang = (np.abs(z_arr - 1.0)).argmin() + self.z_arr = np.array([d_z * i - geo_center[2] for i in range(0, n_z, 1)]) - for i, z in enumerate(z_arr): + for i, z in enumerate(self.z_arr): options[u"{:.3f} Å".format(z)] = i self.height_slider.options = options - self.height_slider.value = list(options.values())[i_closest_to_1ang] + + i_start = (np.abs(self.z_arr - 2.5)).argmin() + self.height_slider.value = list(options.values())[i_start] + self.selected_height = self.z_arr[i_start] def update_plot(self, _=None): """Update the 2D plot with the new data.""" @@ -470,6 +475,7 @@ def update_plot(self, _=None): fig, axplt = plt.subplots() fig.dpi = 150.0 data = self._current_data[:, :, self.height_slider.value] + self.selected_height = self.z_arr[self.height_slider.value] flipped_data = np.flip(data.transpose(), axis=0) vmax = np.max(flipped_data) * self.colormap_slider.value @@ -530,9 +536,11 @@ def make_export_link_txt(self, data): enc_file = b64encode(tempio.getvalue()).decode() if self.export_label is not None: - filename = "{}.txt".format(self.export_label) + plot_name = self.export_label else: - filename = "export.txt" + plot_name = "export" + + filename = "{}_h{:.3f}.txt".format(plot_name, self.selected_height) html = ' Date: Thu, 20 Jan 2022 21:19:46 +0000 Subject: [PATCH 2/2] prepare release 1.4.2 --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 5d8db0f..0667bda 100644 --- a/setup.cfg +++ b/setup.cfg @@ -3,7 +3,7 @@ title = Empa nanotech@surfaces Laboratory - Graphene nanoribbons [metadata] name = nanoribbons -version = 1.4.1 +version = 1.4.2 author = nanotech@surfaces laboratory, Empa description = Tools for graphene nanoribbons, developed at the nanotech@surfaces laboratory, Empa long_description = file: README.md