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

Little simplifications.

parent dadad563
......@@ -100,11 +100,6 @@ class CellFile(object):
# how the cell zones are defined
self.identity_definition = "anatomy"
# attributes set during a growth process
self.has_grown = False
self.start_time, self.stop_time = None, None
self.activation_delay = None
def concentration_scale(self):
"""Return a 'characterstic concentration' uswful for plotting.
......@@ -149,12 +144,12 @@ class CellFile(object):
Returns
-------
zone_1 : 1-D ndarray of ints
zone_1 : list of ints
Lists of the indices of the cells above the division threshold.
zone_2 : 1-D ndarray of ints
zone_2 : list of ints
Lists of the indices of the cells between the division threshold
and the enlargement threshold.
zone_3 : 1-D ndarray of ints
zone_3 : list of ints
Lists of the indices of the cells below the division threshold.
"""
div_id_conc = cell_conc[self.div_id_index]
......@@ -220,7 +215,7 @@ class CellFile(object):
raise UserWarning("Identities are incomplete!")
return identities
def get_cell_zones_anatomy(self, time=-1):
def get_cell_zones_anatomy(self, time):
"""Return cell zones as defined by the anatomical criterion.
Returns
......@@ -243,7 +238,7 @@ class CellFile(object):
zone_2.append(cell.indices[i])
elif identity == "non growing":
zone_3.append(cell.indices[i])
return np.sort(zone_1), np.sort(zone_2), np.sort(zone_3)
return zone_1, zone_2, zone_3
def get_cell_concentrations(self, u, concentration_operator):
"""Return signal concentrations of the cells."""
......@@ -629,7 +624,7 @@ class CellFile(object):
return self.M_primer, RdX_flux_diff
def evolution_matrices(self, nodes_per_cell):
"""Compute the diffusion matrix of a signal."""
"""Compute and return the evolution matrix of a signal profile."""
if "uniform diffusion" in self.transport_mechanisms:
self.set_counters_and_masks(nodes_per_cell)
M_init, RdX_flux_diff = self.init_diffusion_matrix(nodes_per_cell)
......@@ -738,8 +733,9 @@ class CellFile(object):
Start time of the simulation.
stop_time : datetime instance
Stop time of the simulation.
activation_time : datetime instance, optional, default: None
Activation time of the simulation.
activation_time : datetime instance, optional, default: 0
Time at which the cambium is activated (i.e. starts to respond to
signals).
input_time_step : float, optional, default: 3600
Time step between input value updates, in seconds.
growth_time_step : float, optional, default: 3600
......@@ -762,18 +758,15 @@ class CellFile(object):
quantity of signals the file (the default is False).
"""
self.start_time, self.stop_time = start_time, stop_time
if activation_time is None:
self.activation_delay = timedelta(0)
activation_delay = start_time
else:
self.activation_delay = activation_time - self.start_time
activation_delay_seconds = self.activation_delay.total_seconds()
total_time = (self.stop_time - self.start_time).total_seconds()
activation_delay = (activation_time - start_time).total_seconds()
total_time = (stop_time - start_time).total_seconds()
self.start_time, self.stop_time = start_time, stop_time
self.date_list = self.date_list[:1]
delta = timedelta(seconds=snapshot_time_step)
self.growth_time_step = growth_time_step
self.snapshot_time_step = snapshot_time_step
self.conversion = self.data_time_unit / self.snapshot_time_step
self.conversion = self.data_time_unit / snapshot_time_step
self.initial_nodes_per_cell = nodes_per_cell
self.nodes_per_cell = nodes_per_cell*np.ones(self.nb_cells, dtype=int)
self.nb_nodes = self.nodes_per_cell.sum()
......@@ -915,7 +908,7 @@ class CellFile(object):
# cell identity lists bases on anatomy
self.inactive_cells, self.growing_cells, self.non_growing_cells, \
self.small_cells = [], [], [], []
if activation_delay_seconds > 0:
if activation_delay > 0:
inactive = True
self.inactive_cells = range(self.nb_cells)
else:
......@@ -940,7 +933,7 @@ class CellFile(object):
self.init_history()
self.make_history(u, PIN, check_conservation)
current_time = 0
sample_time = 0
self.sample_time = 0
for tw in range(nb_time_windows):
......@@ -1025,7 +1018,7 @@ class CellFile(object):
current_time += time_window
# update cell identities
if inactive and current_time >= activation_delay_seconds:
if inactive and current_time >= activation_delay:
inactive = False
self.inactive_cells = []
self.cell_conc = self.get_cell_concentrations(
......@@ -1044,17 +1037,16 @@ class CellFile(object):
self.get_gradient_zones(self.cell_conc)
# snapshot
self.make_history(u, PIN, check_conservation)
self.date += delta
self.date += timedelta(seconds=snapshot_time_step)
self.date_list.append(self.date)
identities = self.get_cells_identities()
for i, cell in enumerate(self.cells):
cell.indices.append(i)
cell.dates.append(sample_time)
cell.dates.append(self.sample_time)
cell.diameters.append(self.D_real[i])
cell.strain_rates.append(self.S[i])
cell.identities.append(identities[i])
sample_time += 1
self.has_grown = True
self.sample_time += 1
def Gamma(self, X, R, D):
"""Map from Omega_0 to Omega_t."""
......
......@@ -301,10 +301,10 @@ def fill_cell_file_drawing(
# an arrow on one well-selected membrane
elif show_transport_polarity == "one":
zone_1, zone_2, zone_3 = cf.get_cell_zones_anatomy(time)
if zone_2.size:
if zone_2:
cell_index = zone_2[len(zone_2)//2]
else:
cell_index = nb_cells / 2
cell_index = nb_cells // 2
x_pos = rectangle_positions[cell_index]
arrows.append(Arrow(x_pos - polarity * arrow_stem/2, y_pos,
polarity * arrow_stem, 0,
......
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