Skip to content

Commit bc566cc

Browse files
authored
Merge pull request #117 from uit-cosmo/docstrings
Add docstrings
2 parents e5303e0 + 2353ab2 commit bc566cc

File tree

5 files changed

+46
-6
lines changed

5 files changed

+46
-6
lines changed

blobmodel/blob_shape.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66

77

88
class BlobShapeEnum(Enum):
9+
"""
10+
Enum class representing blob shapes.
11+
"""
12+
913
exp = 1
1014
lorentz = 2
1115
double_exp = 3

blobmodel/blobs.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,25 @@
99

1010

1111
class Blob:
12-
"""Define a single blob."""
12+
"""
13+
Class representing a single blob. It stores all blob parameters and discretizes the blob on a grid through
14+
the function `discretize_blob`. The contribution of a single blob to a grid defined by `x`, `y` and `t` is given by:
15+
16+
.. math::
17+
a e^{-(t-t_k)/\tau_\shortparallel}\varphi\left( \frac{x-v(t-t_k)}{\ell_x}, \frac{(y-y_k)-w(t-t_k)}{\ell_y} \right)
18+
19+
Where:
20+
- :math:`a` is the blob amplitude, `amplitude`.
21+
- :math:`\ell_x` is the blob width in the propagation direction, `width_prop`.
22+
- :math:`\ell_y` is the blob width in the perpendicular direction, `width_perp`.
23+
- :math:`v` is the horizontal blob velocity.
24+
- :math:`w` is the vertical blob velocity.
25+
- :math:`t_k` is the blob arriving time at the position x=0, `t_init`.
26+
- :math:`\tau_\shortparallel` is the drainage time, `t_drain`.
27+
- :math:`\varphi` is the blob pulse shape, `blob_shape`.
28+
29+
Additionally, a tilt angle can be provided through `theta`.
30+
"""
1331

1432
def __init__(
1533
self,
@@ -124,6 +142,11 @@ def discretize_blob(
124142
one_dimensional : bool, optional
125143
Flag indicating a one-dimensional blob (default: False).
126144
145+
Notes
146+
-----
147+
The periodicity in the y direction is implemented by first substracting the number of full domain Ly
148+
propagations made by the blob and by summing mirror blobs at vertical positions +-Ly.
149+
127150
Returns
128151
-------
129152
discretized_blob : NDArray

blobmodel/geometry.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77

88

99
class Geometry:
10-
"""Define grid for Model."""
10+
"""
11+
Represents the space and time grid used by the Model class to discretize the blob evolution.
12+
It builds a meshgrid based on the desired resolution and length in each coordinate.
13+
"""
1114

1215
def __init__(
1316
self,

blobmodel/model.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@
1313

1414

1515
class Model:
16-
"""2D Model of propagating blobs."""
16+
"""
17+
Class storing all parameters relevant for the realization of a random process of a superposition of
18+
uncorrelated pulses propagating in two dimensions. The realization is performed by calling `make_realization` which:
19+
- uses a `BlobFactory` to make a list of blobs following the specified blob parameter distribution functions,
20+
- each 'Blob' is discretized by calling its `discretize_blob` function and
21+
- the discretization is performed on a grid given by the `Geometry`.
22+
"""
1723

1824
def __init__(
1925
self,

blobmodel/stochasticality.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@
88

99

1010
class BlobFactory(ABC):
11-
"""Abstract class used by 2d propagating blob model to specify blob
12-
parameters."""
11+
"""
12+
Abstract class used by 2d propagating blob model to specify blob
13+
parameters.
14+
"""
1315

1416
@abstractmethod
1517
def sample_blobs(
@@ -20,7 +22,9 @@ def sample_blobs(
2022
blob_shape: AbstractBlobShape,
2123
t_drain: Union[float, NDArray],
2224
) -> List[Blob]:
23-
"""creates list of Blobs used in Model."""
25+
"""
26+
Creates a list of Blobs used in Model.
27+
"""
2428
raise NotImplementedError
2529

2630
@abstractmethod

0 commit comments

Comments
 (0)