Download fuxicfd-model/inference_example/utils/postprocessing.py from daisy1212/FuXi-CFD-model: direct link, hf CLI and curl.
- Browser
- Download file 446 Bytes
-
https://huggingface.co/daisy1212/FuXi-CFD-model/resolve/main/fuxicfd-model/inference_example/utils/postprocessing.py
- Command line
-
hf download hf://daisy1212/FuXi-CFD-model/fuxicfd-model/inference_example/utils/postprocessing.py
-
curl -L -o postprocessing.py https://huggingface.co/daisy1212/FuXi-CFD-model/resolve/main/fuxicfd-model/inference_example/utils/postprocessing.py
446 Bytes
| import numpy as np | |
| def denormalize_and_split(pred: np.ndarray, out_stats: dict): | |
| # pred: (1,27,4,300,300) or (27,4,300,300) | |
| if pred.ndim == 5: | |
| pred = pred[0] | |
| mean = out_stats["mean"][:, :, None, None] # (27,4,1,1) | |
| std = out_stats["std"][:, :, None, None] | |
| pred = pred * std + mean # (27,4,300,300) | |
| u = pred[:, 0] | |
| v = pred[:, 1] | |
| w = pred[:, 2] | |
| k = pred[:, 3] | |
| return u, v, w, k | |