download-script-dev
БесплатноБез исполняемых скриптовНе проверенUse this skill when users ask to "develop a download script", "debug data download", "fix download error", "create data pipeline template", "download…
от uw-ssec★ 33 звезды на GitHubОб этом скилле
Download Script Development Skill
Requirements
- Python 3.9+ with
xarray,geopandas,rioxarray - Source-specific libraries:
herbie-data(HRRR),pyPRISMClimate(PRISM),obspy(IRIS),boto3(WRF/S3),elevation(DEM),s3fs(CONUS404) - System dependencies:
wgrib2for HRRR (conda install -c conda-forge wgrib2, not pip)
Script Structure Pattern
All download scripts follow CONFIG-at-top separating parameters from logic. Complete templates for each source are in references/DOWNLOAD_PATTERNS.md.
import xarray as xr
import geopandas as gpd
import logging
from concurrent.futures import ThreadPoolExecutor, as_completed
from pathlib import Path
# ============================================================
# Configuration — modify these parameters before running
# ============================================================
CONFIG = {
"source": "SOURCE_NAME",
"date_range": ("2024-01-01", "2024-01-31"),
"variables": ["var1", "var2"],
"aoi_path": "../data/GIS/boundary.json",
"output_path": "../data/output.zarr",
"output_format": "zarr", # "zarr" | "netcdf" | "csv"
"max_workers": 8,
}
# ============================================================
# Download logic — generally no need to modify below this line
# ============================================================
logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)s %(message)s")
log = logging.getLogger(__name__)
def validate_config(cfg):
required = ["source", "date_range", "variables", "output_path", "output_format"]
missing = [k for k in required if not cfg.get(k)]
if missing:
raise ValueError(f"Missing config keys: {missing}")
def validate_aoi(aoi):
if aoi.empty:
raise ValueError("AOI GeoDataFrame is empty — check aoi_path")
if aoi.crs is None:
raise ValueError("AOI CRS is None — set CRS before subsetting")
def download_with_retry(item, download_fn, retries=3, backoff=2):
"""Run download_fn(item) with exponential backoff on failure."""
import time
for attempt in range(retries):
try:
return download_fn(item)
except Exception as e:
if attempt == retries - 1:
raise
wait = backoff ** attempt
log.warning(f"Attempt {attempt+1} failed for {item}: {e}. Retrying in {wait}s")
time.sleep(wait)
def main():
# Step 0: Validate configuration
validate_config(CONFIG)
log.info(f"Starting {CONFIG['source']} download: {CONFIG['date_range']}")
# Step 1: Load and validate AOI
aoi = gpd.read_file(CONFIG["aoi_path"])
validate_aoi(aoi)
log.info(f"AOI loaded: {len(aoi)} feature(s), CRS={aoi.crs}")
# Step 2: Build item list and download with retry + failure capture
items = [] # populate with dates, URLs, or identifiers for this source
failed = []
results = []
with ThreadPoolExecutor(max_workers=CONFIG["max_workers"]) as executor:
futures = {executor.submit(download_with_retry, item, _download_item): item
for item in items}
for i, future in enumerate(as_completed(futures), 1):
item = futures[future]
try:
results.append(future.result())
log.info(f"[{i}/{len(items)}] Downloaded {item}")
except Exception as e:
log.error(f"FAILED {item}: {e}")
failed.append((item, str(e)))
# Step 3: Validate completeness — fail hard if any items are missing
if failed:
log.error(f"{len(failed)} items failed after retries: {[f[0] for f in failed]}")
raise RuntimeError(
f"Download incomplete: {len(failed)}/{len(items)} failed. "
"Fix CONFIG or network issues, then re-run."
)
expected = len(items)
assert len(results) == expected, f"Expected {expected} results, got {len(results)}"
# Step 4: Combine results and validate dimensions
ds = xr.open_mfdataset(results, combine="by_coords") if results else None
assert ds is not None and ds.dims.get("time", 0) > 0, "Combined dataset has no time steps"
# Step 5: Reproject AOI if needed, spatial subset, validate bounds
if aoi.crs != ds.rio.crs:
aoi = aoi.to_crs(ds.rio.crs)
ds_sub = ds.rio.clip(aoi.geometry)
assert not ds_sub.isnull().all().values.any(), "Spatial subset is entirely NaN — check AOI alignment"
# Step 6: Derive variables and validate units/ranges
# (source-specific; see references/DOWNLOAD_PATTERNS.md)
# Step 7: Save output and verify artifact
out = Path(CONFIG["output_path"])
if CONFIG["output_format"] == "zarr":
ds_sub.to_zarr(out, mode="w")
xr.open_zarr(out) # verify reopens cleanly
elif CONFIG["output_format"] == "netcdf":
ds_sub.to_netcdf(out)
xr.open_dataset(out).close()
log.info(f"Saved to {out}")
# Step 8: QC
Установить download-script-dev в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл download-script-dev?
Use this skill when users ask to "develop a download script", "debug data download", "fix download error", "create data pipeline template", "download template", "GAIA data pipeline", "download from S3", "access Zarr store", "cloud data access", or mention sources like CONUS404, HRRR, WRF, PRISM, Stage IV, USGS, ORNL, DEM, Synoptic, or IRIS. Generates CONFIG-at-top Python download scripts, validates source-specific configuration (auth, endpoint/path, date range, variables, AOI/CRS, and output format), and diagnoses common failures (403/auth, timeout/retry, CRS mismatch, missing binaries, and partial downloads).
Как установить скилл download-script-dev?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл download-script-dev запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic