forked from IPKM/nmreval
use gnuplot as lightweight plotter
This commit is contained in:
parent
233cdd9f80
commit
6e9dd4d45f
@ -11,6 +11,7 @@ import numpy as np
|
|||||||
from nmreval.data.points import Points
|
from nmreval.data.points import Points
|
||||||
from nmreval.io.asciireader import AsciiReader
|
from nmreval.io.asciireader import AsciiReader
|
||||||
from nmreval.io.hdfreader import HdfReader
|
from nmreval.io.hdfreader import HdfReader
|
||||||
|
from nmreval.lib.logger import logger
|
||||||
from nmreval.utils.utils import get_temperature, roundrobin
|
from nmreval.utils.utils import get_temperature, roundrobin
|
||||||
|
|
||||||
|
|
||||||
@ -56,7 +57,7 @@ class FCReader:
|
|||||||
_temp = self._read_from_dir(filename)
|
_temp = self._read_from_dir(filename)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
raise TypeError
|
raise TypeError(f'{filename} is of unknown type')
|
||||||
|
|
||||||
if not _temp:
|
if not _temp:
|
||||||
raise OSError(-666, f'No magnetization found for {filename.name}.', filename.name)
|
raise OSError(-666, f'No magnetization found for {filename.name}.', filename.name)
|
||||||
@ -224,33 +225,30 @@ class FCReader:
|
|||||||
img_file = image_path.joinpath(save_name).with_suffix(".png")
|
img_file = image_path.joinpath(save_name).with_suffix(".png")
|
||||||
|
|
||||||
gnuplot_args = [
|
gnuplot_args = [
|
||||||
'gnuplot',
|
'set terminal png;',
|
||||||
'-e',
|
f'set output "{img_file}";',
|
||||||
'set terminal png',
|
f'set title "f = {k:.4g} Hz\\n{p0[2]:.4g}(+/-{perr[2]:.4g}) beta: {p0[3]:.4g}(+/-{perr[3]:.4g})";',
|
||||||
f'set output "{img_file}"',
|
'set xlabel "t / s";',
|
||||||
f'set title "f = {k:.4g} Hz\n{p0[2]:.4g}(+/-{perr[2]:.4g}) beta: {p0[3]:.4g}(+/-{perr[3]:.4g})"',
|
'set logscale x;',
|
||||||
'set xlabel "t / s"',
|
'set format x "10^{{%L}}";',
|
||||||
'set logscale x',
|
'set ylabel "M";',
|
||||||
'set format x "10^{{%L}}"',
|
'set key off;',
|
||||||
'set ylabel "M"',
|
f'plot "{data_path.joinpath(save_name)}" with points pointtype 5, "{fit_path.joinpath(save_name)}" with lines;',
|
||||||
'set key off',
|
|
||||||
f'plot "{data_path.joinpath(save_name)}" with points pointtype 5, "{fit_path.joinpath(save_name)}" with lines',
|
|
||||||
]
|
]
|
||||||
|
|
||||||
print(gnuplot_args)
|
try:
|
||||||
|
proc = subprocess.Popen(
|
||||||
subprocess.Popen(gnuplot_args)
|
['gnuplot', '-p'],
|
||||||
|
shell=True,
|
||||||
# if save_fig:
|
stdin=subprocess.PIPE,
|
||||||
# fig, ax = plt.subplots()
|
encoding='utf8',
|
||||||
# ax.set_xlabel('t / s')
|
)
|
||||||
# ax.set_ylabel('M')
|
for args in gnuplot_args:
|
||||||
# axheader = f'T1: {p0[2]:.4g}(+/-{perr[2]:.4g}) beta: {p0[3]:.4g}(+/-{perr[3]:.4g})'
|
proc.stdin.write(args)
|
||||||
# ax.set_title(f'f = {k:.4g} Hz\n{axheader}')
|
proc.stdin.write('quit\n')
|
||||||
# ax.semilogx(v.x, v.y, 'o')
|
proc.stdin.flush()
|
||||||
# ax.semilogx(xplot, yplot, '-')
|
except Exception as e:
|
||||||
# fig.savefig(image_path.joinpath(save_name).with_suffix('.png'))
|
logger.error(f'saving image {save_name} failed', e)
|
||||||
# plt.close(fig)
|
|
||||||
|
|
||||||
freqs = np.asanyarray(freqs)
|
freqs = np.asanyarray(freqs)
|
||||||
params = np.asanyarray(params)
|
params = np.asanyarray(params)
|
||||||
|
Loading…
Reference in New Issue
Block a user