élasticité - scénario final montage

L'installation Elasticité dynamique agit comme un filtre et génère de nouveaux espaces démultipliés, comme un empilement quasi infini d'horizons. Par principe de réflexion, la pièce absorbe l'image de l'environnement et accumule les points de vue ; le mouvement permanent requalifie continuellement ce qui est regardé et entendu.

Ce post produit le montage final des séquences.

In [1]:
%load_ext autoreload
%autoreload 2
In [2]:
import matplotlib
matplotlib.use('nbagg')
%matplotlib inline
import matplotlib.pyplot as plt

Saving as a scenario

In [3]:
!ls -ltrh ../mat/*
ls: ../mat/*: No such file or directory
In [4]:
%%writefile ../scenario_line_master.py
#!/usr/bin/env python
# -*- coding: utf8 -*-

import elasticite as el
import numpy as np
import os

def master(e, filename):
    if e.structure: N_lame = e.N_lame-e.struct_N
    else: N_lame = e.N_lame

    def montage(z, z_in, damp_tau=0.):
        z_out = z.copy()
        z_s = z_in.copy()
        #if damp_tau>0:
        #    max_time = z_in.shape[0]/e.desired_fps
        #    time = np.linspace(0., max_time, z_in.shape[0])
        #    smooth = 1.-np.exp((np.cos(2*np.pi* time / max_time)-1)/(damp_tau / max_time)**2)
        #    z_s[:, 1:] *= smooth[:, np.newaxis]

        #print (z_out[0, 0], z_out[-1, 0], z_s[0, 0], z_s[-1, 0])
        z_s[:, 0] += z_out[-1, 0] + 1./e.desired_fps # increment the time on the new array
        #print (z_out.shape, z_s.shape, z_s[0, 0], z_s[-1, 0])
        return np.vstack((z_out, z_s))

    def revert(z_in):
        z_s = z_in.copy()
        z_s[:, 1:] = z_s[:, 1:][:, ::-1]
        return z_s

    def mirror(z_in):
        z_s = z_in.copy()
        z_s[:, 1:] = -z_s[:, 1:]
        return z_s

    def interleave(z_1, z_2):
        z_s_1 = z_1.copy()
        z_s_2 = z_2.copy()
        z_s_1[:, 1::2] = z_s_2[:, 1::2]
        return z_s_1
            
    matpath = 'mat/'
    z_s = {}
    print('importing scenarii')
    for scenario in [#'line_vague_dense', 'line_vague_solo', 
                     'line_onde_dense', 'line_onde_solo', 'line_fresnelastique',
                    'line_fresnelastique_choc', 'line_fresnelastique_chirp', 
                     'line_geometry', 'line_geometry_45deg', 'line_geometry_90deg', 'line_geometry_structure']:
        z_s[scenario] = np.load(os.path.join(matpath, scenario + '.npy'))
        print(scenario)
        el.check(e, z_s[scenario])
    print('finished importing scenarii')    
    ###########################################################################
    burnout_time = 0.1
    z = np.zeros((1, N_lame+1)) # zero at zero
    z = np.vstack((z, np.hstack((np.array(burnout_time), np.zeros(N_lame) ))))
    ###########################################################################
#    z = montage(z, z_s['line_onde_solo'])
    z = montage(z, z_s['line_onde_dense'])
    ###########################################################################
    z = montage(z, z_s['line_geometry_90deg'])
    z = montage(z, z_s['line_geometry_45deg'])
    z = montage(z, z_s['line_geometry_structure'])
    z = montage(z, z_s['line_geometry'])
    z = montage(z, mirror(z_s['line_geometry_structure']))
    z = montage(z, mirror(z_s['line_geometry_45deg']))
    z = montage(z, mirror(z_s['line_geometry_90deg']))
    ###########################################################################
#    z = montage(z, z_s['line_onde_solo'])
    z = montage(z, revert(z_s['line_onde_dense']))
#    z = montage(z, revert(z_s['line_onde_solo']))
    ###########################################################################
    z = montage(z, z_s['line_geometry_structure'])
    z = montage(z, z_s['line_geometry'])
    z = montage(z, z_s['line_fresnelastique'])
    z = montage(z, mirror(z_s['line_fresnelastique']))
    z = montage(z, z_s['line_fresnelastique_chirp'])
    z = montage(z, z_s['line_fresnelastique_choc'])
    z = montage(z, z_s['line_geometry'])
    z = montage(z, z_s['line_geometry_structure'])
    ###########################################################################
    z = montage(z, z_s['line_fresnelastique'])
    z = montage(z, interleave(z_s['line_fresnelastique'], mirror(z_s['line_fresnelastique'])))
    z = montage(z, interleave(z_s['line_fresnelastique_chirp'], mirror(z_s['line_fresnelastique_choc'])))
    z = montage(z, interleave(z_s['line_fresnelastique_choc'], mirror(z_s['line_fresnelastique_chirp'])))
    z = montage(z, z_s['line_fresnelastique'])
    ###########################################################################
    z = montage(z, revert(z_s['line_onde_dense']))
#    z = montage(z, revert(z_s['line_onde_solo']))
    ###########################################################################
    # check that there is not overflow @ 30 fps
    el.check(e, z)
    ###########################################################################
    # save the file
    np.save(filename, z)

    return z_s

if __name__ == "__main__":
    import sys
    if len(sys.argv)>1: mode = sys.argv[1]
    else: mode = 'both'
        
    filename = 'mat/master.npy'
    e = el.EdgeGrid(N_lame=25, grid_type='line', mode=mode,
                 verb=False, filename=filename)

    if mode == 'writer':
        z_s = master(e, filename)
    else:
        # running the code
        el.main(e)
Overwriting ../scenario_line_master.py
In [5]:
%cd ..
!rm mat/master.npy
%run  scenario_line_master.py writer
%cd posts
/Users/laurentperrinet/cloud_nas/science/elasticte
importing scenarii
line_onde_dense
line_onde_solo
line_fresnelastique
line_fresnelastique_choc
line_fresnelastique_chirp
line_geometry
line_geometry_45deg
line_geometry_90deg
line_geometry_structure
finished importing scenarii
/Users/laurentperrinet/cloud_nas/science/elasticte/posts
In [6]:
z = np.load('../mat/master.npy')
fig, ax = plt.subplots(figsize=(15, 3))
_ = ax.plot(z[:, 0])
ax.axis('tight')
Out[6]:
(0.0, 117745.0, 0.0, 3924.8999999999996)
No description has been provided for this image
In [7]:
fig, ax = plt.subplots(figsize=(15, 3))
_ = ax.plot(z[:, 0], z[:, 1:])
ax.axis('tight')
Out[7]:
(0.0, 3924.8999999999996, -1.5707963156318943, 1.5707963156318943)
No description has been provided for this image

some last minute changes

In [8]:
%%writefile ../scenario_line_master_dimanche.py
#!/usr/bin/env python
# -*- coding: utf8 -*-
import sys
sys.path.append('/home/pi/elasticte/')

import elasticite as el
import numpy as np
import os

def master(e, filename):
    if e.structure: N_lame = e.N_lame-e.struct_N
    else: N_lame = e.N_lame

    def montage(z, z_in, damp_tau=0.):
        z_out = z.copy()
        z_s = z_in.copy()
        #if damp_tau>0:
        #    max_time = z_in.shape[0]/e.desired_fps
        #    time = np.linspace(0., max_time, z_in.shape[0])
        #    smooth = 1.-np.exp((np.cos(2*np.pi* time / max_time)-1)/(damp_tau / max_time)**2)
        #    z_s[:, 1:] *= smooth[:, np.newaxis]

        #print (z_out[0, 0], z_out[-1, 0], z_s[0, 0], z_s[-1, 0])
        z_s[:, 0] += z_out[-1, 0] + 1./e.desired_fps # increment the time on the new array
        #print (z_out.shape, z_s.shape, z_s[0, 0], z_s[-1, 0])
        return np.vstack((z_out, z_s))

    def revert(z_in):
        z_s = z_in.copy()
        z_s[:, 1:] = z_s[:, 1:][:, ::-1]
        return z_s

    def mirror(z_in):
        z_s = z_in.copy()
        z_s[:, 1:] = -z_s[:, 1:]
        return z_s

    def interleave(z_1, z_2):
        z_s_1 = z_1.copy()
        z_s_2 = z_2.copy()
        z_s_1[:, 1::2] = z_s_2[:, 1::2]
        return z_s_1
            
    matpath = 'mat/'
    z_s = {}
    print('importing scenarii')
    for scenario in [#'line_vague_dense', 'line_vague_solo', 
                     'line_onde_dense', 'line_onde_solo', 'line_fresnelastique',
                    'line_fresnelastique_choc', 'line_fresnelastique_chirp', 
                     'line_geometry', 'line_geometry_45deg', 'line_geometry_90deg', 'line_geometry_structure']:
        z_s[scenario] = np.load(os.path.join(matpath, scenario + '.npy'))
        print(scenario)
        el.check(e, z_s[scenario])
    print('finished importing scenarii')    
    ###########################################################################
    burnout_time = 0.1
    z = np.zeros((1, N_lame+1)) # zero at zero
    z = np.vstack((z, np.hstack((np.array(burnout_time), np.zeros(N_lame) ))))
    ###########################################################################
#    z = montage(z, z_s['line_onde_solo'])
    z = montage(z, z_s['line_onde_dense'])
    ###########################################################################
#    z = montage(z, z_s['line_geometry_90deg'])
    z = montage(z, z_s['line_geometry_45deg'])
    z = montage(z, z_s['line_geometry_structure'])
    z = montage(z, z_s['line_geometry'])
    z = montage(z, mirror(z_s['line_geometry_structure']))
    z = montage(z, mirror(z_s['line_geometry_45deg']))
#    z = montage(z, mirror(z_s['line_geometry_90deg']))
    ###########################################################################
#    z = montage(z, z_s['line_onde_solo'])
    z = montage(z, revert(z_s['line_onde_dense']))
#    z = montage(z, revert(z_s['line_onde_solo']))
    ###########################################################################
    z = montage(z, z_s['line_geometry_structure'])
    z = montage(z, z_s['line_geometry'])
    z = montage(z, z_s['line_fresnelastique'])
    z = montage(z, mirror(z_s['line_fresnelastique']))
    z = montage(z, z_s['line_fresnelastique_chirp'])
    z = montage(z, z_s['line_fresnelastique_choc'])
    z = montage(z, z_s['line_geometry'])
    z = montage(z, z_s['line_geometry_structure'])
    ###########################################################################
    z = montage(z, z_s['line_fresnelastique'])
    z = montage(z, interleave(z_s['line_fresnelastique'], mirror(z_s['line_fresnelastique'])))
    z = montage(z, interleave(z_s['line_fresnelastique_chirp'], mirror(z_s['line_fresnelastique_choc'])))
    z = montage(z, interleave(z_s['line_fresnelastique_choc'], mirror(z_s['line_fresnelastique_chirp'])))
    z = montage(z, z_s['line_fresnelastique'])
    ###########################################################################
    z = montage(z, revert(z_s['line_onde_dense']))
#    z = montage(z, revert(z_s['line_onde_solo']))
    ###########################################################################
    # check that there is not overflow @ 30 fps
    el.check(e, z)
    ###########################################################################
    # save the file
    np.save(filename, z)

    return z_s

if __name__ == "__main__":
    import sys
    if len(sys.argv)>1: mode = sys.argv[1]
    else: mode = 'both'
        
    #filename = '/home/pi/elasticte/mat/master_dimanche.npy'
    filename = 'mat/master_dimanche.npy'
    e = el.EdgeGrid(N_lame=25, grid_type='line', mode=mode,
                 verb=False, filename=filename)

    if mode == 'writer':
        z_s = master(e, filename)
    else:
        # running the code
        el.main(e)
Overwriting ../scenario_line_master_dimanche.py
In [9]:
%cd ..
#!rm mat/master_dimanche.npy
%run  scenario_line_master_dimanche.py writer
%cd posts
/Users/laurentperrinet/cloud_nas/science/elasticte
importing scenarii
line_onde_dense
line_onde_solo
line_fresnelastique
line_fresnelastique_choc
line_fresnelastique_chirp
line_geometry
line_geometry_45deg
line_geometry_90deg
line_geometry_structure
finished importing scenarii
/Users/laurentperrinet/cloud_nas/science/elasticte/posts
In [10]:
fig, ax = plt.subplots(figsize=(15, 3))
_ = ax.plot(z[:, 0], z[:, 1:])
ax.axis('tight')
Out[10]:
(0.0, 3924.8999999999996, -1.5707963156318943, 1.5707963156318943)
No description has been provided for this image

utile

In [11]:
import matplotlib
%matplotlib inline
import matplotlib.pyplot as plt
damp_tau = 60.
max_time = z_s['line_geometry'].shape[0]/e.desired_fps
time = np.linspace(0., max_time, z_s['line_geometry'].shape[-1])
print(z_s['line_geometry'].shape[0], max_time)
#smooth = 1.-np.exp(-(np.mod(time+max_time/2, max_time)-max_time/2)**2/damp_tau**2)
smooth = 1.-np.exp((np.cos(2*np.pi* time / max_time)-1)/(damp_tau / max_time)**2)
print (smooth)
fig, ax = plt.subplots(figsize=(15, 3))
_ = ax.plot(time, smooth)
7200 240.0
[ 0.          0.39508627  0.86180549  0.98691779  0.99940489  0.9999842
  0.99999969  0.99999999  1.          1.          1.          1.          1.
  1.          1.          1.          1.          1.          0.99999999
  0.99999969  0.9999842   0.99940489  0.98691779  0.86180549  0.39508627
  0.        ]
No description has been provided for this image
In [12]:
angle_actuel = np.linspace(-1.5*np.pi, 1.5*np.pi, 300)
angle_actuel_ = np.mod(angle_actuel + np.pi/2, np.pi) - np.pi/2
fig, ax = plt.subplots(figsize=(15, 3))
_ = ax.plot(angle_actuel, angle_actuel_)
No description has been provided for this image

git

In [17]:
! git add ../mat/master_dimanche.npy ../scenario_line_master_dimanche.py
!git d *py
!git s
?? ../mat/line_contraint.npy
?? ../mat/master.npy
?? __temp_ipython__.png
?? anim.gif
In [14]:
!git commit -am' scenario master HACK3R du dimanche '
[master e7ac7da]  scenario master HACK3R du dimanche
 4 files changed, 195 insertions(+), 36 deletions(-)
 create mode 100644 mat/master_dimanche.npy
In [15]:
! git push
Counting objects: 8, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (8/8), done.
Writing objects: 100% (8/8), 16.80 MiB | 12.55 MiB/s, done.
Total 8 (delta 5), reused 0 (delta 0)
To git@git.framasoft.org:laurentperrinet/elasticte.git
   fc1a301..e7ac7da  master -> master
In [16]:
%pwd
Out[16]:
'/Users/laurentperrinet/cloud_nas/science/elasticte/posts'