From 551a06cb4b124d0bc6a7bf49bc53df1803719541 Mon Sep 17 00:00:00 2001 From: Markus Rosenstihl Date: Thu, 24 Nov 2022 10:30:23 +0100 Subject: [PATCH 1/2] This YAML file needs a specific order, otherwise the AppImage will not load. Fixes T235 --- AppImageBuilder.yml | 2 +- tools/update_version.py | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/AppImageBuilder.yml b/AppImageBuilder.yml index 6851229..76609c3 100644 --- a/AppImageBuilder.yml +++ b/AppImageBuilder.yml @@ -20,7 +20,7 @@ AppDir: id: pkm.vogel.nmreval name: NMReval icon: logo - version: 0.2.0 + version: _devel_ # Set the python executable as entry point exec: usr/bin/python3 # Set the application main script path as argument. Use '$@' to forward CLI parameters diff --git a/tools/update_version.py b/tools/update_version.py index c7a9041..e18ab0d 100755 --- a/tools/update_version.py +++ b/tools/update_version.py @@ -2,10 +2,11 @@ import os import yaml -if __name__ == "__main__": +if __name__ == "__main__this_is_broken": if "GO_PIPELINE_LABEL" in os.environ: version = os.environ["GO_PIPELINE_LABEL"] appimage_yaml = yaml.safe_load(open("AppImageBuilder.yml")) + appimage_old_version = appimage_yaml["AppDir"]["app_info"]["version"] appimage_yaml["AppDir"]["app_info"]["version"] = version with open(f"AppImageBuilder{version}.yml","wb") as yaml_file: yaml.safe_dump(appimage_yaml, yaml_file, encoding = 'utf-8') @@ -13,3 +14,15 @@ if __name__ == "__main__": else: print("No GO_PIPELINE_LABEL found, doing nothing") +if __name__ == "__main__": + if "GO_PIPELINE_LABEL" in os.environ: + version = os.environ["GO_PIPELINE_LABEL"] + src_version = open("AppImageBuilder.yml").readlines() + with open(f"AppImageBuilder{version}.yml","w") as new_version: + for line in src_version: + cp_line = line.replace("version: _devel_", f"version: {version}") + new_version.write(f"{cp_line}") + + + + From d91371406a36aa40bebbdf772d8b210ffb2cce44 Mon Sep 17 00:00:00 2001 From: Dominik Demuth Date: Fri, 25 Nov 2022 20:05:52 +0100 Subject: [PATCH 2/2] Remove matplotlib dependence to fix T234 --- AppImageBuilder.yml | 4 +- src/nmreval/io/fcbatchreader.py | 128 ++++++++++++++++---------------- 2 files changed, 66 insertions(+), 66 deletions(-) diff --git a/AppImageBuilder.yml b/AppImageBuilder.yml index 76609c3..db57935 100644 --- a/AppImageBuilder.yml +++ b/AppImageBuilder.yml @@ -41,8 +41,8 @@ AppDir: - python3.9-minimal - python3-pyqt5 - python3-numpy - - python3-matplotlib - - python-matplotlib-data +# - python3-matplotlib +# - python-matplotlib-data - python3-scipy - python3-bsddb3 - python3-h5py diff --git a/src/nmreval/io/fcbatchreader.py b/src/nmreval/io/fcbatchreader.py index c0da0e0..8c1258b 100644 --- a/src/nmreval/io/fcbatchreader.py +++ b/src/nmreval/io/fcbatchreader.py @@ -2,7 +2,7 @@ from __future__ import annotations import pathlib -import matplotlib.pyplot as plt +# import matplotlib.pyplot as plt from scipy.optimize import curve_fit import numpy as np @@ -148,9 +148,9 @@ class FCReader: fit_path = fname_no_ext.joinpath('fit') fit_path.mkdir(parents=True, exist_ok=True) - if save_fig: - image_path = fname_no_ext.joinpath('png') - image_path.mkdir(parents=True, exist_ok=True) + # if save_fig: + # image_path = fname_no_ext.joinpath('png') + # image_path.mkdir(parents=True, exist_ok=True) header = 'm0\tt1\tbeta\toff\n' @@ -189,16 +189,16 @@ class FCReader: np.savetxt(fit_path.joinpath(save_name), np.c_[xplot, yplot], header=header+'\t'.join([f'{p}+/-{err}' for p, err in zip(p0, perr)])) - if save_fig: - fig, ax = plt.subplots() - ax.set_xlabel('t / s') - ax.set_ylabel('M') - axheader = f'T1: {p0[2]:.4g}(+/-{perr[2]:.4g}) beta: {p0[3]:.4g}(+/-{perr[3]:.4g})' - ax.set_title(f'f = {k:.4g} Hz\n{axheader}') - ax.semilogx(v.x, v.y, 'o') - ax.semilogx(xplot, yplot, '-') - fig.savefig(image_path.joinpath(save_name).with_suffix('.png')) - plt.close(fig) + # if save_fig: + # fig, ax = plt.subplots() + # ax.set_xlabel('t / s') + # ax.set_ylabel('M') + # axheader = f'T1: {p0[2]:.4g}(+/-{perr[2]:.4g}) beta: {p0[3]:.4g}(+/-{perr[3]:.4g})' + # ax.set_title(f'f = {k:.4g} Hz\n{axheader}') + # ax.semilogx(v.x, v.y, 'o') + # ax.semilogx(xplot, yplot, '-') + # fig.savefig(image_path.joinpath(save_name).with_suffix('.png')) + # plt.close(fig) freqs = np.asanyarray(freqs) params = np.asanyarray(params) @@ -282,53 +282,53 @@ class FCReader: fig_beta.savefig(path.joinpath(f'beta_{kind}.png'), bbox_inches="tight") fig_mag.savefig(path.joinpath(f'mag_{kind}.png'), bbox_inches="tight") fig_t1.savefig(path.joinpath(f't1_{kind}.png'), bbox_inches="tight") - plt.close(fig_mag) - plt.close(fig_beta) - plt.close(fig_t1) + # plt.close(fig_mag) + # plt.close(fig_beta) + # plt.close(fig_t1) def plot_parameter(self, path, kind): path = pathlib.Path(path) path.mkdir(parents=True, exist_ok=True) - fig_mag, ax_mag = plt.subplots() - fig_t1, ax_t1 = plt.subplots() - fig_beta, ax_beta = plt.subplots() - - if kind == 'temp': - _params = self.t_params - else: - _params = self.f_params - - save_path = path.joinpath(kind) - if not save_path.exists(): - save_path.mkdir(parents=True) - - for key, par in _params.items(): - pl, = ax_mag.plot(par[:, 0], par[:, 1], 'o', label=key) - ax_mag.plot(par[:, 0], par[:, 3], 's', color=pl.get_color()) - ax_t1.plot(par[:, 0], par[:, 5], 'o', label=key) - ax_beta.plot(par[:, 0], par[:, 7], 'o', label=key) - - for a in [ax_mag, ax_t1, ax_beta]: - if kind == 'freq': - a.legend(loc='upper left', bbox_to_anchor=(1, 1), ncol=2) - a.set_xlabel('T / K') - else: - a.set_xscale('log') - a.legend(loc='upper left', bbox_to_anchor=(1, 1)) - a.set_xlabel('f / Hz') - - ax_t1.set_yscale('log') - ax_t1.set_ylabel('T1 / s') - ax_beta.set_ylabel('beta') - ax_mag.set_ylabel('M0 (squares), Offset (circles)') - - fig_beta.savefig(path.joinpath(f'beta_{kind}.png'), bbox_inches="tight") - fig_mag.savefig(path.joinpath(f'mag_{kind}.png'), bbox_inches="tight") - fig_t1.savefig(path.joinpath(f't1_{kind}.png'), bbox_inches="tight") - plt.close(fig_mag) - plt.close(fig_beta) - plt.close(fig_t1) + # fig_mag, ax_mag = plt.subplots() + # fig_t1, ax_t1 = plt.subplots() + # fig_beta, ax_beta = plt.subplots() + # + # if kind == 'temp': + # _params = self.t_params + # else: + # _params = self.f_params + # + # save_path = path.joinpath(kind) + # if not save_path.exists(): + # save_path.mkdir(parents=True) + # + # for key, par in _params.items(): + # pl, = ax_mag.plot(par[:, 0], par[:, 1], 'o', label=key) + # ax_mag.plot(par[:, 0], par[:, 3], 's', color=pl.get_color()) + # ax_t1.plot(par[:, 0], par[:, 5], 'o', label=key) + # ax_beta.plot(par[:, 0], par[:, 7], 'o', label=key) + # + # for a in [ax_mag, ax_t1, ax_beta]: + # if kind == 'freq': + # a.legend(loc='upper left', bbox_to_anchor=(1, 1), ncol=2) + # a.set_xlabel('T / K') + # else: + # a.set_xscale('log') + # a.legend(loc='upper left', bbox_to_anchor=(1, 1)) + # a.set_xlabel('f / Hz') + # + # ax_t1.set_yscale('log') + # ax_t1.set_ylabel('T1 / s') + # ax_beta.set_ylabel('beta') + # ax_mag.set_ylabel('M0 (squares), Offset (circles)') + # + # fig_beta.savefig(path.joinpath(f'beta_{kind}.png'), bbox_inches="tight") + # fig_mag.savefig(path.joinpath(f'mag_{kind}.png'), bbox_inches="tight") + # fig_t1.savefig(path.joinpath(f't1_{kind}.png'), bbox_inches="tight") + # plt.close(fig_mag) + # plt.close(fig_beta) + # plt.close(fig_t1) def get_parameter(self, parameter='all', kind='freq', path=None, write=True, plot=True): param_list = [] @@ -359,10 +359,10 @@ class FCReader: _params = self.f_params fmt = '011.2f' - if plot: - fig_mag, ax_mag = plt.subplots() - fig_t1, ax_t1 = plt.subplots() - fig_beta, ax_beta = plt.subplots() + # if plot: + # fig_mag, ax_mag = plt.subplots() + # fig_t1, ax_t1 = plt.subplots() + # fig_beta, ax_beta = plt.subplots() ret_val = [] for key, par in _params.items(): @@ -374,15 +374,15 @@ class FCReader: if write: self._write_parameter(key, par, path, kind, fmt) - if plot: - self._plot_parameter(key, par, fig_mag, fig_t1, fig_beta) + # if plot: + # self._plot_parameter(key, par, fig_mag, fig_t1, fig_beta) for i, name in param_list: ret_val.append(Points(x=par[:, 0], y=par[:, 2*i+1], y_err=par[:, 2*i+2], name=f'{key} ({name})', value=value)) - if plot: - self._save_parameter_plot(path, kind, fig_mag, fig_t1, fig_beta) + # if plot: + # self._save_parameter_plot(path, kind, fig_mag, fig_t1, fig_beta) return ret_val