add gnuplot to requirements for plots of FC reading
This commit is contained in:
parent
15c959fd71
commit
233cdd9f80
@ -41,6 +41,7 @@ AppDir:
|
|||||||
# - zsync
|
# - zsync
|
||||||
# - hicolor-icon-theme
|
# - hicolor-icon-theme
|
||||||
- libatlas3-base
|
- libatlas3-base
|
||||||
|
- gnuplot-nox
|
||||||
- python3.9-minimal
|
- python3.9-minimal
|
||||||
- python3-numpy
|
- python3-numpy
|
||||||
- python3-scipy
|
- python3-scipy
|
||||||
@ -70,7 +71,7 @@ AppDir:
|
|||||||
- usr/share/doc/*/README.*
|
- usr/share/doc/*/README.*
|
||||||
- usr/share/doc/*/changelog.*
|
- usr/share/doc/*/changelog.*
|
||||||
- usr/share/doc/*/NEWS.*
|
- usr/share/doc/*/NEWS.*
|
||||||
- usr/share/doc/*/TODO.}*
|
- usr/share/doc/*/TODO.*
|
||||||
runtime:
|
runtime:
|
||||||
# if needed, apparently replaces hardcoded location with APPDIR location
|
# if needed, apparently replaces hardcoded location with APPDIR location
|
||||||
# path_mappings:
|
# path_mappings:
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import pathlib
|
import pathlib
|
||||||
|
import subprocess
|
||||||
|
import tempfile
|
||||||
|
|
||||||
# import matplotlib.pyplot as plt
|
# import matplotlib.pyplot as plt
|
||||||
from scipy.optimize import curve_fit
|
from scipy.optimize import curve_fit
|
||||||
@ -178,6 +180,7 @@ class FCReader:
|
|||||||
fit_path.mkdir(parents=True, exist_ok=True)
|
fit_path.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
if save_fig:
|
if save_fig:
|
||||||
|
data_path = fname_no_ext.joinpath('data')
|
||||||
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)
|
||||||
|
|
||||||
@ -209,7 +212,7 @@ class FCReader:
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
self.f_params[k] = [new_entry]
|
self.f_params[k] = [new_entry]
|
||||||
|
|
||||||
if save_fits or save_fig:
|
if True: # save_fits or save_fig:
|
||||||
xplot = np.geomspace(v.x[0], v.x[-1], num=10*len(v.x))
|
xplot = np.geomspace(v.x[0], v.x[-1], num=10*len(v.x))
|
||||||
yplot = FCReader.kww(xplot, *p0)
|
yplot = FCReader.kww(xplot, *p0)
|
||||||
save_name = f'{filename.stem}_{k:011.2f}'.replace('.', 'p') + '.dat'
|
save_name = f'{filename.stem}_{k:011.2f}'.replace('.', 'p') + '.dat'
|
||||||
@ -218,6 +221,26 @@ 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)]))
|
||||||
|
|
||||||
|
img_file = image_path.joinpath(save_name).with_suffix(".png")
|
||||||
|
|
||||||
|
gnuplot_args = [
|
||||||
|
'gnuplot',
|
||||||
|
'-e',
|
||||||
|
'set terminal png',
|
||||||
|
f'set output "{img_file}"',
|
||||||
|
f'set title "f = {k:.4g} Hz\n{p0[2]:.4g}(+/-{perr[2]:.4g}) beta: {p0[3]:.4g}(+/-{perr[3]:.4g})"',
|
||||||
|
'set xlabel "t / s"',
|
||||||
|
'set logscale x',
|
||||||
|
'set format x "10^{{%L}}"',
|
||||||
|
'set ylabel "M"',
|
||||||
|
'set key off',
|
||||||
|
f'plot "{data_path.joinpath(save_name)}" with points pointtype 5, "{fit_path.joinpath(save_name)}" with lines',
|
||||||
|
]
|
||||||
|
|
||||||
|
print(gnuplot_args)
|
||||||
|
|
||||||
|
subprocess.Popen(gnuplot_args)
|
||||||
|
|
||||||
# if save_fig:
|
# if save_fig:
|
||||||
# fig, ax = plt.subplots()
|
# fig, ax = plt.subplots()
|
||||||
# ax.set_xlabel('t / s')
|
# ax.set_xlabel('t / s')
|
||||||
|
Loading…
Reference in New Issue
Block a user