Merge branch 'master' of ssh://chaos3.fkp.physik.tu-darmstadt.de/source/nmreval

This commit is contained in:
Markus Rosenstihl 2022-11-25 22:19:51 +01:00
commit b7ded8d900
3 changed files with 81 additions and 68 deletions

View File

@ -20,7 +20,7 @@ AppDir:
id: pkm.vogel.nmreval id: pkm.vogel.nmreval
name: NMReval name: NMReval
icon: logo icon: logo
version: 0.2.0 version: _devel_
# Set the python executable as entry point # Set the python executable as entry point
exec: usr/bin/python3 exec: usr/bin/python3
# Set the application main script path as argument. Use '$@' to forward CLI parameters # Set the application main script path as argument. Use '$@' to forward CLI parameters
@ -41,8 +41,8 @@ AppDir:
- python3.9-minimal - python3.9-minimal
- python3-pyqt5 - python3-pyqt5
- python3-numpy - python3-numpy
- python3-matplotlib # - python3-matplotlib
- python-matplotlib-data # - python-matplotlib-data
- python3-scipy - python3-scipy
- python3-bsddb3 - python3-bsddb3
- python3-h5py - python3-h5py

View File

@ -2,7 +2,7 @@ from __future__ import annotations
import pathlib import pathlib
import matplotlib.pyplot as plt # import matplotlib.pyplot as plt
from scipy.optimize import curve_fit from scipy.optimize import curve_fit
import numpy as np import numpy as np
@ -148,9 +148,9 @@ class FCReader:
fit_path = fname_no_ext.joinpath('fit') fit_path = fname_no_ext.joinpath('fit')
fit_path.mkdir(parents=True, exist_ok=True) fit_path.mkdir(parents=True, exist_ok=True)
if save_fig: # if save_fig:
image_path = fname_no_ext.joinpath('png') # image_path = fname_no_ext.joinpath('png')
image_path.mkdir(parents=True, exist_ok=True) # image_path.mkdir(parents=True, exist_ok=True)
header = 'm0\tt1\tbeta\toff\n' header = 'm0\tt1\tbeta\toff\n'
@ -189,16 +189,16 @@ class FCReader:
np.savetxt(fit_path.joinpath(save_name), np.c_[xplot, yplot], 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)])) header=header+'\t'.join([f'{p}+/-{err}' for p, err in zip(p0, perr)]))
if save_fig: # if save_fig:
fig, ax = plt.subplots() # fig, ax = plt.subplots()
ax.set_xlabel('t / s') # ax.set_xlabel('t / s')
ax.set_ylabel('M') # ax.set_ylabel('M')
axheader = f'T1: {p0[2]:.4g}(+/-{perr[2]:.4g}) beta: {p0[3]:.4g}(+/-{perr[3]:.4g})' # 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.set_title(f'f = {k:.4g} Hz\n{axheader}')
ax.semilogx(v.x, v.y, 'o') # ax.semilogx(v.x, v.y, 'o')
ax.semilogx(xplot, yplot, '-') # ax.semilogx(xplot, yplot, '-')
fig.savefig(image_path.joinpath(save_name).with_suffix('.png')) # fig.savefig(image_path.joinpath(save_name).with_suffix('.png'))
plt.close(fig) # plt.close(fig)
freqs = np.asanyarray(freqs) freqs = np.asanyarray(freqs)
params = np.asanyarray(params) params = np.asanyarray(params)
@ -282,53 +282,53 @@ class FCReader:
fig_beta.savefig(path.joinpath(f'beta_{kind}.png'), bbox_inches="tight") 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_mag.savefig(path.joinpath(f'mag_{kind}.png'), bbox_inches="tight")
fig_t1.savefig(path.joinpath(f't1_{kind}.png'), bbox_inches="tight") fig_t1.savefig(path.joinpath(f't1_{kind}.png'), bbox_inches="tight")
plt.close(fig_mag) # plt.close(fig_mag)
plt.close(fig_beta) # plt.close(fig_beta)
plt.close(fig_t1) # plt.close(fig_t1)
def plot_parameter(self, path, kind): def plot_parameter(self, path, kind):
path = pathlib.Path(path) path = pathlib.Path(path)
path.mkdir(parents=True, exist_ok=True) path.mkdir(parents=True, exist_ok=True)
fig_mag, ax_mag = plt.subplots() # fig_mag, ax_mag = plt.subplots()
fig_t1, ax_t1 = plt.subplots() # fig_t1, ax_t1 = plt.subplots()
fig_beta, ax_beta = plt.subplots() # fig_beta, ax_beta = plt.subplots()
#
if kind == 'temp': # if kind == 'temp':
_params = self.t_params # _params = self.t_params
else: # else:
_params = self.f_params # _params = self.f_params
#
save_path = path.joinpath(kind) # save_path = path.joinpath(kind)
if not save_path.exists(): # if not save_path.exists():
save_path.mkdir(parents=True) # save_path.mkdir(parents=True)
#
for key, par in _params.items(): # for key, par in _params.items():
pl, = ax_mag.plot(par[:, 0], par[:, 1], 'o', label=key) # pl, = ax_mag.plot(par[:, 0], par[:, 1], 'o', label=key)
ax_mag.plot(par[:, 0], par[:, 3], 's', color=pl.get_color()) # ax_mag.plot(par[:, 0], par[:, 3], 's', color=pl.get_color())
ax_t1.plot(par[:, 0], par[:, 5], 'o', label=key) # ax_t1.plot(par[:, 0], par[:, 5], 'o', label=key)
ax_beta.plot(par[:, 0], par[:, 7], 'o', label=key) # ax_beta.plot(par[:, 0], par[:, 7], 'o', label=key)
#
for a in [ax_mag, ax_t1, ax_beta]: # for a in [ax_mag, ax_t1, ax_beta]:
if kind == 'freq': # if kind == 'freq':
a.legend(loc='upper left', bbox_to_anchor=(1, 1), ncol=2) # a.legend(loc='upper left', bbox_to_anchor=(1, 1), ncol=2)
a.set_xlabel('T / K') # a.set_xlabel('T / K')
else: # else:
a.set_xscale('log') # a.set_xscale('log')
a.legend(loc='upper left', bbox_to_anchor=(1, 1)) # a.legend(loc='upper left', bbox_to_anchor=(1, 1))
a.set_xlabel('f / Hz') # a.set_xlabel('f / Hz')
#
ax_t1.set_yscale('log') # ax_t1.set_yscale('log')
ax_t1.set_ylabel('T1 / s') # ax_t1.set_ylabel('T1 / s')
ax_beta.set_ylabel('beta') # ax_beta.set_ylabel('beta')
ax_mag.set_ylabel('M0 (squares), Offset (circles)') # ax_mag.set_ylabel('M0 (squares), Offset (circles)')
#
fig_beta.savefig(path.joinpath(f'beta_{kind}.png'), bbox_inches="tight") # 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_mag.savefig(path.joinpath(f'mag_{kind}.png'), bbox_inches="tight")
fig_t1.savefig(path.joinpath(f't1_{kind}.png'), bbox_inches="tight") # fig_t1.savefig(path.joinpath(f't1_{kind}.png'), bbox_inches="tight")
plt.close(fig_mag) # plt.close(fig_mag)
plt.close(fig_beta) # plt.close(fig_beta)
plt.close(fig_t1) # plt.close(fig_t1)
def get_parameter(self, parameter='all', kind='freq', path=None, write=True, plot=True): def get_parameter(self, parameter='all', kind='freq', path=None, write=True, plot=True):
param_list = [] param_list = []
@ -359,10 +359,10 @@ class FCReader:
_params = self.f_params _params = self.f_params
fmt = '011.2f' fmt = '011.2f'
if plot: # if plot:
fig_mag, ax_mag = plt.subplots() # fig_mag, ax_mag = plt.subplots()
fig_t1, ax_t1 = plt.subplots() # fig_t1, ax_t1 = plt.subplots()
fig_beta, ax_beta = plt.subplots() # fig_beta, ax_beta = plt.subplots()
ret_val = [] ret_val = []
for key, par in _params.items(): for key, par in _params.items():
@ -374,15 +374,15 @@ class FCReader:
if write: if write:
self._write_parameter(key, par, path, kind, fmt) self._write_parameter(key, par, path, kind, fmt)
if plot: # if plot:
self._plot_parameter(key, par, fig_mag, fig_t1, fig_beta) # self._plot_parameter(key, par, fig_mag, fig_t1, fig_beta)
for i, name in param_list: for i, name in param_list:
ret_val.append(Points(x=par[:, 0], y=par[:, 2*i+1], y_err=par[:, 2*i+2], ret_val.append(Points(x=par[:, 0], y=par[:, 2*i+1], y_err=par[:, 2*i+2],
name=f'{key} ({name})', value=value)) name=f'{key} ({name})', value=value))
if plot: # if plot:
self._save_parameter_plot(path, kind, fig_mag, fig_t1, fig_beta) # self._save_parameter_plot(path, kind, fig_mag, fig_t1, fig_beta)
return ret_val return ret_val

View File

@ -2,10 +2,11 @@
import os import os
import yaml import yaml
if __name__ == "__main__": if __name__ == "__main__this_is_broken":
if "GO_PIPELINE_LABEL" in os.environ: if "GO_PIPELINE_LABEL" in os.environ:
version = os.environ["GO_PIPELINE_LABEL"] version = os.environ["GO_PIPELINE_LABEL"]
appimage_yaml = yaml.safe_load(open("AppImageBuilder.yml")) appimage_yaml = yaml.safe_load(open("AppImageBuilder.yml"))
appimage_old_version = appimage_yaml["AppDir"]["app_info"]["version"]
appimage_yaml["AppDir"]["app_info"]["version"] = version appimage_yaml["AppDir"]["app_info"]["version"] = version
with open(f"AppImageBuilder{version}.yml","wb") as yaml_file: with open(f"AppImageBuilder{version}.yml","wb") as yaml_file:
yaml.safe_dump(appimage_yaml, yaml_file, encoding = 'utf-8') yaml.safe_dump(appimage_yaml, yaml_file, encoding = 'utf-8')
@ -13,3 +14,15 @@ if __name__ == "__main__":
else: else:
print("No GO_PIPELINE_LABEL found, doing nothing") 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}")