# Kothagudem Rainfall Log Analyzer

## PURPOSE
A command-line tool (Click + Pandas) that reads a CSV of daily weather observations for Bhadradri Kothagudem district and summarises rain, temperature dip, and thunder days, then flags the two-day windows that match the news bulletin: sudden cooling plus light rain that threatens harvesting-stage crops. It gives an agriculture officer a quick, reproducible report from raw station logs instead of eyeballing a spreadsheet.

## WHY THIS MATTERS
The video is a short warning built on data: cooling weather, thunder and lightning for the next two days, and light rain in "several places". This project teaches that a warning is only credible when it is traceable to records — so students learn to compute the summary statistics (rain totals, temperature change, thunder-day counts) that justify an advisory, and to segment them by place.

## HOW TO BUILD
1. Define the expected columns: `date`, `place`, `rain_mm`, `temp_c`, `thunder`.
2. With Click, accept `--input`, `--place`, and `--harvest-window` (days) options, and a `summary` and `risk` subcommand.
3. Use Pandas to group by `place`, sum `rain_mm`, count thunder days, and compute the day-over-day temperature drop.

```python
import click, pandas as pd

@click.command()
@click.option("--input", "path", required=True)
@click.option("--harvest-window", default=2, type=int)
def risk(path: str, harvest_window: int) -> None:
    df = pd.read_csv(path, parse_dates=["date"])
    df["drop"] = df.groupby("place")["temp_c"].diff().fillna(0)
    wet = df[(df["rain_mm"] > 0) & (df["thunder"])]
    click.echo(f"{len(wet)} thunder-and-rain day(s) across {df['place'].nunique()} place(s)")
```

## WHEN TO USE IN PRODUCTION
Use it as a nightly cron job producing a text/CSV report for an extension office, or inside a larger pipeline that emits advisories. Do NOT use it for real-time streaming observations, for sub-daily data, or as the sole basis for an emergency broadcast — it is an offline summariser over historical logs.

## HOW IT HELPS STUDENTS
Students gain hands-on skill with Click option parsing, Pandas groupby/aggregation, date handling, and turning a domain question ("was the harvest threatened?") into concrete filters. They also learn to design a tool usable by a non-programmer via flags, and to keep output deterministic for testing.

## STARTER CODE
See `starter/main.py` for a Click CLI with `summary` and `risk` commands, a deterministic sample-data fallback, and `# TODO` markers for extra metrics.
