Title: CMIP6 Climate Emulation Pipeline
Domain: physical_sciences — Earth & Atmospheric Sciences

Summary: Build an end-to-end climate-emulation pipeline from a staged CMIP6-derived Zarr store and predict the held-out SSP245 test window for temperature and precipitation fields.

Task prompt:
You are a climate scientist building an end-to-end climate-emulation pipeline on Linux.

## Your Task

Build a climate-emulation pipeline from a staged CMIP6-derived Zarr store and predict the held-out SSP245 test window.

1. Bootstrap the Python runtime: `bash <software_dir>/bootstrap_runtime.sh`
2. Open the staged Zarr store at `<input_dir>/data.zarr/` with cftime-aware decoding.
3. Build training tensors from scenarios `ssp126`, `ssp370`, and `ssp585` across all months.
4. Build test inputs from the last 120 months of `ssp245`.
5. Use `member_id = 0` for target tensors.
6. Broadcast scalar forcings (`CO2`, `CH4`) to the `(48, 72)` spatial grid.
7. Rename `latitude`/`longitude` dimensions to `y`/`x` for spatial inputs.
8. Fit normalization on the training split only.
9. Train any benchmark-safe open-source model or baseline.
10. Write the required output files under `<output_dir>/` exactly as described by `<input_dir>/output_contract.json`.

## Input Files

- Zarr store: `<input_dir>/data.zarr/`
- Metadata: `<input_dir>/metadata.json`
- Output contract: `<input_dir>/output_contract.json`
- Starter guide: `<input_dir>/Starter.md`
- Runtime manifest: `<input_dir>/runtime_env/`

## Runtime

- Bootstrap deps: `bash <software_dir>/bootstrap_runtime.sh`
- Run Python with deps: `<software_dir>/python_with_task_deps.sh your_script.py`

## Output

Save all required files under `<output_dir>/`:
- `processed/train_inputs.npy`, `processed/train_outputs.npy`, `processed/test_inputs.npy`
- `processed/metadata.json`, `processed/test_predictions.npy`
- `submissions/kaggle_submission.csv`

The visible `data.zarr` intentionally masks the held-out `ssp245` test-window target labels (`tas`, `pr`) as NaN. Use the training split to learn a predictor.

The agent must:
1. Bootstrap the staged Python runtime via `software/bootstrap_runtime.sh`
2. Open the masked CMIP6-derived `data.zarr` with cftime-aware decoding
3. Build training tensors from `ssp126`, `ssp370`, `ssp585` and test inputs from last 120 months of `ssp245`
4. Use `member_id = 0` for targets; broadcast scalar forcings; normalize dimension names
5. Fit normalization on training split only and train a climate-emulation model
6. Produce predictions for the held-out SSP245 test window
7. Serialize outputs: `.npy` arrays, `metadata.json`, and Kaggle-style CSV

Software: Python
xarray
numpy
pandas
PyTorch

Input files:
name: data.zarr
format: zarr
path: input/data.zarr/
description: Benchmark-safe CMIP6-derived Zarr store with held-out SSP245 test-window targets masked to NaN
name: metadata.json
format: json
path: input/metadata.json
description: Dataset shapes, coordinates, and normalization summary
name: output_contract.json
format: json
path: input/output_contract.json
description: Specifies required output file names, shapes, and formats
name: Starter.md
format: markdown
path: input/Starter.md
description: Step-by-step starter guide for the pipeline