chatcad / fetch_drivaernet.py
Samarjithbiswas's picture
chat_cad live (Docker app + weights)
32c7c43 verified
Raw
History Blame Contribute Delete
2.74 kB
"""Download the small DrivAerNet++ aerodynamic-coefficient CSVs.
DrivAerNet++ (Elrefaie et al., MIT, CC-BY-NC-4.0) ships its full 39 TB of
meshes + CFD volume fields on Harvard Dataverse (use Globus for that).
But the per-design DRAG coefficients and frontal areas are published as
two small CSVs via the authors' Dropbox β€” a few hundred KB total β€” and
that is all we need for:
* drivaernet_data.retrieve_by_cd() (real CFD retrieval)
* dataset statistics / calibration
* labels for a parametric (26-param) drag surrogate
This script fetches just those two CSVs into ./DrivAerNet/.
Full dataset (meshes, point clouds, pressure / wall-shear / volume fields)
is NOT downloaded here β€” see:
https://dataverse.harvard.edu/dataverse/DrivAerNet (39 TB, Globus)
https://github.com/Mohamedelrefaie/DrivAerNet
Usage:
python fetch_drivaernet.py
"""
from __future__ import annotations
import sys
import urllib.request
from pathlib import Path
DATA_DIR = Path(__file__).parent / "DrivAerNet"
# Official author-hosted Dropbox links (dl=1 forces a direct download).
FILES = {
"DrivAerNetPlusPlus_Cd_8k.csv":
"https://www.dropbox.com/scl/fi/2rtchqnpmzy90uwa9wwny/"
"DrivAerNetPlusPlus_Cd_8k_Updated.csv"
"?rlkey=vjnjurtxfuqr40zqgupnks8sn&dl=1",
"DrivAerNetPlusPlus_Areas.csv":
"https://www.dropbox.com/scl/fi/b7fenj0wmhzqx64bj82t1/"
"DrivAerNetPlusPlus_CarDesign_Areas.csv"
"?rlkey=usbunuupxwmx6g49r9r7dh8zk&dl=1",
}
def fetch():
DATA_DIR.mkdir(parents=True, exist_ok=True)
for name, url in FILES.items():
dest = DATA_DIR / name
if dest.exists() and dest.stat().st_size > 0:
print(f"[fetch] {name} already present ({dest.stat().st_size:,} B)")
continue
print(f"[fetch] downloading {name} ...")
req = urllib.request.Request(url, headers={"User-Agent": "Mozilla/5.0"})
with urllib.request.urlopen(req, timeout=60) as r, open(dest, "wb") as f:
f.write(r.read())
n = dest.stat().st_size
print(f"[fetch] -> {dest} ({n:,} B)")
if n < 1000:
print(f"[fetch] WARNING: file looks too small; check the URL.")
# quick sanity report
try:
import drivaernet_data as DN
s = DN.dataset_stats()
if s.get("available"):
print(f"[fetch] OK β€” {s['n']} real designs, "
f"Cd mean={s['cd_mean']:.3f} "
f"[{s['cd_min']:.3f}, {s['cd_max']:.3f}]")
except Exception as e:
print(f"[fetch] note: stats check skipped ({e})")
if __name__ == "__main__":
try:
fetch()
except Exception as e:
print(f"[fetch] FAILED: {e}", file=sys.stderr)
sys.exit(1)