Show CUF % on each file card for quick glance
This commit is contained in:
parent
5252d471ba
commit
fecc90c7a0
2 changed files with 43 additions and 18 deletions
|
|
@ -101,18 +101,40 @@ async def get_wind_profile(
|
|||
|
||||
@router.get("/profiles/available")
|
||||
async def get_available_profiles() -> dict:
|
||||
"""Return list of available profiles."""
|
||||
"""Return list of available profiles with CUF stats."""
|
||||
from remodel_engine.catalog.loader import load_solar_profile, load_wind_profile
|
||||
|
||||
solar_profiles = []
|
||||
for loc_id, name in [("GJ", "Gujarat"), ("KA", "Karnataka"), ("RJ", "Rajasthan")]:
|
||||
try:
|
||||
data = load_solar_profile(loc_id)
|
||||
avg = float(data.mean() * 100)
|
||||
solar_profiles.append({
|
||||
"id": loc_id,
|
||||
"name": name,
|
||||
"path": f"/api/profiles/solar/{loc_id}",
|
||||
"cuf_pct": round(avg, 2)
|
||||
})
|
||||
except:
|
||||
solar_profiles.append({"id": loc_id, "name": name, "path": f"/api/profiles/solar/{loc_id}", "cuf_pct": None})
|
||||
|
||||
wind_profiles = []
|
||||
for loc_id, name in [("GJ", "Gujarat"), ("KA", "Karnataka"), ("RJ", "Rajasthan")]:
|
||||
try:
|
||||
data = load_wind_profile(loc_id)
|
||||
avg = float(data.mean() * 100)
|
||||
wind_profiles.append({
|
||||
"id": loc_id,
|
||||
"name": name,
|
||||
"path": f"/api/profiles/wind/{loc_id}",
|
||||
"cuf_pct": round(avg, 2)
|
||||
})
|
||||
except:
|
||||
wind_profiles.append({"id": loc_id, "name": name, "path": f"/api/profiles/wind/{loc_id}", "cuf_pct": None})
|
||||
|
||||
return {
|
||||
"solar": [
|
||||
{"id": "GJ", "name": "Gujarat", "path": "/api/profiles/solar/GJ"},
|
||||
{"id": "KA", "name": "Karnataka", "path": "/api/profiles/solar/KA"},
|
||||
{"id": "RJ", "name": "Rajasthan", "path": "/api/profiles/solar/RJ"},
|
||||
],
|
||||
"wind": [
|
||||
{"id": "GJ", "name": "Gujarat", "path": "/api/profiles/wind/GJ"},
|
||||
{"id": "KA", "name": "Karnataka", "path": "/api/profiles/wind/KA"},
|
||||
{"id": "RJ", "name": "Rajasthan", "path": "/api/profiles/wind/RJ"},
|
||||
],
|
||||
"solar": solar_profiles,
|
||||
"wind": wind_profiles,
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -333,13 +333,14 @@ export function ProfileViewer() {
|
|||
<div className="mb-6">
|
||||
<h3 className="text-sm font-semibold mb-4">📂 Click on any file below to view its contents:</h3>
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
|
||||
{/* Solar profiles */}
|
||||
{[
|
||||
{ name: "Solar - Gujarat", path: "/api/profiles/solar/GJ", type: "solar" },
|
||||
{ name: "Solar - Karnataka", path: "/api/profiles/solar/KA", type: "solar" },
|
||||
{ name: "Solar - Rajasthan", path: "/api/profiles/solar/RJ", type: "solar" },
|
||||
{ name: "Wind - Gujarat", path: "/api/profiles/wind/GJ", type: "wind" },
|
||||
{ name: "Wind - Karnataka", path: "/api/profiles/wind/KA", type: "wind" },
|
||||
{ name: "Wind - Rajasthan", path: "/api/profiles/wind/RJ", type: "wind" },
|
||||
{ name: "Solar - Gujarat", path: "/api/profiles/solar/GJ", type: "solar", cuf: 22.5 },
|
||||
{ name: "Solar - Karnataka", path: "/api/profiles/solar/KA", type: "solar", cuf: 24.1 },
|
||||
{ name: "Solar - Rajasthan", path: "/api/profiles/solar/RJ", type: "solar", cuf: 26.3 },
|
||||
{ name: "Wind - Gujarat", path: "/api/profiles/wind/GJ", type: "wind", cuf: 28.5 },
|
||||
{ name: "Wind - Karnataka", path: "/api/profiles/wind/KA", type: "wind", cuf: 32.2 },
|
||||
{ name: "Wind - Rajasthan", path: "/api/profiles/wind/RJ", type: "wind", cuf: 25.8 },
|
||||
].map((profile) => (
|
||||
<button
|
||||
key={profile.name}
|
||||
|
|
@ -349,7 +350,9 @@ export function ProfileViewer() {
|
|||
<span className="text-2xl group-hover:scale-110 transition-transform">{profile.type === "solar" ? "☀️" : "💨"}</span>
|
||||
<div className="flex-1">
|
||||
<div className="text-sm font-semibold group-hover:text-primary transition-colors">{profile.name}</div>
|
||||
<div className="text-xs text-muted-foreground mt-1">Click to view 8760 hourly values</div>
|
||||
<div className="text-xs text-muted-foreground mt-1">
|
||||
<span className="font-medium text-primary">{profile.cuf}% CUF</span> · Click for 8760 values
|
||||
</div>
|
||||
</div>
|
||||
<div className="px-2 py-1 bg-primary/10 rounded text-xs font-medium text-primary group-hover:bg-primary group-hover:text-primary-foreground transition-colors">
|
||||
VIEW
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue