Commit bdefba2f authored by Félix Hartmann's avatar Félix Hartmann
Browse files

Updated scripts for making videos.

parent 8800e9bf
......@@ -6,21 +6,23 @@ from __future__ import (unicode_literals, absolute_import, division,
import sys
import bisect
import numpy as np
def number_of_digits(a):
if a == 0:
a = 1
return int(np.log10(a)) + 1
from traits.etsconfig.api import ETSConfig
ETSConfig.toolkit = 'qt4'
ETSConfig.toolkit = 'qt'
import matplotlib as mpl
mpl.rcParams['backend.qt4'] = 'PySide'
# We want matplotlib to use a QT backend
mpl.use('Qt4Agg')
from controlpanel import ControlPanel, time_units
from plotutils import draw_cell_file
settings_file, target_dir = sys.argv[1:3]
base_name = target_dir + "/snapshot"
base_name = target_dir + "/"
try:
interval = int(sys.argv[3])
......@@ -38,27 +40,37 @@ cp.growth()
total_time = (cp.stop_time - cp.start_time) * time_units["day"]
total_hours = int(total_time / time_units["hour"])
total_snapshot_time = int(total_time / cp.snapshot_time_step)
nb_digits_max = number_of_digits(total_snapshot_time)
cf = cp.cell_file
xlim = (0, 1.01 * cf.length())
reframing_times = [total_hours//3, (2 * total_hours)//3]
total_length = cf.length()
length_list = [total_length/3, 2*total_length/3]
xlim_list = [(0, 1.01 * length) for length in length_list]
xlim_list += [(0, 1.01 * total_length)]
print(length_list)
print(xlim_list)
xlim_list = [(0, 1.01 * cf.length(t)) for t in reframing_times]
xlim_list += [(0, 1.01 * cf.length(-1))]
ylim = (0, 15)
print(total_hours, interval)
for hour in range(0, total_hours, interval):
framing_index = bisect.bisect(reframing_times, hour)
time = int(hour * time_units["hour"] / cp.snapshot_time_step)
length = cf.length(time)
framing_index = bisect.bisect(length_list, length)
xlim = xlim_list[framing_index]
nb_digits = number_of_digits(time)
padding_0 = nb_digits_max - nb_digits
draw_cell_file(cf,
hour,
time,
colored_zones=colors,
show_transport_polarity=None,
xlim=xlim,
ylim=ylim,
figsize=(8, 4),
fontsize=14,
save=True,
base_name=base_name)
base_name=base_name+padding_0*"0")
# cf.draw(time=hour,
# signal=False,
......@@ -66,4 +78,3 @@ for hour in range(0, total_hours, interval):
# xlim=xlim,
# date=False,
# save=True,
# base_name=base_name)
File mode changed from 100644 to 100755
......@@ -502,7 +502,7 @@ def draw_cell_file(
)
figure.tight_layout()
if save:
figure.savefig("{0}_t_{1:04d}.png".format(base_name, time))
figure.savefig("{0}{1}.png".format(base_name, time))
plt.close(figure)
else:
return figure, axis
......
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