File size: 23,115 Bytes
29ca14e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
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
130
131
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
158
159
160
161
162
163
164
165
166
167
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
194
195
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
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
"""
Circuit Data for F1 Prediction System v3.0.

Contains circuit characteristics and performance data for all 24 circuits
in the 2026 season. Used by feature engineering and probability models.
"""

from typing import Dict, List, Optional


# Circuit data for all 24 circuits in 2026 season
CIRCUITS: Dict[str, Dict] = {
    "australia": {
        "id": "australia",
        "name": "Albert Park Grand Prix Circuit",
        "city": "Melbourne",
        "country": "Australia",
        "round_2026": 1,
        "race_date": "2026-03-08",
        "sprint_weekend": False,
        "circuit_type": ["street", "balanced"],
        "lap_count": 58,
        "lap_distance_km": 5.303,
        "total_distance_km": 307.577,
        "safety_car_probability": 0.35,
        "overtaking_difficulty": 6,
        "power_unit_demand": 6.5,
        "brake_demand": 5.0,
        "tire_deg_rate": 0.6,
        "rain_probability_typical": 0.25,
        "drs_zones": 2,
        "elevation_change_m": 20,
        "first_grand_prix": 1996,
    },
    "china": {
        "id": "china",
        "name": "Shanghai International Circuit",
        "city": "Shanghai",
        "country": "China",
        "round_2026": 2,
        "race_date": "2026-03-15",
        "sprint_weekend": True,
        "circuit_type": ["permanent", "technical"],
        "lap_count": 56,
        "lap_distance_km": 5.451,
        "total_distance_km": 305.066,
        "safety_car_probability": 0.28,
        "overtaking_difficulty": 7,
        "power_unit_demand": 7.0,
        "brake_demand": 7.5,
        "tire_deg_rate": 0.55,
        "rain_probability_typical": 0.30,
        "drs_zones": 2,
        "elevation_change_m": 12,
        "first_grand_prix": 2004,
    },
    "japan": {
        "id": "japan",
        "name": "Suzuka Circuit",
        "city": "Suzuka",
        "country": "Japan",
        "round_2026": 3,
        "race_date": "2026-04-06",
        "sprint_weekend": False,
        "circuit_type": ["permanent", "high_speed", "technical"],
        "lap_count": 53,
        "lap_distance_km": 5.807,
        "total_distance_km": 307.471,
        "safety_car_probability": 0.32,
        "overtaking_difficulty": 5,
        "power_unit_demand": 8.0,
        "brake_demand": 8.5,
        "tire_deg_rate": 0.7,
        "rain_probability_typical": 0.35,
        "drs_zones": 2,
        "elevation_change_m": 133,
        "first_grand_prix": 1987,
    },
    "bahrain": {
        "id": "bahrain",
        "name": "Bahrain International Circuit",
        "city": "Sakhir",
        "country": "Bahrain",
        "round_2026": 4,
        "race_date": "2026-04-12",
        "sprint_weekend": False,
        "circuit_type": ["permanent", "balanced"],
        "lap_count": 57,
        "lap_distance_km": 5.412,
        "total_distance_km": 308.238,
        "safety_car_probability": 0.25,
        "overtaking_difficulty": 6,
        "power_unit_demand": 6.0,
        "brake_demand": 6.5,
        "tire_deg_rate": 0.75,
        "rain_probability_typical": 0.05,
        "drs_zones": 2,
        "elevation_change_m": 12,
        "first_grand_prix": 2004,
    },
    "saudi_arabia": {
        "id": "saudi_arabia",
        "name": "Jeddah Corniche Circuit",
        "city": "Jeddah",
        "country": "Saudi Arabia",
        "round_2026": 5,
        "race_date": "2026-04-26",
        "sprint_weekend": True,
        "circuit_type": ["street", "high_speed"],
        "lap_count": 50,
        "lap_distance_km": 6.175,
        "total_distance_km": 308.750,
        "safety_car_probability": 0.40,
        "overtaking_difficulty": 8,
        "power_unit_demand": 8.5,
        "brake_demand": 6.0,
        "tire_deg_rate": 0.8,
        "rain_probability_typical": 0.02,
        "drs_zones": 2,
        "elevation_change_m": 1,
        "first_grand_prix": 2021,
    },
    "miami": {
        "id": "miami",
        "name": "Miami International Autodrome",
        "city": "Miami",
        "country": "USA",
        "round_2026": 6,
        "race_date": "2026-05-03",
        "sprint_weekend": True,
        "circuit_type": ["street", "high_downforce"],
        "lap_count": 57,
        "lap_distance_km": 5.436,
        "total_distance_km": 309.835,
        "safety_car_probability": 0.38,
        "overtaking_difficulty": 7,
        "power_unit_demand": 6.5,
        "brake_demand": 7.0,
        "tire_deg_rate": 0.65,
        "rain_probability_typical": 0.40,
        "drs_zones": 2,
        "elevation_change_m": 6,
        "first_grand_prix": 2022,
    },
    "canada": {
        "id": "canada",
        "name": "Circuit Gilles Villeneuve",
        "city": "Montreal",
        "country": "Canada",
        "round_2026": 7,
        "race_date": "2026-05-24",
        "sprint_weekend": False,
        "circuit_type": ["street", "power_unit"],
        "lap_count": 70,
        "lap_distance_km": 4.361,
        "total_distance_km": 305.270,
        "safety_car_probability": 0.45,
        "overtaking_difficulty": 4,
        "power_unit_demand": 7.5,
        "brake_demand": 8.0,
        "tire_deg_rate": 0.5,
        "rain_probability_typical": 0.30,
        "drs_zones": 2,
        "elevation_change_m": 74,
        "first_grand_prix": 1961,
    },
    "monaco": {
        "id": "monaco",
        "name": "Circuit de Monaco",
        "city": "Monte Carlo",
        "country": "Monaco",
        "round_2026": 8,
        "race_date": "2026-06-07",
        "sprint_weekend": False,
        "circuit_type": ["street", "technical"],
        "lap_count": 78,
        "lap_distance_km": 3.337,
        "total_distance_km": 260.286,
        "safety_car_probability": 0.55,
        "overtaking_difficulty": 9,
        "power_unit_demand": 4.0,
        "brake_demand": 9.5,
        "tire_deg_rate": 0.3,
        "rain_probability_typical": 0.25,
        "drs_zones": 1,
        "elevation_change_m": 41,
        "first_grand_prix": 1929,
    },
    "spain": {
        "id": "spain",
        "name": "Circuit de Barcelona-Catalunya",
        "city": "Montmeló",
        "country": "Spain",
        "round_2026": 9,
        "race_date": "2026-06-14",
        "sprint_weekend": False,
        "circuit_type": ["permanent", "balanced", "technical"],
        "lap_count": 66,
        "lap_distance_km": 4.655,
        "total_distance_km": 307.230,
        "safety_car_probability": 0.22,
        "overtaking_difficulty": 6,
        "power_unit_demand": 6.5,
        "brake_demand": 8.0,
        "tire_deg_rate": 0.7,
        "rain_probability_typical": 0.20,
        "drs_zones": 2,
        "elevation_change_m": 33,
        "first_grand_prix": 1991,
    },
    "austria": {
        "id": "austria",
        "name": "Red Bull Ring",
        "city": "Spielberg",
        "country": "Austria",
        "round_2026": 10,
        "race_date": "2026-06-28",
        "sprint_weekend": True,
        "circuit_type": ["permanent", "high_speed", "power_unit"],
        "lap_count": 71,
        "lap_distance_km": 4.318,
        "total_distance_km": 306.452,
        "safety_car_probability": 0.30,
        "overtaking_difficulty": 5,
        "power_unit_demand": 8.5,
        "brake_demand": 5.0,
        "tire_deg_rate": 0.55,
        "rain_probability_typical": 0.45,
        "drs_zones": 2,
        "elevation_change_m": 65,
        "first_grand_prix": 1970,
    },
    "britain": {
        "id": "britain",
        "name": "Silverstone Circuit",
        "city": "Silverstone",
        "country": "United Kingdom",
        "round_2026": 11,
        "race_date": "2026-07-05",
        "sprint_weekend": True,
        "circuit_type": ["permanent", "high_speed", "power_unit"],
        "lap_count": 52,
        "lap_distance_km": 5.891,
        "total_distance_km": 306.198,
        "safety_car_probability": 0.38,
        "overtaking_difficulty": 5,
        "power_unit_demand": 9.0,
        "brake_demand": 5.5,
        "tire_deg_rate": 0.65,
        "rain_probability_typical": 0.50,
        "drs_zones": 2,
        "elevation_change_m": 43,
        "first_grand_prix": 1950,
    },
    "hungary": {
        "id": "hungary",
        "name": "Hungaroring",
        "city": "Mogyoród",
        "country": "Hungary",
        "round_2026": 12,
        "race_date": "2026-07-19",
        "sprint_weekend": False,
        "circuit_type": ["permanent", "technical", "high_downforce"],
        "lap_count": 70,
        "lap_distance_km": 4.381,
        "total_distance_km": 306.630,
        "safety_car_probability": 0.20,
        "overtaking_difficulty": 8,
        "power_unit_demand": 5.0,
        "brake_demand": 6.0,
        "tire_deg_rate": 0.6,
        "rain_probability_typical": 0.25,
        "drs_zones": 1,
        "elevation_change_m": 42,
        "first_grand_prix": 1986,
    },
    "belgium": {
        "id": "belgium",
        "name": "Circuit de Spa-Francorchamps",
        "city": "Stavelot",
        "country": "Belgium",
        "round_2026": 13,
        "race_date": "2026-07-26",
        "sprint_weekend": False,
        "circuit_type": ["permanent", "high_speed", "technical"],
        "lap_count": 44,
        "lap_distance_km": 7.004,
        "total_distance_km": 308.052,
        "safety_car_probability": 0.48,
        "overtaking_difficulty": 4,
        "power_unit_demand": 8.0,
        "brake_demand": 7.0,
        "tire_deg_rate": 0.6,
        "rain_probability_typical": 0.60,
        "drs_zones": 2,
        "elevation_change_m": 127,
        "first_grand_prix": 1950,
    },
    "netherlands": {
        "id": "netherlands",
        "name": "Circuit Zandvoort",
        "city": "Zandvoort",
        "country": "Netherlands",
        "round_2026": 14,
        "race_date": "2026-08-30",
        "sprint_weekend": True,
        "circuit_type": ["permanent", "high_downforce", "technical"],
        "lap_count": 72,
        "lap_distance_km": 4.259,
        "total_distance_km": 306.645,
        "safety_car_probability": 0.35,
        "overtaking_difficulty": 5,
        "power_unit_demand": 6.0,
        "brake_demand": 7.5,
        "tire_deg_rate": 0.65,
        "rain_probability_typical": 0.40,
        "drs_zones": 2,
        "elevation_change_m": 3,
        "first_grand_prix": 1952,
    },
    "italy": {
        "id": "italy",
        "name": "Autodromo Nazionale di Monza",
        "city": "Monza",
        "country": "Italy",
        "round_2026": 15,
        "race_date": "2026-09-06",
        "sprint_weekend": False,
        "circuit_type": ["permanent", "high_speed", "power_unit"],
        "lap_count": 53,
        "lap_distance_km": 5.793,
        "total_distance_km": 306.720,
        "safety_car_probability": 0.25,
        "overtaking_difficulty": 4,
        "power_unit_demand": 9.5,
        "brake_demand": 4.0,
        "tire_deg_rate": 0.5,
        "rain_probability_typical": 0.20,
        "drs_zones": 2,
        "elevation_change_m": 17,
        "first_grand_prix": 1950,
    },
    "madrid": {
        "id": "madrid",
        "name": "Madrid Street Circuit",
        "city": "Madrid",
        "country": "Spain",
        "round_2026": 16,
        "race_date": "2026-09-13",
        "sprint_weekend": False,
        "circuit_type": ["street", "balanced"],
        "lap_count": 60,
        "lap_distance_km": 5.474,
        "total_distance_km": 328.440,
        "safety_car_probability": 0.32,
        "overtaking_difficulty": 6,
        "power_unit_demand": 6.5,
        "brake_demand": 7.0,
        "tire_deg_rate": 0.6,
        "rain_probability_typical": 0.25,
        "drs_zones": 2,
        "elevation_change_m": 25,
        "first_grand_prix": 2026,
    },
    "azerbaijan": {
        "id": "azerbaijan",
        "name": "Baku City Circuit",
        "city": "Baku",
        "country": "Azerbaijan",
        "round_2026": 17,
        "race_date": "2026-09-20",
        "sprint_weekend": False,
        "circuit_type": ["street", "high_speed"],
        "lap_count": 51,
        "lap_distance_km": 6.003,
        "total_distance_km": 306.049,
        "safety_car_probability": 0.35,
        "overtaking_difficulty": 3,
        "power_unit_demand": 8.0,
        "brake_demand": 4.0,
        "tire_deg_rate": 0.55,
        "rain_probability_typical": 0.10,
        "drs_zones": 2,
        "elevation_change_m": 46,
        "first_grand_prix": 2016,
    },
    "singapore": {
        "id": "singapore",
        "name": "Marina Bay Street Circuit",
        "city": "Singapore",
        "country": "Singapore",
        "round_2026": 18,
        "race_date": "2026-10-04",
        "sprint_weekend": True,
        "circuit_type": ["street", "high_downforce", "technical"],
        "lap_count": 62,
        "lap_distance_km": 5.063,
        "total_distance_km": 313.880,
        "safety_car_probability": 0.42,
        "overtaking_difficulty": 8,
        "power_unit_demand": 5.0,
        "brake_demand": 8.5,
        "tire_deg_rate": 0.7,
        "rain_probability_typical": 0.70,
        "drs_zones": 2,
        "elevation_change_m": 21,
        "first_grand_prix": 2008,
    },
    "usa": {
        "id": "usa",
        "name": "Circuit of the Americas",
        "city": "Austin",
        "country": "USA",
        "round_2026": 19,
        "race_date": "2026-10-18",
        "sprint_weekend": False,
        "circuit_type": ["permanent", "balanced", "technical"],
        "lap_count": 56,
        "lap_distance_km": 5.513,
        "total_distance_km": 308.845,
        "safety_car_probability": 0.28,
        "overtaking_difficulty": 5,
        "power_unit_demand": 7.0,
        "brake_demand": 7.5,
        "tire_deg_rate": 0.65,
        "rain_probability_typical": 0.20,
        "drs_zones": 2,
        "elevation_change_m": 44,
        "first_grand_prix": 2012,
    },
    "mexico": {
        "id": "mexico",
        "name": "Autódromo Hermanos Rodríguez",
        "city": "Mexico City",
        "country": "Mexico",
        "round_2026": 20,
        "race_date": "2026-10-25",
        "sprint_weekend": False,
        "circuit_type": ["permanent", "high_altitude", "power_unit"],
        "lap_count": 71,
        "lap_distance_km": 4.304,
        "total_distance_km": 305.354,
        "safety_car_probability": 0.30,
        "overtaking_difficulty": 6,
        "power_unit_demand": 8.5,
        "brake_demand": 6.0,
        "tire_deg_rate": 0.55,
        "rain_probability_typical": 0.30,
        "drs_zones": 2,
        "elevation_change_m": 2250,
        "first_grand_prix": 1963,
    },
    "brazil": {
        "id": "brazil",
        "name": "Autódromo José Carlos Pace",
        "city": "São Paulo",
        "country": "Brazil",
        "round_2026": 21,
        "race_date": "2026-11-08",
        "sprint_weekend": True,
        "circuit_type": ["permanent", "technical", "balanced"],
        "lap_count": 71,
        "lap_distance_km": 4.309,
        "total_distance_km": 305.879,
        "safety_car_probability": 0.40,
        "overtaking_difficulty": 5,
        "power_unit_demand": 6.0,
        "brake_demand": 8.0,
        "tire_deg_rate": 0.6,
        "rain_probability_typical": 0.45,
        "drs_zones": 2,
        "elevation_change_m": 14,
        "first_grand_prix": 1973,
    },
    "las_vegas": {
        "id": "las_vegas",
        "name": "Las Vegas Strip Circuit",
        "city": "Las Vegas",
        "country": "USA",
        "round_2026": 22,
        "race_date": "2026-11-21",
        "sprint_weekend": False,
        "circuit_type": ["street", "high_speed"],
        "lap_count": 50,
        "lap_distance_km": 6.201,
        "total_distance_km": 310.050,
        "safety_car_probability": 0.25,
        "overtaking_difficulty": 7,
        "power_unit_demand": 8.0,
        "brake_demand": 5.0,
        "tire_deg_rate": 0.6,
        "rain_probability_typical": 0.05,
        "drs_zones": 2,
        "elevation_change_m": 1,
        "first_grand_prix": 2023,
    },
    "qatar": {
        "id": "qatar",
        "name": "Losail International Circuit",
        "city": "Al Daayen",
        "country": "Qatar",
        "round_2026": 23,
        "race_date": "2026-11-29",
        "sprint_weekend": True,
        "circuit_type": ["permanent", "balanced", "technical"],
        "lap_count": 57,
        "lap_distance_km": 5.380,
        "total_distance_km": 306.630,
        "safety_car_probability": 0.22,
        "overtaking_difficulty": 6,
        "power_unit_demand": 6.5,
        "brake_demand": 7.0,
        "tire_deg_rate": 0.7,
        "rain_probability_typical": 0.02,
        "drs_zones": 2,
        "elevation_change_m": 6,
        "first_grand_prix": 2021,
    },
    "uae": {
        "id": "uae",
        "name": "Yas Marina Circuit",
        "city": "Abu Dhabi",
        "country": "UAE",
        "round_2026": 24,
        "race_date": "2026-12-06",
        "sprint_weekend": False,
        "circuit_type": ["permanent", "balanced"],
        "lap_count": 55,
        "lap_distance_km": 5.281,
        "total_distance_km": 290.455,
        "safety_car_probability": 0.20,
        "overtaking_difficulty": 5,
        "power_unit_demand": 6.5,
        "brake_demand": 6.0,
        "tire_deg_rate": 0.65,
        "rain_probability_typical": 0.05,
        "drs_zones": 2,
        "elevation_change_m": 7,
        "first_grand_prix": 2009,
    }
}


def get_circuit(circuit_id: str) -> Dict:
    """
    Retrieve circuit data by ID.
    
    Args:
        circuit_id: Circuit identifier (e.g., 'canada', 'monaco')
    
    Returns:
        Dictionary containing circuit characteristics
        
    Raises:
        KeyError: If circuit_id not in CIRCUITS
    """
    if circuit_id not in CIRCUITS:
        raise KeyError(f"Circuit '{circuit_id}' not found in circuit data")
    return CIRCUITS[circuit_id]


def get_all_circuits() -> List[Dict]:
    """
    Retrieve all circuit data.
    
    Returns:
        List of all circuit dictionaries
    """
    return list(CIRCUITS.values())


def circuit_favors_team(circuit_id: str, team: str) -> float:
    """
    Return a multiplier indicating how much a circuit favors a particular team.
    
    Args:
        circuit_id: Circuit identifier
        team: Team identifier (e.g., 'mercedes', 'red_bull')
        
    Returns:
        Multiplier between 0.9 and 1.1 indicating circuit favorability
    """
    # Default is neutral (1.0) - this would be enhanced with actual data
    # QUALITY-08 FIX: Return [0.9, 1.1] range instead of allowing >1.0 multipliers
    # that get clamped in the probability model
    circuit = get_circuit(circuit_id)
    
    # Example: Some circuits favor certain types of cars
    if circuit_id in ["monaco", "azerbaijan"]:
        # Street circuits might favor teams with better low-speed performance
        if team in ["red_bull", "ferrari"]:
            return 1.05
        elif team in ["mercedes", "mclaren"]:
            return 0.98
    elif circuit_id in ["hungary"]:
        # High-downforce circuits might favor certain teams
        if team == "red_bull":
            return 1.08
        elif team == "ferrari":
            return 1.02
    elif circuit_id in ["belgium", "italy", "britain"]:
        # High-speed circuits favor power unit performance
        if team in ["mercedes", "ferrari"]:
            return 1.05
        elif team == "red_bull":
            return 1.03
    
    # Default neutral multiplier
    return 1.0


# ═══════════════════════════════════════════════════════════════════════════════
# PHASE 4: FASTF1 CIRCUIT DATABASE REFRESH
# ═══════════════════════════════════════════════════════════════════════════════


def refresh_circuits_from_fastf1(seasons: Optional[List[int]] = None) -> int:
    """
    Refresh circuit stats from FastF1 historical race data.

    Updates the in-memory CIRCUITS dict with:
      - safety_car_probability (from actual SC frequency)
      - rain_probability_typical (from actual rainfall frequency)
      - tire_deg_rate (from observed degradation patterns)

    Args:
        seasons: List of years to analyse (default: last 3 years)

    Returns:
        Number of circuits successfully updated

    Safe to call even if FastF1 is unavailable — returns 0 on failure.
    """
    import logging
    logger = logging.getLogger(__name__)

    if seasons is None:
        seasons = [2025, 2024, 2023]

    updated = 0
    try:
        from src.data.fastf1_integration import FASTF1_AVAILABLE, get_circuit_historical_stats
        if not FASTF1_AVAILABLE:
            logger.warning("FastF1 not available — circuit database unchanged")
            return 0

        # Build circuit name → circuit_id mapping
        name_to_id = {}
        for cid, cdata in CIRCUITS.items():
            name_to_id[cdata["name"]] = cid
            # Also map by city for circuits with different official names
            name_to_id[cdata.get("city", "")] = cid

        for cid, cdata in CIRCUITS.items():
            try:
                stats = get_circuit_historical_stats(cdata["name"], seasons)
                if stats.get("races_analysed", 0) == 0:
                    continue

                # Update safety car probability from actual data
                if "safety_car_frequency" in stats:
                    # Blend: 60% FastF1 data, 40% existing static value
                    old_val = cdata.get("safety_car_probability", 0.3)
                    cdata["safety_car_probability"] = round(
                        0.6 * stats["safety_car_frequency"] + 0.4 * old_val, 3
                    )

                # Update rain probability from actual data
                if "avg_rainfall" in stats:
                    old_val = cdata.get("rain_probability_typical", 0.2)
                    cdata["rain_probability_typical"] = round(
                        0.6 * stats["avg_rainfall"] + 0.4 * old_val, 3
                    )

                updated += 1
                logger.info(
                    f"  {cid}: SC={cdata['safety_car_probability']:.2f}, "
                    f"Rain={cdata['rain_probability_typical']:.2f} "
                    f"(from {stats['races_analysed']} races)"
                )

            except Exception as e:
                logger.warning(f"  {cid}: skipped — {e}")
                continue

        logger.info(f"FastF1 circuit refresh: updated {updated}/{len(CIRCUITS)} circuits")

    except ImportError:
        logger.warning("FastF1 module not found — circuit database unchanged")
    except Exception as e:
        logger.error(f"FastF1 circuit refresh failed: {e}")

    return updated


# ── EXPORT ──────────────────────────────────────────────────────────────────────

__all__ = [
    "CIRCUITS",
    "get_circuit",
    "get_all_circuits",
    "circuit_favors_team",
    # Phase 4 addition
    "refresh_circuits_from_fastf1",
]