Download code/data_preparing/src/preprocess.py from lsh9034/ci-net: direct link, hf CLI and curl.
- Browser
- Download file 1.44 kB
-
https://huggingface.co/lsh9034/ci-net/resolve/main/code/data_preparing/src/preprocess.py
- Command line
-
hf download hf://lsh9034/ci-net/code/data_preparing/src/preprocess.py
-
curl -L -o preprocess.py https://huggingface.co/lsh9034/ci-net/resolve/main/code/data_preparing/src/preprocess.py
1.44 kB
| """Run satellite/radar and L2 preprocessing from one configuration.""" | |
| from __future__ import annotations | |
| import argparse | |
| import json | |
| import subprocess | |
| import sys | |
| from pathlib import Path | |
| from src.config import load_config | |
| def main(argv: list[str] | None = None) -> None: | |
| parser = argparse.ArgumentParser(description="Preprocess one or more days of satellite, radar, and L2 data.") | |
| parser.add_argument("--config", required=True, help="YAML configuration path") | |
| parser.add_argument("--device", default=None, help="Accepted for a common CLI; preprocessing runs on CPU") | |
| parser.add_argument("--output-dir", default=None, help="Override the configured output directory") | |
| args = parser.parse_args(argv) | |
| config = load_config(args.config) | |
| config.pop("_config_path", None) | |
| if args.output_dir: | |
| config["save_dir"] = str(Path(args.output_dir).resolve()) | |
| output_dir = Path(config["save_dir"]) | |
| output_dir.mkdir(parents=True, exist_ok=True) | |
| runtime_config = output_dir / "preprocess_runtime.json" | |
| with runtime_config.open("w", encoding="utf-8") as stream: | |
| json.dump(config, stream, indent=2, ensure_ascii=False) | |
| try: | |
| for module in ("src.satellite_radar", "src.l2"): | |
| subprocess.run([sys.executable, "-m", module, "--config", str(runtime_config)], check=True) | |
| finally: | |
| runtime_config.unlink(missing_ok=True) | |
| if __name__ == "__main__": | |
| main() | |