Download scripts/inference.py from OneScience-Group/WRF-ML: direct link, hf CLI and curl.
- Browser
- Download file 873 Bytes
-
https://huggingface.co/OneScience-Group/WRF-ML/resolve/main/scripts/inference.py
- Command line
-
hf download hf://OneScience-Group/WRF-ML/scripts/inference.py
-
curl -L -o inference.py https://huggingface.co/OneScience-Group/WRF-ML/resolve/main/scripts/inference.py
873 Bytes
| from pathlib import Path | |
| import sys,numpy as np,torch | |
| ROOT=Path(__file__).resolve().parents[1];sys.path.insert(0,str(ROOT)) | |
| from model.wrf_ml import * | |
| c=load_config(ROOT);ck=torch.load(ROOT/c["paths"]["checkpoint"],map_location="cpu",weights_only=True);m=RadiationBiLSTM(**ck["model_config"]);m.load_state_dict(ck["model"]);m.eval();x,p,b=synthetic_columns(100,n=6);wrf=x.reshape(2,57,3,10);coupler=SynchronousCoupler(m) | |
| with torch.no_grad():ph_layout,bh_layout=coupler.infer_run(wrf);ph=ph_layout.permute(0,2,1,3).reshape(6,57,4);bh=bh_layout.reshape(6,2) | |
| path=ROOT/c["paths"]["predictions"];path.parent.mkdir(parents=True,exist_ok=True);np.savez_compressed(path,profile_prediction=ph.numpy(),profile_target=p.numpy(),boundary_prediction=bh.numpy(),boundary_target=b.numpy(),vertical_levels=np.arange(57),coupler_mode=np.array("synchronous_request_response"));print(path) | |