Spaces:
Sleeping
Sleeping
ok
Browse files
app.py
CHANGED
@@ -574,6 +574,32 @@ def create_wind_map(region="global"):
|
|
574 |
}}
|
575 |
console.log("β
STEP 4: Leaflet-Velocity plugin loaded");
|
576 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
577 |
// Create initial velocity layer with optimized settings for real data
|
578 |
console.log("π― STEP 5: Creating real ECMWF wind visualization...");
|
579 |
currentVelocityLayer = L.velocityLayer({{
|
@@ -593,20 +619,7 @@ def create_wind_map(region="global"):
|
|
593 |
maxVelocity: 50, // Capture all wind speeds
|
594 |
particleMultiplier: 0.006, // Reduced density for clarity
|
595 |
lineWidth: 0.3, // Thinner lines
|
596 |
-
colorScale:
|
597 |
-
// Dark blue color scale for better visibility on light backgrounds
|
598 |
-
"#1e3a8a", // Very slow winds - dark blue
|
599 |
-
"#1e40af", // Slow winds - dark blue
|
600 |
-
"#1d4ed8", // Light winds - blue
|
601 |
-
"#2563eb", // Moderate winds - bright blue
|
602 |
-
"#3b82f6", // Strong winds - blue
|
603 |
-
"#60a5fa", // Fast winds - light blue
|
604 |
-
"#93c5fd", // Very fast winds - lighter blue
|
605 |
-
"#dbeafe", // High winds - very light blue
|
606 |
-
"#eff6ff", // Very high winds - pale blue
|
607 |
-
"#f0f9ff", // Extreme winds - very pale blue
|
608 |
-
"#ffffff" // Hurricane force - white
|
609 |
-
],
|
610 |
frameRate: 30, // Smooth animation
|
611 |
particleAge: 120, // Shorter particle life for slower winds
|
612 |
particleReduction: 0.5, // Less reduction = more particles
|
@@ -655,10 +668,7 @@ def create_wind_map(region="global"):
|
|
655 |
maxVelocity: 50,
|
656 |
particleMultiplier: 0.006,
|
657 |
lineWidth: 0.3,
|
658 |
-
colorScale:
|
659 |
-
"#1e3a8a", "#1e40af", "#1d4ed8", "#2563eb", "#3b82f6",
|
660 |
-
"#60a5fa", "#93c5fd", "#dbeafe", "#eff6ff", "#f0f9ff", "#ffffff"
|
661 |
-
],
|
662 |
frameRate: 30,
|
663 |
particleAge: 120,
|
664 |
particleReduction: 0.5,
|
@@ -677,10 +687,14 @@ def create_wind_map(region="global"):
|
|
677 |
}}
|
678 |
}}
|
679 |
|
680 |
-
// Event handlers for map interaction
|
681 |
map.on('moveend', immediateParticleReload);
|
682 |
map.on('zoomend', immediateParticleReload);
|
683 |
map.on('dragend', immediateParticleReload);
|
|
|
|
|
|
|
|
|
684 |
|
685 |
console.log("========================================");
|
686 |
console.log("β
SUCCESS: Real ECMWF wind visualization active!");
|
|
|
574 |
}}
|
575 |
console.log("β
STEP 4: Leaflet-Velocity plugin loaded");
|
576 |
|
577 |
+
// Function to get theme-appropriate color scale
|
578 |
+
function getColorScale() {{
|
579 |
+
// Check if we're on light theme by looking at current tile layer
|
580 |
+
var currentTileLayer = null;
|
581 |
+
map.eachLayer(function(layer) {{
|
582 |
+
if (layer.options && layer.options.tiles && layer.options.tiles.includes('positron')) {{
|
583 |
+
currentTileLayer = 'light';
|
584 |
+
}}
|
585 |
+
}});
|
586 |
+
|
587 |
+
// Light blue colors for dark theme, dark blue for light theme
|
588 |
+
if (currentTileLayer === 'light') {{
|
589 |
+
// Dark blue colors for light theme
|
590 |
+
return [
|
591 |
+
"#1e3a8a", "#1e40af", "#1d4ed8", "#2563eb", "#3b82f6",
|
592 |
+
"#60a5fa", "#93c5fd", "#dbeafe", "#eff6ff", "#f0f9ff", "#ffffff"
|
593 |
+
];
|
594 |
+
}} else {{
|
595 |
+
// Light blue colors for dark theme
|
596 |
+
return [
|
597 |
+
"#60a5fa", "#93c5fd", "#dbeafe", "#eff6ff", "#f0f9ff",
|
598 |
+
"#ffffff", "#f8fafc", "#f1f5f9", "#e2e8f0", "#cbd5e1", "#94a3b8"
|
599 |
+
];
|
600 |
+
}}
|
601 |
+
}}
|
602 |
+
|
603 |
// Create initial velocity layer with optimized settings for real data
|
604 |
console.log("π― STEP 5: Creating real ECMWF wind visualization...");
|
605 |
currentVelocityLayer = L.velocityLayer({{
|
|
|
619 |
maxVelocity: 50, // Capture all wind speeds
|
620 |
particleMultiplier: 0.006, // Reduced density for clarity
|
621 |
lineWidth: 0.3, // Thinner lines
|
622 |
+
colorScale: getColorScale(), // Theme-appropriate colors
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
623 |
frameRate: 30, // Smooth animation
|
624 |
particleAge: 120, // Shorter particle life for slower winds
|
625 |
particleReduction: 0.5, // Less reduction = more particles
|
|
|
668 |
maxVelocity: 50,
|
669 |
particleMultiplier: 0.006,
|
670 |
lineWidth: 0.3,
|
671 |
+
colorScale: getColorScale(),
|
|
|
|
|
|
|
672 |
frameRate: 30,
|
673 |
particleAge: 120,
|
674 |
particleReduction: 0.5,
|
|
|
687 |
}}
|
688 |
}}
|
689 |
|
690 |
+
// Event handlers for map interaction and theme changes
|
691 |
map.on('moveend', immediateParticleReload);
|
692 |
map.on('zoomend', immediateParticleReload);
|
693 |
map.on('dragend', immediateParticleReload);
|
694 |
+
map.on('baselayerchange', function() {{
|
695 |
+
console.log("π¨ Theme changed, updating particle colors...");
|
696 |
+
setTimeout(immediateParticleReload, 100); // Small delay to ensure theme change is complete
|
697 |
+
}});
|
698 |
|
699 |
console.log("========================================");
|
700 |
console.log("β
SUCCESS: Real ECMWF wind visualization active!");
|