Download data.py from guanwencan/Sparse_reconstruction_FE_damage_fields: direct link, hf CLI and curl.
- Browser
- Download file 603 Bytes
-
https://huggingface.co/guanwencan/Sparse_reconstruction_FE_damage_fields/resolve/main/data.py
- Command line
-
hf download hf://guanwencan/Sparse_reconstruction_FE_damage_fields/data.py
-
curl -L -o data.py https://huggingface.co/guanwencan/Sparse_reconstruction_FE_damage_fields/resolve/main/data.py
603 Bytes
| import numpy as np | |
| INSTANTS = (11.20, 13.38, 14.70) | |
| FIELDS = ("dkappa", "dWp", "D") | |
| def load(path, field, instants=INSTANTS): | |
| f = np.load(path) | |
| t = f["time"] | |
| frames = [int(np.argmin(np.abs(t - s))) for s in instants] | |
| x = f["x"].astype(float) | |
| y = f["y"].astype(float) | |
| true = f[field][frames].astype(float) | |
| cap = float(true.max()) | |
| return dict(x=x, y=y, true=true, times=t[frames].astype(float), | |
| scale=float(np.abs(x).max()), cap=cap, band_thr=0.5 * cap) | |
| def normalised_coords(fd): | |
| return np.stack([fd["x"] / fd["scale"], fd["y"] / fd["scale"]], 1) | |