forked from IPKM/nmreval
Merge branch 'master' of ssh://chaos3.fkp.physik.tu-darmstadt.de/source/nmreval
This commit is contained in:
commit
b7ded8d900
@ -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
|
||||
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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}")
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user