Simulate snowflakes with Gravner-Griffeath algorithm.
Project description
snowfake
Make Gravner-Griffeath "snowfakes"! This code implements:
Janko Gravner, David Griffeath (2008). Modeling snow crystal growth II: A mesoscopic lattice map with plausible dynamics. Physica D: Nonlinear Phenomena 237 (3), p 385-404. DOI: 10.1016/j.physd.2007.09.008.
Installation
You can install this package with pip
(be careful not to type "snowflake"):
pip install snowfake
Installing scikit-image
allows you to use a different affine transformation, but I haven't figured out yet if it's better or not.
pip install snowfake[skimage]
Documentation
Read the documentation
Example
You can produce a random snowfake with:
import snowfake
s = snowfake.random()
Alternatively, this code produces the crystal in Figure 5b of the Gravner & Griffeath (2008):
from snowfake import Snowfake
params = {
'ρ': 0.35, # or 'rho': 0.35 if you prefer...
'β': 1.4,
'α': 0.001,
'θ': 0.015,
'κ': 0.05,
'μ': 0.015,
'γ': 0.01,
'σ': 0.00005,
'random': False,
}
s = Snowfake(size=801, **params)
Now you're ready to grow and plot the snowfake:
s.grow()
s.plot()
The various physical parameter arrays are available as s.a
(attachment flag), s.b
(boundary mass), s.c
(the crystal itself) and s.d
(the vapour). The arrays exist on hexgrids; you can rectify them with, for example, s.rectify('c')
.
The parameter σ
(note that you can also spell out sigma
if you prefer) can be a 1D array with one sample per epoch. This will vary the vapour density ρ
through time. The parameter ρ
can be a 2D array of shape (size, size)
; this will vary the initial vapour density through space.
Testing
You can run the tests (requires pytest
and pytest-cov
) with
python run_tests.py
Building
This repo uses PEP 517-style packaging. Read more about this and about Python packaging in general.
Building the project requires build
, so first:
pip install build
Then to build snowfake
locally:
python -m build
The builds both .tar.gz
and .whl
files, either of which you can install with pip
.
Continuous integration
This repo has two GitHub 'workflows' or 'actions':
- Push to
main
: Run all tests on all version of Python. This is the Run tests workflow. - Publish a new release: Build and upload to PyPI. This is the Publish to PyPI workflow. Publish using the GitHub interface, for example (read more
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file snowfake-0.2.6.tar.gz
.
File metadata
- Download URL: snowfake-0.2.6.tar.gz
- Upload date:
- Size: 1.8 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c938af6b80a89d6a5848307bd595434aa4ee8f8634747b12bc9fd5cd48c9011c |
|
MD5 | 09f94186cd4a7e0b55cf45f0c66aa6c4 |
|
BLAKE2b-256 | bb82003cdc27007d121c2210aafb8cc771c65fd5bc272d799ed255cb48e6f4cb |
File details
Details for the file snowfake-0.2.6-py3-none-any.whl
.
File metadata
- Download URL: snowfake-0.2.6-py3-none-any.whl
- Upload date:
- Size: 14.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dfa707c0e56ed774c2573c22c2e1c9ed6fdac295cb304c5a7daa9c68a0da9b86 |
|
MD5 | 888cccfa757ea721b4fc5c2905dd4711 |
|
BLAKE2b-256 | 5956764cdc13867b6137262ad7498f8a6b93aac0dab0e7daa1edd130098b0606 |