Source code for spatialpy.core.boundarycondition
-'''
-SpatialPy is a Python 3 package for simulation of
-spatial deterministic/stochastic reaction-diffusion-advection problems
-Copyright (C) 2019 - 2022 SpatialPy developers.
+# SpatialPy is a Python 3 package for simulation of
+# spatial deterministic/stochastic reaction-diffusion-advection problems
+# Copyright (C) 2019 - 2022 SpatialPy developers.
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU GENERAL PUBLIC LICENSE Version 3 as
-published by the Free Software Foundation.
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU GENERAL PUBLIC LICENSE Version 3 as
+# published by the Free Software Foundation.
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU GENERAL PUBLIC LICENSE Version 3 for more details.
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU GENERAL PUBLIC LICENSE Version 3 for more details.
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-'''
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
from spatialpy.core.spatialpyerror import BoundaryConditionError
@@ -274,10 +272,10 @@ Source code for spatialpy.core.boundarycondition
diff --git a/docs/build/html/_modules/spatialpy/core/cleanup.html b/docs/build/html/_modules/spatialpy/core/cleanup.html
index 81d264d1..433d3d38 100644
--- a/docs/build/html/_modules/spatialpy/core/cleanup.html
+++ b/docs/build/html/_modules/spatialpy/core/cleanup.html
@@ -5,7 +5,7 @@
- spatialpy.core.cleanup — SpatialPy 1.0 documentation
+ spatialpy.core.cleanup — SpatialPy 1.0.2 documentation
@@ -91,23 +91,21 @@ Quick search
Source code for spatialpy.core.cleanup
-'''
-SpatialPy is a Python 3 package for simulation of
-spatial deterministic/stochastic reaction-diffusion-advection problems
-Copyright (C) 2019 - 2022 SpatialPy developers.
+# SpatialPy is a Python 3 package for simulation of
+# spatial deterministic/stochastic reaction-diffusion-advection problems
+# Copyright (C) 2019 - 2022 SpatialPy developers.
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU GENERAL PUBLIC LICENSE Version 3 as
-published by the Free Software Foundation.
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU GENERAL PUBLIC LICENSE Version 3 as
+# published by the Free Software Foundation.
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU GENERAL PUBLIC LICENSE Version 3 for more details.
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU GENERAL PUBLIC LICENSE Version 3 for more details.
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-'''
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
import os
import shutil
@@ -196,10 +194,10 @@ Source code for spatialpy.core.cleanup
diff --git a/docs/build/html/_modules/spatialpy/core/datafunction.html b/docs/build/html/_modules/spatialpy/core/datafunction.html
index 3e2840cb..6d95180b 100644
--- a/docs/build/html/_modules/spatialpy/core/datafunction.html
+++ b/docs/build/html/_modules/spatialpy/core/datafunction.html
@@ -5,7 +5,7 @@
- spatialpy.core.datafunction — SpatialPy 1.0 documentation
+ spatialpy.core.datafunction — SpatialPy 1.0.2 documentation
@@ -91,23 +91,21 @@ Quick search
Source code for spatialpy.core.datafunction
-'''
-SpatialPy is a Python 3 package for simulation of
-spatial deterministic/stochastic reaction-diffusion-advection problems
-Copyright (C) 2019 - 2022 SpatialPy developers.
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU GENERAL PUBLIC LICENSE Version 3 as
-published by the Free Software Foundation.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU GENERAL PUBLIC LICENSE Version 3 for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-'''
+# SpatialPy is a Python 3 package for simulation of
+# spatial deterministic/stochastic reaction-diffusion-advection problems
+# Copyright (C) 2019 - 2022 SpatialPy developers.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU GENERAL PUBLIC LICENSE Version 3 as
+# published by the Free Software Foundation.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU GENERAL PUBLIC LICENSE Version 3 for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
from spatialpy.core.spatialpyerror import DataFunctionError
[docs]class DataFunction():
@@ -156,10 +154,10 @@ Source code for spatialpy.core.datafunction
diff --git a/docs/build/html/_modules/spatialpy/core/domain.html b/docs/build/html/_modules/spatialpy/core/domain.html
index 7b608992..0079840b 100644
--- a/docs/build/html/_modules/spatialpy/core/domain.html
+++ b/docs/build/html/_modules/spatialpy/core/domain.html
@@ -5,7 +5,7 @@
- spatialpy.core.domain — SpatialPy 1.0 documentation
+ spatialpy.core.domain — SpatialPy 1.0.2 documentation
@@ -91,23 +91,21 @@ Quick search
Source code for spatialpy.core.domain
-'''
-SpatialPy is a Python 3 package for simulation of
-spatial deterministic/stochastic reaction-diffusion-advection problems
-Copyright (C) 2019 - 2022 SpatialPy developers.
+# SpatialPy is a Python 3 package for simulation of
+# spatial deterministic/stochastic reaction-diffusion-advection problems
+# Copyright (C) 2019 - 2022 SpatialPy developers.
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU GENERAL PUBLIC LICENSE Version 3 as
-published by the Free Software Foundation.
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU GENERAL PUBLIC LICENSE Version 3 as
+# published by the Free Software Foundation.
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU GENERAL PUBLIC LICENSE Version 3 for more details.
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU GENERAL PUBLIC LICENSE Version 3 for more details.
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-'''
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
import json
import string
@@ -120,6 +118,7 @@ Source code for spatialpy.core.domain
from plotly.offline import init_notebook_mode, iplot
from scipy.spatial import KDTree
+from spatialpy.core.visualization import Visualization
from spatialpy.core.spatialpyerror import DomainError
[docs]class Domain():
@@ -297,8 +296,8 @@ Source code for spatialpy.core.domain
"""
Add a type definition to the domain. By default, all regions are set to type 0.
- :param geometry_ivar: an instance of a :py:class:`spatialpy.core.geometry.Geometry` subclass. The 'inside()' method
- of this object will be used to assign properties to points.
+ :param geometry_ivar: an instance of a :py:class:`spatialpy.core.geometry.Geometry` subclass. \
+ The 'inside()' method of this object will be used to assign properties to points.
:type geometry_ivar: spatialpy.core.geometry.Geometry
:param type_id: The identifier for this type.
@@ -363,8 +362,8 @@ Source code for spatialpy.core.domain
"""
Fill a geometric shape with particles.
- :param geometry_ivar: an instance of a :py:class:`spatialpy.core.geometry.Geometry` subclass. The 'inside()' method
- of this object will be used to create add the particles.
+ :param geometry_ivar: an instance of a :py:class:`spatialpy.core.geometry.Geometry` subclass. \
+ The 'inside()' method of this object will be used to create add the particles.
:type geometry_ivar: spatialpy.core.geometry.Geometry
:param deltax: Distance between particles on the x-axis.
@@ -628,7 +627,7 @@ Source code for spatialpy.core.domain
self.vol[v3] += t_vol / 4
self.vol[v4] += t_vol / 4
-[docs] def plot_types(self, width=None, height=None, colormap=None, size=5, title=None,
+[docs] def plot_types(self, width=None, height=None, colormap=None, size=None, title=None,
included_types_list=None, use_matplotlib=False, return_plotly_figure=False):
'''
Plots the domain using plotly. Can only be viewed in a Jupyter Notebook.
@@ -667,13 +666,10 @@ Source code for spatialpy.core.domain
'''
from spatialpy.core.result import _plotly_iterate # pylint: disable=import-outside-toplevel
- if use_matplotlib:
- width = 6.4 if width in (None, "auto") else width
- height = 4.8 if height in (None, "auto") else height
- else:
+ if not use_matplotlib:
if width in (None, "auto"):
width = None if width == "auto" else 500
- if height is None:
+ if height in (None, "auto"):
height = None if height == "auto" else 500
if not numpy.count_nonzero(self.vertices[:, 1]):
@@ -686,32 +682,67 @@ Source code for spatialpy.core.domain
self._get_type_name_mapping()
types = {}
+ # Normalize volumes to [0, 1]
+ vols = (self.vol - numpy.min(self.vol))/numpy.ptp(self.vol)
for i, type_id in enumerate(self.type_id):
name = type_id[5:]
if included_types_list is None or name in included_types_list:
if name in types:
types[name]['points'].append(self.vertices[i])
types[name]['data'].append(self.typeNdxMapping[type_id])
+ types[name]['size_scale'] = numpy.append(types[name]['size_scale'], vols[i])
else:
- types[name] = {"points":[self.vertices[i]], "data":[self.typeNdxMapping[type_id]]}
+ types[name] = {
+ "points": [self.vertices[i]],
+ "data": [self.typeNdxMapping[type_id]],
+ "size_scale": numpy.array([vols[i]])
+ }
if use_matplotlib:
- import matplotlib.pyplot as plt # pylint: disable=import-outside-toplevel
-
- fig, ax = plt.subplots(figsize=(width, height))
- for name, data in types.items():
- x_coords = list(map(lambda point: point[0], data["points"]))
- y_coords = list(map(lambda point: point[1], data["points"]))
-
- ax.scatter(x_coords, y_coords, label=name)
- ax.grid(linestyle='--', linewidth=1)
- ax.legend(loc='upper right', fontsize=12)
- if title is not None:
- ax.set_title(title)
-
- plt.axis('scaled')
+ if not isinstance(use_matplotlib, dict):
+ use_matplotlib = {}
+ use_matplotlib['limits'] = (
+ (self.xlim[0] - 0.25, self.xlim[1] + 0.25), (self.ylim[0] - 0.25, self.ylim[1] + 0.25)
+ )
+
+ # Support for width, height, and title args
+ if width not in (None, "auto") and height not in (None, "auto"):
+ # TODO: Deprecation warning for width and height
+ plot_args = {"figsize": (width, height)}
+
+ if "plot_args" in use_matplotlib:
+ for name, val in use_matplotlib['plot_args'].items():
+ plot_args[name] = val
+ use_matplotlib['plot_args'] = plot_args
+
+ base_group_args = {}
+ if colormap is not None:
+ base_group_args['cmap'] = colormap
+ base_group_args['vmin'] = 1 # minimum number of defined types
+ base_group_args['vmax'] = len(self.typeNdxMapping) # number of defined types
+ if size is not None:
+ base_group_args['s'] = size
+
+ if "scatter_args" not in use_matplotlib:
+ use_matplotlib['scatter_args'] = {}
+ for type_id in self.typeNdxMapping.keys():
+ type_id = type_id[5:]
+ group_args = base_group_args.copy()
+ if type_id in use_matplotlib['scatter_args']:
+ for name, val in use_matplotlib['scatter_args'][type_id].items():
+ group_args[name] = val
+ use_matplotlib['scatter_args'][type_id] = group_args
+
+ if title is not None:
+ use_matplotlib['title'] = title
+
+ vis_obj = Visualization(data=types)
+ vis_obj.plot_scatter(**use_matplotlib)
return
+ if size is None:
+ size = 5
+
is_2d = self.dimensions == 2
trace_list = _plotly_iterate(types, size=size, property_name="type",
@@ -953,7 +984,7 @@ Source code for spatialpy.core.domain
:type fixed: bool
:param \**kwargs: Additional keyword arguments passed to :py:class:`Domain`.
-
+
:returns: Uniform 3D SpatialPy Domain object.
:rtype: spatialpy.core.domain.Domain
"""
@@ -1047,10 +1078,10 @@ Source code for spatialpy.core.domain
diff --git a/docs/build/html/_modules/spatialpy/core/geometry.html b/docs/build/html/_modules/spatialpy/core/geometry.html
index 8ca065ff..d016004a 100644
--- a/docs/build/html/_modules/spatialpy/core/geometry.html
+++ b/docs/build/html/_modules/spatialpy/core/geometry.html
@@ -5,7 +5,7 @@
- spatialpy.core.geometry — SpatialPy 1.0 documentation
+ spatialpy.core.geometry — SpatialPy 1.0.2 documentation
@@ -91,23 +91,21 @@ Quick search
Source code for spatialpy.core.geometry
-'''
-SpatialPy is a Python 3 package for simulation of
-spatial deterministic/stochastic reaction-diffusion-advection problems
-Copyright (C) 2019 - 2022 SpatialPy developers.
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU GENERAL PUBLIC LICENSE Version 3 as
-published by the Free Software Foundation.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU GENERAL PUBLIC LICENSE Version 3 for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-'''
+# SpatialPy is a Python 3 package for simulation of
+# spatial deterministic/stochastic reaction-diffusion-advection problems
+# Copyright (C) 2019 - 2022 SpatialPy developers.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU GENERAL PUBLIC LICENSE Version 3 as
+# published by the Free Software Foundation.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU GENERAL PUBLIC LICENSE Version 3 for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
from spatialpy.core.spatialpyerror import GeometryError
[docs]class Geometry:
@@ -198,10 +196,10 @@ Source code for spatialpy.core.geometry
diff --git a/docs/build/html/_modules/spatialpy/core/initialcondition.html b/docs/build/html/_modules/spatialpy/core/initialcondition.html
index 9dc0c791..2c778f33 100644
--- a/docs/build/html/_modules/spatialpy/core/initialcondition.html
+++ b/docs/build/html/_modules/spatialpy/core/initialcondition.html
@@ -5,7 +5,7 @@
- spatialpy.core.initialcondition — SpatialPy 1.0 documentation
+ spatialpy.core.initialcondition — SpatialPy 1.0.2 documentation
@@ -91,23 +91,21 @@ Quick search
Source code for spatialpy.core.initialcondition
-'''
-SpatialPy is a Python 3 package for simulation of
-spatial deterministic/stochastic reaction-diffusion-advection problems
-Copyright (C) 2019 - 2022 SpatialPy developers.
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU GENERAL PUBLIC LICENSE Version 3 as
-published by the Free Software Foundation.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU GENERAL PUBLIC LICENSE Version 3 for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-'''
+# SpatialPy is a Python 3 package for simulation of
+# spatial deterministic/stochastic reaction-diffusion-advection problems
+# Copyright (C) 2019 - 2022 SpatialPy developers.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU GENERAL PUBLIC LICENSE Version 3 as
+# published by the Free Software Foundation.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU GENERAL PUBLIC LICENSE Version 3 for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
import numpy
from spatialpy.core.spatialpyerror import InitialConditionError
@@ -156,6 +154,10 @@ Source code for spatialpy.core.initialcondition
<
:param model: Model contianing the target species.
:type model: spatialpy.core.model.Model
"""
+ if isinstance(self.species, str):
+ if self.species not in model.listOfSpecies:
+ raise InitialConditionError(f"Species {self.species} does not exist in the model.")
+ self.species = model.listOfSpecies[self.species]
spec_name = self.species.name
spec_ndx = None
for index, spec_name in enumerate(model.listOfSpecies.keys()):
@@ -199,6 +201,10 @@ Source code for spatialpy.core.initialcondition
<
:param model: Model contianing the target species.
:type model: spatialpy.core.model.Model
"""
+ if isinstance(self.species, str):
+ if self.species not in model.listOfSpecies:
+ raise InitialConditionError(f"Species {self.species} does not exist in the model.")
+ self.species = model.listOfSpecies[self.species]
spec_name = self.species.name
spec_ndx = None
for index, spec_name in enumerate(model.listOfSpecies.keys()):
@@ -251,6 +257,10 @@ Source code for spatialpy.core.initialcondition
<
:param model: Model contianing the target species.
:type model: spatialpy.core.model.Model
"""
+ if isinstance(self.species, str):
+ if self.species not in model.listOfSpecies:
+ raise InitialConditionError(f"Species {self.species} does not exist in the model.")
+ self.species = model.listOfSpecies[self.species]
spec_name = self.species.name
spec_ndx = None
for index, spec_name in enumerate(model.listOfSpecies.keys()):
@@ -294,10 +304,10 @@ Source code for spatialpy.core.initialcondition
<
diff --git a/docs/build/html/_modules/spatialpy/core/model.html b/docs/build/html/_modules/spatialpy/core/model.html
index 6e155948..09d9db5a 100644
--- a/docs/build/html/_modules/spatialpy/core/model.html
+++ b/docs/build/html/_modules/spatialpy/core/model.html
@@ -5,7 +5,7 @@
- spatialpy.core.model — SpatialPy 1.0 documentation
+ spatialpy.core.model — SpatialPy 1.0.2 documentation
@@ -91,23 +91,21 @@ Quick search
Source code for spatialpy.core.model
-'''
-SpatialPy is a Python 3 package for simulation of
-spatial deterministic/stochastic reaction-diffusion-advection problems
-Copyright (C) 2019 - 2022 SpatialPy developers.
+# SpatialPy is a Python 3 package for simulation of
+# spatial deterministic/stochastic reaction-diffusion-advection problems
+# Copyright (C) 2019 - 2022 SpatialPy developers.
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU GENERAL PUBLIC LICENSE Version 3 as
-published by the Free Software Foundation.
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU GENERAL PUBLIC LICENSE Version 3 as
+# published by the Free Software Foundation.
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU GENERAL PUBLIC LICENSE Version 3 for more details.
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU GENERAL PUBLIC LICENSE Version 3 for more details.
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-'''
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
#This module defines a model that simulates a discrete, stoachastic, mixed biochemical reaction network in python.
@@ -411,6 +409,15 @@ Source code for spatialpy.core.model
self.__update_diffusion_restrictions()
self.__apply_initial_conditions()
self.__resolve_parameters()
+
+ sanitized_params = self.sanitized_parameter_names()
+ for species in self.listOfSpecies.values():
+ diff_coeff = species.diffusion_coefficient
+ if isinstance(diff_coeff, str):
+ if diff_coeff not in sanitized_params:
+ raise ModelError(f"Parameterm {diff_coeff} doesn't exist.")
+ species.diffusion_coefficient = sanitized_params[diff_coeff]
+
self.__get_expression_utility()
stoich_matrix = self.__create_stoichiometric_matrix()
dep_graph = self.__create_dependency_graph()
@@ -853,10 +860,10 @@ Source code for spatialpy.core.model
diff --git a/docs/build/html/_modules/spatialpy/core/parameter.html b/docs/build/html/_modules/spatialpy/core/parameter.html
index a1bd41b0..1cbb243e 100644
--- a/docs/build/html/_modules/spatialpy/core/parameter.html
+++ b/docs/build/html/_modules/spatialpy/core/parameter.html
@@ -5,7 +5,7 @@
- spatialpy.core.parameter — SpatialPy 1.0 documentation
+ spatialpy.core.parameter — SpatialPy 1.0.2 documentation
@@ -91,23 +91,21 @@ Quick search
Source code for spatialpy.core.parameter
-'''
-SpatialPy is a Python 3 package for simulation of
-spatial deterministic/stochastic reaction-diffusion-advection problems
-Copyright (C) 2019 - 2022 SpatialPy developers.
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU GENERAL PUBLIC LICENSE Version 3 as
-published by the Free Software Foundation.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU GENERAL PUBLIC LICENSE Version 3 for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-'''
+# SpatialPy is a Python 3 package for simulation of
+# spatial deterministic/stochastic reaction-diffusion-advection problems
+# Copyright (C) 2019 - 2022 SpatialPy developers.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU GENERAL PUBLIC LICENSE Version 3 as
+# published by the Free Software Foundation.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU GENERAL PUBLIC LICENSE Version 3 for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
from spatialpy.core.spatialpyerror import ParameterError
[docs]class Parameter():
@@ -178,10 +176,10 @@ Source code for spatialpy.core.parameter
diff --git a/docs/build/html/_modules/spatialpy/core/reaction.html b/docs/build/html/_modules/spatialpy/core/reaction.html
index 3c4d5a34..3c7d83bf 100644
--- a/docs/build/html/_modules/spatialpy/core/reaction.html
+++ b/docs/build/html/_modules/spatialpy/core/reaction.html
@@ -5,7 +5,7 @@
- spatialpy.core.reaction — SpatialPy 1.0 documentation
+ spatialpy.core.reaction — SpatialPy 1.0.2 documentation
@@ -91,23 +91,21 @@ Quick search
Source code for spatialpy.core.reaction
-'''
-SpatialPy is a Python 3 package for simulation of
-spatial deterministic/stochastic reaction-diffusion-advection problems
-Copyright (C) 2019 - 2022 SpatialPy developers.
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU GENERAL PUBLIC LICENSE Version 3 as
-published by the Free Software Foundation.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU GENERAL PUBLIC LICENSE Version 3 for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-'''
+# SpatialPy is a Python 3 package for simulation of
+# spatial deterministic/stochastic reaction-diffusion-advection problems
+# Copyright (C) 2019 - 2022 SpatialPy developers.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU GENERAL PUBLIC LICENSE Version 3 as
+# published by the Free Software Foundation.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU GENERAL PUBLIC LICENSE Version 3 for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
import uuid
from spatialpy.core.species import Species
@@ -383,10 +381,10 @@ Source code for spatialpy.core.reaction
diff --git a/docs/build/html/_modules/spatialpy/core/result.html b/docs/build/html/_modules/spatialpy/core/result.html
index aa473c0b..e1d3ddeb 100644
--- a/docs/build/html/_modules/spatialpy/core/result.html
+++ b/docs/build/html/_modules/spatialpy/core/result.html
@@ -5,7 +5,7 @@
- spatialpy.core.result — SpatialPy 1.0 documentation
+ spatialpy.core.result — SpatialPy 1.0.2 documentation
@@ -91,23 +91,21 @@ Quick search
Source code for spatialpy.core.result
-'''
-SpatialPy is a Python 3 package for simulation of
-spatial deterministic/stochastic reaction-diffusion-advection problems
-Copyright (C) 2019 - 2022 SpatialPy developers.
+# SpatialPy is a Python 3 package for simulation of
+# spatial deterministic/stochastic reaction-diffusion-advection problems
+# Copyright (C) 2019 - 2022 SpatialPy developers.
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU GENERAL PUBLIC LICENSE Version 3 as
-published by the Free Software Foundation.
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU GENERAL PUBLIC LICENSE Version 3 as
+# published by the Free Software Foundation.
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU GENERAL PUBLIC LICENSE Version 3 for more details.
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU GENERAL PUBLIC LICENSE Version 3 for more details.
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-'''
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
import csv
import filecmp
@@ -122,6 +120,7 @@ Source code for spatialpy.core.result
from plotly.offline import init_notebook_mode, iplot
# from spatialpy.core.model import *
+from spatialpy.core.visualization import Visualization
from spatialpy.core.vtkreader import VTKReader
from spatialpy.core.spatialpyerror import ResultError
@@ -314,6 +313,9 @@ Source code for spatialpy.core.result
def __map_property_to_type(self, property_name, data, included_types_list, points, p_ndx):
types = {}
if property_name == 'type':
+ # Normalize volumes to [0, 1]
+ vol = data['mass'] / data['rho']
+ vols = (vol - numpy.min(vol))/numpy.ptp(vol)
for i, val in enumerate(data['type']):
name = self.model.domain.typeNameMapping[val][5:]
@@ -321,9 +323,15 @@ Source code for spatialpy.core.result
if name in types:
types[name]['points'].append(points[i])
types[name]['data'].append(data[property_name][i])
+ types[name]['size_scale'] = numpy.append(types[name]['size_scale'], vols[i])
else:
- types[name] = {"points":[points[i]], "data":[data[property_name][i]]}
- elif property_name == 'v':
+ types[name] = {
+ "points": [points[i]],
+ "data": [data[property_name][i]],
+ "size_scale": numpy.array([vols[i]])
+ }
+ return types
+ if property_name == 'v':
types[property_name] = {
"points": points,
"data" : [data[property_name][i][p_ndx] for i in range(0,len(data[property_name]))]
@@ -419,7 +427,8 @@ Source code for spatialpy.core.result
If set to True, the concentration (=copy_number/volume) is returned. Defaults to False
:type concentration: bool
- :param deterministic: Whether or not the species is deterministic (True) or stochastic (False). Defaults to False
+ :param deterministic: Whether or not the species is deterministic (True) or stochastic (False). \
+ Defaults to False
:type deterministic: bool
:param debug: Whether or not debug information should be printed. Defaults to False
@@ -707,7 +716,6 @@ Source code for spatialpy.core.result
t_index_arr = [t_index_arr]
num_timepoints = 1
-
if property_name == "v":
ret = numpy.zeros((num_timepoints, num_voxel, 3))
else:
@@ -723,7 +731,7 @@ Source code for spatialpy.core.result
return ret
[docs] def plot_property(self, property_name, t_ndx=None, t_val=None, p_ndx=0, width=None, height=None,
- colormap=None, size=5, title=None, animated=False, t_ndx_list=None, speed=1,
+ colormap=None, size=None, title=None, animated=False, t_ndx_list=None, speed=1,
f_duration=500, t_duration=300, included_types_list=None, return_plotly_figure=False,
use_matplotlib=False, debug=False):
"""
@@ -836,17 +844,47 @@ Source code for spatialpy.core.result
if use_matplotlib:
import matplotlib.pyplot as plt # pylint: disable=import-outside-toplevel
+ if not isinstance(use_matplotlib, dict):
+ use_matplotlib = {}
+ use_matplotlib['limits'] = (
+ (self.model.domain.xlim[0] - 0.25, self.model.domain.xlim[1] + 0.25),
+ (self.model.domain.ylim[0] - 0.25, self.model.domain.ylim[1] + 0.25)
+ )
+
+ # Support for width, height, and title args
+ if width not in (None, "auto") and height not in (None, "auto"):
+ # TODO: Deprecation warning for width and height
+ plot_args = {"figsize": (width, height)}
+
+ if "plot_args" in use_matplotlib:
+ for name, val in use_matplotlib['plot_args'].items():
+ plot_args[name] = val
+ use_matplotlib['plot_args'] = plot_args
+
+ base_group_args = {}
+ if colormap is not None:
+ base_group_args['cmap'] = colormap
+ base_group_args['vmin'] = 1 # minimum number of defined types
+ base_group_args['vmax'] = len(self.model.domain.typeNdxMapping) # number of defined types
+ if size is not None:
+ base_group_args['s'] = size
+
+ if "scatter_args" not in use_matplotlib:
+ use_matplotlib['scatter_args'] = {}
+ for type_id in self.model.domain.typeNdxMapping.keys():
+ type_id = type_id[5:]
+ group_args = base_group_args.copy()
+ if type_id in use_matplotlib['scatter_args']:
+ for name, val in use_matplotlib['scatter_args'][type_id].items():
+ group_args[name] = val
+ use_matplotlib['scatter_args'][type_id] = group_args
+
+ if title is not None:
+ use_matplotlib['title'] = title
+
if property_name == "type":
- fig, ax = plt.subplots(figsize=(width, height))
- for name, data in types.items():
- x_coords = list(map(lambda point: point[0], data["points"]))
- y_coords = list(map(lambda point: point[1], data["points"]))
-
- ax.scatter(x_coords, y_coords, label=name)
- ax.grid(linestyle='--', linewidth=1)
- ax.legend(loc='upper right', fontsize=12)
- if title is not None:
- ax.set_title(title)
+ vis_obj = Visualization(data=types)
+ vis_obj.plot_scatter(**use_matplotlib)
else:
if property_name == 'v':
p_data = data[property_name]
@@ -862,9 +900,12 @@ Source code for spatialpy.core.result
if title is not None:
plt.title(title)
plt.grid(linestyle='--', linewidth=1)
- plt.axis('scaled')
+ plt.axis('scaled')
return
+ if size is None:
+ size = 5
+
is_2d = self.model.domain.dimensions == 2
trace_list = _plotly_iterate(types, size=size, property_name=property_name,
colormap=colormap, is_2d=is_2d)
@@ -993,10 +1034,10 @@ Source code for spatialpy.core.result
diff --git a/docs/build/html/_modules/spatialpy/core/spatialpyerror.html b/docs/build/html/_modules/spatialpy/core/spatialpyerror.html
index 2cf15b1b..c965256e 100644
--- a/docs/build/html/_modules/spatialpy/core/spatialpyerror.html
+++ b/docs/build/html/_modules/spatialpy/core/spatialpyerror.html
@@ -5,7 +5,7 @@
- spatialpy.core.spatialpyerror — SpatialPy 1.0 documentation
+ spatialpy.core.spatialpyerror — SpatialPy 1.0.2 documentation
@@ -91,23 +91,21 @@ Quick search
Source code for spatialpy.core.spatialpyerror
-'''
-SpatialPy is a Python 3 package for simulation of
-spatial deterministic/stochastic reaction-diffusion-advection problems
-Copyright (C) 2019 - 2022 SpatialPy developers.
+# SpatialPy is a Python 3 package for simulation of
+# spatial deterministic/stochastic reaction-diffusion-advection problems
+# Copyright (C) 2019 - 2022 SpatialPy developers.
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU GENERAL PUBLIC LICENSE Version 3 as
-published by the Free Software Foundation.
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU GENERAL PUBLIC LICENSE Version 3 as
+# published by the Free Software Foundation.
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU GENERAL PUBLIC LICENSE Version 3 for more details.
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU GENERAL PUBLIC LICENSE Version 3 for more details.
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-'''
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Base Module Expections
[docs]class ModelError(Exception):
@@ -120,6 +118,11 @@ Source code for spatialpy.core.spatialpyerror
Class for exceptions in the results module.
"""
+[docs]class VisualizationError(Exception):
+ """
+ Class for exceptions in the visualization module.
+ """
+
[docs]class VTKReaderError(Exception):
"""
Bass class for exceptions in the vtkreader module.
@@ -174,6 +177,9 @@ Source code for spatialpy.core.spatialpyerror
# Result Exceptions
+# Visualization Exceptions
+
+
# VTKReader Exceptions
[docs]class VTKReaderIOError(VTKReaderError):
"""
@@ -204,10 +210,10 @@ Source code for spatialpy.core.spatialpyerror
diff --git a/docs/build/html/_modules/spatialpy/core/species.html b/docs/build/html/_modules/spatialpy/core/species.html
index 8429f830..32643f60 100644
--- a/docs/build/html/_modules/spatialpy/core/species.html
+++ b/docs/build/html/_modules/spatialpy/core/species.html
@@ -5,7 +5,7 @@
- spatialpy.core.species — SpatialPy 1.0 documentation
+ spatialpy.core.species — SpatialPy 1.0.2 documentation
@@ -91,23 +91,21 @@ Quick search
Source code for spatialpy.core.species
-'''
-SpatialPy is a Python 3 package for simulation of
-spatial deterministic/stochastic reaction-diffusion-advection problems
-Copyright (C) 2019 - 2022 SpatialPy developers.
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU GENERAL PUBLIC LICENSE Version 3 as
-published by the Free Software Foundation.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU GENERAL PUBLIC LICENSE Version 3 for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-'''
+# SpatialPy is a Python 3 package for simulation of
+# spatial deterministic/stochastic reaction-diffusion-advection problems
+# Copyright (C) 2019 - 2022 SpatialPy developers.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU GENERAL PUBLIC LICENSE Version 3 as
+# published by the Free Software Foundation.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU GENERAL PUBLIC LICENSE Version 3 for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
from spatialpy.core.parameter import Parameter
from spatialpy.core.spatialpyerror import SpeciesError
@@ -133,9 +131,9 @@ Source code for spatialpy.core.species
if diffusion_coefficient is None:
raise SpeciesError("Species must have a diffusion_coefficient.")
- if not (isinstance(diffusion_coefficient, (Parameter, float, int)) or \
+ if not (isinstance(diffusion_coefficient, (Parameter, str, float, int)) or \
type(diffusion_coefficient).__name__ == 'Parameter'):
- raise SpeciesError("Diffusion coefficient must be a spatialpy.Parameter, float, or int.")
+ raise SpeciesError("Diffusion coefficient must be a spatialpy.Parameter, str, float, or int.")
if isinstance(diffusion_coefficient, (float, int)) and diffusion_coefficient < 0:
raise SpeciesError("Diffusion coefficient must be non-negative.")
@@ -166,9 +164,9 @@ Source code for spatialpy.core.species
:raises SpeciesError: If diffusion_coefficient is negative or not a valid type.
"""
- if not (isinstance(diffusion_coefficient, (Parameter, float, int)) or \
+ if not (isinstance(diffusion_coefficient, (Parameter, str, float, int)) or \
type(diffusion_coefficient).__name__ == 'Parameter'):
- raise SpeciesError("Diffusion coefficient must be a spatialpy.Parameter, float, or int.")
+ raise SpeciesError("Diffusion coefficient must be a spatialpy.Parameter, str, float, or int.")
if diffusion_coefficient < 0:
raise SpeciesError("Diffusion coefficient must be non-negative.")
@@ -189,10 +187,10 @@ Source code for spatialpy.core.species
diff --git a/docs/build/html/_modules/spatialpy/core/visualization.html b/docs/build/html/_modules/spatialpy/core/visualization.html
new file mode 100644
index 00000000..b16466f4
--- /dev/null
+++ b/docs/build/html/_modules/spatialpy/core/visualization.html
@@ -0,0 +1,310 @@
+
+
+
+
+
+
+
+ spatialpy.core.visualization — SpatialPy 1.0.2 documentation
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Source code for spatialpy.core.visualization
+# SpatialPy is a Python 3 package for simulation of
+# spatial deterministic/stochastic reaction-diffusion-advection problems
+# Copyright (C) 2019 - 2022 SpatialPy developers.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU GENERAL PUBLIC LICENSE Version 3 as
+# published by the Free Software Foundation.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU GENERAL PUBLIC LICENSE Version 3 for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+import math
+import numpy
+
+try:
+ import matplotlib.pyplot as plt
+ mpl_import_err = None
+except ImportError as err:
+ mpl_import_err = err
+
+from spatialpy.core.spatialpyerror import VisualizationError
+
+common_rgb_values=['#1f77b4','#ff7f0e','#2ca02c','#d62728','#9467bd','#8c564b','#e377c2','#7f7f7f',
+ '#bcbd22','#17becf','#ff0000','#00ff00','#0000ff','#ffff00','#00ffff','#ff00ff',
+ '#800000','#808000','#008000','#800080','#008080','#000080','#ff9999','#ffcc99',
+ '#ccff99','#cc99ff','#ffccff','#62666a','#8896bb','#77a096','#9d5a6c','#9d5a6c',
+ '#eabc75','#ff9600','#885300','#9172ad','#a1b9c4','#18749b','#dadecf','#c5b8a8',
+ '#000117','#13a8fe','#cf0060','#04354b','#0297a0','#037665','#eed284','#442244',
+ '#ffddee','#702afb']
+
+def _get_coords(points):
+ labels = ["X-Axis", "Y-Axis", "Z-Axis"]
+ coords = []
+ axes = []
+ i = 0
+ while len(coords) < 2 and i < 3:
+ vertex = list(map(lambda point: point[i], points))
+ if numpy.count_nonzero(numpy.diff(vertex)) > 0:
+ coords.append(vertex)
+ axes.append(labels[i])
+ i += 1
+ if len(coords) < 2:
+ if labels[0] not in axes:
+ coords.insert(0, list(map(lambda point: point[0], points)))
+ axes.insert(0, labels[0])
+ elif labels[1] not in axes:
+ coords.append(list(map(lambda point: point[1], points)))
+ axes.append(labels[1])
+ return coords, axes
+
+def _validate_mplplot_args(args):
+ if args is None:
+ return {"figsize": (Visualization.MPL_WIDTH, Visualization.MPL_HEIGHT)}
+
+ supported_splts_args = ["sharex", "sharey", "squeeze"]
+ supported_fig_args = ["figsize", "dpi", "facecolor", "edgecolor", "frameon"]
+
+ kwargs = {}
+ for name, val in args.items():
+ if name in supported_splts_args or name in supported_fig_args:
+ kwargs[name] = val
+ else:
+ from spatialpy.core import log # pylint: disable=import-outside-toplevel
+ logmsg = f"Un-supported key word argument: {name} is not currently supported"
+ log.warning(logmsg)
+ return kwargs
+
+[docs]class Visualization():
+
+ MPL_WIDTH = 6.4
+ MPL_HEIGHT = 4.8
+ MPL_SIZE = 40
+
+ def __init__(self, data):
+ self.data = data
+
+ def __get_grid_shape(self, multiple_graphs):
+ if isinstance(multiple_graphs, tuple):
+ num_subplots = multiple_graphs[0] * multiple_graphs[1]
+ if num_subplots < len(self.data.keys()):
+ errmsg = f"The shape {multiple_graphs} of the graphs is to small for the given data"
+ raise VisualizationError(errmsg)
+ nrows = multiple_graphs[0]
+ ncols = multiple_graphs[1]
+ else:
+ nrows = math.ceil(len(self.data.keys()) / 2)
+ ncols = 2
+ return nrows, ncols
+
+ def __validate_mplscatter_args(self, args, name):
+ if args is None:
+ return {"s": Visualization.MPL_SIZE}
+
+ supported_args = ["s", "cmap", "color", "marker", "vmin", "vmax"]
+
+ group_args = args[name]
+ if "cmap" in group_args and "color" in group_args:
+ errmsg = f"scatter args for {name}: 'cmap' and 'color' cannot both be set."
+ raise VisualizationError(errmsg)
+
+ kwargs = {}
+ for arg_name, val in group_args.items():
+ if arg_name in supported_args:
+ kwargs[arg_name] = val
+ else:
+ from spatialpy.core import log # pylint: disable=import-outside-toplevel
+ logmsg = f"Un-supported key word argument: {arg_name} is not currently supported"
+ log.warning(logmsg)
+ if "s" not in kwargs:
+ if "size_scale" in self.data[name]:
+ mpl_smin = 18
+ mpl_smax = 180
+ kwargs['s'] = (mpl_smax - mpl_smin) * self.data[name]['size_scale'] + mpl_smin
+ else:
+ kwargs['s'] = Visualization.MPL_SIZE
+ return kwargs
+
+[docs] def plot_scatter(self, plot_args=None, scatter_args=None, multiple_graphs=False, title=None, limits=None):
+ """
+ Visualize data using maplotlib scatter plots.
+
+ :param plot_args: additional keyword arguments passed to :py:class:`matplotlib.pyplot.subplots`
+ :type plot_args: dict
+
+ :param scatter_args: dict of additional keyword arguments passed to \
+ :py:class:`matplotlib.pyplot.scatter` for each group.
+ :type scatter_args: dist
+
+ :param multiple_graphs: if each data entry should be ploted separately or on the same plot. \
+ If ploted separately a shape may be provided.
+ :type multiple_graphs: bool | tuple(nrows, ncols)
+ """
+ if mpl_import_err is not None:
+ raise VisualizationError("Missing MatPlotLib dependency.") from mpl_import_err
+
+ plot_args = _validate_mplplot_args(plot_args)
+ if multiple_graphs:
+ plot_args['nrows'], plot_args['ncols'] = self.__get_grid_shape(multiple_graphs)
+
+ fig, axs = plt.subplots(**plot_args)
+ if multiple_graphs:
+ axs = axs.flatten()
+ if len(self.data.keys())%plot_args['ncols'] != 0:
+ fig.delaxes(axs[-1])
+ axs = numpy.delete(axs, -1)
+ data_keys = list(self.data.keys())
+ for index, ax in enumerate(axs):
+ name = data_keys[index]
+ coords, axes_labels = _get_coords(self.data[name]["points"])
+
+ group_args = self.__validate_mplscatter_args(scatter_args, name)
+ if "cmap" in group_args:
+ group_args['c'] = self.data[name]["data"]
+
+ ax.scatter(*coords, label=name, **group_args)
+ ax.set_xlabel(axes_labels[0])
+ ax.set_xlim(limits[0])
+ ax.set_ylabel(axes_labels[1])
+ ax.set_ylim(limits[1])
+ ax.grid(linestyle='--', linewidth=1)
+ ax.legend(loc='upper right', fontsize=12)
+ if title is not None:
+ ax.set_title(title)
+ else:
+ for index, (name, data) in enumerate(self.data.items()):
+ x_coords = list(map(lambda point: point[0], data["points"]))
+ y_coords = list(map(lambda point: point[1], data["points"]))
+
+ group_args = self.__validate_mplscatter_args(scatter_args, name)
+ if "cmap" in group_args:
+ group_args['c'] = data["data"]
+
+ axs.scatter(x_coords, y_coords, label=name, **group_args)
+ axs.grid(linestyle='--', linewidth=1)
+ axs.legend(loc='upper right', fontsize=12)
+ if title is not None:
+ axs.set_title(title)
+
+ plt.axis('scaled')
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/docs/build/html/_modules/spatialpy/core/vtkreader.html b/docs/build/html/_modules/spatialpy/core/vtkreader.html
index 68768261..d725520b 100644
--- a/docs/build/html/_modules/spatialpy/core/vtkreader.html
+++ b/docs/build/html/_modules/spatialpy/core/vtkreader.html
@@ -5,7 +5,7 @@
- spatialpy.core.vtkreader — SpatialPy 1.0 documentation
+ spatialpy.core.vtkreader — SpatialPy 1.0.2 documentation
@@ -91,23 +91,21 @@ Quick search
Source code for spatialpy.core.vtkreader
-'''
-SpatialPy is a Python 3 package for simulation of
-spatial deterministic/stochastic reaction-diffusion-advection problems
-Copyright (C) 2019 - 2022 SpatialPy developers.
+# SpatialPy is a Python 3 package for simulation of
+# spatial deterministic/stochastic reaction-diffusion-advection problems
+# Copyright (C) 2019 - 2022 SpatialPy developers.
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU GENERAL PUBLIC LICENSE Version 3 as
-published by the Free Software Foundation.
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU GENERAL PUBLIC LICENSE Version 3 as
+# published by the Free Software Foundation.
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU GENERAL PUBLIC LICENSE Version 3 for more details.
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU GENERAL PUBLIC LICENSE Version 3 for more details.
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-'''
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
import numpy
@@ -303,10 +301,10 @@ Source code for spatialpy.core.vtkreader
diff --git a/docs/build/html/_modules/spatialpy/solvers/build_expression.html b/docs/build/html/_modules/spatialpy/solvers/build_expression.html
index 6aaf4746..69669844 100644
--- a/docs/build/html/_modules/spatialpy/solvers/build_expression.html
+++ b/docs/build/html/_modules/spatialpy/solvers/build_expression.html
@@ -5,7 +5,7 @@
- spatialpy.solvers.build_expression — SpatialPy 1.0 documentation
+ spatialpy.solvers.build_expression — SpatialPy 1.0.2 documentation
@@ -91,23 +91,21 @@ Quick search
Source code for spatialpy.solvers.build_expression
-'''
-SpatialPy is a Python 3 package for simulation of
-spatial deterministic/stochastic reaction-diffusion-advection problems
-Copyright (C) 2019 - 2022 SpatialPy developers.
+# SpatialPy is a Python 3 package for simulation of
+# spatial deterministic/stochastic reaction-diffusion-advection problems
+# Copyright (C) 2019 - 2022 SpatialPy developers.
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU GENERAL PUBLIC LICENSE Version 3 as
-published by the Free Software Foundation.
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU GENERAL PUBLIC LICENSE Version 3 as
+# published by the Free Software Foundation.
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU GENERAL PUBLIC LICENSE Version 3 for more details.
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU GENERAL PUBLIC LICENSE Version 3 for more details.
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-'''
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
import ast
@@ -862,10 +860,10 @@ Source code for spatialpy.solvers.build_expression
diff --git a/docs/build/html/_modules/spatialpy/solvers/solver.html b/docs/build/html/_modules/spatialpy/solvers/solver.html
index 5c84fcbc..4ebca464 100644
--- a/docs/build/html/_modules/spatialpy/solvers/solver.html
+++ b/docs/build/html/_modules/spatialpy/solvers/solver.html
@@ -5,7 +5,7 @@
- spatialpy.solvers.solver — SpatialPy 1.0 documentation
+ spatialpy.solvers.solver — SpatialPy 1.0.2 documentation
@@ -91,23 +91,21 @@ Quick search
Source code for spatialpy.solvers.solver
-'''
-SpatialPy is a Python 3 package for simulation of
-spatial deterministic/stochastic reaction-diffusion-advection problems
-Copyright (C) 2019 - 2022 SpatialPy developers.
+# SpatialPy is a Python 3 package for simulation of
+# spatial deterministic/stochastic reaction-diffusion-advection problems
+# Copyright (C) 2019 - 2022 SpatialPy developers.
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU GENERAL PUBLIC LICENSE Version 3 as
-published by the Free Software Foundation.
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU GENERAL PUBLIC LICENSE Version 3 as
+# published by the Free Software Foundation.
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU GENERAL PUBLIC LICENSE Version 3 for more details.
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU GENERAL PUBLIC LICENSE Version 3 for more details.
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-'''
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
import os
import shutil
@@ -567,7 +565,12 @@ Source code for spatialpy.solvers.solver
# Build the solver
makefile = self.spatialpy_rootdir+'/build/Makefile'
- cmd_list = ['cd', self.core_dir, '&&', 'make', 'CORE', '-f', makefile,
+ makefile_ann = self.spatialpy_rootdir+'/external/ANN/src/Makefile.spatialpy'
+ cmd_list = ['cd', self.core_dir, '&&',
+ 'make', '-f' , makefile_ann,
+ 'ROOTINC="' + self.spatialpy_rootinc+'"',
+ '&&',
+ 'make', 'CORE', '-f', makefile,
'ROOT="' + self.spatialpy_rootparam+'"',
'ROOTINC="' + self.spatialpy_rootinc+'"',
'BUILD='+self.core_dir, '&&'
@@ -721,10 +724,10 @@ Source code for spatialpy.solvers.solver
diff --git a/docs/build/html/_modules/spatialpy/stochss/stochss_export.html b/docs/build/html/_modules/spatialpy/stochss/stochss_export.html
index cead8e00..67f2458b 100644
--- a/docs/build/html/_modules/spatialpy/stochss/stochss_export.html
+++ b/docs/build/html/_modules/spatialpy/stochss/stochss_export.html
@@ -5,7 +5,7 @@
- spatialpy.stochss.stochss_export — SpatialPy 1.0 documentation
+ spatialpy.stochss.stochss_export — SpatialPy 1.0.2 documentation
@@ -91,23 +91,21 @@ Quick search
Source code for spatialpy.stochss.stochss_export
-'''
-SpatialPy is a Python 3 package for simulation of
-spatial deterministic/stochastic reaction-diffusion-advection problems
-Copyright (C) 2019 - 2022 SpatialPy developers.
+# SpatialPy is a Python 3 package for simulation of
+# spatial deterministic/stochastic reaction-diffusion-advection problems
+# Copyright (C) 2019 - 2022 SpatialPy developers.
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU GENERAL PUBLIC LICENSE Version 3 as
-published by the Free Software Foundation.
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU GENERAL PUBLIC LICENSE Version 3 as
+# published by the Free Software Foundation.
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU GENERAL PUBLIC LICENSE Version 3 for more details.
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU GENERAL PUBLIC LICENSE Version 3 for more details.
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-'''
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
import ast
import json
@@ -364,10 +362,10 @@ Source code for spatialpy.stochss.stochss_export
diff --git a/docs/build/html/_sources/classes/spatialpy.core.rst.txt b/docs/build/html/_sources/classes/spatialpy.core.rst.txt
index 9d0dc903..f259fa08 100644
--- a/docs/build/html/_sources/classes/spatialpy.core.rst.txt
+++ b/docs/build/html/_sources/classes/spatialpy.core.rst.txt
@@ -100,6 +100,14 @@ spatialpy.core.species module
:undoc-members:
:show-inheritance:
+spatialpy.core.visualization module
+-----------------------------------
+
+.. automodule:: spatialpy.core.visualization
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
spatialpy.core.vtkreader module
-------------------------------
diff --git a/docs/build/html/_static/basic.css b/docs/build/html/_static/basic.css
index 912859b5..bf18350b 100644
--- a/docs/build/html/_static/basic.css
+++ b/docs/build/html/_static/basic.css
@@ -4,7 +4,7 @@
*
* Sphinx stylesheet -- basic theme.
*
- * :copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
+ * :copyright: Copyright 2007-2022 by the Sphinx team, see AUTHORS.
* :license: BSD, see LICENSE for details.
*
*/
@@ -731,8 +731,9 @@ dl.glossary dt {
.classifier:before {
font-style: normal;
- margin: 0.5em;
+ margin: 0 0.5em;
content: ":";
+ display: inline-block;
}
abbr, acronym {
@@ -756,6 +757,7 @@ span.pre {
-ms-hyphens: none;
-webkit-hyphens: none;
hyphens: none;
+ white-space: nowrap;
}
div[class*="highlight-"] {
diff --git a/docs/build/html/_static/doctools.js b/docs/build/html/_static/doctools.js
index 8cbf1b16..e509e483 100644
--- a/docs/build/html/_static/doctools.js
+++ b/docs/build/html/_static/doctools.js
@@ -4,7 +4,7 @@
*
* Sphinx JavaScript utilities for all documentation.
*
- * :copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
+ * :copyright: Copyright 2007-2022 by the Sphinx team, see AUTHORS.
* :license: BSD, see LICENSE for details.
*
*/
@@ -264,6 +264,9 @@ var Documentation = {
hideSearchWords : function() {
$('#searchbox .highlight-link').fadeOut(300);
$('span.highlighted').removeClass('highlighted');
+ var url = new URL(window.location);
+ url.searchParams.delete('highlight');
+ window.history.replaceState({}, '', url);
},
/**
diff --git a/docs/build/html/_static/documentation_options.js b/docs/build/html/_static/documentation_options.js
index b24e4743..32a0c247 100644
--- a/docs/build/html/_static/documentation_options.js
+++ b/docs/build/html/_static/documentation_options.js
@@ -1,6 +1,6 @@
var DOCUMENTATION_OPTIONS = {
URL_ROOT: document.getElementById("documentation_options").getAttribute('data-url_root'),
- VERSION: '1.0',
+ VERSION: '1.0.2',
LANGUAGE: 'en',
COLLAPSE_INDEX: false,
BUILDER: 'html',
diff --git a/docs/build/html/_static/language_data.js b/docs/build/html/_static/language_data.js
index 863704b3..ebe2f03b 100644
--- a/docs/build/html/_static/language_data.js
+++ b/docs/build/html/_static/language_data.js
@@ -5,7 +5,7 @@
* This script contains the language-specific data used by searchtools.js,
* namely the list of stopwords, stemmer, scorer and splitter.
*
- * :copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
+ * :copyright: Copyright 2007-2022 by the Sphinx team, see AUTHORS.
* :license: BSD, see LICENSE for details.
*
*/
diff --git a/docs/build/html/_static/pygments.css b/docs/build/html/_static/pygments.css
index 1b945229..87f8bd12 100644
--- a/docs/build/html/_static/pygments.css
+++ b/docs/build/html/_static/pygments.css
@@ -1,7 +1,7 @@
-pre { line-height: 125%; margin: 0; }
-td.linenos pre { color: #000000; background-color: #f0f0f0; padding-left: 5px; padding-right: 5px; }
-span.linenos { color: #000000; background-color: #f0f0f0; padding-left: 5px; padding-right: 5px; }
-td.linenos pre.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
+pre { line-height: 125%; }
+td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
+span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
+td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
.highlight .hll { background-color: #ffffcc }
.highlight { background: #f8f8f8; }
diff --git a/docs/build/html/_static/searchtools.js b/docs/build/html/_static/searchtools.js
index 8eb14218..2d778593 100644
--- a/docs/build/html/_static/searchtools.js
+++ b/docs/build/html/_static/searchtools.js
@@ -4,7 +4,7 @@
*
* Sphinx JavaScript utilities for the full-text search.
*
- * :copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
+ * :copyright: Copyright 2007-2022 by the Sphinx team, see AUTHORS.
* :license: BSD, see LICENSE for details.
*
*/
@@ -276,19 +276,28 @@ var Search = {
setTimeout(function() {
displayNextItem();
}, 5);
- } else {
+ } else if (DOCUMENTATION_OPTIONS.HAS_SOURCE) {
$.ajax({url: requestUrl,
dataType: "text",
complete: function(jqxhr, textstatus) {
var data = jqxhr.responseText;
if (data !== '' && data !== undefined) {
- listItem.append(Search.makeSearchSummary(data, searchterms, hlterms));
+ var summary = Search.makeSearchSummary(data, searchterms, hlterms);
+ if (summary) {
+ listItem.append(summary);
+ }
}
Search.output.append(listItem);
setTimeout(function() {
displayNextItem();
}, 5);
}});
+ } else {
+ // no source available, just display title
+ Search.output.append(listItem);
+ setTimeout(function() {
+ displayNextItem();
+ }, 5);
}
}
// search finished, update title and status message
@@ -319,7 +328,9 @@ var Search = {
var results = [];
for (var prefix in objects) {
- for (var name in objects[prefix]) {
+ for (var iMatch = 0; iMatch != objects[prefix].length; ++iMatch) {
+ var match = objects[prefix][iMatch];
+ var name = match[4];
var fullname = (prefix ? prefix + '.' : '') + name;
var fullnameLower = fullname.toLowerCase()
if (fullnameLower.indexOf(object) > -1) {
@@ -333,7 +344,6 @@ var Search = {
} else if (parts[parts.length - 1].indexOf(object) > -1) {
score += Scorer.objPartialMatch;
}
- var match = objects[prefix][name];
var objname = objnames[match[1]][2];
var title = titles[match[0]];
// If more than one term searched for, we require other words to be
@@ -492,6 +502,9 @@ var Search = {
*/
makeSearchSummary : function(htmlText, keywords, hlwords) {
var text = Search.htmlToText(htmlText);
+ if (text == "") {
+ return null;
+ }
var textLower = text.toLowerCase();
var start = 0;
$.each(keywords, function() {
diff --git a/docs/build/html/classes/spatialpy.core.html b/docs/build/html/classes/spatialpy.core.html
index 0b5b39b2..d2b61df2 100644
--- a/docs/build/html/classes/spatialpy.core.html
+++ b/docs/build/html/classes/spatialpy.core.html
@@ -4,8 +4,9 @@
-
- spatialpy.core package — SpatialPy 1.0 documentation
+
+
+ spatialpy.core package — SpatialPy 1.0.2 documentation
@@ -13,6 +14,7 @@
+
@@ -103,28 +105,16 @@ Quick search
-
+
spatialpy.core package¶
-
+
Submodules¶
-
-
+
+
spatialpy.core.boundarycondition module¶
-SpatialPy is a Python 3 package for simulation of
-spatial deterministic/stochastic reaction-diffusion-advection problems
-Copyright (C) 2019 - 2022 SpatialPy developers.
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU GENERAL PUBLIC LICENSE Version 3 as
-published by the Free Software Foundation.
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU GENERAL PUBLIC LICENSE Version 3 for more details.
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-class spatialpy.core.boundarycondition.BoundaryCondition(xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, type_id=None, deterministic=True, target=None, value=None, model=None)[source]¶
+class spatialpy.core.boundarycondition.BoundaryCondition(xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, type_id=None, deterministic=True, target=None, value=None, model=None)[source]¶
Bases: object
Set spatial regions of the domain where a property of
particles are held constant (updated each simulation step)
@@ -173,21 +163,9 @@ Submodules
+
+
spatialpy.core.cleanup module¶
-SpatialPy is a Python 3 package for simulation of
-spatial deterministic/stochastic reaction-diffusion-advection problems
-Copyright (C) 2019 - 2022 SpatialPy developers.
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU GENERAL PUBLIC LICENSE Version 3 as
-published by the Free Software Foundation.
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU GENERAL PUBLIC LICENSE Version 3 for more details.
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
+
spatialpy.core.datafunction module¶
-SpatialPy is a Python 3 package for simulation of
-spatial deterministic/stochastic reaction-diffusion-advection problems
-Copyright (C) 2019 - 2022 SpatialPy developers.
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU GENERAL PUBLIC LICENSE Version 3 as
-published by the Free Software Foundation.
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU GENERAL PUBLIC LICENSE Version 3 for more details.
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
+
spatialpy.core.domain module¶
-SpatialPy is a Python 3 package for simulation of
-spatial deterministic/stochastic reaction-diffusion-advection problems
-Copyright (C) 2019 - 2022 SpatialPy developers.
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU GENERAL PUBLIC LICENSE Version 3 as
-published by the Free Software Foundation.
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU GENERAL PUBLIC LICENSE Version 3 for more details.
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-class spatialpy.core.domain.Domain(numpoints, xlim, ylim, zlim, rho0=1.0, c0=10, P0=None, gravity=None)[source]¶
+class spatialpy.core.domain.Domain(numpoints, xlim, ylim, zlim, rho0=1.0, c0=10, P0=None, gravity=None)[source]¶
Bases: object
Domain class for SpatialPy. A domain defines points and attributes of a regional space for simulation.
@@ -378,7 +332,7 @@ Submodules
-
-classmethod create_2D_domain(xlim, ylim, nx, ny, type_id=1, mass=1.0, nu=1.0, rho=None, c=0, fixed=False, **kwargs)[source]¶
+classmethod create_2D_domain(xlim, ylim, nx, ny, type_id=1, mass=1.0, nu=1.0, rho=None, c=0, fixed=False, **kwargs)[source]¶
Create a filled 2D domain
- Parameters
@@ -407,7 +361,7 @@ Submodules
-
-classmethod create_3D_domain(xlim, ylim, zlim, nx, ny, nz, type_id=1, mass=1.0, nu=1.0, rho=None, c=0, fixed=False, **kwargs)[source]¶
+classmethod create_3D_domain(xlim, ylim, zlim, nx, ny, nz, type_id=1, mass=1.0, nu=1.0, rho=None, c=0, fixed=False, **kwargs)[source]¶
Create a filled 3D domain
- Parameters
@@ -463,8 +417,7 @@ Submodules
- Parameters
-geometry_ivar (spatialpy.core.geometry.Geometry) – an instance of a spatialpy.core.geometry.Geometry subclass. The ‘inside()’ method
-of this object will be used to create add the particles.
+geometry_ivar (spatialpy.core.geometry.Geometry) – an instance of a spatialpy.core.geometry.Geometry subclass. The ‘inside()’ method of this object will be used to create add the particles.
deltax (float) – Distance between particles on the x-axis.
deltay (float) – Distance between particles on the y-axis (defaults to deltax).
deltaz (float) – Distance between particles on the z-axis (defaults to deltax).
@@ -594,7 +547,7 @@ Submodules
-
-classmethod import_meshio_object(mesh_obj)[source]¶
+classmethod import_meshio_object(mesh_obj)[source]¶
Import a python meshio mesh object.
- Parameters
@@ -611,7 +564,7 @@ Submodules
-
-plot_types(width=None, height=None, colormap=None, size=5, title=None, included_types_list=None, use_matplotlib=False, return_plotly_figure=False)[source]¶
+plot_types(width=None, height=None, colormap=None, size=None, title=None, included_types_list=None, use_matplotlib=False, return_plotly_figure=False)[source]¶
Plots the domain using plotly. Can only be viewed in a Jupyter Notebook.
- Parameters
@@ -637,7 +590,7 @@ Submodules
-
-classmethod read_msh_file(filename)[source]¶
+classmethod read_msh_file(filename)[source]¶
Read a Gmsh style .msh file
- Parameters
@@ -654,7 +607,7 @@ Submodules
-
-classmethod read_stochss_domain(filename)[source]¶
+classmethod read_stochss_domain(filename)[source]¶
Read a StochSS Domain (.domn) file or pull a StochSS Domain from a StochSS Spatial Model (.smdl) file.
- Parameters
@@ -688,7 +641,7 @@ Submodules
-
-classmethod read_xml_mesh(filename)[source]¶
+classmethod read_xml_mesh(filename)[source]¶
Read a FEniCS/dolfin style XML mesh file
- Parameters
@@ -710,8 +663,7 @@ Submodules
- Parameters
-geometry_ivar (spatialpy.core.geometry.Geometry) – an instance of a spatialpy.core.geometry.Geometry subclass. The ‘inside()’ method
-of this object will be used to assign properties to points.
+geometry_ivar (spatialpy.core.geometry.Geometry) – an instance of a spatialpy.core.geometry.Geometry subclass. The ‘inside()’ method of this object will be used to assign properties to points.
type_id (str | int) – The identifier for this type.
vol (float) – The volume of each particle in the type.
mass (float) – The mass of each particle in the type.
@@ -735,24 +687,12 @@ Submodules
+
+
spatialpy.core.geometry module¶
-SpatialPy is a Python 3 package for simulation of
-spatial deterministic/stochastic reaction-diffusion-advection problems
-Copyright (C) 2019 - 2022 SpatialPy developers.
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU GENERAL PUBLIC LICENSE Version 3 as
-published by the Free Software Foundation.
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU GENERAL PUBLIC LICENSE Version 3 for more details.
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-class spatialpy.core.geometry.Geometry[source]¶
+class spatialpy.core.geometry.Geometry[source]¶
Bases: object
Geometry class provides a method for tagging parts of the spatial domain as separate parts.
@@ -778,7 +718,7 @@ Submodules
-
-class spatialpy.core.geometry.GeometryAll[source]¶
+class spatialpy.core.geometry.GeometryAll[source]¶
Bases: spatialpy.core.geometry.Geometry
Mark all particles.
@@ -804,7 +744,7 @@ Submodules
-
-class spatialpy.core.geometry.GeometryExterior[source]¶
+class spatialpy.core.geometry.GeometryExterior[source]¶
Bases: spatialpy.core.geometry.Geometry
Mark particles that are on the edge of the domain.
only works for domains that define triangles and tetrahedrons.
@@ -831,7 +771,7 @@ Submodules
-
-class spatialpy.core.geometry.GeometryInterior[source]¶
+class spatialpy.core.geometry.GeometryInterior[source]¶
Bases: spatialpy.core.geometry.Geometry
Mark particles that are not on the edge of the domain.
Only works for domains that define triangles and tetrahedrons.
@@ -856,24 +796,12 @@ Submodules
+
+
spatialpy.core.initialcondition module¶
-SpatialPy is a Python 3 package for simulation of
-spatial deterministic/stochastic reaction-diffusion-advection problems
-Copyright (C) 2019 - 2022 SpatialPy developers.
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU GENERAL PUBLIC LICENSE Version 3 as
-published by the Free Software Foundation.
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU GENERAL PUBLIC LICENSE Version 3 for more details.
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-class spatialpy.core.initialcondition.InitialCondition[source]¶
+class spatialpy.core.initialcondition.InitialCondition[source]¶
Bases: object
Class used to defined initial conditions in SpatialPy.
SubClasses must implement the ‘apply(model)’ method, which
@@ -893,7 +821,7 @@
Submodules
-
-class spatialpy.core.initialcondition.PlaceInitialCondition(species, count, location)[source]¶
+class spatialpy.core.initialcondition.PlaceInitialCondition(species, count, location)[source]¶
Bases: spatialpy.core.initialcondition.InitialCondition
Class used to defined the place initial condition in SpatialPy.
@@ -920,7 +848,7 @@ Submodules
-
-class spatialpy.core.initialcondition.ScatterInitialCondition(species, count, types=None)[source]¶
+class spatialpy.core.initialcondition.ScatterInitialCondition(species, count, types=None)[source]¶
Bases: spatialpy.core.initialcondition.InitialCondition
Class used to defined the scatter initial condition in SpatialPy.
@@ -947,7 +875,7 @@ Submodules
-
-class spatialpy.core.initialcondition.UniformInitialCondition(species, count, types=None)[source]¶
+class spatialpy.core.initialcondition.UniformInitialCondition(species, count, types=None)[source]¶
Bases: spatialpy.core.initialcondition.InitialCondition
Class used to defined the uniform initial condition in SpatialPy.
@@ -972,24 +900,12 @@ Submodules
+
+
spatialpy.core.model module¶
-SpatialPy is a Python 3 package for simulation of
-spatial deterministic/stochastic reaction-diffusion-advection problems
-Copyright (C) 2019 - 2022 SpatialPy developers.
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU GENERAL PUBLIC LICENSE Version 3 as
-published by the Free Software Foundation.
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU GENERAL PUBLIC LICENSE Version 3 for more details.
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-class spatialpy.core.model.Model(name='spatialpy')[source]¶
+class spatialpy.core.model.Model(name='spatialpy')[source]¶
Bases: object
Representation of a spatial biochemical model.
@@ -1320,7 +1236,7 @@ Submodules
-
-reserved_names = ['vol', 't']¶
+reserved_names = ['vol', 't']¶
@@ -1414,7 +1330,7 @@ Submodules
-
-special_characters = ['[', ']', '+', '-', '*', '/', '.', '^']¶
+special_characters = ['[', ']', '+', '-', '*', '/', '.', '^']¶
@@ -1464,24 +1380,12 @@ Submodules
+
+
spatialpy.core.parameter module¶
-SpatialPy is a Python 3 package for simulation of
-spatial deterministic/stochastic reaction-diffusion-advection problems
-Copyright (C) 2019 - 2022 SpatialPy developers.
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU GENERAL PUBLIC LICENSE Version 3 as
-published by the Free Software Foundation.
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU GENERAL PUBLIC LICENSE Version 3 for more details.
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-class spatialpy.core.parameter.Parameter(name=None, expression=None)[source]¶
+class spatialpy.core.parameter.Parameter(name=None, expression=None)[source]¶
Bases: object
Model of a rate paramter.
A parameter can be given as a String expression (function) or directly as a scalar value.
@@ -1497,24 +1401,12 @@
Submodules
+
+
spatialpy.core.reaction module¶
-SpatialPy is a Python 3 package for simulation of
-spatial deterministic/stochastic reaction-diffusion-advection problems
-Copyright (C) 2019 - 2022 SpatialPy developers.
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU GENERAL PUBLIC LICENSE Version 3 as
-published by the Free Software Foundation.
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU GENERAL PUBLIC LICENSE Version 3 for more details.
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-class spatialpy.core.reaction.Reaction(name='', reactants=None, products=None, propensity_function=None, rate=None, annotation=None, restrict_to=None)[source]¶
+class spatialpy.core.reaction.Reaction(name='', reactants=None, products=None, propensity_function=None, rate=None, annotation=None, restrict_to=None)[source]¶
Bases: object
Models a biochemical reaction. A reaction conatains dictionaries of species (reactants and products) and parameters. The reaction’s propensity function needs to be evaluable and result in a non-negative scalar value in the namespace defined by the union of its Reactant, Product and Parameter dictionaries. For mass-action, zeroth, first and second order reactions are supported, attempting to used higher orders will result in an error.
@@ -1582,24 +1474,12 @@ Submodules
+
+
spatialpy.core.result module¶
-SpatialPy is a Python 3 package for simulation of
-spatial deterministic/stochastic reaction-diffusion-advection problems
-Copyright (C) 2019 - 2022 SpatialPy developers.
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU GENERAL PUBLIC LICENSE Version 3 as
-published by the Free Software Foundation.
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU GENERAL PUBLIC LICENSE Version 3 for more details.
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-class spatialpy.core.result.Result(model=None, result_dir=None)[source]¶
+class spatialpy.core.result.Result(model=None, result_dir=None)[source]¶
Bases: object
Result object for a URDME simulation.
@@ -1663,7 +1543,7 @@ Submodules
-
-plot_property(property_name, t_ndx=None, t_val=None, p_ndx=0, width=None, height=None, colormap=None, size=5, title=None, animated=False, t_ndx_list=None, speed=1, f_duration=500, t_duration=300, included_types_list=None, return_plotly_figure=False, use_matplotlib=False, debug=False)[source]¶
+plot_property(property_name, t_ndx=None, t_val=None, p_ndx=0, width=None, height=None, colormap=None, size=None, title=None, animated=False, t_ndx_list=None, speed=1, f_duration=500, t_duration=300, included_types_list=None, return_plotly_figure=False, use_matplotlib=False, debug=False)[source]¶
Plots the Results using plotly. Can only be viewed in a Jupyter Notebook.
- Parameters
@@ -1808,137 +1688,120 @@ Submodules
+
+
spatialpy.core.spatialpyerror module¶
-SpatialPy is a Python 3 package for simulation of
-spatial deterministic/stochastic reaction-diffusion-advection problems
-Copyright (C) 2019 - 2022 SpatialPy developers.
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU GENERAL PUBLIC LICENSE Version 3 as
-published by the Free Software Foundation.
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU GENERAL PUBLIC LICENSE Version 3 for more details.
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-exception spatialpy.core.spatialpyerror.BoundaryConditionError[source]¶
+exception spatialpy.core.spatialpyerror.BoundaryConditionError[source]¶
Bases: spatialpy.core.spatialpyerror.ModelError
Base class for exceptions in the boundarycondition module.
-
-exception spatialpy.core.spatialpyerror.DataFunctionError[source]¶
+exception spatialpy.core.spatialpyerror.DataFunctionError[source]¶
Bases: spatialpy.core.spatialpyerror.ModelError
Class for exceptions in the datafunction module.
-
-exception spatialpy.core.spatialpyerror.DomainError[source]¶
+exception spatialpy.core.spatialpyerror.DomainError[source]¶
Bases: spatialpy.core.spatialpyerror.ModelError
Class for exceptions in the domain module.
-
-exception spatialpy.core.spatialpyerror.GeometryError[source]¶
+exception spatialpy.core.spatialpyerror.GeometryError[source]¶
Bases: spatialpy.core.spatialpyerror.ModelError
Class for exceptions in the geometry module.
-
-exception spatialpy.core.spatialpyerror.InitialConditionError[source]¶
+exception spatialpy.core.spatialpyerror.InitialConditionError[source]¶
Bases: spatialpy.core.spatialpyerror.ModelError
Class for exceptions in initailcondition module.
-
-exception spatialpy.core.spatialpyerror.ModelError[source]¶
+exception spatialpy.core.spatialpyerror.ModelError[source]¶
Bases: Exception
Class for exceptions in the model module.
-
-exception spatialpy.core.spatialpyerror.ParameterError[source]¶
+exception spatialpy.core.spatialpyerror.ParameterError[source]¶
Bases: spatialpy.core.spatialpyerror.ModelError
Class for exceptions in parameter module.
-
-exception spatialpy.core.spatialpyerror.ReactionError[source]¶
+exception spatialpy.core.spatialpyerror.ReactionError[source]¶
Bases: spatialpy.core.spatialpyerror.ModelError
Class for exceptions in reaction module.
-
-exception spatialpy.core.spatialpyerror.ResultError[source]¶
+exception spatialpy.core.spatialpyerror.ResultError[source]¶
Bases: Exception
Class for exceptions in the results module.
-
-exception spatialpy.core.spatialpyerror.SimulationError[source]¶
+exception spatialpy.core.spatialpyerror.SimulationError[source]¶
Bases: Exception
Class for exceptions in the simulation module.
-
-exception spatialpy.core.spatialpyerror.SimulationTimeout[source]¶
+exception spatialpy.core.spatialpyerror.SimulationTimeout[source]¶
Bases: spatialpy.core.spatialpyerror.SimulationError
Exception raised for timeout errors.
-
-exception spatialpy.core.spatialpyerror.SpeciesError[source]¶
+exception spatialpy.core.spatialpyerror.SpeciesError[source]¶
Bases: spatialpy.core.spatialpyerror.ModelError
Class for exceptions in the species module.
-
-exception spatialpy.core.spatialpyerror.VTKReaderError[source]¶
+exception spatialpy.core.spatialpyerror.VTKReaderError[source]¶
Bases: Exception
Bass class for exceptions in the vtkreader module.
-
-exception spatialpy.core.spatialpyerror.VTKReaderIOError(message)[source]¶
+exception spatialpy.core.spatialpyerror.VTKReaderIOError(message)[source]¶
Bases: spatialpy.core.spatialpyerror.VTKReaderError
Exception raised for I/O errors.
-
-
+
+-
+exception spatialpy.core.spatialpyerror.VisualizationError[source]¶
+Bases: Exception
+Class for exceptions in the visualization module.
+
+
+
+
spatialpy.core.species module¶
-SpatialPy is a Python 3 package for simulation of
-spatial deterministic/stochastic reaction-diffusion-advection problems
-Copyright (C) 2019 - 2022 SpatialPy developers.
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU GENERAL PUBLIC LICENSE Version 3 as
-published by the Free Software Foundation.
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU GENERAL PUBLIC LICENSE Version 3 for more details.
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-class spatialpy.core.species.Species(name=None, diffusion_coefficient=None, restrict_to=None)[source]¶
+class spatialpy.core.species.Species(name=None, diffusion_coefficient=None, restrict_to=None)[source]¶
Bases: object
Model of a biochemical species. Must be assigned a diffusion coefficent.
@@ -1966,24 +1829,51 @@ Submodules
+
+
+spatialpy.core.visualization module¶
+
+-
+class spatialpy.core.visualization.Visualization(data)[source]¶
+Bases: object
+
+-
+MPL_HEIGHT = 4.8¶
+
+
+
+-
+MPL_SIZE = 40¶
+
+
+
+-
+MPL_WIDTH = 6.4¶
+
+
+
+-
+plot_scatter(plot_args=None, scatter_args=None, multiple_graphs=False, title=None, limits=None)[source]¶
+Visualize data using maplotlib scatter plots.
+
+- Parameters
+
+plot_args (dict) – additional keyword arguments passed to matplotlib.pyplot.subplots
+scatter_args (dist) – dict of additional keyword arguments passed to matplotlib.pyplot.scatter for each group.
+multiple_graphs (bool | tuple(nrows, ncols)) – if each data entry should be ploted separately or on the same plot. If ploted separately a shape may be provided.
+
+
+
+
+
+
+
+
+
spatialpy.core.vtkreader module¶
-SpatialPy is a Python 3 package for simulation of
-spatial deterministic/stochastic reaction-diffusion-advection problems
-Copyright (C) 2019 - 2022 SpatialPy developers.
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU GENERAL PUBLIC LICENSE Version 3 as
-published by the Free Software Foundation.
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU GENERAL PUBLIC LICENSE Version 3 for more details.
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-class spatialpy.core.vtkreader.VTKReader(filename=None, debug=False)[source]¶
+class spatialpy.core.vtkreader.VTKReader(filename=None, debug=False)[source]¶
Bases: object
VTKReader.py: SpatialPy minimal VTK legacy file reader.
Reference: https://vtk.org/wp-content/uploads/2015/04/file-formats.pdf
@@ -2078,24 +1968,12 @@ Submodules
+
+
Module contents¶
-SpatialPy is a Python 3 package for simulation of
-spatial deterministic/stochastic reaction-diffusion-advection problems
-Copyright (C) 2019 - 2022 SpatialPy developers.
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU GENERAL PUBLIC LICENSE Version 3 as
-published by the Free Software Foundation.
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU GENERAL PUBLIC LICENSE Version 3 for more details.
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-class spatialpy.core.BoundaryCondition(xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, type_id=None, deterministic=True, target=None, value=None, model=None)[source]¶
+class spatialpy.core.BoundaryCondition(xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, type_id=None, deterministic=True, target=None, value=None, model=None)[source]¶
Bases: object
Set spatial regions of the domain where a property of
particles are held constant (updated each simulation step)
@@ -2146,14 +2024,14 @@ Submodules
-
-exception spatialpy.core.BoundaryConditionError[source]¶
+exception spatialpy.core.BoundaryConditionError[source]¶
Bases: spatialpy.core.spatialpyerror.ModelError
Base class for exceptions in the boundarycondition module.
-
-class spatialpy.core.DataFunction(name=None)[source]¶
+class spatialpy.core.DataFunction(name=None)[source]¶
Bases: object
Abstract class used to constuct the data function.
@@ -2186,14 +2064,14 @@ Submodules
-
-exception spatialpy.core.DataFunctionError[source]¶
+exception spatialpy.core.DataFunctionError[source]¶
Bases: spatialpy.core.spatialpyerror.ModelError
Class for exceptions in the datafunction module.
-
-class spatialpy.core.Domain(numpoints, xlim, ylim, zlim, rho0=1.0, c0=10, P0=None, gravity=None)[source]¶
+class spatialpy.core.Domain(numpoints, xlim, ylim, zlim, rho0=1.0, c0=10, P0=None, gravity=None)[source]¶
Bases: object
Domain class for SpatialPy. A domain defines points and attributes of a regional space for simulation.
@@ -2284,7 +2162,7 @@ Submodules
-
-classmethod create_2D_domain(xlim, ylim, nx, ny, type_id=1, mass=1.0, nu=1.0, rho=None, c=0, fixed=False, **kwargs)[source]¶
+classmethod create_2D_domain(xlim, ylim, nx, ny, type_id=1, mass=1.0, nu=1.0, rho=None, c=0, fixed=False, **kwargs)[source]¶
Create a filled 2D domain
- Parameters
@@ -2313,7 +2191,7 @@ Submodules
-
-classmethod create_3D_domain(xlim, ylim, zlim, nx, ny, nz, type_id=1, mass=1.0, nu=1.0, rho=None, c=0, fixed=False, **kwargs)[source]¶
+classmethod create_3D_domain(xlim, ylim, zlim, nx, ny, nz, type_id=1, mass=1.0, nu=1.0, rho=None, c=0, fixed=False, **kwargs)[source]¶
Create a filled 3D domain
- Parameters
@@ -2369,8 +2247,7 @@ Submodules
- Parameters
-geometry_ivar (spatialpy.core.geometry.Geometry) – an instance of a spatialpy.core.geometry.Geometry subclass. The ‘inside()’ method
-of this object will be used to create add the particles.
+geometry_ivar (spatialpy.core.geometry.Geometry) – an instance of a spatialpy.core.geometry.Geometry subclass. The ‘inside()’ method of this object will be used to create add the particles.
deltax (float) – Distance between particles on the x-axis.
deltay (float) – Distance between particles on the y-axis (defaults to deltax).
deltaz (float) – Distance between particles on the z-axis (defaults to deltax).
@@ -2500,7 +2377,7 @@ Submodules
-
-classmethod import_meshio_object(mesh_obj)[source]¶
+classmethod import_meshio_object(mesh_obj)[source]¶
Import a python meshio mesh object.
- Parameters
@@ -2517,7 +2394,7 @@ Submodules
-
-plot_types(width=None, height=None, colormap=None, size=5, title=None, included_types_list=None, use_matplotlib=False, return_plotly_figure=False)[source]¶
+plot_types(width=None, height=None, colormap=None, size=None, title=None, included_types_list=None, use_matplotlib=False, return_plotly_figure=False)[source]¶
Plots the domain using plotly. Can only be viewed in a Jupyter Notebook.
- Parameters
@@ -2543,7 +2420,7 @@ Submodules
-
-classmethod read_msh_file(filename)[source]¶
+classmethod read_msh_file(filename)[source]¶
Read a Gmsh style .msh file
- Parameters
@@ -2560,7 +2437,7 @@ Submodules
-
-classmethod read_stochss_domain(filename)[source]¶
+classmethod read_stochss_domain(filename)[source]¶
Read a StochSS Domain (.domn) file or pull a StochSS Domain from a StochSS Spatial Model (.smdl) file.
- Parameters
@@ -2594,7 +2471,7 @@ Submodules
-
-classmethod read_xml_mesh(filename)[source]¶
+classmethod read_xml_mesh(filename)[source]¶
Read a FEniCS/dolfin style XML mesh file
- Parameters
@@ -2616,8 +2493,7 @@ Submodules
- Parameters
-geometry_ivar (spatialpy.core.geometry.Geometry) – an instance of a spatialpy.core.geometry.Geometry subclass. The ‘inside()’ method
-of this object will be used to assign properties to points.
+geometry_ivar (spatialpy.core.geometry.Geometry) – an instance of a spatialpy.core.geometry.Geometry subclass. The ‘inside()’ method of this object will be used to assign properties to points.
type_id (str | int) – The identifier for this type.
vol (float) – The volume of each particle in the type.
mass (float) – The mass of each particle in the type.
@@ -2643,14 +2519,14 @@ Submodules
-
-exception spatialpy.core.DomainError[source]¶
+exception spatialpy.core.DomainError[source]¶
Bases: spatialpy.core.spatialpyerror.ModelError
Class for exceptions in the domain module.
-
-class spatialpy.core.Geometry[source]¶
+class spatialpy.core.Geometry[source]¶
Bases: object
Geometry class provides a method for tagging parts of the spatial domain as separate parts.
@@ -2676,7 +2552,7 @@ Submodules
-
-class spatialpy.core.GeometryAll[source]¶
+class spatialpy.core.GeometryAll[source]¶
Bases: spatialpy.core.geometry.Geometry
Mark all particles.
@@ -2702,14 +2578,14 @@ Submodules
-
-exception spatialpy.core.GeometryError[source]¶
+exception spatialpy.core.GeometryError[source]¶
Bases: spatialpy.core.spatialpyerror.ModelError
Class for exceptions in the geometry module.
-
-class spatialpy.core.GeometryExterior[source]¶
+class spatialpy.core.GeometryExterior[source]¶
Bases: spatialpy.core.geometry.Geometry
Mark particles that are on the edge of the domain.
only works for domains that define triangles and tetrahedrons.
@@ -2736,7 +2612,7 @@ Submodules
-
-class spatialpy.core.GeometryInterior[source]¶
+class spatialpy.core.GeometryInterior[source]¶
Bases: spatialpy.core.geometry.Geometry
Mark particles that are not on the edge of the domain.
Only works for domains that define triangles and tetrahedrons.
@@ -2763,7 +2639,7 @@ Submodules
-
-class spatialpy.core.InitialCondition[source]¶
+class spatialpy.core.InitialCondition[source]¶
Bases: object
Class used to defined initial conditions in SpatialPy.
SubClasses must implement the ‘apply(model)’ method, which
@@ -2783,43 +2659,46 @@
Submodules
-
-exception spatialpy.core.InitialConditionError[source]¶
+exception spatialpy.core.InitialConditionError[source]¶
Bases: spatialpy.core.spatialpyerror.ModelError
Class for exceptions in initailcondition module.
-
-class spatialpy.core.KDTree(data, leafsize=10)[source]¶
-Bases: object
-kd-tree for quick nearest-neighbor lookup
-This class provides an index into a set of k-D points which
-can be used to rapidly look up the nearest neighbors of any point.
+class spatialpy.core.KDTree(data, leafsize=10, compact_nodes=True, copy_data=False, balanced_tree=True, boxsize=None)[source]¶
+Bases: scipy.spatial.ckdtree.cKDTree
+kd-tree for quick nearest-neighbor lookup.
+This class provides an index into a set of k-dimensional points
+which can be used to rapidly look up the nearest neighbors of any
+point.
- Parameters
-data ((N,K) array_like) – The data points to be indexed. This array is not copied, and
-so modifying this data will result in bogus results.
-leafsize (int, optional) – The number of points at which the algorithm switches over to
-brute-force. Has to be positive.
+data (array_like, shape (n,m)) – The n data points of dimension m to be indexed. This array is
+not copied unless this is necessary to produce a contiguous
+array of doubles, and so modifying this data will result in
+bogus results. The data are also copied if the kd-tree is built
+with copy_data=True.
+leafsize (positive int, optional) – The number of points at which the algorithm switches over to
+brute-force. Default: 10.
+compact_nodes (bool, optional) – If True, the kd-tree is built to shrink the hyperrectangles to
+the actual data range. This usually gives a more compact tree that
+is robust against degenerated input data and gives faster queries
+at the expense of longer build time. Default: True.
+copy_data (bool, optional) – If True the data is always copied to protect the kd-tree against
+data corruption. Default: False.
+balanced_tree (bool, optional) – If True, the median is used to split the hyperrectangles instead of
+the midpoint. This usually gives a more compact tree and
+faster queries at the expense of longer build time. Default: True.
+boxsize (array_like or scalar, optional) – Apply a m-d toroidal topology to the KDTree.. The topology is generated
+by \(x_i + n_i L_i\) where \(n_i\) are integers and \(L_i\)
+is the boxsize along i-th dimension. The input data shall be wrapped
+into \([0, L_i)\). A ValueError is raised if any of the data is
+outside of this bound.
-- Raises
-RuntimeError – The maximum recursion limit can be exceeded for large data
- sets. If this happens, either increase the value for the leafsize
- parameter or increase the recursion limit by::
-
- >>> import sys
- >>> sys.setrecursionlimit(10000)
-
-
-See also
-
-cKDTreeImplementation of KDTree in Cython
-
-
-
Notes
The algorithm used is described in Maneewongvatana and Mount 1999.
The general idea is that the kd-tree is a binary tree, each of whose
@@ -2836,153 +2715,414 @@
Submodules
+-
+data¶
+The n data points of dimension m to be indexed. This array is
+not copied unless this is necessary to produce a contiguous
+array of doubles. The data are also copied if the kd-tree is built
+with copy_data=True.
+
+- Type
+ndarray, shape (n,m)
+
+
+
+
+
+-
+leafsize¶
+The number of points at which the algorithm switches over to
+brute-force.
+
+- Type
+positive int
+
+
+
+
+
+-
+m¶
+The dimension of a single data-point.
+
+- Type
+int
+
+
+
+
+
+-
+n¶
+The number of data points.
+
+- Type
+int
+
+
+
+
+
+-
+maxes¶
+The maximum value in each dimension of the n data points.
+
+- Type
+ndarray, shape (m,)
+
+
+
+
+
+-
+mins¶
+The minimum value in each dimension of the n data points.
+
+- Type
+ndarray, shape (m,)
+
+
+
+
+
+-
+size¶
+The number of nodes in the tree.
+
+- Type
+int
+
+
+
+
-
-count_neighbors(other, r, p=2.0)[source]¶
+count_neighbors(other, r, p=2.0, weights=None, cumulative=True)[source]¶
Count how many nearby pairs can be formed.
-Count the number of pairs (x1,x2) can be formed, with x1 drawn
-from self and x2 drawn from other, and where
-distance(x1, x2, p) <= r.
-This is the “two-point correlation” described in Gray and Moore 2000,
-“N-body problems in statistical learning”, and the code here is based
-on their algorithm.
+Count the number of pairs (x1,x2) can be formed, with x1 drawn
+from self and x2 drawn from other, and where
+distance(x1, x2, p) <= r.
+Data points on self and other are optionally weighted by the
+weights argument. (See below)
+This is adapted from the “two-point correlation” algorithm described by
+Gray and Moore 1. See notes for further discussion.
- Parameters
-other (KDTree instance) – The other tree to draw points from.
+other (KDTree) – The other tree to draw points from, can be the same tree as self.
r (float or one-dimensional array of floats) – The radius to produce a count for. Multiple radii are searched with
-a single tree traversal.
-p (float, 1<=p<=infinity, optional) – Which Minkowski p-norm to use
+a single tree traversal.
+If the count is non-cumulative(cumulative=False), r defines
+the edges of the bins, and must be non-decreasing.
+p (float, optional) – 1<=p<=infinity.
+Which Minkowski p-norm to use.
+Default 2.0.
+A finite large p may cause a ValueError if overflow can occur.
+weights (tuple, array_like, or None, optional) –
If None, the pair-counting is unweighted.
+If given as a tuple, weights[0] is the weights of points in
+self, and weights[1] is the weights of points in other;
+either can be None to indicate the points are unweighted.
+If given as an array_like, weights is the weights of points in
+self and other. For this to make sense, self and
+other must be the same tree. If self and other are two
+different trees, a ValueError is raised.
+Default: None
+
+New in version 1.6.0.
+
+
+cumulative (bool, optional) –
Whether the returned counts are cumulative. When cumulative is set
+to False the algorithm is optimized to work with a large number
+of bins (>10) specified by r. When cumulative is set to
+True, the algorithm is optimized to work with a small number of
+r. Default: True
+
+New in version 1.6.0.
+
+
- Returns
-result – The number of pairs. Note that this is internally stored in a numpy
-int, and so may overflow if very large (2e9).
+result – The number of pairs. For unweighted counts, the result is integer.
+For weighted counts, the result is float.
+If cumulative is False, result[i] contains the counts with
+(-inf if i == 0 else r[i-1]) < R <= r[i]
- Return type
-int or 1-D array of ints
+scalar or 1-D array
+Notes
+Pair-counting is the basic operation used to calculate the two point
+correlation functions from a data set composed of position of objects.
+Two point correlation function measures the clustering of objects and
+is widely used in cosmology to quantify the large scale structure
+in our Universe, but it may be useful for data analysis in other fields
+where self-similar assembly of objects also occur.
+The Landy-Szalay estimator for the two point correlation function of
+D measures the clustering signal in D. 2
+For example, given the position of two sets of objects,
+
+objects D (data) contains the clustering signal, and
+objects R (random) that contains no signal,
+
+
+\[\xi(r) = \frac{<D, D> - 2 f <D, R> + f^2<R, R>}{f^2<R, R>},\]
+where the brackets represents counting pairs between two data sets
+in a finite bin around r (distance), corresponding to setting
+cumulative=False, and f = float(len(D)) / float(len(R)) is the
+ratio between number of objects from data and random.
+The algorithm implemented here is loosely based on the dual-tree
+algorithm described in 1. We switch between two different
+pair-cumulation scheme depending on the setting of cumulative.
+The computing time of the method we use when for
+cumulative == False does not scale with the total number of bins.
+The algorithm for cumulative == True scales linearly with the
+number of bins, though it is slightly faster when only
+1 or 2 bins are used. 5.
+As an extension to the naive pair-counting,
+weighted pair-counting counts the product of weights instead
+of number of pairs.
+Weighted pair-counting is used to estimate marked correlation functions
+(3, section 2.2),
+or to properly calculate the average of data per distance bin
+(e.g. 4, section 2.1 on redshift).
+
+- 1(1,2)
+Gray and Moore,
+“N-body problems in statistical learning”,
+Mining the sky, 2000,
+https://arxiv.org/abs/astro-ph/0012333
+
+- 2
+Landy and Szalay,
+“Bias and variance of angular correlation functions”,
+The Astrophysical Journal, 1993,
+http://adsabs.harvard.edu/abs/1993ApJ…412…64L
+
+- 3
+Sheth, Connolly and Skibba,
+“Marked correlations in galaxy formation models”,
+Arxiv e-print, 2005,
+https://arxiv.org/abs/astro-ph/0511773
+
+- 4
+Hawkins, et al.,
+“The 2dF Galaxy Redshift Survey: correlation functions,
+peculiar velocities and the matter density of the Universe”,
+Monthly Notices of the Royal Astronomical Society, 2002,
+http://adsabs.harvard.edu/abs/2003MNRAS.346…78H
+
+- 5
+https://github.com/scipy/scipy/pull/5647#issuecomment-168474926
+
+
+Examples
+You can count neighbors number between two kd-trees within a distance:
+>>> import numpy as np
+>>> from scipy.spatial import KDTree
+>>> rng = np.random.default_rng()
+>>> points1 = rng.random((5, 2))
+>>> points2 = rng.random((5, 2))
+>>> kd_tree1 = KDTree(points1)
+>>> kd_tree2 = KDTree(points2)
+>>> kd_tree1.count_neighbors(kd_tree2, 0.2)
+1
+
+
+This number is same as the total pair number calculated by
+query_ball_tree:
+>>> indexes = kd_tree1.query_ball_tree(kd_tree2, r=0.2)
+>>> sum([len(i) for i in indexes])
+1
+
+
-
-class innernode(split_dim, split, less, greater)[source]¶
+class innernode(ckdtreenode)[source]¶
Bases: scipy.spatial.kdtree.KDTree.node
+
+-
+property children¶
+
+
+
+-
+property split¶
+
+
+
+-
+property split_dim¶
+
+
-
-class leafnode(idx)[source]¶
+class leafnode(ckdtree_node=None)[source]¶
Bases: scipy.spatial.kdtree.KDTree.node
+
+-
+property children¶
+
+
+
+-
+property idx¶
+
+
-
-query(x, k=1, eps=0, p=2, distance_upper_bound=inf)[source]¶
-Query the kd-tree for nearest neighbors
+query(x, k=1, eps=0, p=2, distance_upper_bound=inf, workers=1)[source]¶
+Query the kd-tree for nearest neighbors.
- Parameters
x (array_like, last dimension self.m) – An array of points to query.
-k (int, optional) – The number of nearest neighbors to return.
+k (int or Sequence[int], optional) – Either the number of nearest neighbors to return, or a list of the
+k-th nearest neighbors to return, starting from 1.
eps (nonnegative float, optional) – Return approximate nearest neighbors; the kth returned value
is guaranteed to be no further than (1+eps) times the
distance to the real kth nearest neighbor.
p (float, 1<=p<=infinity, optional) – Which Minkowski p-norm to use.
-1 is the sum-of-absolute-values “Manhattan” distance
-2 is the usual Euclidean distance
-infinity is the maximum-coordinate-difference distance
+1 is the sum-of-absolute-values distance (“Manhattan” distance).
+2 is the usual Euclidean distance.
+infinity is the maximum-coordinate-difference distance.
+A large, finite p may cause a ValueError if overflow can occur.
distance_upper_bound (nonnegative float, optional) – Return only neighbors within this distance. This is used to prune
tree searches, so if you are doing a series of nearest-neighbor
queries, it may help to supply the distance to the nearest neighbor
of the most recent point.
+workers (int, optional) –
Number of workers to use for parallel processing. If -1 is given
+all CPU threads are used. Default: 1.
+
+New in version 1.6.0.
+
+
- Returns
-
+
d (float or array of floats) – The distances to the nearest neighbors.
-If x has shape tuple+(self.m,), then d has shape tuple if
-k is one, or tuple+(k,) if k is larger than one. Missing
-neighbors (e.g. when k > n or distance_upper_bound is
-given) are indicated with infinite distances. If k is None,
-then d is an object array of shape tuple, containing lists
-of distances. In either case the hits are sorted by distance
-(nearest first).
-i (integer or array of integers) – The locations of the neighbors in self.data. i is the same
-shape as d.
+If x has shape tuple+(self.m,), then d has shape
+tuple+(k,).
+When k == 1, the last dimension of the output is squeezed.
+Missing neighbors are indicated with infinite distances.
+Hits are sorted by distance (nearest first).
+
+Deprecated since version 1.6.0: If k=None, then d is an object array of shape tuple,
+containing lists of distances. This behavior is deprecated and
+will be removed in SciPy 1.8.0, use query_ball_point
+instead.
+
+
+i (integer or array of integers) – The index of each neighbor in self.data.
+i is the same shape as d.
+Missing neighbors are indicated with self.n.
Examples
->>> from scipy import spatial
+>>> import numpy as np
+>>> from scipy.spatial import KDTree
>>> x, y = np.mgrid[0:5, 2:8]
->>> tree = spatial.KDTree(list(zip(x.ravel(), y.ravel())))
->>> tree.data
-array([[0, 2],
- [0, 3],
- [0, 4],
- [0, 5],
- [0, 6],
- [0, 7],
- [1, 2],
- [1, 3],
- [1, 4],
- [1, 5],
- [1, 6],
- [1, 7],
- [2, 2],
- [2, 3],
- [2, 4],
- [2, 5],
- [2, 6],
- [2, 7],
- [3, 2],
- [3, 3],
- [3, 4],
- [3, 5],
- [3, 6],
- [3, 7],
- [4, 2],
- [4, 3],
- [4, 4],
- [4, 5],
- [4, 6],
- [4, 7]])
->>> pts = np.array([[0, 0], [2.1, 2.9]])
->>> tree.query(pts)
-(array([ 2. , 0.14142136]), array([ 0, 13]))
->>> tree.query(pts[0])
-(2.0, 0)
+>>> tree = KDTree(np.c_[x.ravel(), y.ravel()])
+
+
+To query the nearest neighbours and return squeezed result, use
+>>> dd, ii = tree.query([[0, 0], [2.2, 2.9]], k=1)
+>>> print(dd, ii, sep='\n')
+[2. 0.2236068]
+[ 0 13]
+
+
+To query the nearest neighbours and return unsqueezed result, use
+>>> dd, ii = tree.query([[0, 0], [2.2, 2.9]], k=[1])
+>>> print(dd, ii, sep='\n')
+[[2. ]
+ [0.2236068]]
+[[ 0]
+ [13]]
+
+
+To query the second nearest neighbours and return unsqueezed result,
+use
+>>> dd, ii = tree.query([[0, 0], [2.2, 2.9]], k=[2])
+>>> print(dd, ii, sep='\n')
+[[2.23606798]
+ [0.80622577]]
+[[ 6]
+ [19]]
+
+
+To query the first and second nearest neighbours, use
+>>> dd, ii = tree.query([[0, 0], [2.2, 2.9]], k=2)
+>>> print(dd, ii, sep='\n')
+[[2. 2.23606798]
+ [0.2236068 0.80622577]]
+[[ 0 6]
+ [13 19]]
+
+
+or, be more specific
+>>> dd, ii = tree.query([[0, 0], [2.2, 2.9]], k=[1, 2])
+>>> print(dd, ii, sep='\n')
+[[2. 2.23606798]
+ [0.2236068 0.80622577]]
+[[ 0 6]
+ [13 19]]
-
-query_ball_point(x, r, p=2.0, eps=0)[source]¶
+query_ball_point(x, r, p=2.0, eps=0, workers=1, return_sorted=None, return_length=False)[source]¶
Find all points within distance r of point(s) x.
- Parameters
x (array_like, shape tuple + (self.m,)) – The point or points to search for neighbors of.
-r (positive float) – The radius of points to return.
-p (float, optional) – Which Minkowski p-norm to use. Should be in the range [1, inf].
+r (array_like, float) – The radius of points to return, must broadcast to the length of x.
+p (float, optional) – Which Minkowski p-norm to use. Should be in the range [1, inf].
+A finite large p may cause a ValueError if overflow can occur.
eps (nonnegative float, optional) – Approximate search. Branches of the tree are not explored if their
nearest points are further than r / (1 + eps), and branches are
added in bulk if their furthest points are nearer than
r * (1 + eps).
+workers (int, optional) –
Number of jobs to schedule for parallel processing. If -1 is given
+all processors are used. Default: 1.
+
+New in version 1.6.0.
+
+
+return_sorted (bool, optional) –
Sorts returned indicies if True and does not sort them if False. If
+None, does not sort single point queries, but does sort
+multi-point queries which was the behavior before this option
+was added.
+
+New in version 1.6.0.
+
+
+return_length (bool, optional) –
Return the number of points inside the radius instead of a list
+of the indices.
+
+New in version 1.6.0.
+
+
- Returns
@@ -3003,7 +3143,7 @@ Submodules>>> x, y = np.mgrid[0:5, 0:5]
>>> points = np.c_[x.ravel(), y.ravel()]
>>> tree = spatial.KDTree(points)
->>> tree.query_ball_point([2, 0], 1)
+>>> sorted(tree.query_ball_point([2, 0], 1))
[5, 10, 11, 15]
@@ -3023,7 +3163,8 @@ Submodules
-
query_ball_tree(other, r, p=2.0, eps=0)[source]¶
-Find all pairs of points whose distance is at most r
+Find all pairs of points between self and other whose distance is
+at most r.
- Parameters
@@ -3045,12 +3186,33 @@ Submoduleslist of lists
+Examples
+You can search all pairs of points between two kd-trees within a distance:
+>>> import matplotlib.pyplot as plt
+>>> import numpy as np
+>>> from scipy.spatial import KDTree
+>>> rng = np.random.default_rng()
+>>> points1 = rng.random((15, 2))
+>>> points2 = rng.random((15, 2))
+>>> plt.figure(figsize=(6, 6))
+>>> plt.plot(points1[:, 0], points1[:, 1], "xk", markersize=14)
+>>> plt.plot(points2[:, 0], points2[:, 1], "og", markersize=14)
+>>> kd_tree1 = KDTree(points1)
+>>> kd_tree2 = KDTree(points2)
+>>> indexes = kd_tree1.query_ball_tree(kd_tree2, r=0.2)
+>>> for i in range(len(indexes)):
+... for j in indexes[i]:
+... plt.plot([points1[i, 0], points2[j, 0]],
+... [points1[i, 1], points2[j, 1]], "-r")
+>>> plt.show()
+
+
-
-query_pairs(r, p=2.0, eps=0)[source]¶
-Find all pairs of points within a distance.
+query_pairs(r, p=2.0, eps=0, output_type='set')[source]¶
+Find all pairs of points in self whose distance is at most r.
- Parameters
-
- Returns
results – Set of pairs (i,j), with i < j, for which the corresponding
-positions are close.
+positions are close. If output_type is ‘ndarray’, an ndarry is
+returned instead of a set.
- Return type
-set
+set or ndarray
+Examples
+You can search all pairs of points in a kd-tree within a distance:
+>>> import matplotlib.pyplot as plt
+>>> import numpy as np
+>>> from scipy.spatial import KDTree
+>>> rng = np.random.default_rng()
+>>> points = rng.random((20, 2))
+>>> plt.figure(figsize=(6, 6))
+>>> plt.plot(points[:, 0], points[:, 1], "xk", markersize=14)
+>>> kd_tree = KDTree(points)
+>>> pairs = kd_tree.query_pairs(r=0.2)
+>>> for (i, j) in pairs:
+... plt.plot([points[i, 0], points[j, 0]],
+... [points[i, 1], points[j, 1]], "-r")
+>>> plt.show()
+
+
-
-sparse_distance_matrix(other, max_distance, p=2.0)[source]¶
-Compute a sparse distance matrix
+sparse_distance_matrix(other, max_distance, p=2.0, output_type='dok_matrix')[source]¶
+Compute a sparse distance matrix.
Computes a distance matrix between two KDTrees, leaving as zero
any distance greater than max_distance.
@@ -3084,23 +3269,66 @@ Submodules
other (KDTree) –
max_distance (positive float) –
-p (float, optional) –
+p (float, 1<=p<=infinity) – Which Minkowski p-norm to use.
+A finite large p may cause a ValueError if overflow can occur.
+output_type (string, optional) –
Which container to use for output data. Options: ‘dok_matrix’,
+‘coo_matrix’, ‘dict’, or ‘ndarray’. Default: ‘dok_matrix’.
+
+New in version 1.6.0.
+
+
- Returns
-result – Sparse matrix representing the results in “dictionary of keys” format.
+result – Sparse matrix representing the results in “dictionary of keys”
+format. If a dict is returned the keys are (i,j) tuples of indices.
+If output_type is ‘ndarray’ a record array with fields ‘i’, ‘j’,
+and ‘v’ is returned,
- Return type
-dok_matrix
+dok_matrix, coo_matrix, dict or ndarray
+Examples
+You can compute a sparse distance matrix between two kd-trees:
+>>> import numpy as np
+>>> from scipy.spatial import KDTree
+>>> rng = np.random.default_rng()
+>>> points1 = rng.random((5, 2))
+>>> points2 = rng.random((5, 2))
+>>> kd_tree1 = KDTree(points1)
+>>> kd_tree2 = KDTree(points2)
+>>> sdm = kd_tree1.sparse_distance_matrix(kd_tree2, 0.3)
+>>> sdm.toarray()
+array([[0. , 0. , 0.12295571, 0. , 0. ],
+ [0. , 0. , 0. , 0. , 0. ],
+ [0.28942611, 0. , 0. , 0.2333084 , 0. ],
+ [0. , 0. , 0. , 0. , 0. ],
+ [0.24617575, 0.29571802, 0.26836782, 0. , 0. ]])
+
+
+You can check distances above the max_distance are zeros:
+>>> from scipy.spatial import distance_matrix
+>>> distance_matrix(points1, points2)
+array([[0.56906522, 0.39923701, 0.12295571, 0.8658745 , 0.79428925],
+ [0.37327919, 0.7225693 , 0.87665969, 0.32580855, 0.75679479],
+ [0.28942611, 0.30088013, 0.6395831 , 0.2333084 , 0.33630734],
+ [0.31994999, 0.72658602, 0.71124834, 0.55396483, 0.90785663],
+ [0.24617575, 0.29571802, 0.26836782, 0.57714465, 0.6473269 ]])
+
+
+
+-
+property tree¶
+
+
-
-class spatialpy.core.Model(name='spatialpy')[source]¶
+class spatialpy.core.Model(name='spatialpy')[source]¶
Bases: object
Representation of a spatial biochemical model.
@@ -3431,7 +3659,7 @@ Submodules
-
-reserved_names = ['vol', 't']¶
+reserved_names = ['vol', 't']¶
@@ -3525,7 +3753,7 @@ Submodules
-
-special_characters = ['[', ']', '+', '-', '*', '/', '.', '^']¶
+special_characters = ['[', ']', '+', '-', '*', '/', '.', '^']¶
@@ -3556,14 +3784,14 @@ Submodules
-
-exception spatialpy.core.ModelError[source]¶
+exception spatialpy.core.ModelError[source]¶
Bases: Exception
Class for exceptions in the model module.
-
-class spatialpy.core.OrderedDict[source]¶
+class spatialpy.core.OrderedDict[source]¶
Bases: dict
Dictionary that remembers insertion order
@@ -3584,12 +3812,12 @@ Submodules
-
-items() a set-like object providing a view on D’s items¶
+items() a set-like object providing a view on D's items¶
-
-keys() a set-like object providing a view on D’s keys¶
+keys() a set-like object providing a view on D's keys¶
@@ -3601,7 +3829,7 @@ Submodules
-
-pop(k[, d]) v, remove specified key and return the corresponding¶
+pop(k[, d]) v, remove specified key and return the corresponding¶
value. If key is not found, d is returned if given, otherwise KeyError
is raised.
@@ -3622,7 +3850,7 @@ Submodules
-
-update([E, ]**F) None. Update D from dict/iterable E and F.¶
+update([E, ]**F) None. Update D from dict/iterable E and F.¶
If E is present and has a .keys() method, then does: for k in E: D[k] = E[k]
If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v
In either case, this is followed by: for k in F: D[k] = F[k]
@@ -3630,14 +3858,14 @@ Submodules
-
-values() an object providing a view on D’s values¶
+values() an object providing a view on D's values¶
-
-class spatialpy.core.Parameter(name=None, expression=None)[source]¶
+class spatialpy.core.Parameter(name=None, expression=None)[source]¶
Bases: object
Model of a rate paramter.
A parameter can be given as a String expression (function) or directly as a scalar value.
@@ -3655,14 +3883,14 @@
Submodules
-
-exception spatialpy.core.ParameterError[source]¶
+exception spatialpy.core.ParameterError[source]¶
Bases: spatialpy.core.spatialpyerror.ModelError
Class for exceptions in parameter module.
-
-class spatialpy.core.PlaceInitialCondition(species, count, location)[source]¶
+class spatialpy.core.PlaceInitialCondition(species, count, location)[source]¶
Bases: spatialpy.core.initialcondition.InitialCondition
Class used to defined the place initial condition in SpatialPy.
@@ -3689,7 +3917,7 @@ Submodules
-
-class spatialpy.core.Reaction(name='', reactants=None, products=None, propensity_function=None, rate=None, annotation=None, restrict_to=None)[source]¶
+class spatialpy.core.Reaction(name='', reactants=None, products=None, propensity_function=None, rate=None, annotation=None, restrict_to=None)[source]¶
Bases: object
Models a biochemical reaction. A reaction conatains dictionaries of species (reactants and products) and parameters. The reaction’s propensity function needs to be evaluable and result in a non-negative scalar value in the namespace defined by the union of its Reactant, Product and Parameter dictionaries. For mass-action, zeroth, first and second order reactions are supported, attempting to used higher orders will result in an error.
@@ -3759,14 +3987,14 @@ Submodules
-
-exception spatialpy.core.ReactionError[source]¶
+exception spatialpy.core.ReactionError[source]¶
Bases: spatialpy.core.spatialpyerror.ModelError
Class for exceptions in reaction module.
-
-class spatialpy.core.Result(model=None, result_dir=None)[source]¶
+class spatialpy.core.Result(model=None, result_dir=None)[source]¶
Bases: object
Result object for a URDME simulation.
@@ -3830,7 +4058,7 @@ Submodules
-
-plot_property(property_name, t_ndx=None, t_val=None, p_ndx=0, width=None, height=None, colormap=None, size=5, title=None, animated=False, t_ndx_list=None, speed=1, f_duration=500, t_duration=300, included_types_list=None, return_plotly_figure=False, use_matplotlib=False, debug=False)[source]¶
+plot_property(property_name, t_ndx=None, t_val=None, p_ndx=0, width=None, height=None, colormap=None, size=None, title=None, animated=False, t_ndx_list=None, speed=1, f_duration=500, t_duration=300, included_types_list=None, return_plotly_figure=False, use_matplotlib=False, debug=False)[source]¶
Plots the Results using plotly. Can only be viewed in a Jupyter Notebook.
- Parameters
@@ -3977,14 +4205,14 @@ Submodules
-
-exception spatialpy.core.ResultError[source]¶
+exception spatialpy.core.ResultError[source]¶
Bases: Exception
Class for exceptions in the results module.
-
-class spatialpy.core.ScatterInitialCondition(species, count, types=None)[source]¶
+class spatialpy.core.ScatterInitialCondition(species, count, types=None)[source]¶
Bases: spatialpy.core.initialcondition.InitialCondition
Class used to defined the scatter initial condition in SpatialPy.
@@ -4011,21 +4239,21 @@ Submodules
-
-exception spatialpy.core.SimulationError[source]¶
+exception spatialpy.core.SimulationError[source]¶
Bases: Exception
Class for exceptions in the simulation module.
-
-exception spatialpy.core.SimulationTimeout[source]¶
+exception spatialpy.core.SimulationTimeout[source]¶
Bases: spatialpy.core.spatialpyerror.SimulationError
Exception raised for timeout errors.
-
-class spatialpy.core.Species(name=None, diffusion_coefficient=None, restrict_to=None)[source]¶
+class spatialpy.core.Species(name=None, diffusion_coefficient=None, restrict_to=None)[source]¶
Bases: object
Model of a biochemical species. Must be assigned a diffusion coefficent.
@@ -4055,14 +4283,14 @@ Submodules
-
-exception spatialpy.core.SpeciesError[source]¶
+exception spatialpy.core.SpeciesError[source]¶
Bases: spatialpy.core.spatialpyerror.ModelError
Class for exceptions in the species module.
-
-class spatialpy.core.UniformInitialCondition(species, count, types=None)[source]¶
+class spatialpy.core.UniformInitialCondition(species, count, types=None)[source]¶
Bases: spatialpy.core.initialcondition.InitialCondition
Class used to defined the uniform initial condition in SpatialPy.
@@ -4089,7 +4317,7 @@ Submodules
-
-class spatialpy.core.VTKReader(filename=None, debug=False)[source]¶
+class spatialpy.core.VTKReader(filename=None, debug=False)[source]¶
Bases: object
VTKReader.py: SpatialPy minimal VTK legacy file reader.
Reference: https://vtk.org/wp-content/uploads/2015/04/file-formats.pdf
@@ -4186,18 +4414,61 @@ Submodules
-
-exception spatialpy.core.VTKReaderError[source]¶
+exception spatialpy.core.VTKReaderError[source]¶
Bases: Exception
Bass class for exceptions in the vtkreader module.
-
-exception spatialpy.core.VTKReaderIOError(message)[source]¶
+exception spatialpy.core.VTKReaderIOError(message)[source]¶
Bases: spatialpy.core.spatialpyerror.VTKReaderError
Exception raised for I/O errors.
+
+-
+class spatialpy.core.Visualization(data)[source]¶
+Bases: object
+
+-
+MPL_HEIGHT = 4.8¶
+
+
+
+-
+MPL_SIZE = 40¶
+
+
+
+-
+MPL_WIDTH = 6.4¶
+
+
+
+-
+plot_scatter(plot_args=None, scatter_args=None, multiple_graphs=False, title=None, limits=None)[source]¶
+Visualize data using maplotlib scatter plots.
+
+- Parameters
+
+plot_args (dict) – additional keyword arguments passed to matplotlib.pyplot.subplots
+scatter_args (dist) – dict of additional keyword arguments passed to matplotlib.pyplot.scatter for each group.
+multiple_graphs (bool | tuple(nrows, ncols)) – if each data entry should be ploted separately or on the same plot. If ploted separately a shape may be provided.
+
+
+
+
+
+
+
+
+-
+exception spatialpy.core.VisualizationError[source]¶
+Bases: Exception
+Class for exceptions in the visualization module.
+
+
-
spatialpy.core.cleanup_build_files(build_dir=None)[source]¶
@@ -4234,7 +4505,7 @@ Submodules
-
-class spatialpy.core.combinations(iterable, r)¶
+class spatialpy.core.combinations(iterable, r)¶
Bases: object
Return successive r-length combinations of elements in the iterable.
combinations(range(4), 3) –> (0,1,2), (0,1,3), (0,2,3), (1,2,3)
@@ -4289,7 +4560,7 @@ Submodules
-- image (default=None |’png’ |’jpeg’ |’svg’ |’webp’) – This parameter sets
the format of the image to be downloaded, if we choose to download an
+
- image (default=None |’png’ |’jpeg’ |’svg’ |’webp’) – This parameter sets
the format of the image to be downloaded, if we choose to download an
image. This parameter has a default value of None indicating that no
image should be downloaded. Please note: for higher resolution images
and more export options, consider using plotly.io.write_image. See
@@ -4326,7 +4597,7 @@
Submodulesiplot([{'x': [1, 2, 3], 'y': [5, 2, 7]}], image='png')
`
animation_opts Example:
-```
+```
from plotly.offline import iplot
figure = {‘data’: [{‘x’: [0, 1], ‘y’: [0, 1]}],
@@ -4343,11 +4614,11 @@ Submodules```
+```
-
-
+
+
@@ -4372,10 +4643,10 @@ Submodules
+
+
+
+