ArchEGraph commited on
Commit
74d207f
·
1 Parent(s): eecbf34

Update README and app.py for energy file handling and visualization details

Browse files
Files changed (2) hide show
  1. README.md +5 -2
  2. app.py +17 -4
README.md CHANGED
@@ -24,12 +24,15 @@ For the selected weather/building pair, the app fetches:
24
  - `geometry/<building_id>.npz`
25
  - `building/<building_id>.npz`
26
  - `weather/<weather_id>.npz`
27
- - `energy/<sample_id>.npz`
28
 
29
- Then it renders four views:
 
 
30
 
31
  - Geometry polygons
32
  - Building graph
 
33
  - Weather curves (selected time window)
34
  - Energy curves (selected time window)
35
 
 
24
  - `geometry/<building_id>.npz`
25
  - `building/<building_id>.npz`
26
  - `weather/<weather_id>.npz`
27
+ - `energy/<energy_file from manifest.csv>`
28
 
29
+ The energy file can live under nested subfolders such as `energy/00/00017__Anchorage.npz`.
30
+
31
+ Then it renders five views:
32
 
33
  - Geometry polygons
34
  - Building graph
35
+ - Graph/geometry overlap
36
  - Weather curves (selected time window)
37
  - Energy curves (selected time window)
38
 
app.py CHANGED
@@ -6,6 +6,7 @@ import time
6
  from dataclasses import dataclass
7
  from functools import lru_cache
8
  from pathlib import Path
 
9
 
10
  import gradio as gr
11
  from huggingface_hub import hf_hub_download
@@ -148,28 +149,40 @@ def _resolve_record(weather_id: str, building_id: str) -> SampleRecord:
148
  )
149
 
150
 
 
 
 
 
 
 
 
 
 
151
  def _download_modalities(record: SampleRecord) -> tuple[Path, Path, Path, Path]:
152
  building_key = record.sample_id.split("__", 1)[0]
 
 
 
153
 
154
  geometry_npz = hf_hub_download(
155
  repo_id=DATASET_REPO_ID,
156
  repo_type="dataset",
157
- filename=f"geometry/{building_key}.npz",
158
  )
159
  graph_npz = hf_hub_download(
160
  repo_id=DATASET_REPO_ID,
161
  repo_type="dataset",
162
- filename=f"building/{building_key}.npz",
163
  )
164
  weather_npz = hf_hub_download(
165
  repo_id=DATASET_REPO_ID,
166
  repo_type="dataset",
167
- filename=f"weather/{record.weather_id}.npz",
168
  )
169
  energy_npz = hf_hub_download(
170
  repo_id=DATASET_REPO_ID,
171
  repo_type="dataset",
172
- filename=f"energy/{record.energy_file}",
173
  )
174
 
175
  return Path(geometry_npz), Path(graph_npz), Path(weather_npz), Path(energy_npz)
 
6
  from dataclasses import dataclass
7
  from functools import lru_cache
8
  from pathlib import Path
9
+ from pathlib import PurePosixPath
10
 
11
  import gradio as gr
12
  from huggingface_hub import hf_hub_download
 
149
  )
150
 
151
 
152
+ def _repo_dataset_path(*parts: str) -> str:
153
+ clean_parts: list[str] = []
154
+ for part in parts:
155
+ text = (part or "").replace("\\", "/").strip("/")
156
+ if text:
157
+ clean_parts.extend(segment for segment in text.split("/") if segment and segment != ".")
158
+ return str(PurePosixPath(*clean_parts))
159
+
160
+
161
  def _download_modalities(record: SampleRecord) -> tuple[Path, Path, Path, Path]:
162
  building_key = record.sample_id.split("__", 1)[0]
163
+ energy_relpath = record.energy_file.replace("\\", "/").lstrip("/")
164
+ if energy_relpath.startswith("energy/"):
165
+ energy_relpath = energy_relpath[len("energy/") :]
166
 
167
  geometry_npz = hf_hub_download(
168
  repo_id=DATASET_REPO_ID,
169
  repo_type="dataset",
170
+ filename=_repo_dataset_path("geometry", f"{building_key}.npz"),
171
  )
172
  graph_npz = hf_hub_download(
173
  repo_id=DATASET_REPO_ID,
174
  repo_type="dataset",
175
+ filename=_repo_dataset_path("building", f"{building_key}.npz"),
176
  )
177
  weather_npz = hf_hub_download(
178
  repo_id=DATASET_REPO_ID,
179
  repo_type="dataset",
180
+ filename=_repo_dataset_path("weather", f"{record.weather_id}.npz"),
181
  )
182
  energy_npz = hf_hub_download(
183
  repo_id=DATASET_REPO_ID,
184
  repo_type="dataset",
185
+ filename=_repo_dataset_path("energy", energy_relpath),
186
  )
187
 
188
  return Path(geometry_npz), Path(graph_npz), Path(weather_npz), Path(energy_npz)