mirror of
https://gitlab.science.ru.nl/mthesis-edeboone/m-thesis-introduction.git
synced 2024-11-13 01:53:31 +01:00
Simu 5: rewrite imports
This commit is contained in:
parent
147e786707
commit
3120495e02
1 changed files with 9 additions and 9 deletions
|
@ -22,7 +22,7 @@
|
|||
"rng = np.random.default_rng(12345)\n",
|
||||
"\n",
|
||||
"import matplotlib.pyplot as plt\n",
|
||||
"from scipy import signal as sgl\n",
|
||||
"from scipy import signal\n",
|
||||
"import copy\n",
|
||||
"\n",
|
||||
"from lib.signals import DigitisedSignal\n",
|
||||
|
@ -33,7 +33,7 @@
|
|||
"ns = 1e9\n",
|
||||
"\n",
|
||||
"# monkey patch correlation_lags into signal if it does not exist\n",
|
||||
"if not hasattr(sgl, 'correlation_lags'):\n",
|
||||
"if not hasattr(signal, 'correlation_lags'):\n",
|
||||
" def correlation_lags(in1_len, in2_len, mode='full'):\n",
|
||||
" r\"\"\"\n",
|
||||
" Calculates the lag / displacement indices array for 1D cross-correlation.\n",
|
||||
|
@ -118,7 +118,7 @@
|
|||
" lags = np.arange(lag_bound, 1)\n",
|
||||
" return lags\n",
|
||||
"\n",
|
||||
" sgl.correlation_lags = correlation_lags"
|
||||
" signal.correlation_lags = correlation_lags"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -161,9 +161,9 @@
|
|||
" signal_pulse1_center = 125e-9 # 100 ns\n",
|
||||
" \n",
|
||||
" if not True:\n",
|
||||
" signal_1 = DigitisedSignal(sgl.gausspulse(signal_time - signal_pulse1_center, fc=fc),\n",
|
||||
" signal_1 = DigitisedSignal(signal.gausspulse(signal_time - signal_pulse1_center, fc=fc),\n",
|
||||
" signal_sample_rate)\n",
|
||||
" signal_2 = DigitisedSignal(sgl.gausspulse(signal_time - signal_pulse1_center, fc=fc), \n",
|
||||
" signal_2 = DigitisedSignal(signal.gausspulse(signal_time - signal_pulse1_center, fc=fc), \n",
|
||||
" signal_sample_rate)\n",
|
||||
" signal_2.t_0 = shift\n",
|
||||
" else:\n",
|
||||
|
@ -220,7 +220,7 @@
|
|||
"## Using scipy\n",
|
||||
"\n",
|
||||
"if True:\n",
|
||||
" scipy_corr = sgl.correlate(sig_1, sig_2, mode='same')\n",
|
||||
" scipy_corr = signal.correlate(sig_1, sig_2, mode='same')\n",
|
||||
" scipy_id = scipy_corr.argmax()\n",
|
||||
" calc_shift = ((len(scipy_corr)-1)/2 -scipy_id)/signal_1.sample_rate\n",
|
||||
"\n",
|
||||
|
@ -330,7 +330,7 @@
|
|||
" elif in1_len is None:\n",
|
||||
" in1_len = in2_len\n",
|
||||
"\n",
|
||||
" lags = sgl.correlation_lags(in1_len, in2_len, mode=mode)\n",
|
||||
" lags = signal.correlation_lags(in1_len, in2_len, mode=mode)\n",
|
||||
"\n",
|
||||
" max_lag = max(lags)\n",
|
||||
" min_lag = min(lags)\n",
|
||||
|
@ -388,8 +388,8 @@
|
|||
"t_grid = grid/signal_1.sample_rate\n",
|
||||
"\n",
|
||||
"scipy_mode = my_mode\n",
|
||||
"scipy_corr = sgl.correlate(sig_2, sig_1, mode=scipy_mode)\n",
|
||||
"scipy_lags = sgl.correlation_lags(len(sig_2), len(sig_1), mode=scipy_mode)\n",
|
||||
"scipy_corr = signal.correlate(sig_2, sig_1, mode=scipy_mode)\n",
|
||||
"scipy_lags = signal.correlation_lags(len(sig_2), len(sig_1), mode=scipy_mode)\n",
|
||||
"corrs = grid_correlate(grid, sig_2, sig_1)\n",
|
||||
" \n",
|
||||
"\n",
|
||||
|
|
Loading…
Reference in a new issue