add more motions

This commit is contained in:
Dominik Demuth
2024-12-15 18:34:05 +01:00
parent adbf2af72b
commit bfb1cb314c
26 changed files with 243 additions and 71 deletions

View File

@ -1,7 +1,6 @@
from __future__ import annotations
import pathlib
import re
import subprocess
from itertools import product

View File

@ -1,8 +1,7 @@
import numpy
import numpy as np
from matplotlib import pyplot
import matplotlib.pyplot as plt
from python.helpers import read_parameter_file
# parameter for spectrum simulations
lb = 2e3
@ -41,30 +40,39 @@ def pulse_attn(freq: np.ndarray, t_pulse: float) -> np.ndarray:
return np.pi * numerator / denominator / 2
def post_process_spectrum(taus, apod, tpulse):
reduction_factor = np.zeros((taus.size, 5)) # hard-coded t_echo :(
def post_process_spectrum(parameter_file, apod, tpulse):
parameter = read_parameter_file(parameter_file)
for i, tau in enumerate(taus):
try:
raw_data = np.loadtxt(f'fid_tau={tau:.6e}.dat')
except OSError:
continue
# files have form ste_arg=0.000000e+01_parameter.txt, first remove ste part then parameter.txt to get variables
varied_string = str(parameter_file).partition('_')[-1].rpartition('_')[0]
t = raw_data[:, 0]
timesignal = raw_data[:, 1:]
# make evolution times
tevo = np.linspace(parameter['techo_start'], parameter['techo_stop'], num=int(parameter['techo_steps']))
timesignal *= dampening(t, apod)[:, None]
timesignal[0, :] /= 2
if varied_string:
raw_data = np.loadtxt(parameter_file.with_name(f'timesignal_{varied_string}.dat'))
else:
raw_data = np.loadtxt(parameter_file.with_name(f'timesignal.dat'))
# FT to spectrum
freq = np.fft.fftshift(np.fft.fftfreq(t.size, d=1e-6))
spec = np.fft.fftshift(np.fft.fft(timesignal, axis=0), axes=0).real
spec *= pulse_attn(freq, t_pulse=tpulse)[:, None]
t = raw_data[:, 0]
timesignal = raw_data[:, 1:]
reduction_factor[i, :] = 2*timesignal[0, :]
timesignal *= dampening(t, apod)[:, None]
timesignal[0, :] /= 2
plt.plot(freq, spec)
plt.show()
# FT to spectrum
freq = np.fft.fftshift(np.fft.fftfreq(t.size, d=parameter['dwell_time']))
spec = np.fft.fftshift(np.fft.fft(timesignal, axis=0), axes=0).real
spec *= pulse_attn(freq, t_pulse=tpulse)[:, None]
plt.semilogx(taus, reduction_factor, '.')
#
#
# reduction_factor[i, :] = 2*timesignal[0, :]
plt.plot(freq, spec)
plt.gca().set_title(varied_string)
plt.show()
#
# plt.semilogx(taus, reduction_factor, '.')
# plt.show()

View File

@ -1,6 +1,5 @@
import pathlib
import numpy
import numpy as np
from matplotlib import pyplot as plt
from scipy.optimize import curve_fit
@ -74,7 +73,10 @@ def fit_ste(
# make evolution times
tevo = np.linspace(parameter['tevo_start'], parameter['tevo_stop'], num=int(parameter['tevo_steps']))
raw_data = np.loadtxt(parameter_file.with_name(f'{prefix}_{varied_string}.dat'))
if varied_string:
raw_data = np.loadtxt(parameter_file.with_name(f'{prefix}_{varied_string}.dat'))
else:
raw_data = np.loadtxt(parameter_file.with_name(f'{prefix}.dat'))
t_mix = raw_data[:, 0]
decay = raw_data[:, 1:]