Skip to main content

Simulate snowflakes with Gravner-Griffeath algorithm.

Project description

snowfake

PyPI status PyPI versions PyPI license

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

Experimental

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]

Example

You can produce a random snowfake with:

import snowfake
s = snowfake.random()

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)
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.


© 2021 Agile Scientific, openly licenced under Apache 2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

snowfake-0.2.3.tar.gz (12.7 kB view details)

Uploaded Source

Built Distribution

snowfake-0.2.3-py3-none-any.whl (12.2 kB view details)

Uploaded Python 3

File details

Details for the file snowfake-0.2.3.tar.gz.

File metadata

  • Download URL: snowfake-0.2.3.tar.gz
  • Upload date:
  • Size: 12.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for snowfake-0.2.3.tar.gz
Algorithm Hash digest
SHA256 dc287130331b744677e9ff7e585d14f0768eb46a019c295b4d42394454fba0ee
MD5 44462e160d97a02a97210be3547ca8b6
BLAKE2b-256 0e905f732d81d21ef10597b6de3acf28e32596ba0c7a71f8d02546915e987244

See more details on using hashes here.

File details

Details for the file snowfake-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: snowfake-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 12.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for snowfake-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 88a0e04facc4967e794b55a84c6f18f4e07ebbc6676a763364382eaff00d5e86
MD5 4b51c4585c56284c349aadb37a77c30f
BLAKE2b-256 01df00628e945a53abad93cbb3fdd0dc55c16aa066b1274962aba07224872a59

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page