MSKit — Mini Simulation Kit
MSKit is a lightweight Python library for running terrain-based simulations backed by real-world elevation data from JAXA's AW3D30 30m Digital Elevation Model.
Tiles are streamed on-demand from the MegaBites-AI/AW3D30-DEM-Tiles dataset hosted on Hugging Face — no manual data download required.
Installation
pip install mskit
With optional visualisation support:
pip install mskit[viz]
Quick Start
from mskit import DEMLoader, RandomWalk, Projectile, WaterFlow, TerrainAgent
# Create a loader — tiles are fetched automatically as needed
loader = DEMLoader()
# ── Random Walk ──────────────────────────────────────────────────────────────
rw = RandomWalk(loader, start_lat=35.68, start_lon=139.69, step_m=300)
path = rw.run(steps=500)
print(f"Distance: {rw.total_distance_km():.2f} km")
print(f"Elevation gain: {rw.elevation_gain_m():.0f} m")
# ── Projectile ───────────────────────────────────────────────────────────────
proj = Projectile(loader, lat=36.0, lon=137.5,
azimuth_deg=45, elevation_deg=30, speed_ms=80)
traj = proj.run()
print(f"Range: {proj.range_km():.3f} km | Flight time: {proj.flight_time():.1f} s")
# ── Water Flow ───────────────────────────────────────────────────────────────
wf = WaterFlow(loader, patch_km=10)
flow = wf.run(lat=35.6, lon=137.5)
print(f"Flow length: {len(flow)} steps | Descent: {wf.total_descent_m():.0f} m")
# ── Terrain-Navigating AI Agent ──────────────────────────────────────────────
agent = TerrainAgent(loader,
start_lat=35.60, start_lon=139.70,
target_lat=35.65, target_lon=139.75)
dataset = agent.generate_episode(max_steps=300, policy="mixed")
arr = agent.to_numpy() # shape (N, 7): [step, lat, lon, elev, action, reward, done]
print(f"Episode: {len(dataset)} steps | Reached target: {agent.reached_target()}")
Simulations
| Class | Description |
|---|---|
DEMLoader |
Multi-tile loader with LRU cache. Core data access layer. |
DEMTile |
Single 1°×1° elevation tile with spatial query methods. |
RandomWalk |
Slope-biased 2D random walk on real terrain. |
Projectile |
Ballistic trajectory simulation that terminates on terrain impact. |
WaterFlow |
D8 water runoff routing on real elevation grids. |
TerrainAgent |
RL-ready navigation agent producing training trajectories. |
Dataset
Elevation tiles are served from:
- Source: JAXA ALOS World 3D 30m (AW3D30 v3.2)
- Coverage: Global
- Resolution: 30 m/pixel, 1°×1° tiles (3600×3600 px)
- Format: Compressed NumPy
.npy(int16, metres) - Cache: Tiles are cached locally at
~/.cache/mskit/dem/
Uploading Tiles
To upload tiles to the dataset (MegaBites team only):
# Upload Japan tiles
python scripts/upload_tiles.py --region japan --token $HF_TOKEN
# Upload a custom bounding box
python scripts/upload_tiles.py --lat-range 30 45 --lon-range 130 145 --token $HF_TOKEN
# Dry run first
python scripts/upload_tiles.py --region japan --dry-run
License
- MSKit code: MIT License
- AW3D30 data: © JAXA, CC-BY-4.0
Produced by MegaBites AI