Commit ·
50464c0
0
Parent(s):
1.0.0 release
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .gitattributes +60 -0
- README.md +526 -0
- c4w-root.json +34 -0
- c4w-root/files.parquet +3 -0
- c4w-root/scenes.parquet +3 -0
- docs/files.png +3 -0
- docs/hf-datasets.md +153 -0
- docs/layout.svg +31 -0
- docs/library-guide.md +186 -0
- docs/ml-guide.md +220 -0
- docs/notebooks/01-read-one-scene-library.ipynb +345 -0
- docs/notebooks/02-read-one-scene-numpy.ipynb +342 -0
- docs/notebooks/03-dataloader.ipynb +322 -0
- docs/overview.png +3 -0
- docs/read_archives.py +108 -0
- docs/scenes.png +3 -0
- docs/schema-reference.md +226 -0
- docs/tutorial-library.md +213 -0
- docs/tutorial-numpy.md +210 -0
- docs/without-library.md +291 -0
- groups/test-metro-g00000/catalog/geometry.parquet +3 -0
- groups/test-metro-g00000/catalog/members.parquet +3 -0
- groups/test-metro-g00000/catalog/objects.parquet +3 -0
- groups/test-metro-g00000/catalog/records.parquet +3 -0
- groups/test-metro-g00000/catalog/scenes.parquet +3 -0
- groups/test-metro-g00000/snapshot.json +0 -0
- groups/test-metro-g00001/catalog/geometry.parquet +3 -0
- groups/test-metro-g00001/catalog/members.parquet +3 -0
- groups/test-metro-g00001/catalog/objects.parquet +3 -0
- groups/test-metro-g00001/catalog/records.parquet +3 -0
- groups/test-metro-g00001/catalog/scenes.parquet +3 -0
- groups/test-metro-g00001/snapshot.json +0 -0
- groups/test-metro-g00002/catalog/geometry.parquet +3 -0
- groups/test-metro-g00002/catalog/members.parquet +3 -0
- groups/test-metro-g00002/catalog/objects.parquet +3 -0
- groups/test-metro-g00002/catalog/records.parquet +3 -0
- groups/test-metro-g00002/catalog/scenes.parquet +3 -0
- groups/test-metro-g00002/snapshot.json +0 -0
- groups/test-metro-g00003/catalog/geometry.parquet +3 -0
- groups/test-metro-g00003/catalog/members.parquet +3 -0
- groups/test-metro-g00003/catalog/objects.parquet +3 -0
- groups/test-metro-g00003/catalog/records.parquet +3 -0
- groups/test-metro-g00003/catalog/scenes.parquet +3 -0
- groups/test-metro-g00003/snapshot.json +0 -0
- groups/test-metro-g00004/catalog/geometry.parquet +3 -0
- groups/test-metro-g00004/catalog/members.parquet +3 -0
- groups/test-metro-g00004/catalog/objects.parquet +3 -0
- groups/test-metro-g00004/catalog/records.parquet +3 -0
- groups/test-metro-g00004/catalog/scenes.parquet +3 -0
- groups/test-metro-g00004/snapshot.json +0 -0
.gitattributes
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
| 2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
| 3 |
+
*.avro filter=lfs diff=lfs merge=lfs -text
|
| 4 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
| 5 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
| 6 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
| 7 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
| 8 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
| 9 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
| 10 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
| 11 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
| 12 |
+
*.lz4 filter=lfs diff=lfs merge=lfs -text
|
| 13 |
+
*.mds filter=lfs diff=lfs merge=lfs -text
|
| 14 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
| 15 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
| 16 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
| 17 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
| 18 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
| 19 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
| 20 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
| 21 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
| 22 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
| 23 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
| 24 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
| 25 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
| 26 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
| 27 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
| 28 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
| 29 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
| 30 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
| 31 |
+
*.tar filter=lfs diff=lfs merge=lfs -text
|
| 32 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
| 33 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
| 34 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
| 35 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 38 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 39 |
+
# Audio files - uncompressed
|
| 40 |
+
*.pcm filter=lfs diff=lfs merge=lfs -text
|
| 41 |
+
*.sam filter=lfs diff=lfs merge=lfs -text
|
| 42 |
+
*.raw filter=lfs diff=lfs merge=lfs -text
|
| 43 |
+
# Audio files - compressed
|
| 44 |
+
*.aac filter=lfs diff=lfs merge=lfs -text
|
| 45 |
+
*.flac filter=lfs diff=lfs merge=lfs -text
|
| 46 |
+
*.mp3 filter=lfs diff=lfs merge=lfs -text
|
| 47 |
+
*.ogg filter=lfs diff=lfs merge=lfs -text
|
| 48 |
+
*.wav filter=lfs diff=lfs merge=lfs -text
|
| 49 |
+
# Image files - uncompressed
|
| 50 |
+
*.bmp filter=lfs diff=lfs merge=lfs -text
|
| 51 |
+
*.gif filter=lfs diff=lfs merge=lfs -text
|
| 52 |
+
*.png filter=lfs diff=lfs merge=lfs -text
|
| 53 |
+
*.tiff filter=lfs diff=lfs merge=lfs -text
|
| 54 |
+
# Image files - compressed
|
| 55 |
+
*.jpg filter=lfs diff=lfs merge=lfs -text
|
| 56 |
+
*.jpeg filter=lfs diff=lfs merge=lfs -text
|
| 57 |
+
*.webp filter=lfs diff=lfs merge=lfs -text
|
| 58 |
+
# Video files - compressed
|
| 59 |
+
*.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 60 |
+
*.webm filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
|
@@ -0,0 +1,526 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
pretty_name: Channels4World
|
| 3 |
+
license: cc-by-4.0
|
| 4 |
+
language:
|
| 5 |
+
- en
|
| 6 |
+
tags:
|
| 7 |
+
- wireless
|
| 8 |
+
- ray-tracing
|
| 9 |
+
- sionna
|
| 10 |
+
- channel-modeling
|
| 11 |
+
- radio-propagation
|
| 12 |
+
- synthetic
|
| 13 |
+
size_categories:
|
| 14 |
+
- 100K<n<1M
|
| 15 |
+
configs:
|
| 16 |
+
- config_name: scenes
|
| 17 |
+
default: true
|
| 18 |
+
data_files:
|
| 19 |
+
- split: catalog
|
| 20 |
+
path: c4w-root/scenes.parquet
|
| 21 |
+
- config_name: files
|
| 22 |
+
data_files:
|
| 23 |
+
- split: catalog
|
| 24 |
+
path: c4w-root/files.parquet
|
| 25 |
+
- config_name: tiny_scenes
|
| 26 |
+
data_files:
|
| 27 |
+
- split: catalog
|
| 28 |
+
path: tiny/c4w-root/scenes.parquet
|
| 29 |
+
---
|
| 30 |
+
|
| 31 |
+
# Channels4World
|
| 32 |
+
|
| 33 |
+
**An environment-scale foundation for wireless AI.** Channels4World is a ray-traced
|
| 34 |
+
wireless channel dataset for learning across many environments, from wireless foundation
|
| 35 |
+
models to channel prediction and localization: **100,000 synthetic outdoor scenes**, each
|
| 36 |
+
with **32 base stations (BSs) and 16,384 UE positions**, simulated at **3.5 and 7 GHz** with
|
| 37 |
+
Sionna RT. Scenes come from three generation profiles (urban, metropolitan and suburban).
|
| 38 |
+
Train and test are split by scene, and nested tiers from 200 to 100,000 scenes let you scale
|
| 39 |
+
the number of environments separately from the data in each.
|
| 40 |
+
|
| 41 |
+
**Get data:** [Choose a subset and get download commands](https://cbchae.yonsei.ac.kr/channels4world/download.html) ([Space](https://huggingface.co/spaces/Intelligence-Networking-Lab/channels4world-download)) ·
|
| 42 |
+
[Try one scene](#download)
|
| 43 |
+
|
| 44 |
+

|
| 45 |
+
|
| 46 |
+
*Example scenes from the three profiles. Building colours show material classes.*
|
| 47 |
+
|
| 48 |
+
| Release 1.0.0 | Coverage |
|
| 49 |
+
|---|---|
|
| 50 |
+
| Geometry and positions | All 100,000 scenes |
|
| 51 |
+
| Core channels | All 100,000 scenes, both carriers |
|
| 52 |
+
| Detail (interactions) | The 10,000 Medium-tier scenes, both carriers |
|
| 53 |
+
| Total | About **20.8 TB**: the Full tier, the loose Tiny copy and metadata |
|
| 54 |
+
|
| 55 |
+
Start with plain NumPy, use the `channels4world` library to select larger subsets, or
|
| 56 |
+
read the TAR archives with 🤗 Datasets. Numeric records are standard NPZ files;
|
| 57 |
+
geometry is ZIP. Every example follows one link: BS 0 and UE 14 of `urban_scene_019234`
|
| 58 |
+
at 3.5 GHz, the link the project website shows.
|
| 59 |
+
|
| 60 |
+
[Project website](https://cbchae.yonsei.ac.kr/channels4world/) ·
|
| 61 |
+
[Library source on GitHub](https://github.com/JoonkyuJang/channels4world) ·
|
| 62 |
+
[Paper (submitted; arXiv preprint pending)](#license-and-citation) ·
|
| 63 |
+
[Tutorials](#tutorials) ·
|
| 64 |
+
[Schema reference](docs/schema-reference.md) ·
|
| 65 |
+
[Library guide](docs/library-guide.md) ·
|
| 66 |
+
[Without the library](docs/without-library.md)
|
| 67 |
+
|
| 68 |
+
## Contents
|
| 69 |
+
|
| 70 |
+
Each scene is divided into four **components**, which you can download separately.
|
| 71 |
+
|
| 72 |
+

|
| 73 |
+
|
| 74 |
+
*`urban_scene_019234` at 3.5 GHz, top view (heights not shown). UE positions are a sample
|
| 75 |
+
of the 16,384. Each path segment takes the colour of the interaction it leaves.*
|
| 76 |
+
|
| 77 |
+
| Component | What it holds | One file per | Files per scene |
|
| 78 |
+
|---|---|---|---|
|
| 79 |
+
| **geometry** | The 3-D scene: Mitsuba XML and OBJ meshes | scene | 1 |
|
| 80 |
+
| **positions** | Coordinates of the 32 BSs and 16,384 UEs | scene | 1 |
|
| 81 |
+
| **core** | Every retained path from one BS to each UE it reaches: gain, delay, angles, interaction count and type flags | scene × carrier × BS | 64 |
|
| 82 |
+
| **detail** | Each path's interactions in order: type and location | scene × carrier × BS | 64 |
|
| 83 |
+
|
| 84 |
+
Geometry and positions are shared by both carriers; core and detail are frequency-specific.
|
| 85 |
+
Most channel work needs only positions and core.
|
| 86 |
+
|
| 87 |
+
**What a record keeps.** Each link keeps at most the 16 strongest paths whose power exceeds
|
| 88 |
+
−150 dB, ordered by decreasing power (computed in float32). Paths combine line of sight, specular reflection and
|
| 89 |
+
diffraction, with up to four interactions per path; diffuse reflection and refraction are
|
| 90 |
+
not modeled. A UE with no stored link to a BS has no retained path to it; that is not a
|
| 91 |
+
zero-power channel. The scenes are synthetic and the channels are simulated, not measured;
|
| 92 |
+
the paper describes how they were generated.
|
| 93 |
+
|
| 94 |
+
Gains are the passband coefficients without the carrier-delay phase, relative to unit
|
| 95 |
+
power. Angles: zenith from +z, azimuth from +x toward +y. Each BS and UE has one isotropic,
|
| 96 |
+
vertically polarized antenna, already included in the gains. Details: [schema reference](docs/schema-reference.md).
|
| 97 |
+
|
| 98 |
+
<details>
|
| 99 |
+
<summary><b>How the files connect</b></summary>
|
| 100 |
+
|
| 101 |
+

|
| 102 |
+
|
| 103 |
+
*Illustrative values: link 0 is UE 2 and owns paths 0–1; link 1 is UE 9 and owns path 2.*
|
| 104 |
+
|
| 105 |
+
- **One frame:** geometry, positions and interaction vertices share scene coordinates in metres.
|
| 106 |
+
- **BS:** the number in a file name (`bs00000`) is its row in `bs_positions`.
|
| 107 |
+
- **UE:** each value of `link_ue_index` is a row in `ue_positions`. A UE that isn't listed
|
| 108 |
+
has no retained link to this BS (not a zero-power channel).
|
| 109 |
+
- **Paths:** link ℓ owns paths `link_path_offsets[ℓ]` to `link_path_offsets[ℓ+1]` (end excluded).
|
| 110 |
+
- **Interactions:** detail lists paths in core's order; path *p* owns interactions
|
| 111 |
+
`path_interaction_offsets[p]` to `[p+1]`.
|
| 112 |
+
|
| 113 |
+
</details>
|
| 114 |
+
|
| 115 |
+
<details>
|
| 116 |
+
<summary><b>Arrays in each file</b></summary>
|
| 117 |
+
|
| 118 |
+
*L* links, *P* paths and *I* interactions vary per record. For example, BS 0 of
|
| 119 |
+
`urban_scene_019234` at 3.5 GHz has *L* = 15,873 retained links and *P* = 214,443 paths.
|
| 120 |
+
|
| 121 |
+
**geometry** · `geometry.zip`: `scene.json` names the entry XML, which references OBJ
|
| 122 |
+
meshes in metres.
|
| 123 |
+
|
| 124 |
+
**positions** · `positions.npz`
|
| 125 |
+
|
| 126 |
+
| Array | Shape | Type | Meaning |
|
| 127 |
+
|---|---|---|---|
|
| 128 |
+
| `bs_positions` | 32 × 3 | float32 | BS coordinates, m |
|
| 129 |
+
| `ue_positions` | 16,384 × 3 | float32 | UE coordinates, m |
|
| 130 |
+
|
| 131 |
+
**core** · `band_hz=<Hz>/component=core/bs<NNNNN>.npz`
|
| 132 |
+
|
| 133 |
+
| Array | Shape | Type | Meaning |
|
| 134 |
+
|---|---|---|---|
|
| 135 |
+
| `link_ue_index` | *L* | int32 | UE ID of each link, ascending |
|
| 136 |
+
| `link_path_offsets` | *L* + 1 | int64 | Where each link's paths start and end |
|
| 137 |
+
| `a_real`, `a_imag` | *P* | float32 | Complex path gain |
|
| 138 |
+
| `tau` | *P* | float32 | Delay, s |
|
| 139 |
+
| `theta_t`, `phi_t` | *P* | float32 | Departure angles at the BS, rad |
|
| 140 |
+
| `theta_r`, `phi_r` | *P* | float32 | Arrival angles at the UE, rad |
|
| 141 |
+
| `interaction_count` | *P* | uint8 | Number of interactions |
|
| 142 |
+
| `interaction_flags` | *P* | uint16 | Interaction types present, one bit per type |
|
| 143 |
+
| `path_rank` | *P* | uint8 | 0-based position within its link, by decreasing float32 power |
|
| 144 |
+
|
| 145 |
+
**detail** · same name under `component=detail`
|
| 146 |
+
|
| 147 |
+
| Array | Shape | Type | Meaning |
|
| 148 |
+
|---|---|---|---|
|
| 149 |
+
| `path_interaction_offsets` | *P* + 1 | int64 | Where each path's interactions start and end |
|
| 150 |
+
| `interaction_type` | *I* | int8 | 1 specular reflection, 8 diffraction (2 diffuse reflection and 4 refraction are defined but not modeled) |
|
| 151 |
+
| `interaction_rank` | *I* | uint8 | 0-based position along the path |
|
| 152 |
+
| `interaction_vertex` | *I* × 3 | float32 | Location, m |
|
| 153 |
+
|
| 154 |
+
</details>
|
| 155 |
+
|
| 156 |
+
## Organization
|
| 157 |
+
|
| 158 |
+
Every scene belongs to one **split** (train or test) and one **profile** (urban,
|
| 159 |
+
metropolitan or suburban). Scenes are offered in nested **tiers**, so a larger tier keeps
|
| 160 |
+
every scene of the smaller ones. Every tier is 90% train and 10% test, and within each
|
| 161 |
+
split 50% urban, 25% metropolitan and 25% suburban.
|
| 162 |
+
|
| 163 |
+
| Tier | Train urban | Train metropolitan | Train suburban | Test urban | Test metropolitan | Test suburban | Total |
|
| 164 |
+
|---|---:|---:|---:|---:|---:|---:|---:|
|
| 165 |
+
| Tiny | 90 | 45 | 45 | 10 | 5 | 5 | 200 |
|
| 166 |
+
| Small | 450 | 225 | 225 | 50 | 25 | 25 | 1,000 |
|
| 167 |
+
| Medium | 4,500 | 2,250 | 2,250 | 500 | 250 | 250 | 10,000 |
|
| 168 |
+
| Large | 22,500 | 11,250 | 11,250 | 2,500 | 1,250 | 1,250 | 50,000 |
|
| 169 |
+
| Full | 45,000 | 22,500 | 22,500 | 5,000 | 2,500 | 2,500 | 100,000 |
|
| 170 |
+
|
| 171 |
+
- A scene is in exactly one split. Both carriers and all four components of a scene share it.
|
| 172 |
+
- There is no validation split. Hold out training scenes by scene, not by link or UE.
|
| 173 |
+
- In the catalog, `tier` is the **smallest** tier that contains a scene. Medium is therefore
|
| 174 |
+
`tier in {"tiny", "small", "medium"}`.
|
| 175 |
+
|
| 176 |
+
| Tier | Core | Detail | Geometry + positions | Total |
|
| 177 |
+
|---|---:|---:|---:|---:|
|
| 178 |
+
| Tiny | 38.9 GB | 26.7 GB | 41 MB | 65.6 GB |
|
| 179 |
+
| Small | 194 GB | 133 GB | 207 MB | 327 GB |
|
| 180 |
+
| Medium | 1.93 TB | 1.32 TB | 2.07 GB | 3.26 TB |
|
| 181 |
+
| Large | 9.66 TB | 1.32 TB (Medium only) | 10.3 GB | 10.99 TB |
|
| 182 |
+
| Full | 19.32 TB | 1.32 TB (Medium only) | 20.7 GB | 20.66 TB |
|
| 183 |
+
|
| 184 |
+
*Sizes cover both carriers (GB = 10⁹ bytes, TB = 10¹² bytes); catalogs and group metadata
|
| 185 |
+
add under 0.2%. Tiny is published as loose files (65.7 GB with its metadata), and its
|
| 186 |
+
scenes are also part of Small.*
|
| 187 |
+
|
| 188 |
+
Tiers choose scenes; components and carriers are chosen separately. Tiny needs no unpacking.
|
| 189 |
+
|
| 190 |
+
## Download
|
| 191 |
+
|
| 192 |
+
Try one scene from Tiny to get loose files without unpacking. For Small or larger,
|
| 193 |
+
download TAR archives and use the catalog to select scenes, carriers and components.
|
| 194 |
+
Each example below leaves files under `c4w/`. Commands use the release tag `v1.0.0`; the
|
| 195 |
+
`hf` command comes with `huggingface_hub` (`pip install huggingface_hub`).
|
| 196 |
+
The [download helper](https://cbchae.yonsei.ac.kr/channels4world/download.html) (also a [Space](https://huggingface.co/spaces/Intelligence-Networking-Lab/channels4world-download)) sizes any
|
| 197 |
+
tier, split, profile, carrier and component choice and writes these commands for it.
|
| 198 |
+
|
| 199 |
+
<details>
|
| 200 |
+
<summary><b>Try one scene from Tiny</b></summary>
|
| 201 |
+
|
| 202 |
+
Download base station 0 of one scene (**26.0 MB** in 16 files, including the metadata the
|
| 203 |
+
library needs):
|
| 204 |
+
|
| 205 |
+
```bash
|
| 206 |
+
hf download Intelligence-Networking-Lab/Channels4World --repo-type dataset \
|
| 207 |
+
--revision v1.0.0 --local-dir c4w \
|
| 208 |
+
--include 'tiny/c4w-root.json' --include 'tiny/c4w-root/*' --include 'tiny/schema/*' \
|
| 209 |
+
--include 'tiny/groups/test-urban-g00000/catalog/members.parquet' \
|
| 210 |
+
--include 'tiny/groups/test-urban-g00000/snapshot.json' \
|
| 211 |
+
--include 'tiny/records/scene=urban_scene_019234/positions.npz' \
|
| 212 |
+
--include 'tiny/records/scene=urban_scene_019234/geometry.zip' \
|
| 213 |
+
--include 'tiny/records/scene=urban_scene_019234/band_hz=*/component=*/bs00000.npz'
|
| 214 |
+
```
|
| 215 |
+
|
| 216 |
+
For NumPy alone, the last three `--include` patterns are enough (15.2 MB). For all 32 BSs
|
| 217 |
+
of the scene, replace them with `--include 'tiny/records/scene=urban_scene_019234/*'`
|
| 218 |
+
(418.0 MB with the metadata). For all of Tiny, use `--include 'tiny/*'` (65.7 GB). For
|
| 219 |
+
another Tiny scene, take its `group` from the `tiny_scenes` catalog. The three scenes shown
|
| 220 |
+
on the project website, `urban_scene_019234`, `metro_scene_054046` and
|
| 221 |
+
`suburban_scene_096016`, are Tiny test scenes.
|
| 222 |
+
Then [read the data](#read-the-data) below.
|
| 223 |
+
|
| 224 |
+
</details>
|
| 225 |
+
|
| 226 |
+
<details>
|
| 227 |
+
<summary><b>Download a tier</b></summary>
|
| 228 |
+
|
| 229 |
+
Install the optional library with `pip install channels4world` (Python ≥3.11).
|
| 230 |
+
Download the release catalog, then select Small, positions and core at 3.5 GHz:
|
| 231 |
+
|
| 232 |
+
```bash
|
| 233 |
+
hf download Intelligence-Networking-Lab/Channels4World --repo-type dataset \
|
| 234 |
+
--revision v1.0.0 --local-dir c4w \
|
| 235 |
+
--include 'c4w-root.json' --include 'c4w-root/*'
|
| 236 |
+
```
|
| 237 |
+
|
| 238 |
+
```python
|
| 239 |
+
import channels4world as c4w
|
| 240 |
+
from huggingface_hub import snapshot_download
|
| 241 |
+
|
| 242 |
+
ds = c4w.open("c4w")
|
| 243 |
+
selection = ds.select(tier="small", frequencies_hz=[3_500_000_000],
|
| 244 |
+
components=("positions", "core"))
|
| 245 |
+
report = selection.missing()
|
| 246 |
+
print(report) # planned files and total size
|
| 247 |
+
if report.files:
|
| 248 |
+
snapshot_download(
|
| 249 |
+
"Intelligence-Networking-Lab/Channels4World", repo_type="dataset",
|
| 250 |
+
revision="v1.0.0", local_dir=report.local_dir,
|
| 251 |
+
allow_patterns=report.repo_files,
|
| 252 |
+
)
|
| 253 |
+
assert selection.missing().complete
|
| 254 |
+
```
|
| 255 |
+
|
| 256 |
+
`select()` also takes `split=` and `profile=` (catalog spelling: `urban`, `metropolitan`,
|
| 257 |
+
`suburban`). Each archive holds one group: 25 scenes of one split and profile, from one
|
| 258 |
+
tier, with all 32 BSs. Tier, split and profile selections therefore download exactly their
|
| 259 |
+
scenes; a list of scene IDs downloads the whole groups that contain them.
|
| 260 |
+
`selection.to_recipe()` saves a selection as a small JSON recipe that others can replay
|
| 261 |
+
with `ds.select_recipe(...)` or `c4w missing c4w --recipe FILE`; the download helper
|
| 262 |
+
writes the same recipes.
|
| 263 |
+
The [library guide](docs/library-guide.md) covers larger download plans, subsets and
|
| 264 |
+
caching; [without the library](docs/without-library.md) covers glob downloads and ordinary
|
| 265 |
+
TAR extraction.
|
| 266 |
+
|
| 267 |
+
</details>
|
| 268 |
+
|
| 269 |
+
<details>
|
| 270 |
+
<summary><b>Select scenes and components</b></summary>
|
| 271 |
+
|
| 272 |
+
With the release catalog from the tier example local, choose exact scene IDs and the
|
| 273 |
+
components you need. The catalog finds the containing archives:
|
| 274 |
+
|
| 275 |
+
```python
|
| 276 |
+
import channels4world as c4w
|
| 277 |
+
from huggingface_hub import snapshot_download
|
| 278 |
+
|
| 279 |
+
ds = c4w.open("c4w")
|
| 280 |
+
selection = ds.select(scene_ids=["urban_scene_019234"],
|
| 281 |
+
frequencies_hz=[3_500_000_000], components=("positions", "core"))
|
| 282 |
+
report = selection.missing()
|
| 283 |
+
print(report)
|
| 284 |
+
if report.files:
|
| 285 |
+
snapshot_download(
|
| 286 |
+
"Intelligence-Networking-Lab/Channels4World", repo_type="dataset",
|
| 287 |
+
revision="v1.0.0", local_dir=report.local_dir,
|
| 288 |
+
allow_patterns=report.repo_files,
|
| 289 |
+
)
|
| 290 |
+
assert selection.missing().complete
|
| 291 |
+
```
|
| 292 |
+
|
| 293 |
+
</details>
|
| 294 |
+
|
| 295 |
+
HF Datasets can also [stream archives](#streaming-archives) without downloading the
|
| 296 |
+
entire selection first.
|
| 297 |
+
|
| 298 |
+
## Read the data
|
| 299 |
+
|
| 300 |
+
We recommend the `channels4world` library for selection, verification and repeated reads;
|
| 301 |
+
standard NumPy works directly with loose files. Both examples read the same link, BS 0 →
|
| 302 |
+
UE 14 of `urban_scene_019234` at 3.5 GHz: its delays, complex gains and BS–UE distance.
|
| 303 |
+
Change the IDs at the top to read any other link you have downloaded.
|
| 304 |
+
|
| 305 |
+
<details>
|
| 306 |
+
<summary><b>Read with the library</b></summary>
|
| 307 |
+
|
| 308 |
+
```python
|
| 309 |
+
from pathlib import Path
|
| 310 |
+
import numpy as np
|
| 311 |
+
import channels4world as c4w
|
| 312 |
+
|
| 313 |
+
TINY_ROOT = Path("c4w/tiny")
|
| 314 |
+
SCENE_ID, CARRIER_HZ, BS_ID, UE_ID = "urban_scene_019234", 3_500_000_000, 0, 14
|
| 315 |
+
ds = c4w.open(TINY_ROOT)
|
| 316 |
+
scene = ds.scene(SCENE_ID)
|
| 317 |
+
record = scene.frequencies[CARRIER_HZ].base_stations[BS_ID].read()
|
| 318 |
+
positions = scene.read_positions()
|
| 319 |
+
|
| 320 |
+
link = record.get_link(UE_ID) # None when this UE has no retained link to this BS
|
| 321 |
+
print(link.n_paths, link.core["tau"]) # 16 retained paths, delays in s
|
| 322 |
+
print(link.core["a_real"] + 1j * link.core["a_imag"])
|
| 323 |
+
print(np.linalg.norm(positions.ue[UE_ID] - positions.bs[BS_ID]))
|
| 324 |
+
```
|
| 325 |
+
|
| 326 |
+
The library's arrays keep the stored dtypes and are read-only. For downloaded TARs, open the
|
| 327 |
+
release root (`c4w/`) and iterate your selection directly; extraction is optional.
|
| 328 |
+
See [iteration and extraction](docs/library-guide.md#iterate-extract-or-cache).
|
| 329 |
+
|
| 330 |
+
</details>
|
| 331 |
+
|
| 332 |
+
<details>
|
| 333 |
+
<summary><b>Read loose files with NumPy</b></summary>
|
| 334 |
+
|
| 335 |
+
The same code works after ordinary TAR extraction: change `TINY_ROOT` to the extracted
|
| 336 |
+
folder.
|
| 337 |
+
|
| 338 |
+
```python
|
| 339 |
+
from pathlib import Path
|
| 340 |
+
import numpy as np
|
| 341 |
+
|
| 342 |
+
TINY_ROOT = Path("c4w/tiny")
|
| 343 |
+
SCENE_ID, CARRIER_HZ, BS_ID, UE_ID = "urban_scene_019234", 3_500_000_000, 0, 14
|
| 344 |
+
scene_dir = TINY_ROOT / "records" / f"scene={SCENE_ID}"
|
| 345 |
+
core_path = scene_dir / f"band_hz={CARRIER_HZ}" / "component=core" / f"bs{BS_ID:05d}.npz"
|
| 346 |
+
|
| 347 |
+
with np.load(core_path, allow_pickle=False) as core, np.load(
|
| 348 |
+
scene_dir / "positions.npz", allow_pickle=False
|
| 349 |
+
) as positions:
|
| 350 |
+
ue_ids = core["link_ue_index"] # retained UE IDs, ascending
|
| 351 |
+
row = int(np.searchsorted(ue_ids, UE_ID)) # this UE's link row
|
| 352 |
+
assert row < ue_ids.size and ue_ids[row] == UE_ID, "No retained link to this UE."
|
| 353 |
+
start, stop = map(int, core["link_path_offsets"][row:row + 2])
|
| 354 |
+
print(stop - start, core["tau"][start:stop])
|
| 355 |
+
print(core["a_real"][start:stop] + 1j * core["a_imag"][start:stop])
|
| 356 |
+
print(np.linalg.norm(positions["ue_positions"][UE_ID] - positions["bs_positions"][BS_ID]))
|
| 357 |
+
```
|
| 358 |
+
|
| 359 |
+
NumPy preserves the NPZ's stored dtypes and shapes. `UE_ID` indexes positions; `row`
|
| 360 |
+
indexes retained links. Keep that mapping when filtering. Ordinary TAR extraction writes
|
| 361 |
+
these payload paths; library extraction also creates a navigable subset root.
|
| 362 |
+
|
| 363 |
+
</details>
|
| 364 |
+
|
| 365 |
+
<details>
|
| 366 |
+
<summary><b>Pad paths to fixed-size arrays</b></summary>
|
| 367 |
+
|
| 368 |
+
Each link has at most 16 paths, so any per-path array becomes an `(L, 16)` array plus a
|
| 369 |
+
mask. Row *i* belongs to UE `link_ue_index[i]`:
|
| 370 |
+
|
| 371 |
+
```python
|
| 372 |
+
import numpy as np
|
| 373 |
+
|
| 374 |
+
def pad_paths(core, name, max_paths=16):
|
| 375 |
+
"""Per-path array -> (links, max_paths) array and a mask of stored paths."""
|
| 376 |
+
offsets = np.asarray(core["link_path_offsets"])
|
| 377 |
+
values = np.asarray(core[name])
|
| 378 |
+
counts = np.diff(offsets) # paths per link
|
| 379 |
+
rows = np.repeat(np.arange(counts.size), counts)
|
| 380 |
+
cols = np.arange(offsets[-1]) - np.repeat(offsets[:-1], counts)
|
| 381 |
+
padded = np.zeros((counts.size, max_paths), values.dtype)
|
| 382 |
+
padded[rows, cols] = values
|
| 383 |
+
mask = np.arange(max_paths) < counts[:, None]
|
| 384 |
+
return padded, mask
|
| 385 |
+
|
| 386 |
+
with np.load(core_path, allow_pickle=False) as core: # core_path from the example above
|
| 387 |
+
tau, mask = pad_paths(core, "tau") # (L, 16) float32, (L, 16) bool
|
| 388 |
+
gain = pad_paths(core, "a_real")[0] + 1j * pad_paths(core, "a_imag")[0]
|
| 389 |
+
ue_ids = core["link_ue_index"] # (L,) row i <-> UE ue_ids[i]
|
| 390 |
+
```
|
| 391 |
+
|
| 392 |
+
Padded entries are zero; use the mask, not the value, to tell them apart. The same works
|
| 393 |
+
on library records and on HF Datasets rows after
|
| 394 |
+
[restoring their shapes](docs/hf-datasets.md#decoding-and-array-representation). The
|
| 395 |
+
library has the same function, with a per-path version for interactions:
|
| 396 |
+
`from channels4world.transforms import pad_paths, pad_interactions`.
|
| 397 |
+
|
| 398 |
+
</details>
|
| 399 |
+
|
| 400 |
+
### Streaming archives
|
| 401 |
+
|
| 402 |
+
Stream remote TARs on demand, or iterate the same TARs saved locally without a network
|
| 403 |
+
read. Each HF Datasets example is one BS record, not one UE or a joined scene. Archives
|
| 404 |
+
stream in order: to reach one record, stream only the group archive that holds it.
|
| 405 |
+
|
| 406 |
+
<details>
|
| 407 |
+
<summary><b>Stream archives with 🤗 Datasets</b></summary>
|
| 408 |
+
|
| 409 |
+
```python
|
| 410 |
+
import numpy as np
|
| 411 |
+
from datasets import load_dataset
|
| 412 |
+
|
| 413 |
+
SCENE_ID, BS_ID, UE_ID = "urban_scene_019234", 0, 14
|
| 414 |
+
archive = ("hf://datasets/Intelligence-Networking-Lab/Channels4World@v1.0.0/payload/"
|
| 415 |
+
"3.5ghz/core/inc1-small/test-urban-g00000-3.5ghz-core.tar") # this scene's group
|
| 416 |
+
# For a downloaded copy: archive = "c4w/payload/3.5ghz/core/inc1-small/test-urban-g00000-3.5ghz-core.tar"
|
| 417 |
+
member = f"records/scene={SCENE_ID}/band_hz=3500000000/component=core/bs{BS_ID:05d}"
|
| 418 |
+
core = load_dataset("webdataset", streaming=True, data_files={"test": archive})["test"]
|
| 419 |
+
record = next(r for r in core.with_format("numpy") if r["__key__"] == member)
|
| 420 |
+
arrays = record["npz"] # HF has already decoded the NPZ
|
| 421 |
+
row = int(np.searchsorted(arrays["link_ue_index"], UE_ID))
|
| 422 |
+
start, stop = map(int, arrays["link_path_offsets"][row:row + 2])
|
| 423 |
+
print(arrays["tau"][start:stop]) # UE 14's delays (s)
|
| 424 |
+
```
|
| 425 |
+
|
| 426 |
+
The group comes from the `scenes` catalog. Streaming reads the archive from its start, so
|
| 427 |
+
the members before this record are read too (at most one group's archive). `streaming=True`
|
| 428 |
+
iterates on demand; without it, HF Datasets downloads the archives and builds an Arrow
|
| 429 |
+
dataset on disk, from remote or local input. HF formatting can change dtypes. See the
|
| 430 |
+
[HF guide](docs/hf-datasets.md) for explicit features, shape and dtype restoration, and
|
| 431 |
+
joining positions. To read one record without the rest of its archive, use a byte-range
|
| 432 |
+
read ([file guide](docs/without-library.md#find-the-byte-location-of-one-record)). Tiny
|
| 433 |
+
stays loose.
|
| 434 |
+
|
| 435 |
+
</details>
|
| 436 |
+
|
| 437 |
+
## Tutorials
|
| 438 |
+
|
| 439 |
+
Each tutorial is a page and a notebook that runs top to bottom. The two reading tutorials
|
| 440 |
+
follow the same link, BS 0 → UE 14 of `urban_scene_019234`.
|
| 441 |
+
|
| 442 |
+
| Tutorial | Reads with | Covers |
|
| 443 |
+
|---|---|---|
|
| 444 |
+
| [Read one scene](docs/tutorial-library.md) ([notebook](docs/notebooks/01-read-one-scene-library.ipynb)) | the library | catalog → scene → carrier → BS → UE link → paths; geometry and positions; the stored arrays; the same link at 7 GHz |
|
| 445 |
+
| [Read one scene without the library](docs/tutorial-numpy.md) ([notebook](docs/notebooks/02-read-one-scene-numpy.ipynb)) | NumPy | the same steps on the loose files |
|
| 446 |
+
| [From channel records to a DataLoader](docs/ml-guide.md) ([notebook](docs/notebooks/03-dataloader.ipynb)) | the library, PyTorch | link samples, train/validation/test by scene, padded arrays, preprocessing, a cache and batches |
|
| 447 |
+
|
| 448 |
+
## Files and catalogs
|
| 449 |
+
|
| 450 |
+
The catalogs list scenes and files so you can choose downloads and locate records;
|
| 451 |
+
metadata supplies their identities and checksums. The dataset viewer shows three catalog
|
| 452 |
+
configs: `scenes` (default; one row per scene), `files` (every archive, group metadata and schema file with its size
|
| 453 |
+
and SHA-256; the root catalog files and this card are not listed) and `tiny_scenes` (Tiny's 200 scenes). Their split is named `catalog`; it is
|
| 454 |
+
not the train/test split, which is the `split` column. The viewer shows catalog rows, not
|
| 455 |
+
channel arrays. The [file guide](docs/without-library.md) explains how to use them.
|
| 456 |
+
|
| 457 |
+
<details>
|
| 458 |
+
<summary><b>File reference</b></summary>
|
| 459 |
+
|
| 460 |
+
| Path | What it is |
|
| 461 |
+
|---|---|
|
| 462 |
+
| `c4w-root.json`, `c4w-root/` | Release catalog: every scene (split, profile, tier, group) and every archive, metadata and schema file (path, size, checksum) |
|
| 463 |
+
| `groups/<group>/` | Group metadata: where each record sits inside the archives, and its identity and checksums |
|
| 464 |
+
| `schema/` | Interpretation documents (units, conventions, interaction codes) |
|
| 465 |
+
|
| 466 |
+
```text
|
| 467 |
+
c4w-root.json, c4w-root/ release catalog
|
| 468 |
+
schema/, groups/ interpretation documents, group metadata
|
| 469 |
+
payload/ TAR archives (paths below)
|
| 470 |
+
tiny/ Tiny: its own catalog, schema/, groups/ and
|
| 471 |
+
records/scene=<id>/ loose files per scene:
|
| 472 |
+
geometry.zip, positions.npz
|
| 473 |
+
band_hz=<3500000000|7000000000>/component=<core|detail>/bs00000.npz … bs00031.npz
|
| 474 |
+
```
|
| 475 |
+
|
| 476 |
+
Archive path templates:
|
| 477 |
+
|
| 478 |
+
```text
|
| 479 |
+
payload/scene/<geometry|positions>/inc<N>-<tier>/<group>-<component>.tar
|
| 480 |
+
payload/<3.5ghz|7ghz>/<core|detail>/inc<N>-<tier>/<group>-<band>-<component>.tar
|
| 481 |
+
```
|
| 482 |
+
|
| 483 |
+
- **Groups** are named `<split>-<profile code>-g<NNNNN>`, with profile code `urban`, `metro`
|
| 484 |
+
or `suburban` (the catalog spells `metro` as `metropolitan`). Each holds exactly 25 scenes.
|
| 485 |
+
- **Increments** are `inc1-small`, `inc2-medium`, `inc3-large` and `inc4-full`. A tier is
|
| 486 |
+
its own increment plus all smaller ones, so in every component folder Small is `inc1-*`,
|
| 487 |
+
Medium `inc[1-2]-*`, Large `inc[1-3]-*` and Full `inc*`.
|
| 488 |
+
- **Detail** is hosted in `inc1-small` and `inc2-medium` only.
|
| 489 |
+
|
| 490 |
+
</details>
|
| 491 |
+
|
| 492 |
+
<details>
|
| 493 |
+
<summary><b>Query the catalogs</b></summary>
|
| 494 |
+
|
| 495 |
+
```python
|
| 496 |
+
from datasets import load_dataset
|
| 497 |
+
|
| 498 |
+
REPO, REV = "Intelligence-Networking-Lab/Channels4World", "v1.0.0"
|
| 499 |
+
scenes = load_dataset(REPO, "scenes", split="catalog", revision=REV)
|
| 500 |
+
files = load_dataset(REPO, "files", split="catalog", revision=REV)
|
| 501 |
+
print(scenes.filter(lambda row: row["split"] == "test")[:3])
|
| 502 |
+
print(files.filter(lambda row: row["kind"] == "payload")[:3])
|
| 503 |
+
```
|
| 504 |
+
|
| 505 |
+
</details>
|
| 506 |
+
|
| 507 |
+
## License and citation
|
| 508 |
+
|
| 509 |
+
Channels4World: [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/). If you share or
|
| 510 |
+
adapt it, credit **Joonkyu Jang**, link the license and indicate changes.
|
| 511 |
+
channels4world library: [Apache-2.0](https://www.apache.org/licenses/LICENSE-2.0).
|
| 512 |
+
|
| 513 |
+
If Channels4World is useful in your research, please cite the dataset paper:
|
| 514 |
+
|
| 515 |
+
> J. Jang, H.-J. Moon, K. S. Kim, S.-L. Kim, J. Hoydis, R. W. Heath Jr. and C.-B. Chae,
|
| 516 |
+
> "Channels4World: An Environment-Scale Dataset for Wireless Foundation Models,"
|
| 517 |
+
> submitted to *IEEE Transactions on Communications*.
|
| 518 |
+
|
| 519 |
+
The arXiv preprint and a BibTeX entry will be added here when the preprint is available.
|
| 520 |
+
|
| 521 |
+
| Item | Version |
|
| 522 |
+
|---|---|
|
| 523 |
+
| Channels4World release | 1.0.0: tag `v1.0.0` (the tag pins the exact repository commit) |
|
| 524 |
+
| Collection ID | `channels4world-v1-20260714`, in every record header; it names the generated collection, while `1.0.0` names this release |
|
| 525 |
+
| Library | `channels4world` 1.0.0, Python ≥3.11 |
|
| 526 |
+
| Catalog format | `channels4world.root` version 1 |
|
c4w-root.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"collection_id": "channels4world-v1-20260714",
|
| 3 |
+
"format": "channels4world.root",
|
| 4 |
+
"format_version": 1,
|
| 5 |
+
"frequencies_hz": [
|
| 6 |
+
3500000000,
|
| 7 |
+
7000000000
|
| 8 |
+
],
|
| 9 |
+
"hf_path": "",
|
| 10 |
+
"hf_repo": "Intelligence-Networking-Lab/Channels4World",
|
| 11 |
+
"kind": "release",
|
| 12 |
+
"payload": "tar",
|
| 13 |
+
"release": "1.0.0",
|
| 14 |
+
"source": null,
|
| 15 |
+
"tables": {
|
| 16 |
+
"files": {
|
| 17 |
+
"bytes": 1637414,
|
| 18 |
+
"path": "c4w-root/files.parquet",
|
| 19 |
+
"sha256": "77a971c31f048162e595b88218daca355e64119f2bfdd4902d9b104d0201c102"
|
| 20 |
+
},
|
| 21 |
+
"scenes": {
|
| 22 |
+
"bytes": 427119,
|
| 23 |
+
"path": "c4w-root/scenes.parquet",
|
| 24 |
+
"sha256": "cf6c74f3ff96f755b8dbfa178547a73756a1dfe1c2053c76059add0c7f1763c9"
|
| 25 |
+
}
|
| 26 |
+
},
|
| 27 |
+
"tiers": [
|
| 28 |
+
"tiny",
|
| 29 |
+
"small",
|
| 30 |
+
"medium",
|
| 31 |
+
"large",
|
| 32 |
+
"full"
|
| 33 |
+
]
|
| 34 |
+
}
|
c4w-root/files.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:77a971c31f048162e595b88218daca355e64119f2bfdd4902d9b104d0201c102
|
| 3 |
+
size 1637414
|
c4w-root/scenes.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:cf6c74f3ff96f755b8dbfa178547a73756a1dfe1c2053c76059add0c7f1763c9
|
| 3 |
+
size 427119
|
docs/files.png
ADDED
|
Git LFS Details
|
docs/hf-datasets.md
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# TAR records with HF Datasets
|
| 2 |
+
|
| 3 |
+
HF Datasets can read the existing TAR member names with its `webdataset` loader. The
|
| 4 |
+
examples need `pip install datasets`; `hf://` paths are read through `huggingface_hub`,
|
| 5 |
+
which `datasets` installs.
|
| 6 |
+
Each core/detail NPZ is one scene × carrier × BS record; each positions NPZ is one
|
| 7 |
+
scene record. These are ragged records, not preassembled UE training samples.
|
| 8 |
+
Choose and join components before defining samples or batching them.
|
| 9 |
+
|
| 10 |
+
The [card](../README.md#streaming-archives) shows a short remote/local iteration example.
|
| 11 |
+
`streaming=True` returns an iterable; omitting it downloads remote input as needed and
|
| 12 |
+
builds an Arrow dataset on disk, even when the TARs are already local. Neither route
|
| 13 |
+
extracts a subset root for the channels4world library. Tiny can remain loose throughout.
|
| 14 |
+
|
| 15 |
+
## Decoding and array representation
|
| 16 |
+
|
| 17 |
+
HF's loader already decodes `record["npz"]`; do not pass that mapping to `np.load`.
|
| 18 |
+
Its feature inference and NumPy formatting are separate steps: integer widths can
|
| 19 |
+
change, and empty arrays need their declared dimensions restored. Direct NumPy NPZ
|
| 20 |
+
reads and the channels4world library retain the stored numeric dtypes and shapes; HF's formatted
|
| 21 |
+
rows do not promise that representation unchanged.
|
| 22 |
+
|
| 23 |
+
The explicit features and restoration below follow the release's array schema
|
| 24 |
+
(`schema/arrays.json`, summarized in the [schema reference](schema-reference.md)). The
|
| 25 |
+
shape comes from each NPZ's embedded JSON `__meta__`.
|
| 26 |
+
|
| 27 |
+
```python
|
| 28 |
+
import json
|
| 29 |
+
import numpy as np
|
| 30 |
+
from datasets import Array2D, Features, Sequence, Value, load_dataset
|
| 31 |
+
|
| 32 |
+
SCHEMAS = {
|
| 33 |
+
"core": {
|
| 34 |
+
"link_ue_index": ("int32", ("links",)),
|
| 35 |
+
"link_path_offsets": ("int64", ("links+1",)),
|
| 36 |
+
"path_rank": ("uint8", ("paths",)),
|
| 37 |
+
"a_real": ("float32", ("paths",)), "a_imag": ("float32", ("paths",)),
|
| 38 |
+
"tau": ("float32", ("paths",)),
|
| 39 |
+
"theta_t": ("float32", ("paths",)), "phi_t": ("float32", ("paths",)),
|
| 40 |
+
"theta_r": ("float32", ("paths",)), "phi_r": ("float32", ("paths",)),
|
| 41 |
+
"interaction_count": ("uint8", ("paths",)),
|
| 42 |
+
"interaction_flags": ("uint16", ("paths",)),
|
| 43 |
+
},
|
| 44 |
+
"detail": {
|
| 45 |
+
"path_interaction_offsets": ("int64", ("paths+1",)),
|
| 46 |
+
"interaction_rank": ("uint8", ("interactions",)),
|
| 47 |
+
"interaction_type": ("int8", ("interactions",)),
|
| 48 |
+
"interaction_vertex": ("float32", ("interactions", 3)),
|
| 49 |
+
},
|
| 50 |
+
"positions": {
|
| 51 |
+
"bs_positions": ("float32", ("bs", 3)),
|
| 52 |
+
"ue_positions": ("float32", ("ues", 3)),
|
| 53 |
+
},
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
def features_for(component):
|
| 57 |
+
fields = {"__meta__": Value("string")}
|
| 58 |
+
for name, (dtype, axes) in SCHEMAS[component].items():
|
| 59 |
+
fields[name] = (Array2D(shape=(None, 3), dtype=dtype) if len(axes) == 2
|
| 60 |
+
else Sequence(Value(dtype)))
|
| 61 |
+
return Features({"__key__": Value("string"), "__url__": Value("string"), "npz": fields})
|
| 62 |
+
|
| 63 |
+
def restore_npz(record):
|
| 64 |
+
raw = record["npz"]
|
| 65 |
+
meta = json.loads(str(raw["__meta__"]))
|
| 66 |
+
def size(axis):
|
| 67 |
+
if isinstance(axis, int):
|
| 68 |
+
return axis
|
| 69 |
+
name, _, extra = axis.partition("+")
|
| 70 |
+
return meta["dimensions"][name] + (int(extra) if extra else 0)
|
| 71 |
+
arrays = {
|
| 72 |
+
name: np.asarray(raw[name], dtype=dtype).reshape(tuple(size(a) for a in axes))
|
| 73 |
+
for name, (dtype, axes) in SCHEMAS[meta["identity"]["component"]].items()
|
| 74 |
+
}
|
| 75 |
+
return meta, arrays
|
| 76 |
+
```
|
| 77 |
+
|
| 78 |
+
For example, zero interactions restore `interaction_vertex` to `(0, 3)` rather than
|
| 79 |
+
an ambiguous empty vector. Core and detail offsets still have their final sentinel:
|
| 80 |
+
an empty core has `link_path_offsets.shape == (1,)`.
|
| 81 |
+
|
| 82 |
+
## One chosen link, with remote or local TARs
|
| 83 |
+
|
| 84 |
+
Stream only the archives of the group that holds the chosen scene (the `group` column of
|
| 85 |
+
the `scenes` catalog), then pick records by identity:
|
| 86 |
+
|
| 87 |
+
```python
|
| 88 |
+
SCENE_ID, BS_ID, UE_ID = "urban_scene_019234", 0, 14
|
| 89 |
+
GROUP = "test-urban-g00000" # from the scenes catalog
|
| 90 |
+
base = "hf://datasets/Intelligence-Networking-Lab/Channels4World@v1.0.0/payload"
|
| 91 |
+
# For downloaded copies: base = "c4w/payload"
|
| 92 |
+
|
| 93 |
+
def records(component):
|
| 94 |
+
archive = (f"{base}/3.5ghz/core/inc1-small/{GROUP}-3.5ghz-core.tar" if component == "core"
|
| 95 |
+
else f"{base}/scene/positions/inc1-small/{GROUP}-positions.tar")
|
| 96 |
+
return load_dataset(
|
| 97 |
+
"webdataset", streaming=True, features=features_for(component),
|
| 98 |
+
data_files={"test": archive},
|
| 99 |
+
)["test"].with_format("numpy")
|
| 100 |
+
|
| 101 |
+
def identity_of(meta):
|
| 102 |
+
i = meta["identity"]
|
| 103 |
+
return i["scene_id"], i["bs_index"]
|
| 104 |
+
|
| 105 |
+
meta, core = next((m, a) for m, a in map(restore_npz, records("core"))
|
| 106 |
+
if identity_of(m) == (SCENE_ID, BS_ID))
|
| 107 |
+
positions = next(a for m, a in map(restore_npz, records("positions"))
|
| 108 |
+
if m["identity"]["scene_id"] == SCENE_ID)
|
| 109 |
+
|
| 110 |
+
row = int(np.searchsorted(core["link_ue_index"], UE_ID)) # UE 14's link row
|
| 111 |
+
assert row < core["link_ue_index"].size and core["link_ue_index"][row] == UE_ID
|
| 112 |
+
start, stop = map(int, core["link_path_offsets"][row:row + 2])
|
| 113 |
+
print(core["tau"][start:stop])
|
| 114 |
+
print(core["a_real"][start:stop] + 1j * core["a_imag"][start:stop])
|
| 115 |
+
print(np.linalg.norm(positions["ue_positions"][UE_ID] - positions["bs_positions"][BS_ID]))
|
| 116 |
+
```
|
| 117 |
+
|
| 118 |
+
Archives stream in order, so each iterator reads until it reaches the matching record:
|
| 119 |
+
at most one group's archive (800 channel records or 25 scene records). This scene is the
|
| 120 |
+
first in its group, so both stop almost at once. To fetch one record without reading the
|
| 121 |
+
rest of its archive, use a byte-range read
|
| 122 |
+
([file guide](without-library.md#find-the-byte-location-of-one-record)). For repeated
|
| 123 |
+
workloads, index or cache positions rather than rescanning them for every BS.
|
| 124 |
+
Core and detail additionally join by carrier and BS and must share `path_axis_sha256`;
|
| 125 |
+
their `__key__` values differ by component. Use the identity and dependency metadata, not
|
| 126 |
+
only equal array lengths. Restoration itself does not verify content hashes.
|
| 127 |
+
|
| 128 |
+
## Optional: stock WebDataset and NumPy
|
| 129 |
+
|
| 130 |
+
Stock `webdataset`, without calling its decoder, yields NPZ **bytes**. For a downloaded
|
| 131 |
+
core TAR, standard NumPy opens those bytes with their stored dtypes and shapes:
|
| 132 |
+
|
| 133 |
+
```python
|
| 134 |
+
import io
|
| 135 |
+
import webdataset as wds
|
| 136 |
+
|
| 137 |
+
archive = "c4w/payload/3.5ghz/core/inc1-small/test-urban-g00000-3.5ghz-core.tar"
|
| 138 |
+
key = "records/scene=urban_scene_019234/band_hz=3500000000/component=core/bs00000"
|
| 139 |
+
record = next(r for r in wds.WebDataset(archive, shardshuffle=False) if r["__key__"] == key)
|
| 140 |
+
with np.load(io.BytesIO(record["npz"]), allow_pickle=False) as npz:
|
| 141 |
+
core = {name: npz[name] for name in npz.files if name != "__meta__"}
|
| 142 |
+
meta = json.loads(npz["__meta__"].item())
|
| 143 |
+
```
|
| 144 |
+
|
| 145 |
+
Each WebDataset sample is one member: `__key__` is the member path without its `.npz`
|
| 146 |
+
extension. Keep the same UE, scene and component associations as above.
|
| 147 |
+
|
| 148 |
+
Explicit features avoid relying on types inferred from the first examples, and
|
| 149 |
+
restoration makes the stored dtypes and shapes explicit again. Reference behavior:
|
| 150 |
+
[HF WebDataset loader](https://github.com/huggingface/datasets/blob/5.1.0/src/datasets/packaged_modules/webdataset/webdataset.py)
|
| 151 |
+
and [NumPy formatter](https://github.com/huggingface/datasets/blob/5.1.0/src/datasets/formatting/np_formatter.py).
|
| 152 |
+
|
| 153 |
+
[Return to card](../README.md) · [Without the library](without-library.md) · [Schema](schema-reference.md)
|
docs/layout.svg
ADDED
|
|
docs/library-guide.md
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Library guide
|
| 2 |
+
|
| 3 |
+
The `channels4world` library (1.0.0) requires Python ≥3.11, NumPy and PyArrow. Install it
|
| 4 |
+
with `pip install channels4world`; its full documentation is at <https://github.com/JoonkyuJang/channels4world#readme>. It reads local
|
| 5 |
+
files and never downloads them. A download into the Hugging Face cache
|
| 6 |
+
(`snapshot_download` without `local_dir`) works too: open the snapshot folder it returns.
|
| 7 |
+
|
| 8 |
+
## Partial Tiny and direct reads
|
| 9 |
+
|
| 10 |
+
Opening a root reads `c4w-root.json` and **every table referenced by that manifest**.
|
| 11 |
+
For Tiny these include scenes, files and included records. Payloads and group
|
| 12 |
+
metadata load later. Downloading those root tables, shared schemas, the chosen
|
| 13 |
+
scene's group metadata and its payloads permits direct access to that explicit
|
| 14 |
+
scene even when the other Tiny payloads are absent. Do not select an arbitrary first
|
| 15 |
+
scene when only one known scene has been downloaded.
|
| 16 |
+
|
| 17 |
+
```python
|
| 18 |
+
from pathlib import Path
|
| 19 |
+
import channels4world as c4w
|
| 20 |
+
|
| 21 |
+
TINY_ROOT = Path("c4w/tiny")
|
| 22 |
+
SCENE_ID, CARRIER_HZ, BS_ID, UE_ID = "urban_scene_019234", 3_500_000_000, 0, 14
|
| 23 |
+
|
| 24 |
+
ds = c4w.open(TINY_ROOT)
|
| 25 |
+
scene = ds.scene(SCENE_ID)
|
| 26 |
+
record = scene.frequencies[CARRIER_HZ].base_stations[BS_ID].read()
|
| 27 |
+
positions = scene.read_positions()
|
| 28 |
+
link = record.get_link(UE_ID) # BS 0 → UE 14: 16 retained paths
|
| 29 |
+
```
|
| 30 |
+
|
| 31 |
+
A loaded record's absent UE IDs mean no retained link; missing files and unpublished
|
| 32 |
+
components raise separate availability errors. Selecting across partially downloaded
|
| 33 |
+
**loose** Tiny before group metadata is available can conservatively plan other files
|
| 34 |
+
in a touched group. For the first scene, use the card's narrow include command and
|
| 35 |
+
explicit scene read; direct reads do not require every scene's payload.
|
| 36 |
+
|
| 37 |
+
## Root-first planning for TAR releases
|
| 38 |
+
|
| 39 |
+
Download the release catalog (`c4w-root.json` and `c4w-root/`) at the release revision.
|
| 40 |
+
`missing()` can then plan from the catalog alone.
|
| 41 |
+
For groups whose members/snapshot are absent, it lists matching component/carrier
|
| 42 |
+
TARs and requested scene assets, plus required metadata and schemas. Once metadata
|
| 43 |
+
is local, it maps selected records to their TARs. Because a TAR contains the group's
|
| 44 |
+
records for one component/carrier, either route uses archives as download units.
|
| 45 |
+
Rerun after downloading to resolve unpublished requests and confirm completeness.
|
| 46 |
+
|
| 47 |
+
```python
|
| 48 |
+
import channels4world as c4w
|
| 49 |
+
|
| 50 |
+
ds = c4w.open("c4w") # the release root is the repository top level
|
| 51 |
+
selection = ds.select(
|
| 52 |
+
tier="small", frequencies_hz=[3_500_000_000], components=("positions", "core"),
|
| 53 |
+
)
|
| 54 |
+
report = selection.missing()
|
| 55 |
+
print(report) # files and total bytes
|
| 56 |
+
if report.files:
|
| 57 |
+
print(report.hf_command(revision="v1.0.0"))
|
| 58 |
+
```
|
| 59 |
+
|
| 60 |
+
`report.files` are paths inside the opened root. `report.repo_files` are the same files
|
| 61 |
+
as repository paths (identical for the release root; prefixed with `tiny/` for Tiny), and
|
| 62 |
+
`report.local_dir` is the folder that corresponds to the repository's top level.
|
| 63 |
+
`hf_command(revision=...)` uses both and quotes every argument. It refuses an empty plan
|
| 64 |
+
and roots that are not published as-is, such as a subset you extracted yourself, whose
|
| 65 |
+
loose files exist only on your disk.
|
| 66 |
+
|
| 67 |
+
For long plans, avoid putting thousands of paths on a shell command line:
|
| 68 |
+
|
| 69 |
+
```python
|
| 70 |
+
from huggingface_hub import snapshot_download
|
| 71 |
+
|
| 72 |
+
if report.files:
|
| 73 |
+
snapshot_download(
|
| 74 |
+
repo_id="Intelligence-Networking-Lab/Channels4World", repo_type="dataset",
|
| 75 |
+
revision="v1.0.0", local_dir=report.local_dir,
|
| 76 |
+
allow_patterns=report.repo_files,
|
| 77 |
+
)
|
| 78 |
+
report = selection.missing()
|
| 79 |
+
if report.files:
|
| 80 |
+
raise RuntimeError("Files are still missing; re-plan the download.")
|
| 81 |
+
if report.unpublished:
|
| 82 |
+
raise RuntimeError(f"Requested components are not published: {report.unpublished}")
|
| 83 |
+
```
|
| 84 |
+
|
| 85 |
+
The published catalogs at that revision are the source of truth for paths, sizes and
|
| 86 |
+
hashes. Without the library, the increment-folder patterns in the
|
| 87 |
+
[file guide](without-library.md#download-a-tiers-archives) select a whole tier.
|
| 88 |
+
|
| 89 |
+
Selections combine filters. `ds.profiles` lists the catalog's profile names:
|
| 90 |
+
|
| 91 |
+
```python
|
| 92 |
+
metro_train = ds.select(tier="medium", split="train", profile="metropolitan",
|
| 93 |
+
frequencies_hz=[7_000_000_000], components=("positions", "core"))
|
| 94 |
+
```
|
| 95 |
+
|
| 96 |
+
### Share a selection as a recipe
|
| 97 |
+
|
| 98 |
+
A recipe is a small JSON file that records a selection (tier, split, profiles, scene IDs,
|
| 99 |
+
carriers, BS IDs and components) and the release it refers to. It holds no paths or
|
| 100 |
+
commands, so whoever replays it plans the download from their own catalog:
|
| 101 |
+
|
| 102 |
+
```python
|
| 103 |
+
with open("selection.json", "w") as fh:
|
| 104 |
+
fh.write(c4w.recipe.dumps(selection.to_recipe(revision="v1.0.0")))
|
| 105 |
+
|
| 106 |
+
same = c4w.open("c4w").select_recipe("selection.json")
|
| 107 |
+
```
|
| 108 |
+
|
| 109 |
+
The command line does the same. `c4w recipe` never overwrites a file, so choose a new name:
|
| 110 |
+
|
| 111 |
+
```bash
|
| 112 |
+
c4w recipe c4w --tier small --frequency 3500000000 --components positions,core \
|
| 113 |
+
--revision v1.0.0 -o small-core.json
|
| 114 |
+
c4w missing c4w --recipe small-core.json # prints the hf download command, pinned to v1.0.0
|
| 115 |
+
```
|
| 116 |
+
|
| 117 |
+
The [download helper](https://cbchae.yonsei.ac.kr/channels4world/download.html) on the
|
| 118 |
+
project website writes the same recipes. A recipe for another release is refused, and every
|
| 119 |
+
filter is checked against the catalog exactly as `select()` checks it.
|
| 120 |
+
|
| 121 |
+
The examples below continue with the Small selection from above.
|
| 122 |
+
|
| 123 |
+
## Iterate, extract or cache
|
| 124 |
+
|
| 125 |
+
```python
|
| 126 |
+
for scene in selection.scenes():
|
| 127 |
+
positions = scene.read_positions()
|
| 128 |
+
for record in scene.records(): # selected scene preserves carrier/BS/component filters
|
| 129 |
+
print(record.scene_id, record.frequency_hz, record.bs_id, record.n_links)
|
| 130 |
+
|
| 131 |
+
# Use new destinations after missing()/coverage checks have passed.
|
| 132 |
+
c4w.extract(selection, "small-loose", verify="basic", check_space=True)
|
| 133 |
+
c4w.to_cache(selection, "small-npy", verify="basic", check_space=True)
|
| 134 |
+
```
|
| 135 |
+
|
| 136 |
+
Packed TARs preserve original NPZ/ZIP records. `extract` preserves selected
|
| 137 |
+
`member_path` values and original payload bytes and writes a common loose subset
|
| 138 |
+
root. The optional NPY cache instead stores arrays plus indexes for memory-mapped
|
| 139 |
+
repeated access; values, IDs, dtypes and ragged associations stay the same. Geometry
|
| 140 |
+
remains ZIP. A cache is not another scene tier.
|
| 141 |
+
|
| 142 |
+
## Arrays are read-only
|
| 143 |
+
|
| 144 |
+
Arrays returned by the library are read-only views of the stored data. Arithmetic such as
|
| 145 |
+
`record.core["tau"] * 1e9` creates a new array; to modify values in place, copy first
|
| 146 |
+
(`record.copy()` or `np.array(...)`).
|
| 147 |
+
|
| 148 |
+
## Reads, file handles and disk writes
|
| 149 |
+
|
| 150 |
+
| Verb | Meaning | Examples |
|
| 151 |
+
|---|---|---|
|
| 152 |
+
| `read` / `read_*` | Load data into memory | `bs.read()`, `scene.read_positions()` |
|
| 153 |
+
| `open_*` | Return a handle to close | `scene.open_geometry()` returns `ZipFile` |
|
| 154 |
+
| `extract` / `extract_*` | Write files and return a path | `c4w.extract(selection, dest)`, `scene.extract_geometry(dest)` |
|
| 155 |
+
|
| 156 |
+
Geometry extraction requires a destination because renderers load XML and referenced
|
| 157 |
+
meshes from disk. Positions are arrays. No hidden temporary geometry location is
|
| 158 |
+
assumed.
|
| 159 |
+
|
| 160 |
+
`verify="basic"` checks declared bytes and array structure. `verify="full"` adds
|
| 161 |
+
scientific/content-proof checks for loaded components. A full core+detail read checks
|
| 162 |
+
their association together. Extraction/cache conversion does not replace that
|
| 163 |
+
pairwise read check. See the [schema reference](schema-reference.md).
|
| 164 |
+
|
| 165 |
+
## Optional transforms
|
| 166 |
+
|
| 167 |
+
```python
|
| 168 |
+
import numpy as np
|
| 169 |
+
from channels4world import transforms as T
|
| 170 |
+
|
| 171 |
+
rms_delay_s = T.delay_spread(record)
|
| 172 |
+
response = T.frequency_response(
|
| 173 |
+
record, np.array([-1e6, 0.0, 1e6]), delay_reference="absolute",
|
| 174 |
+
)
|
| 175 |
+
```
|
| 176 |
+
|
| 177 |
+
These return new writable arrays describing retained paths. Frequency inputs above
|
| 178 |
+
are **offsets from the record's carrier**, not absolute frequencies. `T.pad_paths(record.core,
|
| 179 |
+
"tau")` gives one row per link, `(links, 16)`, with a mask of stored paths, and
|
| 180 |
+
`T.pad_interactions(record.detail, "interaction_vertex")` one row per path, `(paths, 4, 3)`;
|
| 181 |
+
both match the card's padding snippet. Stored
|
| 182 |
+
`a_real + 1j*a_imag` is a scalar passband coefficient excluding carrier-delay phase;
|
| 183 |
+
`tau` is absolute propagation delay. Do not add antenna effects twice. The
|
| 184 |
+
[conventions reference](schema-reference.md) provides the details.
|
| 185 |
+
|
| 186 |
+
[Return to card](../README.md) · [Without the library](without-library.md)
|
docs/ml-guide.md
ADDED
|
@@ -0,0 +1,220 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# From channel records to a DataLoader
|
| 2 |
+
|
| 3 |
+
This guide turns Channels4World records into fixed-size arrays and a PyTorch `DataLoader`,
|
| 4 |
+
with train, validation and test sets split by scene. It ends at one batch whose contents
|
| 5 |
+
are explained, so you can adapt the inputs and targets to your model, or swap these
|
| 6 |
+
batches into an existing training loop. The [notebook version](notebooks/03-dataloader.ipynb)
|
| 7 |
+
runs top to bottom.
|
| 8 |
+
|
| 9 |
+
The example uses the 100 urban scenes of Tiny (90 train, 10 test), BS 0 at 3.5 GHz. Change the
|
| 10 |
+
selection to scale up; the steps stay the same. Install the library with `pip install channels4world`
|
| 11 |
+
(Python 3.11+), then `pip install torch huggingface_hub`.
|
| 12 |
+
|
| 13 |
+
```python
|
| 14 |
+
from pathlib import Path
|
| 15 |
+
import hashlib
|
| 16 |
+
import json
|
| 17 |
+
|
| 18 |
+
import numpy as np
|
| 19 |
+
import torch
|
| 20 |
+
from huggingface_hub import snapshot_download
|
| 21 |
+
from torch.utils.data import DataLoader, Dataset
|
| 22 |
+
|
| 23 |
+
import channels4world as c4w
|
| 24 |
+
from channels4world import transforms as T
|
| 25 |
+
|
| 26 |
+
REPO, REVISION = "Intelligence-Networking-Lab/Channels4World", "v1.0.0"
|
| 27 |
+
DATA = Path("c4w")
|
| 28 |
+
```
|
| 29 |
+
|
| 30 |
+
## 1. Choose the records
|
| 31 |
+
|
| 32 |
+
One **sample** here is one retained link: a (scene, carrier, BS, UE) channel. A record holds
|
| 33 |
+
every retained link of one BS at one carrier, so records are read whole and split into
|
| 34 |
+
links. First download Tiny's catalog and the metadata of the five groups that hold its urban
|
| 35 |
+
scenes (about 42 MB), so the library can plan exactly which record files the selection needs:
|
| 36 |
+
here about 0.4 GB.
|
| 37 |
+
|
| 38 |
+
```python
|
| 39 |
+
snapshot_download(REPO, repo_type="dataset", revision=REVISION, local_dir=DATA, allow_patterns=[
|
| 40 |
+
"tiny/c4w-root.json", "tiny/c4w-root/*", "tiny/schema/*",
|
| 41 |
+
"tiny/groups/*-urban-g*/catalog/members.parquet", "tiny/groups/*-urban-g*/snapshot.json"])
|
| 42 |
+
|
| 43 |
+
ds = c4w.open(DATA / "tiny")
|
| 44 |
+
selection = ds.select(profile="urban", frequencies_hz=[3_500_000_000], bs_ids=[0],
|
| 45 |
+
components=("core", "positions"))
|
| 46 |
+
report = selection.missing()
|
| 47 |
+
print(report)
|
| 48 |
+
if report.files:
|
| 49 |
+
snapshot_download(REPO, repo_type="dataset", revision=REVISION, local_dir=report.local_dir,
|
| 50 |
+
allow_patterns=report.repo_files)
|
| 51 |
+
assert selection.missing().complete
|
| 52 |
+
```
|
| 53 |
+
|
| 54 |
+
## 2. Split by scene
|
| 55 |
+
|
| 56 |
+
Keep the release's train and test split: test scenes are places no training scene shows.
|
| 57 |
+
Take validation scenes from the training split, by scene and never by link, so links of one
|
| 58 |
+
place never sit on both sides. Hashing the scene ID makes the choice reproducible, and
|
| 59 |
+
saving the lists records it.
|
| 60 |
+
|
| 61 |
+
```python
|
| 62 |
+
def is_validation(scene_id, fraction=0.1):
|
| 63 |
+
return int(hashlib.sha256(scene_id.encode()).hexdigest(), 16) % 1000 < fraction * 1000
|
| 64 |
+
|
| 65 |
+
splits = {"train": [], "validation": [], "test": []}
|
| 66 |
+
for scene in selection.scenes():
|
| 67 |
+
part = "test" if scene.split == "test" else ("validation" if is_validation(scene.id) else "train")
|
| 68 |
+
splits[part].append(scene.id)
|
| 69 |
+
print({k: len(v) for k, v in splits.items()})
|
| 70 |
+
Path("splits.json").write_text(json.dumps(splits, indent=1))
|
| 71 |
+
```
|
| 72 |
+
|
| 73 |
+
## 3. From a record to arrays
|
| 74 |
+
|
| 75 |
+
Each record becomes arrays with one row per link. This is where your own preprocessing goes:
|
| 76 |
+
`inputs` here are the UE position relative to the BS and the BS height; `targets` are the
|
| 77 |
+
strongest 16 paths' delays (ns), powers (dB) and arrival angles, padded to fixed size with a
|
| 78 |
+
mask that marks stored paths. Replace either function to fit your task. `LINKS_PER_RECORD`
|
| 79 |
+
bounds memory by sampling links reproducibly.
|
| 80 |
+
|
| 81 |
+
```python
|
| 82 |
+
LINKS_PER_RECORD = 512
|
| 83 |
+
PREPROCESSING = "v1: dxyz+bs_z -> 16 x (delay ns, power dB, cos/sin AoA az, AoA zenith)"
|
| 84 |
+
|
| 85 |
+
def inputs(record, positions):
|
| 86 |
+
ue = positions.ue[record.ue_ids].astype(np.float32)
|
| 87 |
+
bs = positions.bs[record.bs_id].astype(np.float32)
|
| 88 |
+
return np.concatenate([ue - bs, np.full((len(ue), 1), bs[2], np.float32)], axis=1) # (links, 4)
|
| 89 |
+
|
| 90 |
+
def targets(record):
|
| 91 |
+
core = record.core
|
| 92 |
+
power = 10 * np.log10(core["a_real"].astype(np.float64) ** 2 + core["a_imag"].astype(np.float64) ** 2)
|
| 93 |
+
per_path = np.stack([core["tau"] * 1e9, power, np.cos(core["phi_r"]), np.sin(core["phi_r"]),
|
| 94 |
+
core["theta_r"]], axis=1).astype(np.float32) # (paths, 5)
|
| 95 |
+
padded, mask = T.pad_paths(core, per_path) # (links, 16, 5), (links, 16)
|
| 96 |
+
return padded, mask
|
| 97 |
+
|
| 98 |
+
def arrays(scene_ids):
|
| 99 |
+
rng = np.random.default_rng(0)
|
| 100 |
+
x, y, m, ids = [], [], [], []
|
| 101 |
+
for scene in selection.scenes():
|
| 102 |
+
if scene.id not in scene_ids:
|
| 103 |
+
continue
|
| 104 |
+
positions = scene.read_positions()
|
| 105 |
+
for record in scene.records():
|
| 106 |
+
keep = np.sort(rng.permutation(record.n_links)[:LINKS_PER_RECORD])
|
| 107 |
+
padded, mask = targets(record)
|
| 108 |
+
x.append(inputs(record, positions)[keep]); y.append(padded[keep]); m.append(mask[keep])
|
| 109 |
+
ids += [(scene.id, record.frequency_hz, record.bs_id, int(u)) for u in record.ue_ids[keep]]
|
| 110 |
+
return {"x": np.concatenate(x), "y": np.concatenate(y), "mask": np.concatenate(m),
|
| 111 |
+
"ids": np.array(ids, dtype=object)}
|
| 112 |
+
```
|
| 113 |
+
|
| 114 |
+
## 4. Cache, then normalize with training statistics only
|
| 115 |
+
|
| 116 |
+
Converting records takes a while, so save the arrays once. The cache key covers the release,
|
| 117 |
+
the selection, the scene lists of the split and the preprocessing version: change any of them
|
| 118 |
+
(including the validation fraction) and a new cache is built. Loading checks that every cached
|
| 119 |
+
row comes from a scene of its part.
|
| 120 |
+
Normalization is fitted on the training split and then applied unchanged to validation and
|
| 121 |
+
test, so no information leaks from held-out scenes. Target statistics use stored paths only,
|
| 122 |
+
and padded entries stay zero. Keep the statistics to turn predictions back into units.
|
| 123 |
+
|
| 124 |
+
```python
|
| 125 |
+
recipe = c4w.recipe.dumps(selection.to_recipe(revision=REVISION))
|
| 126 |
+
split_lists = json.dumps(splits, sort_keys=True)
|
| 127 |
+
key = hashlib.sha256(
|
| 128 |
+
f"{ds.release}|{recipe}|{split_lists}|{PREPROCESSING}|{LINKS_PER_RECORD}".encode()).hexdigest()[:16]
|
| 129 |
+
cache = Path("cache") / key
|
| 130 |
+
data = {}
|
| 131 |
+
for part, scene_ids in splits.items():
|
| 132 |
+
path = cache / f"{part}.npz"
|
| 133 |
+
if not path.exists():
|
| 134 |
+
cache.mkdir(parents=True, exist_ok=True)
|
| 135 |
+
a = arrays(set(scene_ids))
|
| 136 |
+
np.savez(path, x=a["x"], y=a["y"], mask=a["mask"], ids=a["ids"].astype(str))
|
| 137 |
+
with np.load(path) as z:
|
| 138 |
+
data[part] = {k: z[k] for k in z.files}
|
| 139 |
+
assert set(data[part]["ids"][:, 0]) <= set(scene_ids), f"cached {part} rows from other scenes"
|
| 140 |
+
print(part, data[part]["x"].shape, data[part]["y"].shape)
|
| 141 |
+
|
| 142 |
+
train = data["train"]
|
| 143 |
+
stored = train["y"][train["mask"]] # (stored paths, 5)
|
| 144 |
+
stats = {"x_mean": train["x"].mean(axis=0), "x_std": train["x"].std(axis=0) + 1e-6,
|
| 145 |
+
"y_mean": stored.mean(axis=0), "y_std": stored.std(axis=0) + 1e-6}
|
| 146 |
+
np.savez(cache / "normalization.npz", **stats)
|
| 147 |
+
for part in data.values():
|
| 148 |
+
part["x"] = ((part["x"] - stats["x_mean"]) / stats["x_std"]).astype(np.float32)
|
| 149 |
+
y = (part["y"] - stats["y_mean"]) / stats["y_std"]
|
| 150 |
+
part["y"] = np.where(part["mask"][..., None], y, 0).astype(np.float32)
|
| 151 |
+
```
|
| 152 |
+
|
| 153 |
+
## 5. A Dataset and a DataLoader
|
| 154 |
+
|
| 155 |
+
Every sample has the same shape, so PyTorch's default collate function batches them. Shuffle
|
| 156 |
+
the training set; keep validation and test in order.
|
| 157 |
+
|
| 158 |
+
```python
|
| 159 |
+
class LinkDataset(Dataset):
|
| 160 |
+
def __init__(self, part):
|
| 161 |
+
self.x = torch.from_numpy(part["x"])
|
| 162 |
+
self.y = torch.from_numpy(part["y"])
|
| 163 |
+
self.mask = torch.from_numpy(part["mask"])
|
| 164 |
+
|
| 165 |
+
def __len__(self):
|
| 166 |
+
return len(self.x)
|
| 167 |
+
|
| 168 |
+
def __getitem__(self, i):
|
| 169 |
+
return {"x": self.x[i], "y": self.y[i], "mask": self.mask[i]}
|
| 170 |
+
|
| 171 |
+
loaders = {part: DataLoader(LinkDataset(data[part]), batch_size=256, shuffle=(part == "train"))
|
| 172 |
+
for part in data}
|
| 173 |
+
batch = next(iter(loaders["train"]))
|
| 174 |
+
for name, value in batch.items():
|
| 175 |
+
print(f"{name:5s} {tuple(value.shape)} {value.dtype}")
|
| 176 |
+
```
|
| 177 |
+
|
| 178 |
+
## 6. What a batch holds
|
| 179 |
+
|
| 180 |
+
- `x` (batch, 4): the UE position relative to the BS, in metres, and the BS height,
|
| 181 |
+
normalized with training statistics.
|
| 182 |
+
- `y` (batch, 16, 5): up to 16 paths per link, strongest first; per path the delay in ns, the
|
| 183 |
+
power in dB relative to unit power, the cosine and sine of the arrival azimuth and the
|
| 184 |
+
arrival zenith in radians, each normalized with the training split's stored paths.
|
| 185 |
+
- `mask` (batch, 16): true where a path is stored. Padded paths are zeros: use the mask in
|
| 186 |
+
every loss and metric so they never count as weak paths.
|
| 187 |
+
|
| 188 |
+
The saved `ids` (scene, carrier, BS, UE) tie each row back to its record.
|
| 189 |
+
|
| 190 |
+
```python
|
| 191 |
+
paths = data["train"]["mask"].sum(axis=1)
|
| 192 |
+
print("stored paths per link: min", paths.min(), "mean", round(float(paths.mean()), 1), "max", paths.max())
|
| 193 |
+
|
| 194 |
+
def masked_mse(prediction, target, mask):
|
| 195 |
+
error = ((prediction - target) ** 2).mean(dim=-1) # (batch, 16)
|
| 196 |
+
return (error * mask).sum() / mask.sum().clamp(min=1)
|
| 197 |
+
|
| 198 |
+
# Predicting the training mean (zero after normalization) gives a masked MSE near 1.
|
| 199 |
+
print("masked MSE of predicting the mean:",
|
| 200 |
+
round(float(masked_mse(torch.zeros_like(batch["y"]), batch["y"], batch["mask"])), 3))
|
| 201 |
+
```
|
| 202 |
+
|
| 203 |
+
## Adapt it
|
| 204 |
+
|
| 205 |
+
- **Other inputs:** add the carrier, the scene geometry (`scene.open_geometry()`), or the
|
| 206 |
+
channel at the other carrier for cross-band tasks; keep them per link.
|
| 207 |
+
- **Other targets:** use the complex coefficients, departure angles, the frequency response
|
| 208 |
+
(`T.frequency_response`) or the interaction detail (`components=("core", "detail")`,
|
| 209 |
+
`T.pad_interactions`).
|
| 210 |
+
- **More data:** widen the selection (`tier="small"` on the release catalog, other profiles or
|
| 211 |
+
BSs) and raise `LINKS_PER_RECORD`; the [library guide](library-guide.md) plans TAR
|
| 212 |
+
downloads, and `c4w.to_cache` keeps records memory-mapped for repeated reads.
|
| 213 |
+
- **Shuffling at scale:** records are stored in groups of 25 scenes; shuffle groups or scenes
|
| 214 |
+
and read each one's records together, as above.
|
| 215 |
+
- **Records instead of links:** `channels4world.torch.RecordDataset(selection, transform=...)`
|
| 216 |
+
yields one record per item and reopens the dataset in each worker process.
|
| 217 |
+
|
| 218 |
+
*Notebook: [03-dataloader.ipynb](notebooks/03-dataloader.ipynb). The page and the notebook hold the same code.*
|
| 219 |
+
|
| 220 |
+
[Return to card](../README.md)
|
docs/notebooks/01-read-one-scene-library.ipynb
ADDED
|
@@ -0,0 +1,345 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"cells": [
|
| 3 |
+
{
|
| 4 |
+
"cell_type": "markdown",
|
| 5 |
+
"id": "cell-00",
|
| 6 |
+
"metadata": {},
|
| 7 |
+
"source": [
|
| 8 |
+
"# Read one scene with the channels4world library\n",
|
| 9 |
+
"\n",
|
| 10 |
+
"This tutorial follows one link of Channels4World from the catalog down to its paths:\n",
|
| 11 |
+
"**BS 0 → UE 14 of `urban_scene_019234` at 3.5 GHz**, the link the project website shows.\n",
|
| 12 |
+
"It downloads about 26 MB of one Tiny scene, walks the hierarchy, reads the geometry, the\n",
|
| 13 |
+
"positions and the channel record, explains the stored arrays, and ends with the same link\n",
|
| 14 |
+
"at 7 GHz. [The same tutorial without the library](https://huggingface.co/datasets/Intelligence-Networking-Lab/Channels4World/blob/v1.0.0/docs/tutorial-numpy.md) reads the same link\n",
|
| 15 |
+
"with NumPy alone.\n",
|
| 16 |
+
"\n",
|
| 17 |
+
"Install the library with `pip install channels4world` (Python 3.11+), then\n",
|
| 18 |
+
"`pip install huggingface_hub matplotlib`."
|
| 19 |
+
]
|
| 20 |
+
},
|
| 21 |
+
{
|
| 22 |
+
"cell_type": "code",
|
| 23 |
+
"execution_count": null,
|
| 24 |
+
"id": "cell-01",
|
| 25 |
+
"metadata": {},
|
| 26 |
+
"outputs": [],
|
| 27 |
+
"source": [
|
| 28 |
+
"from pathlib import Path\n",
|
| 29 |
+
"import json\n",
|
| 30 |
+
"\n",
|
| 31 |
+
"import matplotlib.pyplot as plt\n",
|
| 32 |
+
"import numpy as np\n",
|
| 33 |
+
"from huggingface_hub import snapshot_download\n",
|
| 34 |
+
"from matplotlib.collections import PolyCollection\n",
|
| 35 |
+
"\n",
|
| 36 |
+
"import channels4world as c4w"
|
| 37 |
+
]
|
| 38 |
+
},
|
| 39 |
+
{
|
| 40 |
+
"cell_type": "markdown",
|
| 41 |
+
"id": "cell-02",
|
| 42 |
+
"metadata": {},
|
| 43 |
+
"source": [
|
| 44 |
+
"## 1. Choose the link\n",
|
| 45 |
+
"\n",
|
| 46 |
+
"Change these to read any other link. `GROUP` is the scene's `group` in the `tiny_scenes`\n",
|
| 47 |
+
"catalog. BS IDs run from 0 to 31 and UE IDs from 0 to 16,383; both are rows\n",
|
| 48 |
+
"of the scene's positions. Carriers are integers in Hz."
|
| 49 |
+
]
|
| 50 |
+
},
|
| 51 |
+
{
|
| 52 |
+
"cell_type": "code",
|
| 53 |
+
"execution_count": null,
|
| 54 |
+
"id": "cell-03",
|
| 55 |
+
"metadata": {},
|
| 56 |
+
"outputs": [],
|
| 57 |
+
"source": [
|
| 58 |
+
"REPO, REVISION = \"Intelligence-Networking-Lab/Channels4World\", \"v1.0.0\"\n",
|
| 59 |
+
"SCENE_ID, GROUP = \"urban_scene_019234\", \"test-urban-g00000\" # GROUP: from the tiny_scenes catalog\n",
|
| 60 |
+
"CARRIER_HZ, BS_ID, UE_ID = 3_500_000_000, 0, 14\n",
|
| 61 |
+
"OTHER_HZ = 7_000_000_000\n",
|
| 62 |
+
"DATA = Path(\"c4w\")"
|
| 63 |
+
]
|
| 64 |
+
},
|
| 65 |
+
{
|
| 66 |
+
"cell_type": "markdown",
|
| 67 |
+
"id": "cell-04",
|
| 68 |
+
"metadata": {},
|
| 69 |
+
"source": [
|
| 70 |
+
"## 2. Download what this tutorial reads\n",
|
| 71 |
+
"\n",
|
| 72 |
+
"Tiny is published as loose files under `tiny/`. The library needs Tiny's catalog, the shared\n",
|
| 73 |
+
"schemas and the scene's group metadata (about 11 MB); the records are the scene's positions\n",
|
| 74 |
+
"and geometry and BS 0's core and detail at both carriers (about 15 MB)."
|
| 75 |
+
]
|
| 76 |
+
},
|
| 77 |
+
{
|
| 78 |
+
"cell_type": "code",
|
| 79 |
+
"execution_count": null,
|
| 80 |
+
"id": "cell-05",
|
| 81 |
+
"metadata": {},
|
| 82 |
+
"outputs": [],
|
| 83 |
+
"source": [
|
| 84 |
+
"scene_dir = f\"tiny/records/scene={SCENE_ID}\"\n",
|
| 85 |
+
"patterns = [\n",
|
| 86 |
+
" \"tiny/c4w-root.json\", \"tiny/c4w-root/*\", \"tiny/schema/*\",\n",
|
| 87 |
+
" f\"tiny/groups/{GROUP}/catalog/members.parquet\", f\"tiny/groups/{GROUP}/snapshot.json\",\n",
|
| 88 |
+
" f\"{scene_dir}/positions.npz\", f\"{scene_dir}/geometry.zip\",\n",
|
| 89 |
+
" f\"{scene_dir}/band_hz=*/component=*/bs{BS_ID:05d}.npz\",\n",
|
| 90 |
+
"]\n",
|
| 91 |
+
"snapshot_download(REPO, repo_type=\"dataset\", revision=REVISION, local_dir=DATA, allow_patterns=patterns)"
|
| 92 |
+
]
|
| 93 |
+
},
|
| 94 |
+
{
|
| 95 |
+
"cell_type": "markdown",
|
| 96 |
+
"id": "cell-06",
|
| 97 |
+
"metadata": {},
|
| 98 |
+
"source": [
|
| 99 |
+
"## 3. Walk the hierarchy\n",
|
| 100 |
+
"\n",
|
| 101 |
+
"The dataset is organized as **dataset → scene → carrier → base station → UE link → paths**.\n",
|
| 102 |
+
"Opening reads only the small catalog; group metadata and records load when first needed."
|
| 103 |
+
]
|
| 104 |
+
},
|
| 105 |
+
{
|
| 106 |
+
"cell_type": "code",
|
| 107 |
+
"execution_count": null,
|
| 108 |
+
"id": "cell-07",
|
| 109 |
+
"metadata": {},
|
| 110 |
+
"outputs": [],
|
| 111 |
+
"source": [
|
| 112 |
+
"ds = c4w.open(DATA / \"tiny\")\n",
|
| 113 |
+
"print(ds)\n",
|
| 114 |
+
"scene = ds.scene(SCENE_ID)\n",
|
| 115 |
+
"print(scene) # split, profile and smallest tier\n",
|
| 116 |
+
"print(\"carriers (Hz):\", scene.frequencies.ids)\n",
|
| 117 |
+
"print(\"base stations:\", scene.frequencies[CARRIER_HZ].base_stations.ids)"
|
| 118 |
+
]
|
| 119 |
+
},
|
| 120 |
+
{
|
| 121 |
+
"cell_type": "markdown",
|
| 122 |
+
"id": "cell-08",
|
| 123 |
+
"metadata": {},
|
| 124 |
+
"source": [
|
| 125 |
+
"`urban_scene_019234` is a **test** scene: every link and both carriers of a scene stay in\n",
|
| 126 |
+
"one split, so a model trained on the training split has never seen this place.\n",
|
| 127 |
+
"\n",
|
| 128 |
+
"## 4. Geometry and positions\n",
|
| 129 |
+
"\n",
|
| 130 |
+
"Geometry, positions and interaction points share one frame: scene metres, z up. Positions\n",
|
| 131 |
+
"hold all 32 BS and 16,384 UE coordinates of the scene; the geometry is a Mitsuba XML file\n",
|
| 132 |
+
"with OBJ meshes in a ZIP."
|
| 133 |
+
]
|
| 134 |
+
},
|
| 135 |
+
{
|
| 136 |
+
"cell_type": "code",
|
| 137 |
+
"execution_count": null,
|
| 138 |
+
"id": "cell-09",
|
| 139 |
+
"metadata": {},
|
| 140 |
+
"outputs": [],
|
| 141 |
+
"source": [
|
| 142 |
+
"positions = scene.read_positions()\n",
|
| 143 |
+
"bs_positions, ue_positions = positions.bs, positions.ue\n",
|
| 144 |
+
"bs_xyz, ue_xyz = bs_positions[BS_ID], ue_positions[UE_ID]\n",
|
| 145 |
+
"print(positions)\n",
|
| 146 |
+
"print(\"BS\", bs_xyz, \"UE\", ue_xyz, f\"distance {np.linalg.norm(ue_xyz - bs_xyz):.1f} m\")\n",
|
| 147 |
+
"\n",
|
| 148 |
+
"def top_view(read, names):\n",
|
| 149 |
+
" \"\"\"Building triangles projected onto the ground (x, y), from OBJ meshes.\"\"\"\n",
|
| 150 |
+
" triangles = []\n",
|
| 151 |
+
" for name in names:\n",
|
| 152 |
+
" verts, faces = [], []\n",
|
| 153 |
+
" for line in read(name).decode().splitlines():\n",
|
| 154 |
+
" if line.startswith(\"v \"):\n",
|
| 155 |
+
" verts.append([float(v) for v in line.split()[1:4]])\n",
|
| 156 |
+
" elif line.startswith(\"f \"):\n",
|
| 157 |
+
" idx = [int(t.split(\"/\")[0]) for t in line.split()[1:]]\n",
|
| 158 |
+
" faces += [[idx[0], idx[k], idx[k + 1]] for k in range(1, len(idx) - 1)]\n",
|
| 159 |
+
" v = np.array(verts)\n",
|
| 160 |
+
" triangles += [v[[i - 1 for i in f], :2] for f in faces] # OBJ indices start at 1\n",
|
| 161 |
+
" return triangles\n",
|
| 162 |
+
"\n",
|
| 163 |
+
"with scene.open_geometry() as geometry:\n",
|
| 164 |
+
" print(\"entry point:\", json.loads(geometry.read(\"scene.json\"))[\"entrypoint\"])\n",
|
| 165 |
+
" meshes = [n for n in geometry.namelist() if n.endswith(\".obj\") and \"ground\" not in n]\n",
|
| 166 |
+
" triangles = top_view(geometry.read, meshes)\n",
|
| 167 |
+
"print(len(meshes), \"building meshes\")"
|
| 168 |
+
]
|
| 169 |
+
},
|
| 170 |
+
{
|
| 171 |
+
"cell_type": "code",
|
| 172 |
+
"execution_count": null,
|
| 173 |
+
"id": "cell-10",
|
| 174 |
+
"metadata": {},
|
| 175 |
+
"outputs": [],
|
| 176 |
+
"source": [
|
| 177 |
+
"fig, ax = plt.subplots(figsize=(6, 6))\n",
|
| 178 |
+
"ax.add_collection(PolyCollection(triangles, facecolor=\"#c3cbc2\", edgecolor=\"none\"))\n",
|
| 179 |
+
"ax.scatter(ue_positions[:, 0], ue_positions[:, 1], s=0.2, color=\"#4d9688\", label=f\"{len(ue_positions):,} UEs\")\n",
|
| 180 |
+
"ax.scatter(bs_positions[:, 0], bs_positions[:, 1], marker=\"^\", s=30, color=\"k\", label=f\"{len(bs_positions)} BSs\")\n",
|
| 181 |
+
"ax.plot(*zip(bs_xyz[:2], ue_xyz[:2]), color=\"#e2733d\", lw=2, label=f\"BS {BS_ID} → UE {UE_ID}\")\n",
|
| 182 |
+
"ax.set(xlim=(-250, 250), ylim=(-250, 250), aspect=\"equal\", xlabel=\"x (m)\", ylabel=\"y (m)\", title=SCENE_ID)\n",
|
| 183 |
+
"ax.legend(loc=\"upper right\")\n",
|
| 184 |
+
"plt.show()"
|
| 185 |
+
]
|
| 186 |
+
},
|
| 187 |
+
{
|
| 188 |
+
"cell_type": "markdown",
|
| 189 |
+
"id": "cell-11",
|
| 190 |
+
"metadata": {},
|
| 191 |
+
"source": [
|
| 192 |
+
"## 5. One channel record\n",
|
| 193 |
+
"\n",
|
| 194 |
+
"A record holds every retained link from one BS at one carrier. `get_link(UE_ID)` returns\n",
|
| 195 |
+
"that UE's link, or `None` when the UE has no retained link to this BS (which is not a\n",
|
| 196 |
+
"zero-valued channel). A UE ID is a row of the positions; the link's row inside the record\n",
|
| 197 |
+
"is a different index."
|
| 198 |
+
]
|
| 199 |
+
},
|
| 200 |
+
{
|
| 201 |
+
"cell_type": "code",
|
| 202 |
+
"execution_count": null,
|
| 203 |
+
"id": "cell-12",
|
| 204 |
+
"metadata": {},
|
| 205 |
+
"outputs": [],
|
| 206 |
+
"source": [
|
| 207 |
+
"record = scene.frequencies[CARRIER_HZ].base_stations[BS_ID].read(detail=True)\n",
|
| 208 |
+
"print(record)\n",
|
| 209 |
+
"link = record.get_link(UE_ID)\n",
|
| 210 |
+
"print(link, f\"- row {link.index} of the record's {record.n_links} links\")"
|
| 211 |
+
]
|
| 212 |
+
},
|
| 213 |
+
{
|
| 214 |
+
"cell_type": "markdown",
|
| 215 |
+
"id": "cell-13",
|
| 216 |
+
"metadata": {},
|
| 217 |
+
"source": [
|
| 218 |
+
"## 6. What each path stores\n",
|
| 219 |
+
"\n",
|
| 220 |
+
"For every retained path the core record stores the complex coefficient `a_real + 1j*a_imag`\n",
|
| 221 |
+
"(passband, without the carrier-delay phase, antennas included), the delay `tau` in seconds,\n",
|
| 222 |
+
"departure and arrival angles in radians, and its interaction count and type flags; the detail\n",
|
| 223 |
+
"record adds each interaction's type and location in order. Paths are stored strongest first,\n",
|
| 224 |
+
"and each link keeps at most its 16 strongest paths above −150 dB."
|
| 225 |
+
]
|
| 226 |
+
},
|
| 227 |
+
{
|
| 228 |
+
"cell_type": "code",
|
| 229 |
+
"execution_count": null,
|
| 230 |
+
"id": "cell-14",
|
| 231 |
+
"metadata": {},
|
| 232 |
+
"outputs": [],
|
| 233 |
+
"source": [
|
| 234 |
+
"NAMES = {1: \"specular reflection\", 2: \"diffuse reflection\", 4: \"refraction\", 8: \"diffraction\"}\n",
|
| 235 |
+
"\n",
|
| 236 |
+
"def describe(core, detail):\n",
|
| 237 |
+
" \"\"\"One line per retained path, strongest first.\"\"\"\n",
|
| 238 |
+
" re, im = core[\"a_real\"].astype(np.float64), core[\"a_imag\"].astype(np.float64)\n",
|
| 239 |
+
" power_db = 10 * np.log10(re**2 + im**2)\n",
|
| 240 |
+
" off = detail[\"path_interaction_offsets\"]\n",
|
| 241 |
+
" for p in range(len(core[\"tau\"])):\n",
|
| 242 |
+
" kinds = [NAMES.get(int(t), str(t)) for t in detail[\"interaction_type\"][off[p]:off[p + 1]]]\n",
|
| 243 |
+
" print(f\"rank {int(core['path_rank'][p]):2d} {core['tau'][p] * 1e9:8.2f} ns {power_db[p]:7.2f} dB \"\n",
|
| 244 |
+
" f\"AoD az {np.degrees(core['phi_t'][p]):6.1f}° AoA az {np.degrees(core['phi_r'][p]):6.1f}° \"\n",
|
| 245 |
+
" f\"{' → '.join(kinds) or 'line of sight'}\")\n",
|
| 246 |
+
"\n",
|
| 247 |
+
"describe(link.core, link.detail)"
|
| 248 |
+
]
|
| 249 |
+
},
|
| 250 |
+
{
|
| 251 |
+
"cell_type": "markdown",
|
| 252 |
+
"id": "cell-15",
|
| 253 |
+
"metadata": {},
|
| 254 |
+
"source": [
|
| 255 |
+
"## 7. A power–delay profile\n",
|
| 256 |
+
"\n",
|
| 257 |
+
"Placing each path by delay and power gives the link's power–delay profile: a path-based view\n",
|
| 258 |
+
"of the stored channel. It is not a sampled impulse response; for a channel at a given\n",
|
| 259 |
+
"bandwidth, `channels4world.transforms` provides baseband coefficients and frequency\n",
|
| 260 |
+
"responses."
|
| 261 |
+
]
|
| 262 |
+
},
|
| 263 |
+
{
|
| 264 |
+
"cell_type": "code",
|
| 265 |
+
"execution_count": null,
|
| 266 |
+
"id": "cell-16",
|
| 267 |
+
"metadata": {},
|
| 268 |
+
"outputs": [],
|
| 269 |
+
"source": [
|
| 270 |
+
"def stems(ax, tau, a_real, a_imag, label, marker, color):\n",
|
| 271 |
+
" power_db = 10 * np.log10(a_real.astype(np.float64)**2 + a_imag.astype(np.float64)**2)\n",
|
| 272 |
+
" ax.vlines(tau * 1e9, -150, power_db, color=color, lw=1.2)\n",
|
| 273 |
+
" ax.scatter(tau * 1e9, power_db, marker=marker, color=color, zorder=3, label=label)\n",
|
| 274 |
+
"\n",
|
| 275 |
+
"fig, ax = plt.subplots(figsize=(7, 3))\n",
|
| 276 |
+
"stems(ax, link.core[\"tau\"], link.core[\"a_real\"], link.core[\"a_imag\"], \"3.5 GHz\", \"o\", \"#e2733d\")\n",
|
| 277 |
+
"ax.set(xlabel=\"delay (ns)\", ylabel=\"path power (dB)\", ylim=(-150, None),\n",
|
| 278 |
+
" title=f\"{SCENE_ID} · BS {BS_ID} → UE {UE_ID}\")\n",
|
| 279 |
+
"ax.legend()\n",
|
| 280 |
+
"plt.show()"
|
| 281 |
+
]
|
| 282 |
+
},
|
| 283 |
+
{
|
| 284 |
+
"cell_type": "markdown",
|
| 285 |
+
"id": "cell-17",
|
| 286 |
+
"metadata": {},
|
| 287 |
+
"source": [
|
| 288 |
+
"## 8. The same link at 7 GHz\n",
|
| 289 |
+
"\n",
|
| 290 |
+
"Every scene is simulated at both carriers with the same BS and UE positions. Read the same\n",
|
| 291 |
+
"BS and UE at 7 GHz and compare on shared axes:"
|
| 292 |
+
]
|
| 293 |
+
},
|
| 294 |
+
{
|
| 295 |
+
"cell_type": "code",
|
| 296 |
+
"execution_count": null,
|
| 297 |
+
"id": "cell-18",
|
| 298 |
+
"metadata": {},
|
| 299 |
+
"outputs": [],
|
| 300 |
+
"source": [
|
| 301 |
+
"link7 = scene.frequencies[OTHER_HZ].base_stations[BS_ID].read(detail=True).get_link(UE_ID)\n",
|
| 302 |
+
"fig, ax = plt.subplots(figsize=(7, 3))\n",
|
| 303 |
+
"stems(ax, link.core[\"tau\"], link.core[\"a_real\"], link.core[\"a_imag\"], \"3.5 GHz\", \"o\", \"#e2733d\")\n",
|
| 304 |
+
"if link7 is None:\n",
|
| 305 |
+
" print(\"UE\", UE_ID, \"has no retained link at 7 GHz\")\n",
|
| 306 |
+
"else:\n",
|
| 307 |
+
" stems(ax, link7.core[\"tau\"], link7.core[\"a_real\"], link7.core[\"a_imag\"], \"7 GHz\", \"s\", \"#4d9688\")\n",
|
| 308 |
+
" for l, label in ((link, \"3.5 GHz\"), (link7, \"7 GHz\")):\n",
|
| 309 |
+
" a = l.core[\"a_real\"].astype(np.float64) + 1j * l.core[\"a_imag\"].astype(np.float64)\n",
|
| 310 |
+
" print(f\"{label}: {l.n_paths} paths, link power {10 * np.log10(np.sum(np.abs(a) ** 2)):.2f} dB\")\n",
|
| 311 |
+
"ax.set(xlabel=\"delay (ns)\", ylabel=\"path power (dB)\", ylim=(-150, None))\n",
|
| 312 |
+
"ax.legend()\n",
|
| 313 |
+
"plt.show()"
|
| 314 |
+
]
|
| 315 |
+
},
|
| 316 |
+
{
|
| 317 |
+
"cell_type": "markdown",
|
| 318 |
+
"id": "cell-19",
|
| 319 |
+
"metadata": {},
|
| 320 |
+
"source": [
|
| 321 |
+
"Ranks order the paths within one record: rank 0 at 7 GHz need not be the route of rank 0\n",
|
| 322 |
+
"at 3.5 GHz. To match routes across carriers, compare delays, interaction sequences or\n",
|
| 323 |
+
"interaction points (`link7.detail`), not ranks.\n",
|
| 324 |
+
"\n",
|
| 325 |
+
"## Next\n",
|
| 326 |
+
"\n",
|
| 327 |
+
"- [From channel records to a DataLoader](https://huggingface.co/datasets/Intelligence-Networking-Lab/Channels4World/blob/v1.0.0/docs/ml-guide.md): link samples, splits, padding and batches.\n",
|
| 328 |
+
"- [Library guide](https://huggingface.co/datasets/Intelligence-Networking-Lab/Channels4World/blob/v1.0.0/docs/library-guide.md): download plans for larger tiers, recipes, extraction and caches.\n",
|
| 329 |
+
"- [Schema reference](https://huggingface.co/datasets/Intelligence-Networking-Lab/Channels4World/blob/v1.0.0/docs/schema-reference.md): every array and its meaning."
|
| 330 |
+
]
|
| 331 |
+
}
|
| 332 |
+
],
|
| 333 |
+
"metadata": {
|
| 334 |
+
"kernelspec": {
|
| 335 |
+
"display_name": "Python 3",
|
| 336 |
+
"language": "python",
|
| 337 |
+
"name": "python3"
|
| 338 |
+
},
|
| 339 |
+
"language_info": {
|
| 340 |
+
"name": "python"
|
| 341 |
+
}
|
| 342 |
+
},
|
| 343 |
+
"nbformat": 4,
|
| 344 |
+
"nbformat_minor": 5
|
| 345 |
+
}
|
docs/notebooks/02-read-one-scene-numpy.ipynb
ADDED
|
@@ -0,0 +1,342 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"cells": [
|
| 3 |
+
{
|
| 4 |
+
"cell_type": "markdown",
|
| 5 |
+
"id": "cell-00",
|
| 6 |
+
"metadata": {},
|
| 7 |
+
"source": [
|
| 8 |
+
"# Read one scene without the library\n",
|
| 9 |
+
"\n",
|
| 10 |
+
"The same link as the [library tutorial](https://huggingface.co/datasets/Intelligence-Networking-Lab/Channels4World/blob/v1.0.0/docs/tutorial-library.md), **BS 0 → UE 14 of\n",
|
| 11 |
+
"`urban_scene_019234` at 3.5 GHz**, read with NumPy and the standard library from Tiny's loose\n",
|
| 12 |
+
"files: about 15 MB. Archives from larger tiers hold the same files; see\n",
|
| 13 |
+
"[without the library](https://huggingface.co/datasets/Intelligence-Networking-Lab/Channels4World/blob/v1.0.0/docs/without-library.md) for TAR access.\n",
|
| 14 |
+
"\n",
|
| 15 |
+
"Install with `pip install numpy huggingface_hub matplotlib`."
|
| 16 |
+
]
|
| 17 |
+
},
|
| 18 |
+
{
|
| 19 |
+
"cell_type": "code",
|
| 20 |
+
"execution_count": null,
|
| 21 |
+
"id": "cell-01",
|
| 22 |
+
"metadata": {},
|
| 23 |
+
"outputs": [],
|
| 24 |
+
"source": [
|
| 25 |
+
"from pathlib import Path\n",
|
| 26 |
+
"import json\n",
|
| 27 |
+
"import zipfile\n",
|
| 28 |
+
"\n",
|
| 29 |
+
"import matplotlib.pyplot as plt\n",
|
| 30 |
+
"import numpy as np\n",
|
| 31 |
+
"from huggingface_hub import snapshot_download\n",
|
| 32 |
+
"from matplotlib.collections import PolyCollection"
|
| 33 |
+
]
|
| 34 |
+
},
|
| 35 |
+
{
|
| 36 |
+
"cell_type": "markdown",
|
| 37 |
+
"id": "cell-02",
|
| 38 |
+
"metadata": {},
|
| 39 |
+
"source": [
|
| 40 |
+
"## 1. Choose the link\n",
|
| 41 |
+
"\n",
|
| 42 |
+
"The same identifiers as the library tutorial. A UE ID is a row of `ue_positions`, and the BS\n",
|
| 43 |
+
"ID is both a row of `bs_positions` and the number in the record's file name."
|
| 44 |
+
]
|
| 45 |
+
},
|
| 46 |
+
{
|
| 47 |
+
"cell_type": "code",
|
| 48 |
+
"execution_count": null,
|
| 49 |
+
"id": "cell-03",
|
| 50 |
+
"metadata": {},
|
| 51 |
+
"outputs": [],
|
| 52 |
+
"source": [
|
| 53 |
+
"REPO, REVISION = \"Intelligence-Networking-Lab/Channels4World\", \"v1.0.0\"\n",
|
| 54 |
+
"SCENE_ID, GROUP = \"urban_scene_019234\", \"test-urban-g00000\" # GROUP: from the tiny_scenes catalog\n",
|
| 55 |
+
"CARRIER_HZ, BS_ID, UE_ID = 3_500_000_000, 0, 14\n",
|
| 56 |
+
"OTHER_HZ = 7_000_000_000\n",
|
| 57 |
+
"DATA = Path(\"c4w\")"
|
| 58 |
+
]
|
| 59 |
+
},
|
| 60 |
+
{
|
| 61 |
+
"cell_type": "markdown",
|
| 62 |
+
"id": "cell-04",
|
| 63 |
+
"metadata": {},
|
| 64 |
+
"source": [
|
| 65 |
+
"## 2. Download the scene's files\n",
|
| 66 |
+
"\n",
|
| 67 |
+
"NumPy needs only the record files: positions, geometry, and BS 0's core and detail at both\n",
|
| 68 |
+
"carriers."
|
| 69 |
+
]
|
| 70 |
+
},
|
| 71 |
+
{
|
| 72 |
+
"cell_type": "code",
|
| 73 |
+
"execution_count": null,
|
| 74 |
+
"id": "cell-05",
|
| 75 |
+
"metadata": {},
|
| 76 |
+
"outputs": [],
|
| 77 |
+
"source": [
|
| 78 |
+
"scene_dir = DATA / \"tiny\" / \"records\" / f\"scene={SCENE_ID}\"\n",
|
| 79 |
+
"remote = f\"tiny/records/scene={SCENE_ID}\"\n",
|
| 80 |
+
"snapshot_download(REPO, repo_type=\"dataset\", revision=REVISION, local_dir=DATA, allow_patterns=[\n",
|
| 81 |
+
" f\"{remote}/positions.npz\", f\"{remote}/geometry.zip\", f\"{remote}/band_hz=*/component=*/bs{BS_ID:05d}.npz\"])\n",
|
| 82 |
+
"\n",
|
| 83 |
+
"def record_path(carrier_hz, component):\n",
|
| 84 |
+
" return scene_dir / f\"band_hz={carrier_hz}\" / f\"component={component}\" / f\"bs{BS_ID:05d}.npz\"\n",
|
| 85 |
+
"\n",
|
| 86 |
+
"print(sorted(p.relative_to(scene_dir).as_posix() for p in scene_dir.rglob(\"*\") if p.is_file()))"
|
| 87 |
+
]
|
| 88 |
+
},
|
| 89 |
+
{
|
| 90 |
+
"cell_type": "markdown",
|
| 91 |
+
"id": "cell-06",
|
| 92 |
+
"metadata": {},
|
| 93 |
+
"source": [
|
| 94 |
+
"## 3. The hierarchy on disk\n",
|
| 95 |
+
"\n",
|
| 96 |
+
"Each scene folder holds `positions.npz` and `geometry.zip`, shared by both carriers, and one\n",
|
| 97 |
+
"file per carrier, component and BS: `band_hz=<Hz>/component=<core|detail>/bs<NNNNN>.npz`.\n",
|
| 98 |
+
"Every NPZ carries its identity in a JSON `__meta__` entry:"
|
| 99 |
+
]
|
| 100 |
+
},
|
| 101 |
+
{
|
| 102 |
+
"cell_type": "code",
|
| 103 |
+
"execution_count": null,
|
| 104 |
+
"id": "cell-07",
|
| 105 |
+
"metadata": {},
|
| 106 |
+
"outputs": [],
|
| 107 |
+
"source": [
|
| 108 |
+
"with np.load(record_path(CARRIER_HZ, \"core\"), allow_pickle=False) as npz:\n",
|
| 109 |
+
" meta = json.loads(npz[\"__meta__\"].item())\n",
|
| 110 |
+
"print(json.dumps(meta[\"identity\"], indent=1))\n",
|
| 111 |
+
"print(meta[\"dimensions\"]) # retained links and paths in this record"
|
| 112 |
+
]
|
| 113 |
+
},
|
| 114 |
+
{
|
| 115 |
+
"cell_type": "markdown",
|
| 116 |
+
"id": "cell-08",
|
| 117 |
+
"metadata": {},
|
| 118 |
+
"source": [
|
| 119 |
+
"## 4. Geometry and positions\n",
|
| 120 |
+
"\n",
|
| 121 |
+
"Geometry, positions and interaction points share one frame: scene metres, z up."
|
| 122 |
+
]
|
| 123 |
+
},
|
| 124 |
+
{
|
| 125 |
+
"cell_type": "code",
|
| 126 |
+
"execution_count": null,
|
| 127 |
+
"id": "cell-09",
|
| 128 |
+
"metadata": {},
|
| 129 |
+
"outputs": [],
|
| 130 |
+
"source": [
|
| 131 |
+
"with np.load(scene_dir / \"positions.npz\", allow_pickle=False) as positions:\n",
|
| 132 |
+
" bs_positions, ue_positions = positions[\"bs_positions\"], positions[\"ue_positions\"]\n",
|
| 133 |
+
"bs_xyz, ue_xyz = bs_positions[BS_ID], ue_positions[UE_ID]\n",
|
| 134 |
+
"print(bs_positions.shape, ue_positions.shape)\n",
|
| 135 |
+
"print(\"BS\", bs_xyz, \"UE\", ue_xyz, f\"distance {np.linalg.norm(ue_xyz - bs_xyz):.1f} m\")\n",
|
| 136 |
+
"\n",
|
| 137 |
+
"def top_view(read, names):\n",
|
| 138 |
+
" \"\"\"Building triangles projected onto the ground (x, y), from OBJ meshes.\"\"\"\n",
|
| 139 |
+
" triangles = []\n",
|
| 140 |
+
" for name in names:\n",
|
| 141 |
+
" verts, faces = [], []\n",
|
| 142 |
+
" for line in read(name).decode().splitlines():\n",
|
| 143 |
+
" if line.startswith(\"v \"):\n",
|
| 144 |
+
" verts.append([float(v) for v in line.split()[1:4]])\n",
|
| 145 |
+
" elif line.startswith(\"f \"):\n",
|
| 146 |
+
" idx = [int(t.split(\"/\")[0]) for t in line.split()[1:]]\n",
|
| 147 |
+
" faces += [[idx[0], idx[k], idx[k + 1]] for k in range(1, len(idx) - 1)]\n",
|
| 148 |
+
" v = np.array(verts)\n",
|
| 149 |
+
" triangles += [v[[i - 1 for i in f], :2] for f in faces] # OBJ indices start at 1\n",
|
| 150 |
+
" return triangles\n",
|
| 151 |
+
"\n",
|
| 152 |
+
"with zipfile.ZipFile(scene_dir / \"geometry.zip\") as geometry:\n",
|
| 153 |
+
" print(\"entry point:\", json.loads(geometry.read(\"scene.json\"))[\"entrypoint\"])\n",
|
| 154 |
+
" meshes = [n for n in geometry.namelist() if n.endswith(\".obj\") and \"ground\" not in n]\n",
|
| 155 |
+
" triangles = top_view(geometry.read, meshes)\n",
|
| 156 |
+
"print(len(meshes), \"building meshes\")"
|
| 157 |
+
]
|
| 158 |
+
},
|
| 159 |
+
{
|
| 160 |
+
"cell_type": "code",
|
| 161 |
+
"execution_count": null,
|
| 162 |
+
"id": "cell-10",
|
| 163 |
+
"metadata": {},
|
| 164 |
+
"outputs": [],
|
| 165 |
+
"source": [
|
| 166 |
+
"fig, ax = plt.subplots(figsize=(6, 6))\n",
|
| 167 |
+
"ax.add_collection(PolyCollection(triangles, facecolor=\"#c3cbc2\", edgecolor=\"none\"))\n",
|
| 168 |
+
"ax.scatter(ue_positions[:, 0], ue_positions[:, 1], s=0.2, color=\"#4d9688\", label=f\"{len(ue_positions):,} UEs\")\n",
|
| 169 |
+
"ax.scatter(bs_positions[:, 0], bs_positions[:, 1], marker=\"^\", s=30, color=\"k\", label=f\"{len(bs_positions)} BSs\")\n",
|
| 170 |
+
"ax.plot(*zip(bs_xyz[:2], ue_xyz[:2]), color=\"#e2733d\", lw=2, label=f\"BS {BS_ID} → UE {UE_ID}\")\n",
|
| 171 |
+
"ax.set(xlim=(-250, 250), ylim=(-250, 250), aspect=\"equal\", xlabel=\"x (m)\", ylabel=\"y (m)\", title=SCENE_ID)\n",
|
| 172 |
+
"ax.legend(loc=\"upper right\")\n",
|
| 173 |
+
"plt.show()"
|
| 174 |
+
]
|
| 175 |
+
},
|
| 176 |
+
{
|
| 177 |
+
"cell_type": "markdown",
|
| 178 |
+
"id": "cell-11",
|
| 179 |
+
"metadata": {},
|
| 180 |
+
"source": [
|
| 181 |
+
"## 5. Find the link\n",
|
| 182 |
+
"\n",
|
| 183 |
+
"`link_ue_index` lists the UEs this BS reaches, in ascending order; the link's row is where\n",
|
| 184 |
+
"`UE_ID` sits in that list. Link `row` owns paths `link_path_offsets[row]` to\n",
|
| 185 |
+
"`link_path_offsets[row + 1]`. A UE that is not listed has no retained link to this BS (not a\n",
|
| 186 |
+
"zero-valued channel)."
|
| 187 |
+
]
|
| 188 |
+
},
|
| 189 |
+
{
|
| 190 |
+
"cell_type": "code",
|
| 191 |
+
"execution_count": null,
|
| 192 |
+
"id": "cell-12",
|
| 193 |
+
"metadata": {},
|
| 194 |
+
"outputs": [],
|
| 195 |
+
"source": [
|
| 196 |
+
"def load(carrier_hz, component):\n",
|
| 197 |
+
" with np.load(record_path(carrier_hz, component), allow_pickle=False) as npz:\n",
|
| 198 |
+
" return {name: npz[name] for name in npz.files if name != \"__meta__\"}\n",
|
| 199 |
+
"\n",
|
| 200 |
+
"def link_of(core, detail, ue_id):\n",
|
| 201 |
+
" ue_ids = core[\"link_ue_index\"]\n",
|
| 202 |
+
" row = int(np.searchsorted(ue_ids, ue_id))\n",
|
| 203 |
+
" if row == ue_ids.size or ue_ids[row] != ue_id:\n",
|
| 204 |
+
" return None # no retained link to this UE\n",
|
| 205 |
+
" p0, p1 = map(int, core[\"link_path_offsets\"][row:row + 2])\n",
|
| 206 |
+
" link_core = {k: v[p0:p1] for k, v in core.items() if k not in (\"link_ue_index\", \"link_path_offsets\")}\n",
|
| 207 |
+
" i0, i1 = map(int, detail[\"path_interaction_offsets\"][[p0, p1]])\n",
|
| 208 |
+
" link_detail = {k: detail[k][i0:i1] for k in (\"interaction_rank\", \"interaction_type\", \"interaction_vertex\")}\n",
|
| 209 |
+
" link_detail[\"path_interaction_offsets\"] = detail[\"path_interaction_offsets\"][p0:p1 + 1] - i0\n",
|
| 210 |
+
" return row, link_core, link_detail\n",
|
| 211 |
+
"\n",
|
| 212 |
+
"core, detail = load(CARRIER_HZ, \"core\"), load(CARRIER_HZ, \"detail\")\n",
|
| 213 |
+
"row, link_core, link_detail = link_of(core, detail, UE_ID)\n",
|
| 214 |
+
"print(f\"UE {UE_ID}: link row {row} of {core['link_ue_index'].size}, {link_core['tau'].size} paths\")"
|
| 215 |
+
]
|
| 216 |
+
},
|
| 217 |
+
{
|
| 218 |
+
"cell_type": "markdown",
|
| 219 |
+
"id": "cell-13",
|
| 220 |
+
"metadata": {},
|
| 221 |
+
"source": [
|
| 222 |
+
"## 6. What each path stores\n",
|
| 223 |
+
"\n",
|
| 224 |
+
"The same arrays as in the library tutorial: the complex coefficient `a_real + 1j*a_imag`\n",
|
| 225 |
+
"(passband, without the carrier-delay phase, antennas included), the delay `tau` in seconds,\n",
|
| 226 |
+
"departure and arrival angles in radians and, in detail, each interaction's type and location\n",
|
| 227 |
+
"in order. Paths are stored strongest first, at most 16 per link above −150 dB."
|
| 228 |
+
]
|
| 229 |
+
},
|
| 230 |
+
{
|
| 231 |
+
"cell_type": "code",
|
| 232 |
+
"execution_count": null,
|
| 233 |
+
"id": "cell-14",
|
| 234 |
+
"metadata": {},
|
| 235 |
+
"outputs": [],
|
| 236 |
+
"source": [
|
| 237 |
+
"NAMES = {1: \"specular reflection\", 2: \"diffuse reflection\", 4: \"refraction\", 8: \"diffraction\"}\n",
|
| 238 |
+
"\n",
|
| 239 |
+
"def describe(core, detail):\n",
|
| 240 |
+
" \"\"\"One line per retained path, strongest first.\"\"\"\n",
|
| 241 |
+
" re, im = core[\"a_real\"].astype(np.float64), core[\"a_imag\"].astype(np.float64)\n",
|
| 242 |
+
" power_db = 10 * np.log10(re**2 + im**2)\n",
|
| 243 |
+
" off = detail[\"path_interaction_offsets\"]\n",
|
| 244 |
+
" for p in range(len(core[\"tau\"])):\n",
|
| 245 |
+
" kinds = [NAMES.get(int(t), str(t)) for t in detail[\"interaction_type\"][off[p]:off[p + 1]]]\n",
|
| 246 |
+
" print(f\"rank {int(core['path_rank'][p]):2d} {core['tau'][p] * 1e9:8.2f} ns {power_db[p]:7.2f} dB \"\n",
|
| 247 |
+
" f\"AoD az {np.degrees(core['phi_t'][p]):6.1f}° AoA az {np.degrees(core['phi_r'][p]):6.1f}° \"\n",
|
| 248 |
+
" f\"{' → '.join(kinds) or 'line of sight'}\")\n",
|
| 249 |
+
"\n",
|
| 250 |
+
"describe(link_core, link_detail)"
|
| 251 |
+
]
|
| 252 |
+
},
|
| 253 |
+
{
|
| 254 |
+
"cell_type": "markdown",
|
| 255 |
+
"id": "cell-15",
|
| 256 |
+
"metadata": {},
|
| 257 |
+
"source": [
|
| 258 |
+
"## 7. A power–delay profile\n",
|
| 259 |
+
"\n",
|
| 260 |
+
"Placing each path by delay and power gives the link's power–delay profile: a path-based view\n",
|
| 261 |
+
"of the stored channel, not a sampled impulse response."
|
| 262 |
+
]
|
| 263 |
+
},
|
| 264 |
+
{
|
| 265 |
+
"cell_type": "code",
|
| 266 |
+
"execution_count": null,
|
| 267 |
+
"id": "cell-16",
|
| 268 |
+
"metadata": {},
|
| 269 |
+
"outputs": [],
|
| 270 |
+
"source": [
|
| 271 |
+
"def stems(ax, tau, a_real, a_imag, label, marker, color):\n",
|
| 272 |
+
" power_db = 10 * np.log10(a_real.astype(np.float64)**2 + a_imag.astype(np.float64)**2)\n",
|
| 273 |
+
" ax.vlines(tau * 1e9, -150, power_db, color=color, lw=1.2)\n",
|
| 274 |
+
" ax.scatter(tau * 1e9, power_db, marker=marker, color=color, zorder=3, label=label)\n",
|
| 275 |
+
"\n",
|
| 276 |
+
"fig, ax = plt.subplots(figsize=(7, 3))\n",
|
| 277 |
+
"stems(ax, link_core[\"tau\"], link_core[\"a_real\"], link_core[\"a_imag\"], \"3.5 GHz\", \"o\", \"#e2733d\")\n",
|
| 278 |
+
"ax.set(xlabel=\"delay (ns)\", ylabel=\"path power (dB)\", ylim=(-150, None),\n",
|
| 279 |
+
" title=f\"{SCENE_ID} · BS {BS_ID} → UE {UE_ID}\")\n",
|
| 280 |
+
"ax.legend()\n",
|
| 281 |
+
"plt.show()"
|
| 282 |
+
]
|
| 283 |
+
},
|
| 284 |
+
{
|
| 285 |
+
"cell_type": "markdown",
|
| 286 |
+
"id": "cell-17",
|
| 287 |
+
"metadata": {},
|
| 288 |
+
"source": [
|
| 289 |
+
"## 8. The same link at 7 GHz"
|
| 290 |
+
]
|
| 291 |
+
},
|
| 292 |
+
{
|
| 293 |
+
"cell_type": "code",
|
| 294 |
+
"execution_count": null,
|
| 295 |
+
"id": "cell-18",
|
| 296 |
+
"metadata": {},
|
| 297 |
+
"outputs": [],
|
| 298 |
+
"source": [
|
| 299 |
+
"other = link_of(load(OTHER_HZ, \"core\"), load(OTHER_HZ, \"detail\"), UE_ID)\n",
|
| 300 |
+
"fig, ax = plt.subplots(figsize=(7, 3))\n",
|
| 301 |
+
"stems(ax, link_core[\"tau\"], link_core[\"a_real\"], link_core[\"a_imag\"], \"3.5 GHz\", \"o\", \"#e2733d\")\n",
|
| 302 |
+
"if other is None:\n",
|
| 303 |
+
" print(\"UE\", UE_ID, \"has no retained link at 7 GHz\")\n",
|
| 304 |
+
"else:\n",
|
| 305 |
+
" _, core7, _ = other\n",
|
| 306 |
+
" stems(ax, core7[\"tau\"], core7[\"a_real\"], core7[\"a_imag\"], \"7 GHz\", \"s\", \"#4d9688\")\n",
|
| 307 |
+
" for c, label in ((link_core, \"3.5 GHz\"), (core7, \"7 GHz\")):\n",
|
| 308 |
+
" power = np.sum(c[\"a_real\"].astype(np.float64) ** 2 + c[\"a_imag\"].astype(np.float64) ** 2)\n",
|
| 309 |
+
" print(f\"{label}: {c['tau'].size} paths, link power {10 * np.log10(power):.2f} dB\")\n",
|
| 310 |
+
"ax.set(xlabel=\"delay (ns)\", ylabel=\"path power (dB)\", ylim=(-150, None))\n",
|
| 311 |
+
"ax.legend()\n",
|
| 312 |
+
"plt.show()"
|
| 313 |
+
]
|
| 314 |
+
},
|
| 315 |
+
{
|
| 316 |
+
"cell_type": "markdown",
|
| 317 |
+
"id": "cell-19",
|
| 318 |
+
"metadata": {},
|
| 319 |
+
"source": [
|
| 320 |
+
"Ranks order the paths within one record, so the same rank at 3.5 and 7 GHz need not be\n",
|
| 321 |
+
"the same route. Compare delays, interaction sequences or interaction points instead.\n",
|
| 322 |
+
"\n",
|
| 323 |
+
"## Next\n",
|
| 324 |
+
"\n",
|
| 325 |
+
"- [Without the library](https://huggingface.co/datasets/Intelligence-Networking-Lab/Channels4World/blob/v1.0.0/docs/without-library.md): TAR archives, catalogs and byte-range reads.\n",
|
| 326 |
+
"- [Schema reference](https://huggingface.co/datasets/Intelligence-Networking-Lab/Channels4World/blob/v1.0.0/docs/schema-reference.md): every array, its dtype and its meaning."
|
| 327 |
+
]
|
| 328 |
+
}
|
| 329 |
+
],
|
| 330 |
+
"metadata": {
|
| 331 |
+
"kernelspec": {
|
| 332 |
+
"display_name": "Python 3",
|
| 333 |
+
"language": "python",
|
| 334 |
+
"name": "python3"
|
| 335 |
+
},
|
| 336 |
+
"language_info": {
|
| 337 |
+
"name": "python"
|
| 338 |
+
}
|
| 339 |
+
},
|
| 340 |
+
"nbformat": 4,
|
| 341 |
+
"nbformat_minor": 5
|
| 342 |
+
}
|
docs/notebooks/03-dataloader.ipynb
ADDED
|
@@ -0,0 +1,322 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"cells": [
|
| 3 |
+
{
|
| 4 |
+
"cell_type": "markdown",
|
| 5 |
+
"id": "cell-00",
|
| 6 |
+
"metadata": {},
|
| 7 |
+
"source": [
|
| 8 |
+
"# From channel records to a DataLoader\n",
|
| 9 |
+
"\n",
|
| 10 |
+
"This guide turns Channels4World records into fixed-size arrays and a PyTorch `DataLoader`,\n",
|
| 11 |
+
"with train, validation and test sets split by scene. It ends at one batch whose contents\n",
|
| 12 |
+
"are explained, so you can adapt the inputs and targets to your model, or swap these\n",
|
| 13 |
+
"batches into an existing training loop.\n",
|
| 14 |
+
"\n",
|
| 15 |
+
"The example uses the 100 urban scenes of Tiny (90 train, 10 test), BS 0 at 3.5 GHz. Change the\n",
|
| 16 |
+
"selection to scale up; the steps stay the same. Install the library with `pip install channels4world`\n",
|
| 17 |
+
"(Python 3.11+), then `pip install torch huggingface_hub`."
|
| 18 |
+
]
|
| 19 |
+
},
|
| 20 |
+
{
|
| 21 |
+
"cell_type": "code",
|
| 22 |
+
"execution_count": null,
|
| 23 |
+
"id": "cell-01",
|
| 24 |
+
"metadata": {},
|
| 25 |
+
"outputs": [],
|
| 26 |
+
"source": [
|
| 27 |
+
"from pathlib import Path\n",
|
| 28 |
+
"import hashlib\n",
|
| 29 |
+
"import json\n",
|
| 30 |
+
"\n",
|
| 31 |
+
"import numpy as np\n",
|
| 32 |
+
"import torch\n",
|
| 33 |
+
"from huggingface_hub import snapshot_download\n",
|
| 34 |
+
"from torch.utils.data import DataLoader, Dataset\n",
|
| 35 |
+
"\n",
|
| 36 |
+
"import channels4world as c4w\n",
|
| 37 |
+
"from channels4world import transforms as T\n",
|
| 38 |
+
"\n",
|
| 39 |
+
"REPO, REVISION = \"Intelligence-Networking-Lab/Channels4World\", \"v1.0.0\"\n",
|
| 40 |
+
"DATA = Path(\"c4w\")"
|
| 41 |
+
]
|
| 42 |
+
},
|
| 43 |
+
{
|
| 44 |
+
"cell_type": "markdown",
|
| 45 |
+
"id": "cell-02",
|
| 46 |
+
"metadata": {},
|
| 47 |
+
"source": [
|
| 48 |
+
"## 1. Choose the records\n",
|
| 49 |
+
"\n",
|
| 50 |
+
"One **sample** here is one retained link: a (scene, carrier, BS, UE) channel. A record holds\n",
|
| 51 |
+
"every retained link of one BS at one carrier, so records are read whole and split into\n",
|
| 52 |
+
"links. First download Tiny's catalog and the metadata of the five groups that hold its urban\n",
|
| 53 |
+
"scenes (about 42 MB), so the library can plan exactly which record files the selection needs:\n",
|
| 54 |
+
"here about 0.4 GB."
|
| 55 |
+
]
|
| 56 |
+
},
|
| 57 |
+
{
|
| 58 |
+
"cell_type": "code",
|
| 59 |
+
"execution_count": null,
|
| 60 |
+
"id": "cell-03",
|
| 61 |
+
"metadata": {},
|
| 62 |
+
"outputs": [],
|
| 63 |
+
"source": [
|
| 64 |
+
"snapshot_download(REPO, repo_type=\"dataset\", revision=REVISION, local_dir=DATA, allow_patterns=[\n",
|
| 65 |
+
" \"tiny/c4w-root.json\", \"tiny/c4w-root/*\", \"tiny/schema/*\",\n",
|
| 66 |
+
" \"tiny/groups/*-urban-g*/catalog/members.parquet\", \"tiny/groups/*-urban-g*/snapshot.json\"])\n",
|
| 67 |
+
"\n",
|
| 68 |
+
"ds = c4w.open(DATA / \"tiny\")\n",
|
| 69 |
+
"selection = ds.select(profile=\"urban\", frequencies_hz=[3_500_000_000], bs_ids=[0],\n",
|
| 70 |
+
" components=(\"core\", \"positions\"))\n",
|
| 71 |
+
"report = selection.missing()\n",
|
| 72 |
+
"print(report)\n",
|
| 73 |
+
"if report.files:\n",
|
| 74 |
+
" snapshot_download(REPO, repo_type=\"dataset\", revision=REVISION, local_dir=report.local_dir,\n",
|
| 75 |
+
" allow_patterns=report.repo_files)\n",
|
| 76 |
+
"assert selection.missing().complete"
|
| 77 |
+
]
|
| 78 |
+
},
|
| 79 |
+
{
|
| 80 |
+
"cell_type": "markdown",
|
| 81 |
+
"id": "cell-04",
|
| 82 |
+
"metadata": {},
|
| 83 |
+
"source": [
|
| 84 |
+
"## 2. Split by scene\n",
|
| 85 |
+
"\n",
|
| 86 |
+
"Keep the release's train and test split: test scenes are places no training scene shows.\n",
|
| 87 |
+
"Take validation scenes from the training split, by scene and never by link, so links of one\n",
|
| 88 |
+
"place never sit on both sides. Hashing the scene ID makes the choice reproducible, and\n",
|
| 89 |
+
"saving the lists records it."
|
| 90 |
+
]
|
| 91 |
+
},
|
| 92 |
+
{
|
| 93 |
+
"cell_type": "code",
|
| 94 |
+
"execution_count": null,
|
| 95 |
+
"id": "cell-05",
|
| 96 |
+
"metadata": {},
|
| 97 |
+
"outputs": [],
|
| 98 |
+
"source": [
|
| 99 |
+
"def is_validation(scene_id, fraction=0.1):\n",
|
| 100 |
+
" return int(hashlib.sha256(scene_id.encode()).hexdigest(), 16) % 1000 < fraction * 1000\n",
|
| 101 |
+
"\n",
|
| 102 |
+
"splits = {\"train\": [], \"validation\": [], \"test\": []}\n",
|
| 103 |
+
"for scene in selection.scenes():\n",
|
| 104 |
+
" part = \"test\" if scene.split == \"test\" else (\"validation\" if is_validation(scene.id) else \"train\")\n",
|
| 105 |
+
" splits[part].append(scene.id)\n",
|
| 106 |
+
"print({k: len(v) for k, v in splits.items()})\n",
|
| 107 |
+
"Path(\"splits.json\").write_text(json.dumps(splits, indent=1))"
|
| 108 |
+
]
|
| 109 |
+
},
|
| 110 |
+
{
|
| 111 |
+
"cell_type": "markdown",
|
| 112 |
+
"id": "cell-06",
|
| 113 |
+
"metadata": {},
|
| 114 |
+
"source": [
|
| 115 |
+
"## 3. From a record to arrays\n",
|
| 116 |
+
"\n",
|
| 117 |
+
"Each record becomes arrays with one row per link. This is where your own preprocessing goes:\n",
|
| 118 |
+
"`inputs` here are the UE position relative to the BS and the BS height; `targets` are the\n",
|
| 119 |
+
"strongest 16 paths' delays (ns), powers (dB) and arrival angles, padded to fixed size with a\n",
|
| 120 |
+
"mask that marks stored paths. Replace either function to fit your task. `LINKS_PER_RECORD`\n",
|
| 121 |
+
"bounds memory by sampling links reproducibly."
|
| 122 |
+
]
|
| 123 |
+
},
|
| 124 |
+
{
|
| 125 |
+
"cell_type": "code",
|
| 126 |
+
"execution_count": null,
|
| 127 |
+
"id": "cell-07",
|
| 128 |
+
"metadata": {},
|
| 129 |
+
"outputs": [],
|
| 130 |
+
"source": [
|
| 131 |
+
"LINKS_PER_RECORD = 512\n",
|
| 132 |
+
"PREPROCESSING = \"v1: dxyz+bs_z -> 16 x (delay ns, power dB, cos/sin AoA az, AoA zenith)\"\n",
|
| 133 |
+
"\n",
|
| 134 |
+
"def inputs(record, positions):\n",
|
| 135 |
+
" ue = positions.ue[record.ue_ids].astype(np.float32)\n",
|
| 136 |
+
" bs = positions.bs[record.bs_id].astype(np.float32)\n",
|
| 137 |
+
" return np.concatenate([ue - bs, np.full((len(ue), 1), bs[2], np.float32)], axis=1) # (links, 4)\n",
|
| 138 |
+
"\n",
|
| 139 |
+
"def targets(record):\n",
|
| 140 |
+
" core = record.core\n",
|
| 141 |
+
" power = 10 * np.log10(core[\"a_real\"].astype(np.float64) ** 2 + core[\"a_imag\"].astype(np.float64) ** 2)\n",
|
| 142 |
+
" per_path = np.stack([core[\"tau\"] * 1e9, power, np.cos(core[\"phi_r\"]), np.sin(core[\"phi_r\"]),\n",
|
| 143 |
+
" core[\"theta_r\"]], axis=1).astype(np.float32) # (paths, 5)\n",
|
| 144 |
+
" padded, mask = T.pad_paths(core, per_path) # (links, 16, 5), (links, 16)\n",
|
| 145 |
+
" return padded, mask\n",
|
| 146 |
+
"\n",
|
| 147 |
+
"def arrays(scene_ids):\n",
|
| 148 |
+
" rng = np.random.default_rng(0)\n",
|
| 149 |
+
" x, y, m, ids = [], [], [], []\n",
|
| 150 |
+
" for scene in selection.scenes():\n",
|
| 151 |
+
" if scene.id not in scene_ids:\n",
|
| 152 |
+
" continue\n",
|
| 153 |
+
" positions = scene.read_positions()\n",
|
| 154 |
+
" for record in scene.records():\n",
|
| 155 |
+
" keep = np.sort(rng.permutation(record.n_links)[:LINKS_PER_RECORD])\n",
|
| 156 |
+
" padded, mask = targets(record)\n",
|
| 157 |
+
" x.append(inputs(record, positions)[keep]); y.append(padded[keep]); m.append(mask[keep])\n",
|
| 158 |
+
" ids += [(scene.id, record.frequency_hz, record.bs_id, int(u)) for u in record.ue_ids[keep]]\n",
|
| 159 |
+
" return {\"x\": np.concatenate(x), \"y\": np.concatenate(y), \"mask\": np.concatenate(m),\n",
|
| 160 |
+
" \"ids\": np.array(ids, dtype=object)}"
|
| 161 |
+
]
|
| 162 |
+
},
|
| 163 |
+
{
|
| 164 |
+
"cell_type": "markdown",
|
| 165 |
+
"id": "cell-08",
|
| 166 |
+
"metadata": {},
|
| 167 |
+
"source": [
|
| 168 |
+
"## 4. Cache, then normalize with training statistics only\n",
|
| 169 |
+
"\n",
|
| 170 |
+
"Converting records takes a while, so save the arrays once. The cache key covers the release,\n",
|
| 171 |
+
"the selection, the scene lists of the split and the preprocessing version: change any of them\n",
|
| 172 |
+
"(including the validation fraction) and a new cache is built. Loading checks that every cached\n",
|
| 173 |
+
"row comes from a scene of its part.\n",
|
| 174 |
+
"Normalization is fitted on the training split and then applied unchanged to validation and\n",
|
| 175 |
+
"test, so no information leaks from held-out scenes. Target statistics use stored paths only,\n",
|
| 176 |
+
"and padded entries stay zero. Keep the statistics to turn predictions back into units."
|
| 177 |
+
]
|
| 178 |
+
},
|
| 179 |
+
{
|
| 180 |
+
"cell_type": "code",
|
| 181 |
+
"execution_count": null,
|
| 182 |
+
"id": "cell-09",
|
| 183 |
+
"metadata": {},
|
| 184 |
+
"outputs": [],
|
| 185 |
+
"source": [
|
| 186 |
+
"recipe = c4w.recipe.dumps(selection.to_recipe(revision=REVISION))\n",
|
| 187 |
+
"split_lists = json.dumps(splits, sort_keys=True)\n",
|
| 188 |
+
"key = hashlib.sha256(\n",
|
| 189 |
+
" f\"{ds.release}|{recipe}|{split_lists}|{PREPROCESSING}|{LINKS_PER_RECORD}\".encode()).hexdigest()[:16]\n",
|
| 190 |
+
"cache = Path(\"cache\") / key\n",
|
| 191 |
+
"data = {}\n",
|
| 192 |
+
"for part, scene_ids in splits.items():\n",
|
| 193 |
+
" path = cache / f\"{part}.npz\"\n",
|
| 194 |
+
" if not path.exists():\n",
|
| 195 |
+
" cache.mkdir(parents=True, exist_ok=True)\n",
|
| 196 |
+
" a = arrays(set(scene_ids))\n",
|
| 197 |
+
" np.savez(path, x=a[\"x\"], y=a[\"y\"], mask=a[\"mask\"], ids=a[\"ids\"].astype(str))\n",
|
| 198 |
+
" with np.load(path) as z:\n",
|
| 199 |
+
" data[part] = {k: z[k] for k in z.files}\n",
|
| 200 |
+
" assert set(data[part][\"ids\"][:, 0]) <= set(scene_ids), f\"cached {part} rows from other scenes\"\n",
|
| 201 |
+
" print(part, data[part][\"x\"].shape, data[part][\"y\"].shape)\n",
|
| 202 |
+
"\n",
|
| 203 |
+
"train = data[\"train\"]\n",
|
| 204 |
+
"stored = train[\"y\"][train[\"mask\"]] # (stored paths, 5)\n",
|
| 205 |
+
"stats = {\"x_mean\": train[\"x\"].mean(axis=0), \"x_std\": train[\"x\"].std(axis=0) + 1e-6,\n",
|
| 206 |
+
" \"y_mean\": stored.mean(axis=0), \"y_std\": stored.std(axis=0) + 1e-6}\n",
|
| 207 |
+
"np.savez(cache / \"normalization.npz\", **stats)\n",
|
| 208 |
+
"for part in data.values():\n",
|
| 209 |
+
" part[\"x\"] = ((part[\"x\"] - stats[\"x_mean\"]) / stats[\"x_std\"]).astype(np.float32)\n",
|
| 210 |
+
" y = (part[\"y\"] - stats[\"y_mean\"]) / stats[\"y_std\"]\n",
|
| 211 |
+
" part[\"y\"] = np.where(part[\"mask\"][..., None], y, 0).astype(np.float32)"
|
| 212 |
+
]
|
| 213 |
+
},
|
| 214 |
+
{
|
| 215 |
+
"cell_type": "markdown",
|
| 216 |
+
"id": "cell-10",
|
| 217 |
+
"metadata": {},
|
| 218 |
+
"source": [
|
| 219 |
+
"## 5. A Dataset and a DataLoader\n",
|
| 220 |
+
"\n",
|
| 221 |
+
"Every sample has the same shape, so PyTorch's default collate function batches them. Shuffle\n",
|
| 222 |
+
"the training set; keep validation and test in order."
|
| 223 |
+
]
|
| 224 |
+
},
|
| 225 |
+
{
|
| 226 |
+
"cell_type": "code",
|
| 227 |
+
"execution_count": null,
|
| 228 |
+
"id": "cell-11",
|
| 229 |
+
"metadata": {},
|
| 230 |
+
"outputs": [],
|
| 231 |
+
"source": [
|
| 232 |
+
"class LinkDataset(Dataset):\n",
|
| 233 |
+
" def __init__(self, part):\n",
|
| 234 |
+
" self.x = torch.from_numpy(part[\"x\"])\n",
|
| 235 |
+
" self.y = torch.from_numpy(part[\"y\"])\n",
|
| 236 |
+
" self.mask = torch.from_numpy(part[\"mask\"])\n",
|
| 237 |
+
"\n",
|
| 238 |
+
" def __len__(self):\n",
|
| 239 |
+
" return len(self.x)\n",
|
| 240 |
+
"\n",
|
| 241 |
+
" def __getitem__(self, i):\n",
|
| 242 |
+
" return {\"x\": self.x[i], \"y\": self.y[i], \"mask\": self.mask[i]}\n",
|
| 243 |
+
"\n",
|
| 244 |
+
"loaders = {part: DataLoader(LinkDataset(data[part]), batch_size=256, shuffle=(part == \"train\"))\n",
|
| 245 |
+
" for part in data}\n",
|
| 246 |
+
"batch = next(iter(loaders[\"train\"]))\n",
|
| 247 |
+
"for name, value in batch.items():\n",
|
| 248 |
+
" print(f\"{name:5s} {tuple(value.shape)} {value.dtype}\")"
|
| 249 |
+
]
|
| 250 |
+
},
|
| 251 |
+
{
|
| 252 |
+
"cell_type": "markdown",
|
| 253 |
+
"id": "cell-12",
|
| 254 |
+
"metadata": {},
|
| 255 |
+
"source": [
|
| 256 |
+
"## 6. What a batch holds\n",
|
| 257 |
+
"\n",
|
| 258 |
+
"- `x` (batch, 4): the UE position relative to the BS, in metres, and the BS height,\n",
|
| 259 |
+
" normalized with training statistics.\n",
|
| 260 |
+
"- `y` (batch, 16, 5): up to 16 paths per link, strongest first; per path the delay in ns, the\n",
|
| 261 |
+
" power in dB relative to unit power, the cosine and sine of the arrival azimuth and the\n",
|
| 262 |
+
" arrival zenith in radians, each normalized with the training split's stored paths.\n",
|
| 263 |
+
"- `mask` (batch, 16): true where a path is stored. Padded paths are zeros: use the mask in\n",
|
| 264 |
+
" every loss and metric so they never count as weak paths.\n",
|
| 265 |
+
"\n",
|
| 266 |
+
"The saved `ids` (scene, carrier, BS, UE) tie each row back to its record."
|
| 267 |
+
]
|
| 268 |
+
},
|
| 269 |
+
{
|
| 270 |
+
"cell_type": "code",
|
| 271 |
+
"execution_count": null,
|
| 272 |
+
"id": "cell-13",
|
| 273 |
+
"metadata": {},
|
| 274 |
+
"outputs": [],
|
| 275 |
+
"source": [
|
| 276 |
+
"paths = data[\"train\"][\"mask\"].sum(axis=1)\n",
|
| 277 |
+
"print(\"stored paths per link: min\", paths.min(), \"mean\", round(float(paths.mean()), 1), \"max\", paths.max())\n",
|
| 278 |
+
"\n",
|
| 279 |
+
"def masked_mse(prediction, target, mask):\n",
|
| 280 |
+
" error = ((prediction - target) ** 2).mean(dim=-1) # (batch, 16)\n",
|
| 281 |
+
" return (error * mask).sum() / mask.sum().clamp(min=1)\n",
|
| 282 |
+
"\n",
|
| 283 |
+
"# Predicting the training mean (zero after normalization) gives a masked MSE near 1.\n",
|
| 284 |
+
"print(\"masked MSE of predicting the mean:\",\n",
|
| 285 |
+
" round(float(masked_mse(torch.zeros_like(batch[\"y\"]), batch[\"y\"], batch[\"mask\"])), 3))"
|
| 286 |
+
]
|
| 287 |
+
},
|
| 288 |
+
{
|
| 289 |
+
"cell_type": "markdown",
|
| 290 |
+
"id": "cell-14",
|
| 291 |
+
"metadata": {},
|
| 292 |
+
"source": [
|
| 293 |
+
"## Adapt it\n",
|
| 294 |
+
"\n",
|
| 295 |
+
"- **Other inputs:** add the carrier, the scene geometry (`scene.open_geometry()`), or the\n",
|
| 296 |
+
" channel at the other carrier for cross-band tasks; keep them per link.\n",
|
| 297 |
+
"- **Other targets:** use the complex coefficients, departure angles, the frequency response\n",
|
| 298 |
+
" (`T.frequency_response`) or the interaction detail (`components=(\"core\", \"detail\")`,\n",
|
| 299 |
+
" `T.pad_interactions`).\n",
|
| 300 |
+
"- **More data:** widen the selection (`tier=\"small\"` on the release catalog, other profiles or\n",
|
| 301 |
+
" BSs) and raise `LINKS_PER_RECORD`; the [library guide](https://huggingface.co/datasets/Intelligence-Networking-Lab/Channels4World/blob/v1.0.0/docs/library-guide.md) plans TAR\n",
|
| 302 |
+
" downloads, and `c4w.to_cache` keeps records memory-mapped for repeated reads.\n",
|
| 303 |
+
"- **Shuffling at scale:** records are stored in groups of 25 scenes; shuffle groups or scenes\n",
|
| 304 |
+
" and read each one's records together, as above.\n",
|
| 305 |
+
"- **Records instead of links:** `channels4world.torch.RecordDataset(selection, transform=...)`\n",
|
| 306 |
+
" yields one record per item and reopens the dataset in each worker process."
|
| 307 |
+
]
|
| 308 |
+
}
|
| 309 |
+
],
|
| 310 |
+
"metadata": {
|
| 311 |
+
"kernelspec": {
|
| 312 |
+
"display_name": "Python 3",
|
| 313 |
+
"language": "python",
|
| 314 |
+
"name": "python3"
|
| 315 |
+
},
|
| 316 |
+
"language_info": {
|
| 317 |
+
"name": "python"
|
| 318 |
+
}
|
| 319 |
+
},
|
| 320 |
+
"nbformat": 4,
|
| 321 |
+
"nbformat_minor": 5
|
| 322 |
+
}
|
docs/overview.png
ADDED
|
Git LFS Details
|
docs/read_archives.py
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Read Channels4World channel archives with only NumPy and the standard library.
|
| 2 |
+
|
| 3 |
+
Usage: python read_archives.py RELEASE_DIR [--band 3.5ghz] [--scenes ID ...] [--limit N]
|
| 4 |
+
|
| 5 |
+
RELEASE_DIR is the folder you downloaded the release into (it contains payload/).
|
| 6 |
+
The script finds every archive under RELEASE_DIR/payload, pairs each channel archive
|
| 7 |
+
with its group's positions archive, joins UE IDs to UE positions, and prints the first
|
| 8 |
+
retained link of each record it shows. It works with any folder layout, because archive
|
| 9 |
+
file names are unique.
|
| 10 |
+
"""
|
| 11 |
+
|
| 12 |
+
import argparse
|
| 13 |
+
import io
|
| 14 |
+
import tarfile
|
| 15 |
+
from collections import defaultdict
|
| 16 |
+
from pathlib import Path
|
| 17 |
+
|
| 18 |
+
import numpy as np
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
def find_archives(release_dir):
|
| 22 |
+
"""Map archive file name -> path for every .tar under RELEASE_DIR/payload."""
|
| 23 |
+
payload = Path(release_dir) / "payload"
|
| 24 |
+
if not payload.is_dir():
|
| 25 |
+
raise SystemExit(f"{payload} not found: pass the folder you downloaded the release into")
|
| 26 |
+
found = defaultdict(list)
|
| 27 |
+
for path in payload.rglob("*.tar"):
|
| 28 |
+
found[path.name].append(path)
|
| 29 |
+
duplicates = {name: paths for name, paths in found.items() if len(paths) > 1}
|
| 30 |
+
if duplicates:
|
| 31 |
+
lines = [f" {name}: {', '.join(str(p) for p in paths)}" for name, paths in sorted(duplicates.items())]
|
| 32 |
+
raise SystemExit("The same archive appears more than once (mixed downloads or layouts?):\n"
|
| 33 |
+
+ "\n".join(lines))
|
| 34 |
+
return {name: paths[0] for name, paths in found.items()}
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
def scene_of(member_path):
|
| 38 |
+
"""'records/scene=<id>/...' -> '<id>'"""
|
| 39 |
+
return member_path.split("/")[1].removeprefix("scene=")
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
def npz_members(tar_path, scenes=None):
|
| 43 |
+
"""Yield (member_path, arrays) for NPZ members, optionally only for the given scenes."""
|
| 44 |
+
with tarfile.open(tar_path) as tar:
|
| 45 |
+
for member in tar:
|
| 46 |
+
if not (member.isfile() and member.name.endswith(".npz")):
|
| 47 |
+
continue
|
| 48 |
+
if scenes is not None and scene_of(member.name) not in scenes:
|
| 49 |
+
continue # skip without reading the member's bytes
|
| 50 |
+
with np.load(io.BytesIO(tar.extractfile(member).read())) as npz:
|
| 51 |
+
yield member.name, {k: npz[k] for k in npz.files if k != "__meta__"}
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
def main():
|
| 55 |
+
ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
|
| 56 |
+
ap.add_argument("release_dir")
|
| 57 |
+
ap.add_argument("--band", default="3.5ghz", help="3.5ghz or 7ghz (default: 3.5ghz)")
|
| 58 |
+
ap.add_argument("--scenes", nargs="*", help="only these scene IDs (their archives must be downloaded)")
|
| 59 |
+
ap.add_argument("--limit", type=int, default=5,
|
| 60 |
+
help="stop after printing this many records (default: 5; 0 reads every record)")
|
| 61 |
+
args = ap.parse_args()
|
| 62 |
+
scenes = set(args.scenes) if args.scenes else None
|
| 63 |
+
|
| 64 |
+
archives = find_archives(args.release_dir)
|
| 65 |
+
suffix = f"-{args.band}-core.tar"
|
| 66 |
+
core_archives = sorted(name for name in archives if name.endswith(suffix))
|
| 67 |
+
groups = [name.removesuffix(suffix) for name in core_archives]
|
| 68 |
+
missing = [f"{g}-positions.tar" for g in groups if f"{g}-positions.tar" not in archives]
|
| 69 |
+
if missing:
|
| 70 |
+
print(f"Skipping {len(missing)} group(s) whose positions archive is not downloaded:")
|
| 71 |
+
print("\n".join(f" {name}" for name in missing))
|
| 72 |
+
if not core_archives:
|
| 73 |
+
raise SystemExit(f"No *{suffix} archives under {args.release_dir}/payload")
|
| 74 |
+
|
| 75 |
+
printed = seen = 0
|
| 76 |
+
for group in groups:
|
| 77 |
+
if f"{group}-positions.tar" in missing:
|
| 78 |
+
continue
|
| 79 |
+
if args.limit and printed >= args.limit:
|
| 80 |
+
break # stop reading once enough is printed
|
| 81 |
+
positions = {scene_of(m): a for m, a in npz_members(archives[f"{group}-positions.tar"], scenes)}
|
| 82 |
+
records = npz_members(archives[f"{group}{suffix}"], scenes)
|
| 83 |
+
for member, core in records:
|
| 84 |
+
seen += 1
|
| 85 |
+
scene = scene_of(member)
|
| 86 |
+
bs_id = int(member.rsplit("/bs", 1)[1].removesuffix(".npz"))
|
| 87 |
+
pos = positions[scene]
|
| 88 |
+
ue_ids = core["link_ue_index"] # retained UE IDs (rows of ue_positions)
|
| 89 |
+
offsets = core["link_path_offsets"] # link i owns paths offsets[i]:offsets[i+1]
|
| 90 |
+
if ue_ids.size == 0:
|
| 91 |
+
continue
|
| 92 |
+
i = 0 # first retained link
|
| 93 |
+
start, stop = offsets[i], offsets[i + 1]
|
| 94 |
+
gain = core["a_real"][start:stop] + 1j * core["a_imag"][start:stop]
|
| 95 |
+
distance = np.linalg.norm(pos["ue_positions"][ue_ids[i]] - pos["bs_positions"][bs_id])
|
| 96 |
+
print(f"{scene} BS {bs_id}: {ue_ids.size} links, {offsets[-1]} paths; "
|
| 97 |
+
f"UE {ue_ids[i]} at {distance:.1f} m has {stop - start} paths, "
|
| 98 |
+
f"first delay {core['tau'][start]:.3e} s, |gain| {abs(gain[0]):.3e}")
|
| 99 |
+
printed += 1
|
| 100 |
+
if args.limit and printed >= args.limit:
|
| 101 |
+
records.close() # closes the archive
|
| 102 |
+
break
|
| 103 |
+
note = f" (stopped at --limit {args.limit})" if args.limit and printed >= args.limit else ""
|
| 104 |
+
print(f"Read {seen} channel records{note}.")
|
| 105 |
+
|
| 106 |
+
|
| 107 |
+
if __name__ == "__main__":
|
| 108 |
+
main()
|
docs/scenes.png
ADDED
|
Git LFS Details
|
docs/schema-reference.md
ADDED
|
@@ -0,0 +1,226 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Channels4World schema reference
|
| 2 |
+
|
| 3 |
+
Names, types, shapes and units of every file in release 1.0.0. The release's `schema/`
|
| 4 |
+
folder holds the authoritative versions (`arrays.json`, `conventions.json`,
|
| 5 |
+
`interaction-codes.json` and `release-profile.json`); every record header refers to
|
| 6 |
+
`conventions.json` by its SHA-256.
|
| 7 |
+
|
| 8 |
+
## Numeric payloads
|
| 9 |
+
|
| 10 |
+
Each numeric NPZ has the listed arrays and a scalar string `__meta__` containing
|
| 11 |
+
JSON (`schema="wireless.npz-meta"`, `version=2`). Use `np.load(..., allow_pickle=False)`.
|
| 12 |
+
NumPy dtype strings specify byte order: `<` = little endian; `|` = one-byte value.
|
| 13 |
+
Dimensions below are per record: `L` retained links, `P` retained paths, `I`
|
| 14 |
+
interactions, `B` BS positions, `U` UE positions. Every scene has `B=32` and `U=16384`;
|
| 15 |
+
`L`, `P` and `I` vary. Counts, IDs, ranks and offsets are unitless integers.
|
| 16 |
+
|
| 17 |
+
### Core: one scene × carrier × BS
|
| 18 |
+
|
| 19 |
+
| Exact name | NumPy dtype | Shape | Unit | Meaning |
|
| 20 |
+
|---|---|---|---|---|
|
| 21 |
+
| `link_ue_index` | `<i4` (int32) | `(L,)` | UE row index | Strictly increasing unique retained UE IDs; indexes scene `ue_positions` |
|
| 22 |
+
| `link_path_offsets` | `<i8` (int64) | `(L+1,)` | Path offset | Half-open path span per link |
|
| 23 |
+
| `path_rank` | `\|u1` (uint8) | `(P,)` | Rank | 0-based position within its link, by decreasing float32 power (see below) |
|
| 24 |
+
| `a_real` | `<f4` (float32) | `(P,)` | 1 | Real part of stored scalar passband coefficient |
|
| 25 |
+
| `a_imag` | `<f4` | `(P,)` | 1 | Imaginary part of stored scalar passband coefficient |
|
| 26 |
+
| `tau` | `<f4` | `(P,)` | s | Absolute propagation delay |
|
| 27 |
+
| `theta_t` | `<f4` | `(P,)` | rad | Departure zenith from +z at BS |
|
| 28 |
+
| `phi_t` | `<f4` | `(P,)` | rad | Departure azimuth from +x toward +y at BS |
|
| 29 |
+
| `theta_r` | `<f4` | `(P,)` | rad | Arrival zenith from +z at UE |
|
| 30 |
+
| `phi_r` | `<f4` | `(P,)` | rad | Arrival azimuth from +x toward +y at UE |
|
| 31 |
+
| `interaction_count` | `\|u1` (uint8) | `(P,)` | Count | Number of interactions on each retained path |
|
| 32 |
+
| `interaction_flags` | `<u2` (uint16) | `(P,)` | Bit mask | OR of `1 << interaction_type`, not OR of raw codes |
|
| 33 |
+
|
| 34 |
+
`a_real + 1j*a_imag` excludes the carrier-delay phase. `tau` is not delay spread.
|
| 35 |
+
Summed `|a|²` is relative to unit coefficient power, not dBm/RSRP. For baseband phase
|
| 36 |
+
or a frequency response, see the library's optional transforms below; the card's examples
|
| 37 |
+
inspect stored coefficients without synthesizing a response.
|
| 38 |
+
|
| 39 |
+
**Retention, order and ranks.** For each link, at most the 16 strongest candidate paths
|
| 40 |
+
are kept, and only those with `10·log10|a|² > −150` dB. Paths within a link are ordered by
|
| 41 |
+
decreasing power computed in single (float32) precision; recomputing power in double
|
| 42 |
+
precision can swap near-equal neighbours (differences below 1e-6 dB). The conventions
|
| 43 |
+
document defines `path_rank` as the rank before the −150 dB threshold, with gaps retained.
|
| 44 |
+
Because the threshold removes only the weakest candidates, the kept ranks are always the
|
| 45 |
+
first ones, so `path_rank` equals the path's 0-based position within its link. In all of
|
| 46 |
+
Tiny, `path_rank` and `interaction_rank` are contiguous and 0-based.
|
| 47 |
+
|
| 48 |
+
### Detail: same scene × carrier × BS and core path axis
|
| 49 |
+
|
| 50 |
+
| Exact name | NumPy dtype | Shape | Unit | Meaning |
|
| 51 |
+
|---|---|---|---|---|
|
| 52 |
+
| `path_interaction_offsets` | `<i8` (int64) | `(P+1,)` | Interaction offset | Half-open interaction span for each core path |
|
| 53 |
+
| `interaction_rank` | `\|u1` (uint8) | `(I,)` | Rank | 0-based position along the path, BS to UE |
|
| 54 |
+
| `interaction_type` | `\|i1` (int8) | `(I,)` | Code | `1` specular reflection, `8` diffraction (see below) |
|
| 55 |
+
| `interaction_vertex` | `<f4` (float32) | `(I,3)` | m | Interaction `(x,y,z)`, ordered BS→UE |
|
| 56 |
+
|
| 57 |
+
The interaction codebook defines `1` specular reflection, `2` diffuse reflection,
|
| 58 |
+
`4` refraction and `8` diffraction (`0` means none). Channels4World models line of sight,
|
| 59 |
+
specular reflection and diffraction, with up to four interactions per path, so stored
|
| 60 |
+
rows use codes `1` and `8` and the matching flag bits `2` and `256`. A line-of-sight path
|
| 61 |
+
has zero interactions: an empty span and a zero flag. Detail and core must share
|
| 62 |
+
`path_axis_sha256`, not merely array lengths.
|
| 63 |
+
|
| 64 |
+
### Positions: one scene, shared by carriers
|
| 65 |
+
|
| 66 |
+
| Exact name | NumPy dtype | Shape | Unit | Meaning |
|
| 67 |
+
|---|---|---|---|---|
|
| 68 |
+
| `bs_positions` | `<f4` (float32) | `(B,3)` | m | BS row = zero-based BS ID |
|
| 69 |
+
| `ue_positions` | `<f4` (float32) | `(U,3)` | m | UE row = zero-based UE ID |
|
| 70 |
+
|
| 71 |
+
The frame is right-handed scene Cartesian `(x,y,z)` with +z up. Coordinates are local to
|
| 72 |
+
each scene and not georeferenced; the ground is flat at `z=0`, so `z` is height above
|
| 73 |
+
ground. Scene assets have `frequency_hz=null` and `bs_index=null` in their identity. The two
|
| 74 |
+
carriers reuse these scene assets.
|
| 75 |
+
|
| 76 |
+
## UE → path → interaction offsets
|
| 77 |
+
|
| 78 |
+
All indices are zero-based. Offsets start at zero, are non-decreasing, and end at
|
| 79 |
+
the length of the spanned axis. Slices are half-open:
|
| 80 |
+
|
| 81 |
+
```python
|
| 82 |
+
i = 0 # retained-link row, NOT a UE ID
|
| 83 |
+
ue_id = int(core["link_ue_index"][i])
|
| 84 |
+
xyz = positions["ue_positions"][ue_id]
|
| 85 |
+
p0, p1 = map(int, core["link_path_offsets"][i:i+2])
|
| 86 |
+
# Core path j is in [p0, p1).
|
| 87 |
+
j = p0 # only if p0 < p1
|
| 88 |
+
k0, k1 = map(int, detail["path_interaction_offsets"][j:j+2])
|
| 89 |
+
vertices = detail["interaction_vertex"][k0:k1]
|
| 90 |
+
```
|
| 91 |
+
|
| 92 |
+
For every path `j`, `interaction_count[j]` equals
|
| 93 |
+
`path_interaction_offsets[j+1] - path_interaction_offsets[j]` when both components
|
| 94 |
+
are present. The three interaction arrays share row `k`. Path fields share row `j`;
|
| 95 |
+
`path_rank` is a position within the link, not the flat path index. Preserve
|
| 96 |
+
`link_ue_index` whenever filtering or joining records. A UE ID that is not listed has no
|
| 97 |
+
retained link: do not renumber the remaining UEs or treat the missing ones as zero power.
|
| 98 |
+
|
| 99 |
+
Illustrative indexing only: UE IDs `[2,9]`, link offsets `[0,2,3]` assign paths
|
| 100 |
+
`0,1` to UE 2 and path `2` to UE 9. Interaction offsets `[0,1,1,3]` assign one,
|
| 101 |
+
zero and two interactions to those three paths. Coordinates come from position
|
| 102 |
+
rows `2` and `9`, not rows `0` and `1`.
|
| 103 |
+
|
| 104 |
+
## Numeric record metadata and identity
|
| 105 |
+
|
| 106 |
+
| Header field | Type / structure | Meaning |
|
| 107 |
+
|---|---|---|
|
| 108 |
+
| `schema`, `version` | string, integer | `wireless.npz-meta`, `2` |
|
| 109 |
+
| `identity` | object | `collection_id` (string), `scene_id` (string), `component` (string), `frequency_hz` (integer Hz or null), `bs_index` (integer or null) |
|
| 110 |
+
| `conventions` | `{ref, sha256}` | Relative path and exact SHA-256 of interpretation document |
|
| 111 |
+
| `dimensions` | object of integers | Core `{links,paths}`; detail `{paths,interactions}`; positions `{bs,ues}` |
|
| 112 |
+
| `path_axis_sha256` | SHA-256 string, core/detail | Associates UE IDs, link offsets and path ranks across components |
|
| 113 |
+
| `dependencies.positions` | object, core | Positions `record_id`, `content_sha256`, `conventions_sha256`, `bs`, `ues` |
|
| 114 |
+
| `dependencies.core_axis` | object, detail | Core `record_id`, `path_axis_sha256`, `conventions_sha256`, and positions dependency |
|
| 115 |
+
| `info` | object | Supplementary metadata; not a replacement for identity or dependencies |
|
| 116 |
+
|
| 117 |
+
A `record_id` is the SHA-256 of the identity serialized as JSON with sorted keys, compact
|
| 118 |
+
separators and UTF-8. To associate components, match the full identity and dependency
|
| 119 |
+
hashes. The group snapshot records the numeric manifests, content hashes and NPZ byte
|
| 120 |
+
hashes; each hash has its own meaning, so do not substitute one for another.
|
| 121 |
+
`collection_id` is `channels4world-v1-20260714` for every record of this release.
|
| 122 |
+
|
| 123 |
+
## Root manifest and catalogs
|
| 124 |
+
|
| 125 |
+
`c4w-root.json`: `format="channels4world.root"`, `format_version=1`.
|
| 126 |
+
Other fields are `kind` (`release`, `subset`, or `cache`), `payload` (`tar`, `loose`,
|
| 127 |
+
or cache representation), `collection_id`, `release`, ordered `tiers`,
|
| 128 |
+
`frequencies_hz` (integer Hz list), `hf_repo`, `hf_path`, `tables` and `source`.
|
| 129 |
+
Each table reference has `path`, `sha256` and `bytes`. Subsets, including Tiny, also
|
| 130 |
+
record `created_by`; their `source` records the source release, its kind and the SHA-256
|
| 131 |
+
of its root manifest.
|
| 132 |
+
|
| 133 |
+
The reader opens **all tables referenced by this manifest**. Tiny therefore needs
|
| 134 |
+
the manifest plus its scenes, files and records tables even when only one scene's
|
| 135 |
+
payloads are downloaded. Group metadata and payloads load lazily afterward, so an
|
| 136 |
+
explicit downloaded scene can be read from a partial Tiny root.
|
| 137 |
+
|
| 138 |
+
Every path inside a root is relative to that root. `hf_repo` and `hf_path` record where
|
| 139 |
+
a published root lives: `hf_path` is `""` for the release root at the top of
|
| 140 |
+
`Intelligence-Networking-Lab/Channels4World` and `"tiny"` for Tiny. Only download planning
|
| 141 |
+
(`MissingReport.repo_files`, `local_dir`, `hf_command`) adds `hf_path`. Subsets and caches
|
| 142 |
+
made locally with `extract`/`to_cache` have both fields `null`, so the library never
|
| 143 |
+
proposes downloading their loose files from the repository.
|
| 144 |
+
|
| 145 |
+
| Root table | Exact columns and Arrow types |
|
| 146 |
+
|---|---|
|
| 147 |
+
| `c4w-root/scenes.parquet` | `scene_id:string`, `split:string`, `profile:string`, `tier:string`, `group:string`, `group_order:int64`, `scene_order:int64` |
|
| 148 |
+
| `c4w-root/files.parquet` | `path:string`, `bytes:int64`, `sha256:string`, `group:string`, `kind:string`, `component:string`, `frequency_hz:int64`, `record_id:string` |
|
| 149 |
+
| `c4w-root/records.parquet` | `record_id:string`; subsets and caches only (Tiny has one), listing the included records |
|
| 150 |
+
|
| 151 |
+
Root table fields are nullable in the Arrow schemas; which apply depends on the row's
|
| 152 |
+
kind. `bytes` is file size in bytes. `path` is relative to the root.
|
| 153 |
+
`tier` is the smallest containing tier; `group_order` and `scene_order` fix iteration
|
| 154 |
+
order (`scene_order` is also the member order inside each archive). `split` is `train`
|
| 155 |
+
or `test`. `profile` is `urban`, `metropolitan` or `suburban`; `metro` appears only in
|
| 156 |
+
group names, archive names and scene IDs. Take scene and BS IDs from the catalogs.
|
| 157 |
+
|
| 158 |
+
For a TAR payload row, `record_id` is null because one file holds many records.
|
| 159 |
+
For loose payload rows it identifies the single included record. `group`,
|
| 160 |
+
`component` and `frequency_hz` are null where they do not apply. `kind` is `payload`,
|
| 161 |
+
`snapshot`, `members`, `catalog` or `schema`; the format also defines `cache_index` and
|
| 162 |
+
`cache_array` for local caches. The root files themselves (`c4w-root.json`, `c4w-root/`)
|
| 163 |
+
are not listed.
|
| 164 |
+
|
| 165 |
+
### Group metadata
|
| 166 |
+
|
| 167 |
+
| File | Fields / role |
|
| 168 |
+
|---|---|
|
| 169 |
+
| `groups/<group>/catalog/members.parquet` | `record_id:string`, `object_path:string`, `member_path:string`, `data_offset:int64`, `member_bytes:int64`, `member_sha256:string` |
|
| 170 |
+
| `groups/<group>/catalog/objects.parquet` | `object_path`, `object_bytes`, `object_sha256`: each archive's size and byte hash |
|
| 171 |
+
| `groups/<group>/catalog/scenes.parquet` | The group's scenes, including `scene_id`, `scene_order`, `split` and `profile` |
|
| 172 |
+
| `groups/<group>/catalog/records.parquet`, `geometry.parquet` | Per-record and per-geometry descriptions used by the library |
|
| 173 |
+
| `groups/<group>/snapshot.json` | `wireless.numeric-snapshot` v1: conventions reference and each numeric record's declarations and content proofs |
|
| 174 |
+
|
| 175 |
+
`data_offset` is the byte offset of member data in an uncompressed TAR, not the
|
| 176 |
+
TAR header offset. `member_bytes` is the embedded NPZ/ZIP byte length. Together they
|
| 177 |
+
locate one record's bytes inside an archive, so a byte-range read can fetch it without
|
| 178 |
+
the rest of the archive. `member_path` is also the file's path after extraction. Subset
|
| 179 |
+
roots keep the original group metadata and shared schemas; only the subset root's
|
| 180 |
+
records table defines what the subset contains, and other group catalogs can remain
|
| 181 |
+
present.
|
| 182 |
+
|
| 183 |
+
Archives are plain, uncompressed POSIX ustar TARs with regular-file members only and
|
| 184 |
+
normalized member metadata (mode 0644, uid and gid 0, mtime 0). A channel archive has 800
|
| 185 |
+
members (25 scenes × 32 BSs), ordered by `scene_order` and then by BS; a scene-asset
|
| 186 |
+
archive has 25.
|
| 187 |
+
|
| 188 |
+
## Geometry
|
| 189 |
+
|
| 190 |
+
Geometry is a ZIP rather than a numeric NPZ. `scene.json` identifies an `entrypoint`
|
| 191 |
+
XML; the archive also contains Mitsuba XML and OBJ meshes in metres. Preserve their
|
| 192 |
+
relative paths when extracting. Its identity uses null carrier and BS, like positions.
|
| 193 |
+
|
| 194 |
+
## Library API used on the card
|
| 195 |
+
|
| 196 |
+
```text
|
| 197 |
+
open(path) -> Dataset
|
| 198 |
+
Dataset.select(*, split=None, tier=None, profile=None, scene_ids=None,
|
| 199 |
+
frequencies_hz=None, bs_ids=None,
|
| 200 |
+
components=("core", "positions", "geometry")) -> Selection
|
| 201 |
+
Dataset.profiles; Dataset.scene(scene_id) -> Scene
|
| 202 |
+
Scene.profile; Scene.frequencies[integer_Hz].base_stations[integer_BS]
|
| 203 |
+
BaseStation.read(detail=False, verify="basic") -> Record
|
| 204 |
+
Scene.read_positions(verify="basic") -> Positions
|
| 205 |
+
Record.ue_ids; Record.core; Record.detail; Record.get_link(ue_id)
|
| 206 |
+
extract(selection, dest, *, verify="basic", check_space=True,
|
| 207 |
+
skip_existing=False, confirm=None) -> Path
|
| 208 |
+
to_cache(selection, dest, *, verify="basic", check_space=True, confirm=None) -> Path
|
| 209 |
+
```
|
| 210 |
+
|
| 211 |
+
Selections are lazy; `read()` performs payload I/O and returns read-only arrays.
|
| 212 |
+
Use copies for manipulation. `Selection.missing()` distinguishes requested missing
|
| 213 |
+
files from unpublished components. `verify="basic"` checks published bytes and
|
| 214 |
+
declared structure; `verify="full"` additionally checks scientific rules and content
|
| 215 |
+
proofs. Core/detail association is checked together on a full read of both components.
|
| 216 |
+
|
| 217 |
+
Optional `channels4world.transforms` functions operate on a loaded record and return
|
| 218 |
+
new writable arrays: `complex_gain(rec)`, `path_power_db(rec)`, `delay_spread(rec)`,
|
| 219 |
+
`baseband_coefficients(rec, delay_reference="absolute")`, and
|
| 220 |
+
`frequency_response(rec, offsets_hz, delay_reference="absolute", max_elements=1<<22)`.
|
| 221 |
+
These describe retained paths only. `frequency_response` takes offsets from the
|
| 222 |
+
record's carrier, not absolute carrier frequencies. A local NPY cache stores parts
|
| 223 |
+
by group/component/carrier, with one NPY per array and an index; numeric arrays can
|
| 224 |
+
then be memory-mapped. This changes the local representation, not the scene tier.
|
| 225 |
+
|
| 226 |
+
[Return to dataset card](../README.md)
|
docs/tutorial-library.md
ADDED
|
@@ -0,0 +1,213 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Read one scene with the channels4world library
|
| 2 |
+
|
| 3 |
+
This tutorial follows one link of Channels4World from the catalog down to its paths:
|
| 4 |
+
**BS 0 → UE 14 of `urban_scene_019234` at 3.5 GHz**, the link the project website shows.
|
| 5 |
+
It downloads about 26 MB of one Tiny scene, walks the hierarchy, reads the geometry, the
|
| 6 |
+
positions and the channel record, explains the stored arrays, and ends with the same link
|
| 7 |
+
at 7 GHz. The [notebook version](notebooks/01-read-one-scene-library.ipynb) runs top to
|
| 8 |
+
bottom; [the same tutorial without the library](tutorial-numpy.md) reads the same link with
|
| 9 |
+
NumPy alone.
|
| 10 |
+
|
| 11 |
+
Install the library with `pip install channels4world` (Python 3.11+), then
|
| 12 |
+
`pip install huggingface_hub matplotlib`.
|
| 13 |
+
|
| 14 |
+
```python
|
| 15 |
+
from pathlib import Path
|
| 16 |
+
import json
|
| 17 |
+
|
| 18 |
+
import matplotlib.pyplot as plt
|
| 19 |
+
import numpy as np
|
| 20 |
+
from huggingface_hub import snapshot_download
|
| 21 |
+
from matplotlib.collections import PolyCollection
|
| 22 |
+
|
| 23 |
+
import channels4world as c4w
|
| 24 |
+
```
|
| 25 |
+
|
| 26 |
+
## 1. Choose the link
|
| 27 |
+
|
| 28 |
+
Change these to read any other link. `GROUP` is the scene's `group` in the `tiny_scenes`
|
| 29 |
+
catalog. BS IDs run from 0 to 31 and UE IDs from 0 to 16,383; both are rows
|
| 30 |
+
of the scene's positions. Carriers are integers in Hz.
|
| 31 |
+
|
| 32 |
+
```python
|
| 33 |
+
REPO, REVISION = "Intelligence-Networking-Lab/Channels4World", "v1.0.0"
|
| 34 |
+
SCENE_ID, GROUP = "urban_scene_019234", "test-urban-g00000" # GROUP: from the tiny_scenes catalog
|
| 35 |
+
CARRIER_HZ, BS_ID, UE_ID = 3_500_000_000, 0, 14
|
| 36 |
+
OTHER_HZ = 7_000_000_000
|
| 37 |
+
DATA = Path("c4w")
|
| 38 |
+
```
|
| 39 |
+
|
| 40 |
+
## 2. Download what this tutorial reads
|
| 41 |
+
|
| 42 |
+
Tiny is published as loose files under `tiny/`. The library needs Tiny's catalog, the shared
|
| 43 |
+
schemas and the scene's group metadata (about 11 MB); the records are the scene's positions
|
| 44 |
+
and geometry and BS 0's core and detail at both carriers (about 15 MB).
|
| 45 |
+
|
| 46 |
+
```python
|
| 47 |
+
scene_dir = f"tiny/records/scene={SCENE_ID}"
|
| 48 |
+
patterns = [
|
| 49 |
+
"tiny/c4w-root.json", "tiny/c4w-root/*", "tiny/schema/*",
|
| 50 |
+
f"tiny/groups/{GROUP}/catalog/members.parquet", f"tiny/groups/{GROUP}/snapshot.json",
|
| 51 |
+
f"{scene_dir}/positions.npz", f"{scene_dir}/geometry.zip",
|
| 52 |
+
f"{scene_dir}/band_hz=*/component=*/bs{BS_ID:05d}.npz",
|
| 53 |
+
]
|
| 54 |
+
snapshot_download(REPO, repo_type="dataset", revision=REVISION, local_dir=DATA, allow_patterns=patterns)
|
| 55 |
+
```
|
| 56 |
+
|
| 57 |
+
## 3. Walk the hierarchy
|
| 58 |
+
|
| 59 |
+
The dataset is organized as **dataset → scene → carrier → base station → UE link → paths**.
|
| 60 |
+
Opening reads only the small catalog; group metadata and records load when first needed.
|
| 61 |
+
|
| 62 |
+
```python
|
| 63 |
+
ds = c4w.open(DATA / "tiny")
|
| 64 |
+
print(ds)
|
| 65 |
+
scene = ds.scene(SCENE_ID)
|
| 66 |
+
print(scene) # split, profile and smallest tier
|
| 67 |
+
print("carriers (Hz):", scene.frequencies.ids)
|
| 68 |
+
print("base stations:", scene.frequencies[CARRIER_HZ].base_stations.ids)
|
| 69 |
+
```
|
| 70 |
+
|
| 71 |
+
`urban_scene_019234` is a **test** scene: every link and both carriers of a scene stay in
|
| 72 |
+
one split, so a model trained on the training split has never seen this place.
|
| 73 |
+
|
| 74 |
+
## 4. Geometry and positions
|
| 75 |
+
|
| 76 |
+
Geometry, positions and interaction points share one frame: scene metres, z up. Positions
|
| 77 |
+
hold all 32 BS and 16,384 UE coordinates of the scene; the geometry is a Mitsuba XML file
|
| 78 |
+
with OBJ meshes in a ZIP.
|
| 79 |
+
|
| 80 |
+
```python
|
| 81 |
+
positions = scene.read_positions()
|
| 82 |
+
bs_positions, ue_positions = positions.bs, positions.ue
|
| 83 |
+
bs_xyz, ue_xyz = bs_positions[BS_ID], ue_positions[UE_ID]
|
| 84 |
+
print(positions)
|
| 85 |
+
print("BS", bs_xyz, "UE", ue_xyz, f"distance {np.linalg.norm(ue_xyz - bs_xyz):.1f} m")
|
| 86 |
+
|
| 87 |
+
def top_view(read, names):
|
| 88 |
+
"""Building triangles projected onto the ground (x, y), from OBJ meshes."""
|
| 89 |
+
triangles = []
|
| 90 |
+
for name in names:
|
| 91 |
+
verts, faces = [], []
|
| 92 |
+
for line in read(name).decode().splitlines():
|
| 93 |
+
if line.startswith("v "):
|
| 94 |
+
verts.append([float(v) for v in line.split()[1:4]])
|
| 95 |
+
elif line.startswith("f "):
|
| 96 |
+
idx = [int(t.split("/")[0]) for t in line.split()[1:]]
|
| 97 |
+
faces += [[idx[0], idx[k], idx[k + 1]] for k in range(1, len(idx) - 1)]
|
| 98 |
+
v = np.array(verts)
|
| 99 |
+
triangles += [v[[i - 1 for i in f], :2] for f in faces] # OBJ indices start at 1
|
| 100 |
+
return triangles
|
| 101 |
+
|
| 102 |
+
with scene.open_geometry() as geometry:
|
| 103 |
+
print("entry point:", json.loads(geometry.read("scene.json"))["entrypoint"])
|
| 104 |
+
meshes = [n for n in geometry.namelist() if n.endswith(".obj") and "ground" not in n]
|
| 105 |
+
triangles = top_view(geometry.read, meshes)
|
| 106 |
+
print(len(meshes), "building meshes")
|
| 107 |
+
```
|
| 108 |
+
|
| 109 |
+
```python
|
| 110 |
+
fig, ax = plt.subplots(figsize=(6, 6))
|
| 111 |
+
ax.add_collection(PolyCollection(triangles, facecolor="#c3cbc2", edgecolor="none"))
|
| 112 |
+
ax.scatter(ue_positions[:, 0], ue_positions[:, 1], s=0.2, color="#4d9688", label=f"{len(ue_positions):,} UEs")
|
| 113 |
+
ax.scatter(bs_positions[:, 0], bs_positions[:, 1], marker="^", s=30, color="k", label=f"{len(bs_positions)} BSs")
|
| 114 |
+
ax.plot(*zip(bs_xyz[:2], ue_xyz[:2]), color="#e2733d", lw=2, label=f"BS {BS_ID} → UE {UE_ID}")
|
| 115 |
+
ax.set(xlim=(-250, 250), ylim=(-250, 250), aspect="equal", xlabel="x (m)", ylabel="y (m)", title=SCENE_ID)
|
| 116 |
+
ax.legend(loc="upper right")
|
| 117 |
+
plt.show()
|
| 118 |
+
```
|
| 119 |
+
|
| 120 |
+
## 5. One channel record
|
| 121 |
+
|
| 122 |
+
A record holds every retained link from one BS at one carrier. `get_link(UE_ID)` returns
|
| 123 |
+
that UE's link, or `None` when the UE has no retained link to this BS (which is not a
|
| 124 |
+
zero-valued channel). A UE ID is a row of the positions; the link's row inside the record
|
| 125 |
+
is a different index.
|
| 126 |
+
|
| 127 |
+
```python
|
| 128 |
+
record = scene.frequencies[CARRIER_HZ].base_stations[BS_ID].read(detail=True)
|
| 129 |
+
print(record)
|
| 130 |
+
link = record.get_link(UE_ID)
|
| 131 |
+
print(link, f"- row {link.index} of the record's {record.n_links} links")
|
| 132 |
+
```
|
| 133 |
+
|
| 134 |
+
## 6. What each path stores
|
| 135 |
+
|
| 136 |
+
For every retained path the core record stores the complex coefficient `a_real + 1j*a_imag`
|
| 137 |
+
(passband, without the carrier-delay phase, antennas included), the delay `tau` in seconds,
|
| 138 |
+
departure and arrival angles in radians, and its interaction count and type flags; the detail
|
| 139 |
+
record adds each interaction's type and location in order. Paths are stored strongest first,
|
| 140 |
+
and each link keeps at most its 16 strongest paths above −150 dB.
|
| 141 |
+
|
| 142 |
+
```python
|
| 143 |
+
NAMES = {1: "specular reflection", 2: "diffuse reflection", 4: "refraction", 8: "diffraction"}
|
| 144 |
+
|
| 145 |
+
def describe(core, detail):
|
| 146 |
+
"""One line per retained path, strongest first."""
|
| 147 |
+
re, im = core["a_real"].astype(np.float64), core["a_imag"].astype(np.float64)
|
| 148 |
+
power_db = 10 * np.log10(re**2 + im**2)
|
| 149 |
+
off = detail["path_interaction_offsets"]
|
| 150 |
+
for p in range(len(core["tau"])):
|
| 151 |
+
kinds = [NAMES.get(int(t), str(t)) for t in detail["interaction_type"][off[p]:off[p + 1]]]
|
| 152 |
+
print(f"rank {int(core['path_rank'][p]):2d} {core['tau'][p] * 1e9:8.2f} ns {power_db[p]:7.2f} dB "
|
| 153 |
+
f"AoD az {np.degrees(core['phi_t'][p]):6.1f}° AoA az {np.degrees(core['phi_r'][p]):6.1f}° "
|
| 154 |
+
f"{' → '.join(kinds) or 'line of sight'}")
|
| 155 |
+
|
| 156 |
+
describe(link.core, link.detail)
|
| 157 |
+
```
|
| 158 |
+
|
| 159 |
+
## 7. A power–delay profile
|
| 160 |
+
|
| 161 |
+
Placing each path by delay and power gives the link's power–delay profile: a path-based view
|
| 162 |
+
of the stored channel. It is not a sampled impulse response; for a channel at a given
|
| 163 |
+
bandwidth, `channels4world.transforms` provides baseband coefficients and frequency
|
| 164 |
+
responses.
|
| 165 |
+
|
| 166 |
+
```python
|
| 167 |
+
def stems(ax, tau, a_real, a_imag, label, marker, color):
|
| 168 |
+
power_db = 10 * np.log10(a_real.astype(np.float64)**2 + a_imag.astype(np.float64)**2)
|
| 169 |
+
ax.vlines(tau * 1e9, -150, power_db, color=color, lw=1.2)
|
| 170 |
+
ax.scatter(tau * 1e9, power_db, marker=marker, color=color, zorder=3, label=label)
|
| 171 |
+
|
| 172 |
+
fig, ax = plt.subplots(figsize=(7, 3))
|
| 173 |
+
stems(ax, link.core["tau"], link.core["a_real"], link.core["a_imag"], "3.5 GHz", "o", "#e2733d")
|
| 174 |
+
ax.set(xlabel="delay (ns)", ylabel="path power (dB)", ylim=(-150, None),
|
| 175 |
+
title=f"{SCENE_ID} · BS {BS_ID} → UE {UE_ID}")
|
| 176 |
+
ax.legend()
|
| 177 |
+
plt.show()
|
| 178 |
+
```
|
| 179 |
+
|
| 180 |
+
## 8. The same link at 7 GHz
|
| 181 |
+
|
| 182 |
+
Every scene is simulated at both carriers with the same BS and UE positions. Read the same
|
| 183 |
+
BS and UE at 7 GHz and compare on shared axes:
|
| 184 |
+
|
| 185 |
+
```python
|
| 186 |
+
link7 = scene.frequencies[OTHER_HZ].base_stations[BS_ID].read(detail=True).get_link(UE_ID)
|
| 187 |
+
fig, ax = plt.subplots(figsize=(7, 3))
|
| 188 |
+
stems(ax, link.core["tau"], link.core["a_real"], link.core["a_imag"], "3.5 GHz", "o", "#e2733d")
|
| 189 |
+
if link7 is None:
|
| 190 |
+
print("UE", UE_ID, "has no retained link at 7 GHz")
|
| 191 |
+
else:
|
| 192 |
+
stems(ax, link7.core["tau"], link7.core["a_real"], link7.core["a_imag"], "7 GHz", "s", "#4d9688")
|
| 193 |
+
for l, label in ((link, "3.5 GHz"), (link7, "7 GHz")):
|
| 194 |
+
a = l.core["a_real"].astype(np.float64) + 1j * l.core["a_imag"].astype(np.float64)
|
| 195 |
+
print(f"{label}: {l.n_paths} paths, link power {10 * np.log10(np.sum(np.abs(a) ** 2)):.2f} dB")
|
| 196 |
+
ax.set(xlabel="delay (ns)", ylabel="path power (dB)", ylim=(-150, None))
|
| 197 |
+
ax.legend()
|
| 198 |
+
plt.show()
|
| 199 |
+
```
|
| 200 |
+
|
| 201 |
+
Ranks order the paths within one record: rank 0 at 7 GHz need not be the route of rank 0
|
| 202 |
+
at 3.5 GHz. To match routes across carriers, compare delays, interaction sequences or
|
| 203 |
+
interaction points (`link7.detail`), not ranks.
|
| 204 |
+
|
| 205 |
+
## Next
|
| 206 |
+
|
| 207 |
+
- [From channel records to a DataLoader](ml-guide.md): link samples, splits, padding and batches.
|
| 208 |
+
- [Library guide](library-guide.md): download plans for larger tiers, recipes, extraction and caches.
|
| 209 |
+
- [Schema reference](schema-reference.md): every array and its meaning.
|
| 210 |
+
|
| 211 |
+
*Notebook: [01-read-one-scene-library.ipynb](notebooks/01-read-one-scene-library.ipynb). The page and the notebook hold the same code.*
|
| 212 |
+
|
| 213 |
+
[Return to card](../README.md)
|
docs/tutorial-numpy.md
ADDED
|
@@ -0,0 +1,210 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Read one scene without the library
|
| 2 |
+
|
| 3 |
+
The same link as the [library tutorial](tutorial-library.md), **BS 0 → UE 14 of
|
| 4 |
+
`urban_scene_019234` at 3.5 GHz**, read with NumPy and the standard library from Tiny's loose
|
| 5 |
+
files: about 15 MB. The [notebook version](notebooks/02-read-one-scene-numpy.ipynb) runs top
|
| 6 |
+
to bottom. Archives from larger tiers hold the same files; see
|
| 7 |
+
[without the library](without-library.md) for TAR access.
|
| 8 |
+
|
| 9 |
+
Install with `pip install numpy huggingface_hub matplotlib`.
|
| 10 |
+
|
| 11 |
+
```python
|
| 12 |
+
from pathlib import Path
|
| 13 |
+
import json
|
| 14 |
+
import zipfile
|
| 15 |
+
|
| 16 |
+
import matplotlib.pyplot as plt
|
| 17 |
+
import numpy as np
|
| 18 |
+
from huggingface_hub import snapshot_download
|
| 19 |
+
from matplotlib.collections import PolyCollection
|
| 20 |
+
```
|
| 21 |
+
|
| 22 |
+
## 1. Choose the link
|
| 23 |
+
|
| 24 |
+
The same identifiers as the library tutorial. A UE ID is a row of `ue_positions`, and the BS
|
| 25 |
+
ID is both a row of `bs_positions` and the number in the record's file name.
|
| 26 |
+
|
| 27 |
+
```python
|
| 28 |
+
REPO, REVISION = "Intelligence-Networking-Lab/Channels4World", "v1.0.0"
|
| 29 |
+
SCENE_ID, GROUP = "urban_scene_019234", "test-urban-g00000" # GROUP: from the tiny_scenes catalog
|
| 30 |
+
CARRIER_HZ, BS_ID, UE_ID = 3_500_000_000, 0, 14
|
| 31 |
+
OTHER_HZ = 7_000_000_000
|
| 32 |
+
DATA = Path("c4w")
|
| 33 |
+
```
|
| 34 |
+
|
| 35 |
+
## 2. Download the scene's files
|
| 36 |
+
|
| 37 |
+
NumPy needs only the record files: positions, geometry, and BS 0's core and detail at both
|
| 38 |
+
carriers.
|
| 39 |
+
|
| 40 |
+
```python
|
| 41 |
+
scene_dir = DATA / "tiny" / "records" / f"scene={SCENE_ID}"
|
| 42 |
+
remote = f"tiny/records/scene={SCENE_ID}"
|
| 43 |
+
snapshot_download(REPO, repo_type="dataset", revision=REVISION, local_dir=DATA, allow_patterns=[
|
| 44 |
+
f"{remote}/positions.npz", f"{remote}/geometry.zip", f"{remote}/band_hz=*/component=*/bs{BS_ID:05d}.npz"])
|
| 45 |
+
|
| 46 |
+
def record_path(carrier_hz, component):
|
| 47 |
+
return scene_dir / f"band_hz={carrier_hz}" / f"component={component}" / f"bs{BS_ID:05d}.npz"
|
| 48 |
+
|
| 49 |
+
print(sorted(p.relative_to(scene_dir).as_posix() for p in scene_dir.rglob("*") if p.is_file()))
|
| 50 |
+
```
|
| 51 |
+
|
| 52 |
+
## 3. The hierarchy on disk
|
| 53 |
+
|
| 54 |
+
Each scene folder holds `positions.npz` and `geometry.zip`, shared by both carriers, and one
|
| 55 |
+
file per carrier, component and BS: `band_hz=<Hz>/component=<core|detail>/bs<NNNNN>.npz`.
|
| 56 |
+
Every NPZ carries its identity in a JSON `__meta__` entry:
|
| 57 |
+
|
| 58 |
+
```python
|
| 59 |
+
with np.load(record_path(CARRIER_HZ, "core"), allow_pickle=False) as npz:
|
| 60 |
+
meta = json.loads(npz["__meta__"].item())
|
| 61 |
+
print(json.dumps(meta["identity"], indent=1))
|
| 62 |
+
print(meta["dimensions"]) # retained links and paths in this record
|
| 63 |
+
```
|
| 64 |
+
|
| 65 |
+
## 4. Geometry and positions
|
| 66 |
+
|
| 67 |
+
Geometry, positions and interaction points share one frame: scene metres, z up.
|
| 68 |
+
|
| 69 |
+
```python
|
| 70 |
+
with np.load(scene_dir / "positions.npz", allow_pickle=False) as positions:
|
| 71 |
+
bs_positions, ue_positions = positions["bs_positions"], positions["ue_positions"]
|
| 72 |
+
bs_xyz, ue_xyz = bs_positions[BS_ID], ue_positions[UE_ID]
|
| 73 |
+
print(bs_positions.shape, ue_positions.shape)
|
| 74 |
+
print("BS", bs_xyz, "UE", ue_xyz, f"distance {np.linalg.norm(ue_xyz - bs_xyz):.1f} m")
|
| 75 |
+
|
| 76 |
+
def top_view(read, names):
|
| 77 |
+
"""Building triangles projected onto the ground (x, y), from OBJ meshes."""
|
| 78 |
+
triangles = []
|
| 79 |
+
for name in names:
|
| 80 |
+
verts, faces = [], []
|
| 81 |
+
for line in read(name).decode().splitlines():
|
| 82 |
+
if line.startswith("v "):
|
| 83 |
+
verts.append([float(v) for v in line.split()[1:4]])
|
| 84 |
+
elif line.startswith("f "):
|
| 85 |
+
idx = [int(t.split("/")[0]) for t in line.split()[1:]]
|
| 86 |
+
faces += [[idx[0], idx[k], idx[k + 1]] for k in range(1, len(idx) - 1)]
|
| 87 |
+
v = np.array(verts)
|
| 88 |
+
triangles += [v[[i - 1 for i in f], :2] for f in faces] # OBJ indices start at 1
|
| 89 |
+
return triangles
|
| 90 |
+
|
| 91 |
+
with zipfile.ZipFile(scene_dir / "geometry.zip") as geometry:
|
| 92 |
+
print("entry point:", json.loads(geometry.read("scene.json"))["entrypoint"])
|
| 93 |
+
meshes = [n for n in geometry.namelist() if n.endswith(".obj") and "ground" not in n]
|
| 94 |
+
triangles = top_view(geometry.read, meshes)
|
| 95 |
+
print(len(meshes), "building meshes")
|
| 96 |
+
```
|
| 97 |
+
|
| 98 |
+
```python
|
| 99 |
+
fig, ax = plt.subplots(figsize=(6, 6))
|
| 100 |
+
ax.add_collection(PolyCollection(triangles, facecolor="#c3cbc2", edgecolor="none"))
|
| 101 |
+
ax.scatter(ue_positions[:, 0], ue_positions[:, 1], s=0.2, color="#4d9688", label=f"{len(ue_positions):,} UEs")
|
| 102 |
+
ax.scatter(bs_positions[:, 0], bs_positions[:, 1], marker="^", s=30, color="k", label=f"{len(bs_positions)} BSs")
|
| 103 |
+
ax.plot(*zip(bs_xyz[:2], ue_xyz[:2]), color="#e2733d", lw=2, label=f"BS {BS_ID} → UE {UE_ID}")
|
| 104 |
+
ax.set(xlim=(-250, 250), ylim=(-250, 250), aspect="equal", xlabel="x (m)", ylabel="y (m)", title=SCENE_ID)
|
| 105 |
+
ax.legend(loc="upper right")
|
| 106 |
+
plt.show()
|
| 107 |
+
```
|
| 108 |
+
|
| 109 |
+
## 5. Find the link
|
| 110 |
+
|
| 111 |
+
`link_ue_index` lists the UEs this BS reaches, in ascending order; the link's row is where
|
| 112 |
+
`UE_ID` sits in that list. Link `row` owns paths `link_path_offsets[row]` to
|
| 113 |
+
`link_path_offsets[row + 1]`. A UE that is not listed has no retained link to this BS (not a
|
| 114 |
+
zero-valued channel).
|
| 115 |
+
|
| 116 |
+
```python
|
| 117 |
+
def load(carrier_hz, component):
|
| 118 |
+
with np.load(record_path(carrier_hz, component), allow_pickle=False) as npz:
|
| 119 |
+
return {name: npz[name] for name in npz.files if name != "__meta__"}
|
| 120 |
+
|
| 121 |
+
def link_of(core, detail, ue_id):
|
| 122 |
+
ue_ids = core["link_ue_index"]
|
| 123 |
+
row = int(np.searchsorted(ue_ids, ue_id))
|
| 124 |
+
if row == ue_ids.size or ue_ids[row] != ue_id:
|
| 125 |
+
return None # no retained link to this UE
|
| 126 |
+
p0, p1 = map(int, core["link_path_offsets"][row:row + 2])
|
| 127 |
+
link_core = {k: v[p0:p1] for k, v in core.items() if k not in ("link_ue_index", "link_path_offsets")}
|
| 128 |
+
i0, i1 = map(int, detail["path_interaction_offsets"][[p0, p1]])
|
| 129 |
+
link_detail = {k: detail[k][i0:i1] for k in ("interaction_rank", "interaction_type", "interaction_vertex")}
|
| 130 |
+
link_detail["path_interaction_offsets"] = detail["path_interaction_offsets"][p0:p1 + 1] - i0
|
| 131 |
+
return row, link_core, link_detail
|
| 132 |
+
|
| 133 |
+
core, detail = load(CARRIER_HZ, "core"), load(CARRIER_HZ, "detail")
|
| 134 |
+
row, link_core, link_detail = link_of(core, detail, UE_ID)
|
| 135 |
+
print(f"UE {UE_ID}: link row {row} of {core['link_ue_index'].size}, {link_core['tau'].size} paths")
|
| 136 |
+
```
|
| 137 |
+
|
| 138 |
+
## 6. What each path stores
|
| 139 |
+
|
| 140 |
+
The same arrays as in the library tutorial: the complex coefficient `a_real + 1j*a_imag`
|
| 141 |
+
(passband, without the carrier-delay phase, antennas included), the delay `tau` in seconds,
|
| 142 |
+
departure and arrival angles in radians and, in detail, each interaction's type and location
|
| 143 |
+
in order. Paths are stored strongest first, at most 16 per link above −150 dB.
|
| 144 |
+
|
| 145 |
+
```python
|
| 146 |
+
NAMES = {1: "specular reflection", 2: "diffuse reflection", 4: "refraction", 8: "diffraction"}
|
| 147 |
+
|
| 148 |
+
def describe(core, detail):
|
| 149 |
+
"""One line per retained path, strongest first."""
|
| 150 |
+
re, im = core["a_real"].astype(np.float64), core["a_imag"].astype(np.float64)
|
| 151 |
+
power_db = 10 * np.log10(re**2 + im**2)
|
| 152 |
+
off = detail["path_interaction_offsets"]
|
| 153 |
+
for p in range(len(core["tau"])):
|
| 154 |
+
kinds = [NAMES.get(int(t), str(t)) for t in detail["interaction_type"][off[p]:off[p + 1]]]
|
| 155 |
+
print(f"rank {int(core['path_rank'][p]):2d} {core['tau'][p] * 1e9:8.2f} ns {power_db[p]:7.2f} dB "
|
| 156 |
+
f"AoD az {np.degrees(core['phi_t'][p]):6.1f}° AoA az {np.degrees(core['phi_r'][p]):6.1f}° "
|
| 157 |
+
f"{' → '.join(kinds) or 'line of sight'}")
|
| 158 |
+
|
| 159 |
+
describe(link_core, link_detail)
|
| 160 |
+
```
|
| 161 |
+
|
| 162 |
+
## 7. A power–delay profile
|
| 163 |
+
|
| 164 |
+
Placing each path by delay and power gives the link's power–delay profile: a path-based view
|
| 165 |
+
of the stored channel, not a sampled impulse response.
|
| 166 |
+
|
| 167 |
+
```python
|
| 168 |
+
def stems(ax, tau, a_real, a_imag, label, marker, color):
|
| 169 |
+
power_db = 10 * np.log10(a_real.astype(np.float64)**2 + a_imag.astype(np.float64)**2)
|
| 170 |
+
ax.vlines(tau * 1e9, -150, power_db, color=color, lw=1.2)
|
| 171 |
+
ax.scatter(tau * 1e9, power_db, marker=marker, color=color, zorder=3, label=label)
|
| 172 |
+
|
| 173 |
+
fig, ax = plt.subplots(figsize=(7, 3))
|
| 174 |
+
stems(ax, link_core["tau"], link_core["a_real"], link_core["a_imag"], "3.5 GHz", "o", "#e2733d")
|
| 175 |
+
ax.set(xlabel="delay (ns)", ylabel="path power (dB)", ylim=(-150, None),
|
| 176 |
+
title=f"{SCENE_ID} · BS {BS_ID} → UE {UE_ID}")
|
| 177 |
+
ax.legend()
|
| 178 |
+
plt.show()
|
| 179 |
+
```
|
| 180 |
+
|
| 181 |
+
## 8. The same link at 7 GHz
|
| 182 |
+
|
| 183 |
+
```python
|
| 184 |
+
other = link_of(load(OTHER_HZ, "core"), load(OTHER_HZ, "detail"), UE_ID)
|
| 185 |
+
fig, ax = plt.subplots(figsize=(7, 3))
|
| 186 |
+
stems(ax, link_core["tau"], link_core["a_real"], link_core["a_imag"], "3.5 GHz", "o", "#e2733d")
|
| 187 |
+
if other is None:
|
| 188 |
+
print("UE", UE_ID, "has no retained link at 7 GHz")
|
| 189 |
+
else:
|
| 190 |
+
_, core7, _ = other
|
| 191 |
+
stems(ax, core7["tau"], core7["a_real"], core7["a_imag"], "7 GHz", "s", "#4d9688")
|
| 192 |
+
for c, label in ((link_core, "3.5 GHz"), (core7, "7 GHz")):
|
| 193 |
+
power = np.sum(c["a_real"].astype(np.float64) ** 2 + c["a_imag"].astype(np.float64) ** 2)
|
| 194 |
+
print(f"{label}: {c['tau'].size} paths, link power {10 * np.log10(power):.2f} dB")
|
| 195 |
+
ax.set(xlabel="delay (ns)", ylabel="path power (dB)", ylim=(-150, None))
|
| 196 |
+
ax.legend()
|
| 197 |
+
plt.show()
|
| 198 |
+
```
|
| 199 |
+
|
| 200 |
+
Ranks order the paths within one record, so the same rank at 3.5 and 7 GHz need not be
|
| 201 |
+
the same route. Compare delays, interaction sequences or interaction points instead.
|
| 202 |
+
|
| 203 |
+
## Next
|
| 204 |
+
|
| 205 |
+
- [Without the library](without-library.md): TAR archives, catalogs and byte-range reads.
|
| 206 |
+
- [Schema reference](schema-reference.md): every array, its dtype and its meaning.
|
| 207 |
+
|
| 208 |
+
*Notebook: [02-read-one-scene-numpy.ipynb](notebooks/02-read-one-scene-numpy.ipynb). The page and the notebook hold the same code.*
|
| 209 |
+
|
| 210 |
+
[Return to card](../README.md)
|
docs/without-library.md
ADDED
|
@@ -0,0 +1,291 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Using Channels4World without the library
|
| 2 |
+
|
| 3 |
+
Channel arrays and positions are ordinary NPZ files (`numpy.load`); geometry is an
|
| 4 |
+
ordinary ZIP (`zipfile.ZipFile`). Start with the one-scene Tiny download on the
|
| 5 |
+
[card](../README.md); plain NumPy needs only its record files, the last three patterns. The
|
| 6 |
+
extra Tiny root, schemas and group metadata are needed for channels4world library
|
| 7 |
+
navigation and verification.
|
| 8 |
+
|
| 9 |
+
Commands use the release tag `v1.0.0`. The examples use the same scene, carrier and BS as
|
| 10 |
+
the card.
|
| 11 |
+
|
| 12 |
+
## Archive conventions
|
| 13 |
+
|
| 14 |
+
You can treat a download as a collection of archives; folder names are only needed for
|
| 15 |
+
choosing what to download. Everything else is in two naming patterns:
|
| 16 |
+
|
| 17 |
+
| Item | Pattern | Example |
|
| 18 |
+
|---|---|---|
|
| 19 |
+
| Group | `<split>-<profile code>-g<NNNNN>`, exactly 25 scenes of one split and profile | `test-urban-g00000` |
|
| 20 |
+
| Channel archive | `<group>-<band>-<core\|detail>.tar` | `test-urban-g00000-3.5ghz-core.tar` |
|
| 21 |
+
| Scene-asset archive | `<group>-<positions\|geometry>.tar` | `test-urban-g00000-positions.tar` |
|
| 22 |
+
| File inside an archive | `records/scene=<id>/band_hz=<Hz>/component=<core\|detail>/bs<NNNNN>.npz` | `records/scene=urban_scene_019234/band_hz=3500000000/component=core/bs00000.npz` |
|
| 23 |
+
| Scene asset inside an archive | `records/scene=<id>/positions.npz`, `records/scene=<id>/geometry.zip` | |
|
| 24 |
+
|
| 25 |
+
The profile code is `urban`, `metro` or `suburban`; the catalogs spell `metro` as
|
| 26 |
+
`metropolitan`. Archive file names are unique, so `{p.name: p for p in Path(release_dir).rglob("*.tar")}`
|
| 27 |
+
finds everything regardless of folders. To use a channel record, open the **positions
|
| 28 |
+
archive of the same group** (`<group>-positions.tar`) and take the same scene's
|
| 29 |
+
`positions.npz`. Inside a record, `link_ue_index` holds UE IDs (rows of `ue_positions`),
|
| 30 |
+
and link `i` owns paths `link_path_offsets[i]:link_path_offsets[i+1]`.
|
| 31 |
+
|
| 32 |
+
## A standalone reader
|
| 33 |
+
|
| 34 |
+
[`read_archives.py`](read_archives.py) (about 100 lines, NumPy only) does
|
| 35 |
+
exactly this for one release folder:
|
| 36 |
+
|
| 37 |
+
```bash
|
| 38 |
+
python read_archives.py c4w --band 3.5ghz --limit 5
|
| 39 |
+
python read_archives.py c4w --scenes urban_scene_019234 # filter records afterwards
|
| 40 |
+
```
|
| 41 |
+
|
| 42 |
+
It stops reading once it has printed `--limit` records (`--limit 0` reads every record).
|
| 43 |
+
It searches only `c4w/payload/`, stops if the same archive file name appears twice (for
|
| 44 |
+
example, two downloads mixed in one folder), and lists any group whose positions archive
|
| 45 |
+
is missing instead of failing halfway through. Copy and adapt it freely.
|
| 46 |
+
|
| 47 |
+
## Read one Tiny scene
|
| 48 |
+
|
| 49 |
+
Use exactly the same `TINY_ROOT`, `SCENE_ID`, `CARRIER_HZ`, `BS_ID` and `UE_ID` as the
|
| 50 |
+
card's NumPy example. Do not independently choose the first catalog row and the first
|
| 51 |
+
lexically sorted directory: those orders can differ.
|
| 52 |
+
|
| 53 |
+
```python
|
| 54 |
+
from pathlib import Path
|
| 55 |
+
import numpy as np
|
| 56 |
+
|
| 57 |
+
TINY_ROOT = Path("c4w/tiny")
|
| 58 |
+
SCENE_ID, CARRIER_HZ, BS_ID, UE_ID = "urban_scene_019234", 3_500_000_000, 0, 14
|
| 59 |
+
scene_dir = TINY_ROOT / "records" / f"scene={SCENE_ID}"
|
| 60 |
+
core_path = (scene_dir / f"band_hz={CARRIER_HZ}" / "component=core"
|
| 61 |
+
/ f"bs{BS_ID:05d}.npz")
|
| 62 |
+
|
| 63 |
+
with np.load(core_path, allow_pickle=False) as core, np.load(
|
| 64 |
+
scene_dir / "positions.npz", allow_pickle=False
|
| 65 |
+
) as positions:
|
| 66 |
+
ue_ids = core["link_ue_index"]
|
| 67 |
+
link_row = int(np.searchsorted(ue_ids, UE_ID))
|
| 68 |
+
assert link_row < ue_ids.size and ue_ids[link_row] == UE_ID, "No retained link to this UE."
|
| 69 |
+
start, stop = map(int, core["link_path_offsets"][link_row:link_row + 2])
|
| 70 |
+
gain = core["a_real"][start:stop] + 1j * core["a_imag"][start:stop]
|
| 71 |
+
print(core["tau"][start:stop], gain)
|
| 72 |
+
print(np.linalg.norm(
|
| 73 |
+
positions["ue_positions"][UE_ID] - positions["bs_positions"][BS_ID]
|
| 74 |
+
))
|
| 75 |
+
```
|
| 76 |
+
|
| 77 |
+
`UE_ID` indexes a position row; `link_row` indexes the retained-link table. Preserve
|
| 78 |
+
that association when filtering. An unlisted UE in this **loaded** record has no
|
| 79 |
+
retained link to this BS. This says nothing about payloads not downloaded or
|
| 80 |
+
components not published.
|
| 81 |
+
|
| 82 |
+
For geometry, use ZIP tools, not NumPy:
|
| 83 |
+
|
| 84 |
+
```python
|
| 85 |
+
import json
|
| 86 |
+
import zipfile
|
| 87 |
+
|
| 88 |
+
with zipfile.ZipFile(scene_dir / "geometry.zip") as archive:
|
| 89 |
+
descriptor = json.loads(archive.read("scene.json"))
|
| 90 |
+
print(descriptor["entrypoint"], archive.namelist())
|
| 91 |
+
```
|
| 92 |
+
|
| 93 |
+
The entrypoint is a Mitsuba XML referencing OBJ meshes. Keep relative paths together
|
| 94 |
+
if later extracting the geometry for a renderer. This example only inspects it.
|
| 95 |
+
|
| 96 |
+
## Download a tier's archives
|
| 97 |
+
|
| 98 |
+
Increment folders are numbered in tier order, so a tier is one pattern per component:
|
| 99 |
+
Small is `inc1-*`, Medium `inc[1-2]-*`, Large `inc[1-3]-*`, Full `inc*`. A split or
|
| 100 |
+
profile narrows it by file name. For example, Medium test-split core at 3.5 GHz with
|
| 101 |
+
positions:
|
| 102 |
+
|
| 103 |
+
```bash
|
| 104 |
+
hf download Intelligence-Networking-Lab/Channels4World --repo-type dataset \
|
| 105 |
+
--revision v1.0.0 --local-dir c4w \
|
| 106 |
+
--include 'payload/3.5ghz/core/inc[1-2]-*/test-*' \
|
| 107 |
+
--include 'payload/scene/positions/inc[1-2]-*/test-*'
|
| 108 |
+
```
|
| 109 |
+
|
| 110 |
+
In these patterns `*` also matches `/`. Detail uses `payload/<3.5ghz|7ghz>/detail/...` and
|
| 111 |
+
is hosted for Small and Medium only, so the Large and Full patterns return Medium's detail.
|
| 112 |
+
Positions and geometry archives are carrier-independent. The release root sits at the top
|
| 113 |
+
of the repository, so these paths are also the local paths under `c4w/`.
|
| 114 |
+
|
| 115 |
+
## Select with 🤗 Datasets
|
| 116 |
+
|
| 117 |
+
The catalogs load as ordinary tables, so standard tools can choose what to download:
|
| 118 |
+
|
| 119 |
+
```python
|
| 120 |
+
from datasets import load_dataset
|
| 121 |
+
from huggingface_hub import snapshot_download
|
| 122 |
+
|
| 123 |
+
REPO, REV = "Intelligence-Networking-Lab/Channels4World", "v1.0.0"
|
| 124 |
+
scenes = load_dataset(REPO, "scenes", split="catalog", revision=REV)
|
| 125 |
+
files = load_dataset(REPO, "files", split="catalog", revision=REV)
|
| 126 |
+
groups = set(scenes.filter(lambda r: r["split"] == "test")["group"])
|
| 127 |
+
paths = [r["path"] for r in files
|
| 128 |
+
if r["group"] in groups and r["kind"] == "payload" and r["component"] in ("positions", "core")
|
| 129 |
+
and r["frequency_hz"] in (None, 3_500_000_000)]
|
| 130 |
+
assert paths, "No matching published payloads."
|
| 131 |
+
snapshot_download(REPO, repo_type="dataset", revision=REV, local_dir="c4w", allow_patterns=paths)
|
| 132 |
+
```
|
| 133 |
+
|
| 134 |
+
Use the catalog's actual `profile` values if narrowing further. The archives themselves
|
| 135 |
+
also load with `load_dataset("webdataset", ...)`; the [HF guide](hf-datasets.md) pairs
|
| 136 |
+
remote and local inputs and explains their decoded representation.
|
| 137 |
+
|
| 138 |
+
## Arbitrary scenes: download the containing archives, then filter
|
| 139 |
+
|
| 140 |
+
Archives hold whole groups, so a list of scenes means two steps: download the archives
|
| 141 |
+
that **contain** those scenes (from the catalogs), then **filter records** to those scenes
|
| 142 |
+
when reading. The catalogs are two small Parquet files at the release root:
|
| 143 |
+
|
| 144 |
+
```python
|
| 145 |
+
import pyarrow.parquet as pq
|
| 146 |
+
from huggingface_hub import hf_hub_download, snapshot_download
|
| 147 |
+
|
| 148 |
+
REPO, REV = "Intelligence-Networking-Lab/Channels4World", "v1.0.0"
|
| 149 |
+
for table in ("c4w-root/scenes.parquet", "c4w-root/files.parquet"):
|
| 150 |
+
hf_hub_download(REPO, table, repo_type="dataset", revision=REV, local_dir="c4w")
|
| 151 |
+
|
| 152 |
+
wanted_scenes = {"urban_scene_019234"} # your scene list
|
| 153 |
+
scenes = pq.read_table("c4w/c4w-root/scenes.parquet").to_pylist()
|
| 154 |
+
files = pq.read_table("c4w/c4w-root/files.parquet").to_pylist()
|
| 155 |
+
groups = {s["group"] for s in scenes if s["scene_id"] in wanted_scenes}
|
| 156 |
+
archives = [f["path"] for f in files
|
| 157 |
+
if f["kind"] == "payload" and f["group"] in groups
|
| 158 |
+
and (f["component"], f["frequency_hz"]) in {("core", 3_500_000_000), ("positions", None)}]
|
| 159 |
+
snapshot_download(REPO, repo_type="dataset", revision=REV, local_dir="c4w", allow_patterns=archives)
|
| 160 |
+
```
|
| 161 |
+
|
| 162 |
+
Then read only those scenes: `python read_archives.py c4w --scenes urban_scene_019234`.
|
| 163 |
+
The download includes the other scenes of the same groups; filtering skips them without
|
| 164 |
+
reading their bytes. This works for any folder layout, because the catalog lists each
|
| 165 |
+
archive's actual path.
|
| 166 |
+
|
| 167 |
+
## Find the byte location of one record
|
| 168 |
+
|
| 169 |
+
With PyArrow available, the scene table identifies the group for an explicit scene;
|
| 170 |
+
the members table maps a member path to its archive and byte location:
|
| 171 |
+
|
| 172 |
+
```python
|
| 173 |
+
from pathlib import Path
|
| 174 |
+
import pyarrow.parquet as pq
|
| 175 |
+
|
| 176 |
+
RELEASE_ROOT = Path("c4w") # the release root is the repository top level
|
| 177 |
+
scenes = pq.read_table(RELEASE_ROOT / "c4w-root/scenes.parquet").to_pylist()
|
| 178 |
+
scene_row = next(row for row in scenes if row["scene_id"] == SCENE_ID)
|
| 179 |
+
GROUP_ID = scene_row["group"]
|
| 180 |
+
# Download this group's members.parquet (and other needed metadata) first.
|
| 181 |
+
members = pq.read_table(
|
| 182 |
+
RELEASE_ROOT / "groups" / GROUP_ID / "catalog/members.parquet"
|
| 183 |
+
).to_pylist()
|
| 184 |
+
core_member = (f"records/scene={SCENE_ID}/band_hz={CARRIER_HZ}/component=core/"
|
| 185 |
+
f"bs{BS_ID:05d}.npz")
|
| 186 |
+
positions_member = f"records/scene={SCENE_ID}/positions.npz"
|
| 187 |
+
core_row = next(row for row in members if row["member_path"] == core_member)
|
| 188 |
+
pos_row = next(row for row in members if row["member_path"] == positions_member)
|
| 189 |
+
print(core_row["object_path"], pos_row["object_path"])
|
| 190 |
+
```
|
| 191 |
+
|
| 192 |
+
Retrieve the group metadata, schemas and archives at the same revision as the catalogs
|
| 193 |
+
(tag `v1.0.0`). A TAR is the transfer unit and can contain many scenes, so one chosen
|
| 194 |
+
record can require more bytes than that record's own payload size. Root
|
| 195 |
+
`files.parquet` lists archive byte counts/hashes; `members.parquet` lists member
|
| 196 |
+
byte counts/hashes. Scene-only payload size excludes root/schema/group metadata.
|
| 197 |
+
`data_offset` and `member_bytes` locate the member's bytes inside the uncompressed TAR,
|
| 198 |
+
so a byte-range read can fetch one record without the rest of the archive.
|
| 199 |
+
|
| 200 |
+
The published `files.parquet` is the authority for paths, sizes and hashes; reuse it for
|
| 201 |
+
generated commands and size displays rather than keeping a second hand-written list.
|
| 202 |
+
|
| 203 |
+
## Read one TAR member directly
|
| 204 |
+
|
| 205 |
+
After downloading the archives identified above, ordinary Python can read a single
|
| 206 |
+
NPZ member without extracting the whole TAR:
|
| 207 |
+
|
| 208 |
+
```python
|
| 209 |
+
import hashlib
|
| 210 |
+
import io
|
| 211 |
+
import tarfile
|
| 212 |
+
import numpy as np
|
| 213 |
+
|
| 214 |
+
def read_npz_member(archive_path, row):
|
| 215 |
+
with tarfile.open(archive_path, "r:") as archive:
|
| 216 |
+
member = archive.getmember(row["member_path"])
|
| 217 |
+
if not member.isfile():
|
| 218 |
+
raise ValueError("Expected a regular NPZ member.")
|
| 219 |
+
with archive.extractfile(member) as stream:
|
| 220 |
+
body = stream.read()
|
| 221 |
+
if len(body) != row["member_bytes"]:
|
| 222 |
+
raise ValueError("Member byte count mismatch.")
|
| 223 |
+
if hashlib.sha256(body).hexdigest() != row["member_sha256"]:
|
| 224 |
+
raise ValueError("Member hash mismatch.")
|
| 225 |
+
with np.load(io.BytesIO(body), allow_pickle=False) as npz:
|
| 226 |
+
return {name: npz[name] for name in npz.files if name != "__meta__"}
|
| 227 |
+
|
| 228 |
+
core = read_npz_member(RELEASE_ROOT / core_row["object_path"], core_row)
|
| 229 |
+
positions = read_npz_member(RELEASE_ROOT / pos_row["object_path"], pos_row)
|
| 230 |
+
i = int(np.searchsorted(core["link_ue_index"], UE_ID))
|
| 231 |
+
assert i < core["link_ue_index"].size and core["link_ue_index"][i] == UE_ID
|
| 232 |
+
lo, hi = map(int, core["link_path_offsets"][i:i + 2])
|
| 233 |
+
print(core["tau"][lo:hi], core["a_real"][lo:hi] + 1j * core["a_imag"][lo:hi])
|
| 234 |
+
print(np.linalg.norm(positions["ue_positions"][UE_ID] - positions["bs_positions"][BS_ID]))
|
| 235 |
+
```
|
| 236 |
+
|
| 237 |
+
The shared scene/carrier/BS/UE constants and UE-position join match the card. Check the
|
| 238 |
+
NPZ `__meta__` identity and dependencies when assembling data yourself; matching
|
| 239 |
+
array lengths alone do not establish a core/detail association. The [schema](schema-reference.md)
|
| 240 |
+
explains identities, hashes and path-axis alignment.
|
| 241 |
+
|
| 242 |
+
## Or extract TARs to Tiny-like loose payloads
|
| 243 |
+
|
| 244 |
+
**Prerequisite for this extraction example:** Python with `tarfile.data_filter`,
|
| 245 |
+
provided in **3.11.4+**, including **3.12+**. This does not raise the library's
|
| 246 |
+
Python ≥3.11 requirement. It applies only to this standard-library extraction code.
|
| 247 |
+
|
| 248 |
+
```python
|
| 249 |
+
from pathlib import Path
|
| 250 |
+
import tarfile
|
| 251 |
+
|
| 252 |
+
if not hasattr(tarfile, "data_filter"):
|
| 253 |
+
raise RuntimeError("Use Python 3.11.4+ with tarfile.data_filter (including 3.12+).")
|
| 254 |
+
out = Path("unpacked")
|
| 255 |
+
out.mkdir(exist_ok=False) # use a new destination
|
| 256 |
+
archives = {core_row["object_path"], pos_row["object_path"]}
|
| 257 |
+
for object_path in sorted(archives):
|
| 258 |
+
with tarfile.open(RELEASE_ROOT / object_path, "r:") as archive:
|
| 259 |
+
archive.extractall(out, filter="data")
|
| 260 |
+
```
|
| 261 |
+
|
| 262 |
+
A member `records/scene=S/.../bs00000.npz` becomes
|
| 263 |
+
`unpacked/records/scene=S/.../bs00000.npz`: the archive's own folders are not part of the
|
| 264 |
+
member name. The extracted folder has Tiny's layout, so the same inspection works on it:
|
| 265 |
+
|
| 266 |
+
```python
|
| 267 |
+
import numpy as np
|
| 268 |
+
|
| 269 |
+
scene_dir = out / "records" / f"scene={SCENE_ID}"
|
| 270 |
+
core = np.load(scene_dir / f"band_hz={CARRIER_HZ}" / "component=core" / f"bs{BS_ID:05d}.npz")
|
| 271 |
+
positions = np.load(scene_dir / "positions.npz")
|
| 272 |
+
ue_ids = core["link_ue_index"] # retained UE IDs
|
| 273 |
+
row = int(np.searchsorted(ue_ids, UE_ID)) # this UE's link row
|
| 274 |
+
start, stop = core["link_path_offsets"][row:row + 2]
|
| 275 |
+
print(core["tau"][start:stop])
|
| 276 |
+
print(np.linalg.norm(positions["ue_positions"][UE_ID] - positions["bs_positions"][BS_ID]))
|
| 277 |
+
```
|
| 278 |
+
|
| 279 |
+
An archive holds a whole group of scenes, so extraction writes more scenes than the one
|
| 280 |
+
you inspect.
|
| 281 |
+
|
| 282 |
+

|
| 283 |
+
|
| 284 |
+
Ordinary TAR extraction writes payloads only. The library's
|
| 285 |
+
`c4w.extract(selection, dest)` writes those selected member paths and unchanged
|
| 286 |
+
payload bytes, preserves original group metadata/schemas, and creates a subset root
|
| 287 |
+
and scene/file/record tables. Tiny uses that same loose subset representation.
|
| 288 |
+
Simply copying a larger release manifest beside an extracted subset does not build
|
| 289 |
+
a valid subset root.
|
| 290 |
+
|
| 291 |
+
[Return to card](../README.md) · [Schema](schema-reference.md) · [Library guide](library-guide.md)
|
groups/test-metro-g00000/catalog/geometry.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5e6f71ccbd1f1fe3ee90fd63d3265fdb2eab3f24e004f26182c2d6a22b8cc81e
|
| 3 |
+
size 6172
|
groups/test-metro-g00000/catalog/members.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:520dfa2e3efc7592a7ff41866f6c9220c0bc3d9b963bcfac04426e9452cdcb40
|
| 3 |
+
size 271472
|
groups/test-metro-g00000/catalog/objects.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:cd8bd7e8b50882cf8b539ec22e3f2e2ecae90ff7757cf2cb9f30c7e48280110d
|
| 3 |
+
size 1944
|
groups/test-metro-g00000/catalog/records.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:40d182fc0def92170790102c75e7a1b115ad7956a7ad80d104939dbbbfdf0355
|
| 3 |
+
size 1539612
|
groups/test-metro-g00000/catalog/scenes.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4176d808462f5a34fed019827323ac345b4054ff845af628525181910d1f2d99
|
| 3 |
+
size 1594
|
groups/test-metro-g00000/snapshot.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
groups/test-metro-g00001/catalog/geometry.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:27cfba3d5537dcbd7f92686c5e6e76f09b7401b93f6074c01ab487f405b53553
|
| 3 |
+
size 6175
|
groups/test-metro-g00001/catalog/members.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0f48658527a1cadcbaaa78bf456567d7950038e3d985cc3810d3c204e2482118
|
| 3 |
+
size 271392
|
groups/test-metro-g00001/catalog/objects.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:17c8c1ce5b3a40eae69e6e38c5cfc11a3f0d764215383490ad598a429c846407
|
| 3 |
+
size 1948
|
groups/test-metro-g00001/catalog/records.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d71d05adf1d19352e33c9ef8259764ffcc16df67d5f2ae286d67fc872651a200
|
| 3 |
+
size 1540387
|
groups/test-metro-g00001/catalog/scenes.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:fb3d93245ba246eb0ddc2e09bf18c8cc57407e52a746ae6f4d01c8c10e0904ca
|
| 3 |
+
size 1592
|
groups/test-metro-g00001/snapshot.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
groups/test-metro-g00002/catalog/geometry.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:78a1a7eae1df0a949e9b6dc67cb0264dccb2b1aecc013466e72c77b1f361a69f
|
| 3 |
+
size 6186
|
groups/test-metro-g00002/catalog/members.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:1d14363e0dcb247d58e4fb963673d1359013081a27596fb800a2136522e97bcf
|
| 3 |
+
size 270934
|
groups/test-metro-g00002/catalog/objects.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d1eb7041680a13164e48faa85df08fdf7c0a7793a22351b7d05baf1500c8bbe7
|
| 3 |
+
size 1950
|
groups/test-metro-g00002/catalog/records.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2c2db60564945700bb374dbcf4f884c51810903a1c1290638d5caa9e193b8dd8
|
| 3 |
+
size 1536566
|
groups/test-metro-g00002/catalog/scenes.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ed4fca6d32aa5aeffd05e291da76a1b4f39fc2bfa50ff73f2e84b7fe52fe5c17
|
| 3 |
+
size 1596
|
groups/test-metro-g00002/snapshot.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
groups/test-metro-g00003/catalog/geometry.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:72b7a39ace13b4c57ff3117c26bf3e776a7d864c0edaace51bfc06d4244f2e83
|
| 3 |
+
size 6166
|
groups/test-metro-g00003/catalog/members.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:35a38f8c681085daec0f49a57e412c480e92e7a9a644e4c93782a71ab8553954
|
| 3 |
+
size 272499
|
groups/test-metro-g00003/catalog/objects.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:51958ae62a10496477531a6f643483ee03278fb8b12ecb37f1a747e554643339
|
| 3 |
+
size 1951
|
groups/test-metro-g00003/catalog/records.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:99f3a816231ce589784a5cb302964a8421840acfa87931230a3dcb8716a088e5
|
| 3 |
+
size 1534865
|
groups/test-metro-g00003/catalog/scenes.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2b1f565ce0123b55c306381dc6141dba4bebe08acc0cb0d00b9190b256da8747
|
| 3 |
+
size 1592
|
groups/test-metro-g00003/snapshot.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
groups/test-metro-g00004/catalog/geometry.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:bd85b2dbfabf2f9880e9bff08b09454d7830732d6cf5ef6efba8f9e21f998922
|
| 3 |
+
size 6173
|
groups/test-metro-g00004/catalog/members.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:51c8114412c762f121ebd65e1ebb47ff60b50e26aca32f294354c4d6fc44f72e
|
| 3 |
+
size 273518
|
groups/test-metro-g00004/catalog/objects.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:11c7689039a7785bb76bec06bbb25c1c9ffcb1dd93ab2434daa88fa946dbd4c7
|
| 3 |
+
size 1950
|
groups/test-metro-g00004/catalog/records.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b04f0d80d7be2151e831625fb0eecaef5bb386770a8dfa63becc2c093cbb6869
|
| 3 |
+
size 1536373
|
groups/test-metro-g00004/catalog/scenes.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e731868325532e999a6124809f5446e77460978c5b4c935f6bb99fe8f2dbcb51
|
| 3 |
+
size 1591
|
groups/test-metro-g00004/snapshot.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|