Astronomical animations for Manim - Create stunning, scientifically accurate visualizations of astronomical phenomena.
- π Physically accurate stellar models with proper color-temperature relations
- π Galaxy simulations with realistic morphologies
- πͺ Orbital mechanics using real gravitational physics
- π Astronomical diagrams (HR, Hubble, CMDs)
- π Observation planning tools and projections
- π Spectroscopy animations with real line physics
- π Cosmological simulations with proper scaling
pip install manim-astroFor development:
git clone https://github.com/yourusername/manim-astro.git
cd manim-astro
pip install -e ".[dev,docs]"from manim import *
from manim_astro import Star, HRDiagram
class StellarScene(Scene):
def construct(self):
# Create a main sequence star
sun = Star(mass=1.0)
self.add(sun)
# Create an HR diagram
hr_diagram = HRDiagram()
hr_diagram.plot_main_sequence()
self.play(Create(hr_diagram))Full documentation available at manim-astro.readthedocs.io
# Demonstrate mass-luminosity relation
star_sequence = StarSequence(masses=[0.5, 1.0, 2.0, 5.0])
star_sequence.show_scaling_relations()# Animate galaxy collision
galaxy1 = SpiralGalaxy(mass=1e12)
galaxy2 = SpiralGalaxy(mass=5e11)
collision = GalaxyCollision(galaxy1, galaxy2)We welcome contributions! Please see our Contributing Guide.
This project is licensed under the MIT License - see LICENSE file.
- Manim Community for the amazing animation framework
- ASTR596 course at [Your University]
- Astronomical data from ESA Gaia, SDSS, and NASA
If you use manim-astro in your research or teaching, please cite:
@software{manim_astro,
author = {Your Name},
title = {manim-astro: Astronomical Animations for Manim},
year = {2024},
url = {https://github.com/yourusername/manim-astro}
}
### **CONTRIBUTING.md**
```markdown
# Contributing to manim-astro
Thank you for your interest in contributing to manim-astro!
## π Getting Started
1. Fork the repository
2. Clone your fork:
```bash
git clone https://github.com/yourusername/manim-astro.git
cd manim-astro
-
Create a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install in development mode:
pip install -e ".[dev,docs]" pre-commit install
-
Create a new branch:
git checkout -b feature/your-feature-name
-
Make your changes and ensure:
- All tests pass:
pytest - Code is formatted:
black src/ tests/ - Imports are sorted:
isort src/ tests/ - Type hints are correct:
mypy src/
- All tests pass:
-
Write tests for new features
-
Update documentation if needed
-
Commit with descriptive messages:
git commit -m "feat: add binary star system class" -
Push and create a pull request
- Follow PEP 8
- Use Black for formatting
- Add type hints for all functions
- Document with NumPy-style docstrings
Run tests with:
pytest # All tests
pytest tests/unit/test_star.py # Specific file
pytest -v --cov=manim_astro # With coverageBuild docs locally:
cd docs
make html
open _build/html/index.html- New celestial objects: Nebulae, clusters, etc.
- Physical processes: Accretion, jets, shocks
- Observational tools: Telescope simulations
- Educational animations: Tutorials and demos
- Performance optimizations: Speed improvements
- Documentation: Tutorials, examples, API docs
- Ensure all tests pass
- Update CHANGELOG.md
- Update documentation
- Request review from maintainers
Please read our Code of Conduct.
Open an issue or join our Discord: [link]
### **tests/conftest.py** - Pytest Configuration
```python
"""
Pytest configuration and fixtures for manim-astro tests.
"""
import pytest
import numpy as np
from manim import *
import tempfile
import shutil
from pathlib import Path
# Configure Manim for testing
config.verbosity = "WARNING"
config.preview = False
config.progress_bar = "none"
config.background_color = BLACK
@pytest.fixture
def temp_media_dir():
"""Create temporary directory for test media files."""
temp_dir = tempfile.mkdtemp()
original_media_dir = config.media_dir
config.media_dir = temp_dir
yield Path(temp_dir)
# Cleanup
config.media_dir = original_media_dir
shutil.rmtree(temp_dir)
@pytest.fixture
def test_scene():
"""Create a test scene for animations."""
class TestScene(Scene):
def construct(self):
pass
return TestScene()
@pytest.fixture
def sample_star_data():
"""Sample stellar parameters for testing."""
return {
'sun': {'mass': 1.0, 'radius': 1.0, 'temperature': 5772},
'sirius': {'mass': 2.06, 'radius': 1.71, 'temperature': 9940},
'proxima': {'mass': 0.12, 'radius': 0.15, 'temperature': 3042},
'betelgeuse': {'mass': 20, 'radius': 1000, 'temperature': 3500},
}
@pytest.fixture
def sample_galaxy_data():
"""Sample galaxy parameters for testing."""
return {
'milky_way': {
'mass': 1.5e12, # M_sun
'radius': 50000, # pc
'type': 'spiral'
},
'andromeda': {
'mass': 1.2e12,
'radius': 60000,
'type': 'spiral'
}
}
name: Tests
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.8', '3.9', '3.10', '3.11']
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install system dependencies (Ubuntu)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y ffmpeg libcairo2-dev
- name: Install system dependencies (macOS)
if: runner.os == 'macOS'
run: |
brew install ffmpeg cairo
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"
- name: Lint with flake8
run: |
flake8 src/ tests/ --count --select=E9,F63,F7,F82 --show-source --statistics
- name: Check formatting with black
run: |
black --check src/ tests/
- name: Sort imports with isort
run: |
isort --check-only src/ tests/
- name: Type check with mypy
run: |
mypy src/
- name: Test with pytest
run: |
pytest --cov=manim_astro --cov-report=xml --cov-report=term
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
file: ./coverage.xml
flags: unittests
name: codecov-umbrella# 1. Create the repository structure
mkdir manim-astro
cd manim-astro
# 2. Initialize git
git init
git remote add origin https://github.com/yourusername/manim-astro.git
# 3. Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# 4. Create the directory structure
mkdir -p src/manim_astro/{celestial,coordinates,physics,spectroscopy,diagrams,data,utils,animations}
mkdir -p tests/{unit,integration,fixtures}
mkdir -p docs/{api,tutorials,gallery,_static}
mkdir -p examples/{basic,intermediate,advanced}
mkdir -p scripts
mkdir -p media/{images,videos,logos}
mkdir -p .github/workflows
# 5. Create all the configuration files
# Copy the content from above into respective files
# 6. Install in development mode
pip install -e ".[dev,docs]"
# 7. Initialize pre-commit
pre-commit install
# 8. Run initial tests
pytest
# 9. Build documentation
cd docs
sphinx-quickstart
make html
# 10. Initial commit
git add .
git commit -m "feat: initial manim-astro package structure"
git push -u origin main- Set up repository structure
- Configure packaging (pyproject.toml)
- Set up testing framework
- Configure CI/CD (GitHub Actions)
- Set up documentation (Sphinx)
- Create initial Star class
- Write comprehensive tests
- Add example animations
- Configure pre-commit hooks
- Set up code coverage
- Create contribution guidelines
- Add issue templates
- Configure automated releases
- Set up ReadTheDocs
- Create project logo
- Write comprehensive README
### π Complete Directory Structure
manim-astro/
β
βββ π README.md # Main project documentation
βββ π LICENSE # MIT License
βββ π CONTRIBUTING.md # Contribution guidelines
βββ π CHANGELOG.md # Version history
βββ π CODE_OF_CONDUCT.md # Community guidelines
βββ π pyproject.toml # Modern Python packaging config
βββ π setup.cfg # Additional setup configuration
βββ π MANIFEST.in # Include non-Python files
βββ π .gitignore # Git ignore patterns
βββ π .gitattributes # Git attributes
β
βββ π .github/ # GitHub specific files
β βββ π workflows/ # GitHub Actions CI/CD
β β βββ tests.yml # Run tests on push/PR
β β βββ docs.yml # Build and deploy docs
β β βββ release.yml # Automated releases
β β βββ lint.yml # Code quality checks
β βββ π ISSUE_TEMPLATE/ # Issue templates
β β βββ bug_report.md
β β βββ feature_request.md
β β βββ documentation.md
β βββ π PULL_REQUEST_TEMPLATE.md
β
βββ π src/ # Source code (src layout)
β βββ π manim_astro/
β βββ π __init__.py # Package initialization
β βββ π __version__.py # Version information
β β
β βββ π celestial/ # Celestial objects
β β βββ __init__.py
β β βββ star.py # Star class
β β βββ planet.py # Planet classes
β β βββ galaxy.py # Galaxy classes
β β βββ binary.py # Binary systems
β β βββ exotics.py # Pulsars, black holes, etc.
β β
β βββ π coordinates/ # Coordinate systems
β β βββ __init__.py
β β βββ celestial.py # RA/Dec, Alt/Az
β β βββ projections.py # Sky projections
β β βββ transformations.py # Coordinate transforms
β β
β βββ π physics/ # Physical processes
β β βββ __init__.py
β β βββ radiation.py # Radiation processes
β β βββ dynamics.py # Orbital mechanics
β β βββ relativity.py # GR effects
β β βββ cosmology.py # Cosmological models
β β
β βββ π spectroscopy/ # Spectral analysis
β β βββ __init__.py
β β βββ spectrum.py # Spectrum classes
β β βββ lines.py # Spectral lines
β β βββ photometry.py # Photometric tools
β β
β βββ π diagrams/ # Astronomical diagrams
β β βββ __init__.py
β β βββ hr_diagram.py # HR diagram
β β βββ hubble.py # Hubble diagram
β β βββ color_magnitude.py # CMD
β β
β βββ π data/ # Package data
β β βββ __init__.py
β β βββ constants.py # Physical constants
β β βββ catalogs/ # Star catalogs
β β βββ filters/ # Filter curves
β β βββ colormaps/ # Custom colormaps
β β
β βββ π utils/ # Utilities
β β βββ __init__.py
β β βββ units.py # Unit conversions
β β βββ validators.py # Input validation
β β βββ data_loader.py # Load FITS, etc.
β β βββ colors.py # Color utilities
β β
β βββ π animations/ # Pre-built animations
β βββ __init__.py
β βββ stellar_evolution.py
β βββ galaxy_collision.py
β βββ cosmological_evolution.py
β
βββ π tests/ # Test suite
β βββ π __init__.py
β βββ π conftest.py # Pytest configuration
β βββ π unit/ # Unit tests
β β βββ test_star.py
β β βββ test_coordinates.py
β β βββ test_physics.py
β βββ π integration/ # Integration tests
β β βββ test_animations.py
β βββ π fixtures/ # Test data
β βββ sample_data.py
β
βββ π examples/ # Example animations
β βββ π README.md
β βββ π basic/ # Basic examples
β β βββ 01_creating_stars.py
β β βββ 02_hr_diagram.py
β β βββ 03_orbits.py
β βββ π intermediate/ # Intermediate examples
β β βββ stellar_evolution.py
β β βββ binary_systems.py
β β βββ galaxy_rotation.py
β βββ π advanced/ # Advanced examples
β βββ nbody_simulation.py
β βββ cosmological_sim.py
β βββ gravitational_lensing.py
β
βββ π docs/ # Documentation
β βββ π conf.py # Sphinx configuration
β βββ π index.rst # Documentation home
β βββ π installation.rst # Installation guide
β βββ π quickstart.rst # Quick start guide
β βββ π requirements.txt # Docs dependencies
β βββ π api/ # API reference
β β βββ modules.rst
β βββ π tutorials/ # Tutorials
β β βββ index.rst
β β βββ stellar.rst
β β βββ cosmology.rst
β βββ π gallery/ # Example gallery
β β βββ index.rst
β βββ π _static/ # Static files
β βββ css/
β βββ images/
β
βββ π scripts/ # Utility scripts
β βββ generate_catalog.py # Generate star catalogs
β βββ validate_physics.py # Validate physics
β βββ benchmark.py # Performance benchmarks
β
βββ π media/ # Media files
βββ π images/ # README images
βββ π videos/ # Demo videos
βββ π logos/ # Project logos
