Skip to main content

Moonlight

Matplotlib wave plotting and animation made easy

Installation

  • For pip release - pip install moonlight
  • For source build -
git clone https://github.com/CharlesAverill/moonlight.git moonlight
cd moonlight
python setup.py install

Usage

from moonlight import waves, utils

# Create a damped Sine wave with amplitude, period 2
sine = waves.Sine(amplitude=2, period=2,
                    decay_constant=.25)

# Set range of plot
utils.x_range(-3, 3)
utils.y_range(-4, 4)

# Move axes to center
utils.center_axes()

# Plot 2 periods of the wave (static)
sine.plot(2)

Resulting plot

Animation

Waves can also be animated! Just replace <wave_object>.plot() with <wave_object>.animate()!

animate parameters

  • speed - The speed at which the animation will play. Some waves have their default speed adjusted so that animation can be seen easily.
    • When combining a Square or Sawtooth wave with a Sine or Cosine wave, the sum of the functions naturally grows at an incredibly slow rate, so speed should be set to a multiple of 10**14 to be able to view animations properly.
  • line_width - Sets line width
  • framerate - Measured in ms, this is the time gap between two frames being displayed. Default is 17ms or ~60fps.

Supported Waves

  • Sine
  • Cosine
  • Square
  • Sawtooth
  • Wave - This is a parent class for the previous waves. Custom waves can be implemented by inheriting this class.

Wave parameters

  • amplitude: float = 1 - Initial wave amplitude
  • period: float = <varies by wave> - Period of wave
  • offsets: Tuple(float [x], float [y]) = (0, 0) - X- and Y- offsets of the wave
  • decay_constant: float = 0 - If nonzero, function will decay according to e^(-<decay>x)wavefunc(x). Trig functions only.
  • resolution: int = 500 - Number of x-values that will be generated upon graphing.

Wave operators

Waves can be operated on by each other and by scalar values.

from moonlight.waves import Sine

s1 = Sine()
s2 = Sine(amplitude=2)

add_waves = s1 + s2 # sin(x) + 2sin(x) = 3sin(x)
add_scalar = s1 + 3 # sin(x) + 3

sub_waves = s1 - s2 # sin(x) - 2sin(x) = -sin(x)
sub_scalar = s1 - 3 # sin(x) - 3

mul_waves = s1 * s2 # sin(x) * 2sin(x) = 2sin(x)^2
mul_scalar = s1 * 3 # sin(x) * 3 = 3sin(x)

div_waves = s1 / s2 # sin(x) / 2sin(x) = 1/2
div_scalar = s1 / 3 # sin(x) / 3 = (1/3)sin(x)

call_waves = s1(s2) # sin(2sin(x))
call_scalar = s1(3) # sin(3) ≈ .14112

Metadata

Release files for moonlightplt 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for moonlightplt 0.2.2
File Size Uploaded Provenance Actions
moonlightplt-0.2.2.tar.gz 5.6 kB Without provenance Details for moonlightplt-0.2.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for moonlightplt 0.2.2
File Interpreter ABI Platform Actions
moonlightplt-0.2.2-py3-none-any.whl Python 3 none any Details for moonlightplt-0.2.2-py3-none-any.whl

Total release size: 13.1 kB

Release files / moonlightplt-0.2.2.tar.gz

Download URL moonlightplt-0.2.2.tar.gz
Size 5.6 kB
Tags Source
SHA-256 checksum
How to use checksums
adbb2154460f5574a49f2e6b3f53e189e27788f1c0c34eb6ca71eaca70297a52
BLAKE2b-256 checksum
How to use checksums
935c4bb0c61b0f19f4a9d27387c57e7d92dc9cc6c1245c46f4db8b443cbd901a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.4

Release files / moonlightplt-0.2.2-py3-none-any.whl

Download URL moonlightplt-0.2.2-py3-none-any.whl
Size 7.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6ec8d9b5c47fe5e8561c6b1395442cf772d11b644d717a622b826ad4cb738a2b
BLAKE2b-256 checksum
How to use checksums
0d0e2f91a39ce071a8fd0292dc42710c2c337c41f99bd6ba710aa6f3d8a5d97e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.4

Security for moonlightplt 0.2.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page