Ran linter.

This commit is contained in:
Felix Delattre 2026-06-11 16:33:14 +02:00
parent 49ad6bcaab
commit d29754e4a5
6 changed files with 186 additions and 84 deletions

View file

@ -388,10 +388,14 @@ def download_s2_window(
with rasterio.Env(**_GDAL_COG_ENV):
with ThreadPoolExecutor(max_workers=max_workers) as pool:
futures = {
pool.submit(_process_item, item, bbox, bands, output_dir, ratio): item.id
pool.submit(
_process_item, item, bbox, bands, output_dir, ratio
): item.id
for item in items
}
with tqdm(total=len(futures), unit="granule", desc="S2 COG window read") as pbar:
with tqdm(
total=len(futures), unit="granule", desc="S2 COG window read"
) as pbar:
for fut in as_completed(futures):
msg = fut.result()
if msg:
@ -461,9 +465,7 @@ def _netcdf_to_geotiffs(nc_path: Path, output_dir: Path, epsg: int) -> int:
n = date_counts.get(date_str, 0)
date_counts[date_str] = n + 1
raw = np.stack(
[nc.variables[b][t_idx, :, :] for b in S3_BANDS], axis=0
)
raw = np.stack([nc.variables[b][t_idx, :, :] for b in S3_BANDS], axis=0)
stacked = (
np.ma.filled(raw, fill_value=np.nan).astype("float32")
/ S3_REFLECTANCE_SCALE
@ -523,7 +525,9 @@ def _download_with_retry(datacube: Any, nc_path: Path) -> None:
delay *= 2
else:
print(f"[S3-OEO] All {_S3_DOWNLOAD_RETRIES} download attempts failed")
raise RuntimeError(f"S3 download failed after {_S3_DOWNLOAD_RETRIES} attempts") from last_exc
raise RuntimeError(
f"S3 download failed after {_S3_DOWNLOAD_RETRIES} attempts"
) from last_exc
def download_s3_openeo(
@ -592,9 +596,7 @@ def _import_distance_to_clouds():
return distance_to_clouds
except ImportError as exc:
raise ImportError(
"efast not found. Install with: uv sync"
) from exc
raise ImportError("efast not found. Install with: uv sync") from exc
def _normalize_s2_grid(s2_dir: Path) -> None:
@ -663,9 +665,7 @@ def _import_s3_processing():
return s3_processing
except ImportError as exc:
raise ImportError(
"efast not found. Install with: uv sync"
) from exc
raise ImportError("efast not found. Install with: uv sync") from exc
def _reproject_s3_composites_to_s2_grid(
@ -912,7 +912,9 @@ def main(argv: list[str] | None = None) -> int:
sitename = site["sitename"]
site_dir = DATA_DIR / "sentinel_data" / str(year) / sitename
if args.skip_downloaded and site_dir.exists():
print(f"[Sentinel-3] ({i}/{len(pass_sites)}) {sitename} — skipping (directory exists)")
print(
f"[Sentinel-3] ({i}/{len(pass_sites)}) {sitename} — skipping (directory exists)"
)
continue
print(f"[Sentinel-3] ({i}/{len(pass_sites)}) {sitename}")
summary = process_site(sitename, site["lat"], site["lon"], year)