Skip to main content
Loading navigation

Build a Reanalysis Heatwave Parametric Trigger Simulator — implementation

Prompt source

implementation73 lines11 sectionsNo variables1 code block
## Build
Simulate parametric heat index trigger performance for agricultural contracts using ERA5 reanalysis thermal datasets. Model historical trigger frequencies and calculate simulated seasonal payouts.

## User
Parametric Product Structurer

## Workflow
1. Define parametric trigger rules with temperature thresholds and duration days.
2. Retrieve ERA5 daily temperature series via Copernicus CDS client scripts.
3. Calculate continuous degree-day exceedances over contract active windows.
4. Output simulated trigger events with uncertainty intervals for actuary review.

## Interface
Jupyter Notebook interface with parametric trigger configuration and exceedance plot charts.

## Data
Execute CDS API queries for ERA5 reanalysis pressure levels or use cached mock NetCDF/GRIB temperature records.
Starter examples below are synthetic. They are not downloaded records.

## Source
[Copernicus Climate Data Store client](https://raw.githubusercontent.com/ecmwf/cdsapi/master/README.rst)
Leverages the CDS API retrieval parameter structure (variable, product_type, date, format) for reanalysis-era5 datasets.

## Tools
mlflow, cdsapi, xarray, numpy.
MLflow tracks simulation run parameters, threshold variants, and payout distribution metrics across trial batches.
Local numeric compute environment with optional local LLM to summarize simulation run parameters.

## Deliverables
Submit runnable source, pinned dependencies, setup commands, a working interface, example outputs, and a recorded end-to-end demo. Include tests and an action log.

## Acceptance
- Properly constructs CDS API retrieval request dictionaries.
- Identifies consecutive days exceeding the specified parametric trigger threshold.
- Calculates simulated payout percentage without creating real policy liabilities.

## Starter Examples
```json
[
  {
    "input": {
      "contract_id": "PAR-HEAT-2024",
      "threshold_temp_k": 308.15,
      "duration_days": 3,
      "series": [
        309,
        308.5,
        309.2,
        305
      ]
    },
    "expected_output": {
      "contract_id": "PAR-HEAT-2024",
      "triggered": true,
      "consecutive_exceedance": 3,
      "simulated_payout_pct": 100
    }
  },
  {
    "input": {
      "contract_id": "PAR-HEAT-2025",
      "threshold_temp_k": 310,
      "duration_days": 3,
      "series": [
        309,
        308.5,
        307,
        306
      ]
    },
    "expected_output": {
      "contract_id": "PAR-HEAT-2025",
      "triggered": false,
      "consecutive_exceedance": 0,
      "simulated_payout_pct": 0
    }
  }
]
```

## Safety
Outputs simulated parametric scenarios only; explicitly disclaims commercial policy underwriting validity.
Use mock external writes. Require human review before any real deployment.