Commit 842db2aa authored by Christian Rohlfing's avatar Christian Rohlfing
Browse files

- aligned dockerfile, environment and postbuild to IÜ

parent 4e16003f
Pipeline #282687 passed with stages
in 11 minutes and 24 seconds
[submodule "rwth_nb"]
path = rwth_nb
url = ../../jupyter/rwth-nb.git
ARG BASE_IMAGE=registry.git.rwth-aachen.de/acs/cloud/jupyter/singleuser/python:latest
ARG BASE_IMAGE=registry.git.rwth-aachen.de/jupyter/profiles/rwth-courses
FROM ${BASE_IMAGE}
# update conda base environment to match specifications in environment.yml
ADD binder/environment.yml /tmp/environment.yml
USER root
RUN sed -i "s|name\: gdet3lab|name\: base|g" /tmp/environment.yml # we need to replace the name of the environment with base such that we can update the base environment here
USER $NB_USER
RUN cat /tmp/environment.yml
RUN conda env update -f /tmp/environment.yml
RUN conda install --quiet --yes \
'scipy==1.4.1' && \
conda clean --all
# cleanup conda packages
RUN conda clean --all -f -y
# install some extensions defined in binder postBuild
ADD binder/postBuild /tmp/postBuild.sh
USER root
RUN chmod +x /tmp/postBuild.sh
USER $NB_USER
RUN /tmp/postBuild.sh
# Copy workspace
COPY ./ /home/jovyan
......@@ -330,7 +330,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.1"
"version": "3.8.2"
}
},
"nbformat": 4,
......
......@@ -2,9 +2,9 @@ name: gdet3lab
channels:
- conda-forge
dependencies:
- numpy=1.17.3
- scipy=1.4.1
- matplotlib=3.1.2
- jupyterlab=1.2.4
- nodejs=13.6.0
- ipympl=0.4.1
- numpy==1.18.1
- scipy==1.4.1
- matplotlib-base==3.1.2
- jupyterlab==2.0.1
- nodejs==13.13.0
- ipympl==0.5.6
\ No newline at end of file
jupyter labextension install @jupyter-widgets/jupyterlab-manager@1.1 jupyter-matplotlib@0.5.0
cd rwth_nb
pip install .
jupyter labextension install @jupyter-widgets/jupyterlab-manager@2.0.0 jupyter-matplotlib@0.7.2 jupyterlab-rwth@0.0.1
pip install git+https://git.rwth-aachen.de/jupyter/rwth-nb.git
Subproject commit 8fddf557559f84f7c722c49d04d9d63668bf632b
from ient_nb.ient_plots import *
from ient_nb.ient_transforms import *
from ient_nb.ient_transforms import ient_sample
from ient_nb.ient_signals import *
import matplotlib.pyplot as plt
class SamplingPlot:
fig = None
axes = {'t': None, 'f': None, 't_rec': None}
lines = {'s_t': None, 'sa_t': None, 's_t_id': None, 's_t_rec': None, 'S_f': None, 'H_TP': None, 'Sgesamt_f': None}
containers = {'t': None, 'f': None}
noS_fs = 33
S_fs = [None] * noS_fs
t = np.linspace(-5, 5, 50001)
f = np.linspace(-50, 50, len(t))
s_t = rect(t)
S_f = lambda self, x: 0.5 * rect(x / 2)
signal = 'cos-Funktion'
T = 1
signals = {'cos-Funktion': np.cos(2 * np.pi * t),
'si-Funktion': si(2 * np.pi * t),
'Rechteckimpuls': rect(t / 1.05),
'Dreieckimpuls': tri(t)}
signals_h = {'cos-Funktion': lambda x: np.isin(x, x[find_ind_least_diff(x, [-1, 1])]) * 0.5,
'si-Funktion': lambda x: 0.5 * rect(x / 2),
'Rechteckimpuls': lambda x: si(np.pi * x),
'Dreieckimpuls': lambda x: si(np.pi * x) ** 2}
def __init__(self):
self.open_figure()
def open_figure(self):
fig, (self.axes['t'], self.axes['f'], self.axes['t_rec']) = plt.subplots(3, 1, figsize=(9, 7))
# subplot 1: time domain
# define axis properties
ient_axis(self.axes['t']); ient_grid(self.axes['t'])
self.axes['t'].set_xlim(-5, 5); self.axes['t'].set_ylim(-1.5, 1.5)
self.axes['t'].set_xlabel(r'$\rightarrow t$')
self.axes['t'].xaxis.set_ticklabels([])
# annotate axis
for val1, val2 in zip([1, -1], [r'$T$', r'$-T$']):
ient_annotate_xtick(self.axes['t'], val2, val1 * 0.1, -.15, 'black')
# initial plots
self.lines['s_t'], = self.axes['t'].plot(self.t, self.s_t, '-.', linewidth=1)
self.lines['sa_t'], = self.axes['t'].plot(self.t, self.s_t, 'rot', linewidth=2)
self.lines['s_t'].set_label(r'$s(t)$'); self.lines['sa_t'].set_label(r'$s_\mathrm{a}(t)$')
self.axes['t'].legend(loc=2);
# subplot 2: frq domain
# define axis properties
ient_axis(self.axes['f']); ient_grid(self.axes['f'])
self.axes['f'].set_xlim(-5, 5); self.axes['f'].set_ylim(-1.5, 3)
self.axes['f'].set_xlabel(r'$\rightarrow f$')
self.axes['f'].xaxis.set_ticklabels([])
# annotate axis
for val1, val2, val3 in zip([1, -1, 1/self.T, -1/self.T], [r'$f_g$', r'$-f_g$', r'$\frac{1}{T}$', r'$-\frac{1}{T}$'],
[10, 10, 15, 15]):
ient_annotate_xtick(self.axes['f'], val2, val1, -.1, 'black', fs=val3)
#self.axes['f'].text(1.3, 1.1, r'$H_\mathrm{TP}(f)$', color='black', verticalalignment='top', horizontalalignment='center',
# bbox=dict(facecolor='white', edgecolor='none', alpha=0.75))
# initial plots
self.lines['S_f'], = self.axes['f'].plot(self.f, self.S_f(self.f), '--', linewidth=1, color='black-50')
self.lines['Sgesamt_f'], = self.axes['f'].plot(self.f, self.S_f(self.f), 'rot', label=r'$S_\mathrm{a}(f)$')
for ind, i in enumerate(range(0, int((self.noS_fs+1)/2))):
self.S_fs[ind], = self.axes['f'].plot(self.f, self.S_f(self.f + i / self.T), '--', linewidth=1, color='black-50')
if ind == 0:
continue
self.S_fs[int((self.noS_fs+1)/2)-1 + ind], = self.axes['f'].plot(self.f, self.S_f(self.f - i / self.T), '--', linewidth=1, color='black-50')
self.lines['H_TP'], = self.axes['f'].plot(self.f, rect(self.f / 2), '-', color='black', label=r'$H_\mathrm{TP}(f)$')
self.axes['f'].legend(loc=2);
# subplot 3: time domain (reconstructed signal)
# define axis properties
ient_axis(self.axes['t_rec']); ient_grid(self.axes['t_rec'])
self.axes['t_rec'].set_xlim(-5, 5); self.axes['t_rec'].set_ylim(-1.5, 1.5) # TODO - Change y-lims at runtime
self.axes['t_rec'].set_xlabel(r'$\rightarrow t$')
self.axes['t_rec'].xaxis.set_ticklabels([])
# initial plots
self.lines['s_t_id'], = self.axes['t_rec'].plot(self.t, self.s_t, '-.', linewidth=1, label=r'$s(t)$')
self.lines['s_t_rec'], = self.axes['t_rec'].plot((len(self.t)/(10*(self.f[-1]+abs(self.f[0]))))*self.t, self.s_t, 'grun', linewidth=1, label=r'$g(t)$')
self.axes['t_rec'].legend(loc=2)
# initial dirac plots for t and f domain axis
td = np.array([-1, 1]);
sd = np.array([-1, 1]);
self.containers['t'] = ient_plot_dirac(self.axes['t'], td, sd, 'rot')
self.containers['f'] = ient_plot_dirac(self.axes['f'], td, sd, 'rot')
def update(self, signal='Si-Funktion', T=1):
self.s_t = self.signals[signal]
self.lines['s_t'].set_ydata(self.s_t)
self.lines['s_t_id'].set_ydata(self.s_t)
x, y = ient_sample(self.t, self.s_t, self.T)
ient_dirac_set_data(self.containers['t'], x, y)
self.lines['sa_t'].set_ydata(self.t.shape)
self.S_f = self.signals_h[signal]
Sgesamt = np.zeros(self.f.shape)
if not signal == 'cos-Funktion':
ient_dirac_set_data(self.containers['f'], [], [])
self.lines['S_f'].set_ydata(self.S_f(self.f) / self.T)
for ind, i in enumerate(range(0, int((self.noS_fs+1)/2))):
Sa_f = self.signals_h[signal](self.f - i / self.T)
self.S_fs[ind].set_ydata(Sa_f / self.T)
Sgesamt += Sa_f / self.T
if ind == 0:
continue
Sa_f = self.signals_h[signal](self.f + i / self.T)
Sgesamt += Sa_f / self.T
self.S_fs[int((self.noS_fs+1)/2)-1 + ind].set_ydata(Sa_f / self.T)
# plot resulting Sgesamt_f
self.lines['Sgesamt_f'].set_ydata(Sgesamt)
# idft resulting Sgesamt_f and plot
S_w_rec_filter = Sgesamt * rect(self.f / 2)
s2 = ient_idft(S_w_rec_filter)
self.lines['s_t_rec'].set_ydata(np.fft.ifftshift(np.real(s2)) / (len(self.f)/(self.f[-1]+abs(self.f[0]))) * self.T)
else:
# plot diracs for cos in f-domain
self.lines['Sgesamt_f'].set_ydata([0])
self.lines['S_f'].set_ydata(np.zeros(self.f.shape))
for tmp in self.S_fs:
tmp.set_ydata(np.zeros(self.f.shape))
for ind, i in enumerate(range(0, int((self.noS_fs+1)/2))):
Sa_f = self.signals_h[signal](self.f - i / self.T)
Sgesamt += Sa_f / self.T
if ind == 0:
continue
Sa_f = self.signals_h[signal](self.f + i / self.T)
Sgesamt += Sa_f / self.T
# prepare resulting Sgesamt_f for plotting diracs
fd = self.f[np.where(Sgesamt)]
Sd = Sgesamt[np.where(Sgesamt)]
ient_dirac_set_data(self.containers['f'], fd, Sd)
# idft resulting Sgesamt_f and plot
S_w_rec_filter = Sgesamt * rect(self.f / 2.05) # id. TP
s2 = ient_idft(S_w_rec_filter)
self.lines['s_t_rec'].set_ydata(np.fft.ifftshift(np.real(s2)) * self.T)
# set axis limits
maxSd = np.amax(Sd[1:-2])
if maxSd > 3:
self.axes['f'].set_ylim(-1.5, maxSd+maxSd/10)
elif T > 0.5:
self.axes['f'].set_ylim(-1.5, 3)
def update_signal(self, signal):
self.signal = signal
self.update(self.signal, self.T)
def update_T(self, T):
self.T = T
# change annotations' positions
self.axes['t'].texts[0].set_position([self.T, -.15])
self.axes['t'].lines[0].set_xdata([self.T, self.T])
self.axes['t'].texts[1].set_position([-self.T, -.15])
self.axes['t'].lines[1].set_xdata([-self.T, -self.T])
self.axes['f'].texts[2].set_position([-1 / self.T, -.15])
self.axes['f'].texts[3].set_position([1 / self.T, -.15])
# update plots
self.update(self.signal, self.T)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment