data_gen¶
data.data_gen
¶
ORION dataset generator - fetches satellite tiles from SimSat and writes JSONL splits.
For each target in data.ALL_TARGETS, this script:
- Fetches a 512x512 Mapbox satellite tile from SimSat's static image API.
- Assigns the target to a deterministic train/val/test split (seeded shuffle).
- Writes a conversation-format JSONL record suitable for LLaVA-style fine-tuning.
Train records are augmented with coordinate dropout: each target produces two records, one with GPS coordinates in the prompt and one without, so the model learns to classify from imagery alone when telemetry is unavailable.
Usage:
cd ground_segment/data
uv run data_gen.py # requires SimSat running on localhost:9005
Output structure:
orion_dataset/
images/ # 512x512 PNG tiles
train_dataset.jsonl # 2x train targets (coord augmentation)
val_dataset.jsonl # eval-loss tracking during training
test_dataset.jsonl # held-out evaluation set
fetch_image(lon, lat, filename)
¶
Fetch a satellite tile from SimSat's static Mapbox API and save it to disk.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lon
|
Target longitude. |
required | |
lat
|
Target latitude. |
required | |
filename
|
Output file path for the PNG image. |
required |
Returns:
| Type | Description |
|---|---|
|
|
Source code in ground_segment/data/data_gen.py
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 | |
filter_overlaps(targets, min_dist_km=2.0)
¶
Remove targets whose coordinates are within min_dist_km of an already-kept target.
Uses a greedy first-come-first-kept strategy in list order. This prevents near-duplicate tiles from inflating a single geographic area in the dataset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
targets
|
List of target dicts (must contain |
required | |
min_dist_km
|
Minimum separation in km (default 2.0). |
2.0
|
Returns:
| Type | Description |
|---|---|
|
Filtered list of targets with overlaps removed. |
Source code in ground_segment/data/data_gen.py
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | |
get_prompt(lon, lat, include_coords=True)
¶
Build the ChatML user prompt for a single satellite image.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lon
|
Longitude of the capture location. |
required | |
lat
|
Latitude of the capture location. |
required | |
include_coords
|
If |
True
|
Returns:
| Type | Description |
|---|---|
|
The triage instruction prompt as a string. |
Source code in ground_segment/data/data_gen.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | |
haversine(lon1, lat1, lon2, lat2)
¶
Compute the great-circle distance in km between two points using the Haversine formula.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lon1
|
Longitude of the first point in degrees. |
required | |
lat1
|
Latitude of the first point in degrees. |
required | |
lon2
|
Longitude of the second point in degrees. |
required | |
lat2
|
Latitude of the second point in degrees. |
required |
Returns:
| Type | Description |
|---|---|
|
Distance in kilometres. |
Source code in ground_segment/data/data_gen.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | |
main()
¶
Generate the full ORION training dataset.
Shuffles all targets with a fixed seed, splits into train/val/test, fetches each tile from SimSat, and writes the corresponding JSONL records. Train targets are augmented with coordinate dropout (2x records).
Source code in ground_segment/data/data_gen.py
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 | |
make_record(sample, img_path, include_coords=True)
¶
Build a single conversation-format JSONL record for LLaVA-style fine-tuning.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sample
|
Target dict with |
required | |
img_path
|
Path to the saved satellite tile image. |
required | |
include_coords
|
Whether to include GPS coordinates in the prompt. |
True
|
Returns:
| Type | Description |
|---|---|
|
A dict with |
Source code in ground_segment/data/data_gen.py
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | |
setup_dirs()
¶
Create the output directory structure and clear any previous JSONL files.
Source code in ground_segment/data/data_gen.py
160 161 162 163 164 165 | |