Download scripts/fix_stokes_functions.py from AlanZee/diffvof-simulation-data: direct link, hf CLI and curl.
- Browser
- Download file 644 Bytes
-
https://huggingface.co/datasets/AlanZee/diffvof-simulation-data/resolve/ce593d486a2b73f5e51cb1706091944f79740887/scripts/fix_stokes_functions.py
- Command line
-
hf download hf://datasets/AlanZee/diffvof-simulation-data@ce593d486a2b73f5e51cb1706091944f79740887/scripts/fix_stokes_functions.py
-
curl -L -o fix_stokes_functions.py https://huggingface.co/datasets/AlanZee/diffvof-simulation-data/resolve/ce593d486a2b73f5e51cb1706091944f79740887/scripts/fix_stokes_functions.py
644 Bytes
| #!/usr/bin/env python3 | |
| """移除 stokes_wave 所有 case controlDict 中的 line 函数""" | |
| import os, re | |
| raw = '/mnt/f/agent-workspace/paper2/Exp/data/raw/stokes_wave' | |
| fixed = 0 | |
| for d in sorted(os.listdir(raw)): | |
| if not d.startswith('t'): | |
| continue | |
| cd = os.path.join(raw, d, 'system', 'controlDict') | |
| if not os.path.isfile(cd): | |
| continue | |
| c = open(cd).read() | |
| m = re.search(r'functions\s*\{.*?\}\s*\n', c, re.DOTALL) | |
| if m: | |
| new_c = c[:m.start()] + 'functions {};\n' + c[m.end():] | |
| with open(cd, 'w') as f: | |
| f.write(new_c) | |
| fixed += 1 | |
| print(f'Fixed {fixed} controlDicts') | |