# Format of the standardized monthly NPZ files

**Location:** `D:\ELTE\Nyári gyakorlat BT\egysegesitett_npz_1deg`

Each monthly file contains the same 23 keys. Files use the name `<DATASET>_monthly_YYYYMM.npz` and are stored under `<DATASET>/<YEAR>/`. Original source files were not modified. `conversion_manifest.csv` lists the source and destination of every converted file.

| Dataset | Monthly files | Period | `measurement` | `mean_daily_unit` | Source → output grid |
|---|---:|---|---|---|---|
| ENTH | 138 | 201501–202606 | `thunder_hours` | `TH/day` | 0.05° → 1° |
| WWLLN | 132 | 201501–202512 | `thunder_hours` | `TH/day` | 0.05° → 1° |
| GLM | 85 | 201802–202502 | `flash_density` | `flash/km2/day` | 1° → 1° |
| MTG | 24 | 202408–202607 | `flash_density` | `flash/km2/day` | 1° → 1° |
| GLD (GLD360) | 84 | 201901–202512 | `flash_density` | `flash/km2/day` | 1° → 1° |

## Keys and array shapes

Two-dimensional fields use **latitude × longitude** order and have shape **(180, 360)**. All datasets use the same 1° cell edges. Text fields are Unicode strings; their stored string width can vary by file. Date arrays have variable length.

| Key | Type | Shape | Meaning |
|---|---|---|---|
| `schema_version` | text | scalar | Format version (`1.0`). |
| `source_dataset` | text | scalar | Source dataset: ENTH, WWLLN, GLM, MTG, or GLD (GLD360). |
| `source_file` | text | scalar | Full path of the original NPZ file. |
| `year` | int32 | scalar | Calendar year. |
| `month` | int32 | scalar | Calendar month (1–12). |
| `days` | int32 | scalar | Divisor used for the daily mean; for GLD this is the calendar day count, not verified observed days. |
| `calendar_days` | int32 | scalar | Number of calendar days in the month. |
| `time_basis` | text | scalar | `UT` for ENTH/WWLLN; `unspecified_in_source` for GLM/MTG/GLD. |
| `date_coverage` | text | scalar | `day_count_only`, `explicit_dates`, or `monthly_aggregate_only` (GLD). |
| `available_dates` | text | variable-length 1D array | Available daily dates as `YYYY_MM_DD`; empty for ENTH/WWLLN (not provided) and GLD (actual daily coverage unknown). |
| `missing_dates` | text | variable-length 1D array | Known missing dates as `YYYY_MM_DD`; empty for ENTH/WWLLN and GLD because actual missing dates cannot be identified. |
| `latitude_edges` | float64 | (181,) | 1° latitude cell boundaries from −90° to +90°. |
| `longitude_edges` | float64 | (361,) | 1° longitude cell boundaries from −180° to +180°. |
| `latitude_centers` | float64 | (180,) | Latitude cell centers from −89.5° to +89.5°. |
| `longitude_centers` | float64 | (360,) | Longitude cell centers from −179.5° to +179.5°. |
| `source_grid_resolution_deg` | float32 | scalar | Source resolution: 0.05° for ENTH/WWLLN, 1° for GLM/MTG/GLD. |
| `output_grid_resolution_deg` | float32 | scalar | Output resolution: 1° for every dataset. |
| `spatial_aggregation` | text | scalar | `unweighted_mean_of_20x20_original_cells` or `native_1deg`. |
| `measurement` | text | scalar | `thunder_hours` or `flash_density`. |
| `monthly_total_unit` | text | scalar | Unit of `monthly_total`: `TH` or `flash/km2`. |
| `mean_daily_unit` | text | scalar | Unit of `mean_daily_value`: `TH/day` or `flash/km2/day`. |
| `monthly_total` | float32 | (180, 360) | Monthly total for each output cell; interpret it using `measurement` and `monthly_total_unit`. |
| `mean_daily_value` | float32 | (180, 360) | Daily mean for each output cell: `monthly_total / days`. |

## Conversion rules

**ENTH and WWLLN:** Each 1° cell covers 20 × 20 original 0.05° cells. `monthly_total` is the **arithmetic mean** of their monthly thunder-hour totals, rather than their sum. `mean_daily_value = monthly_total / days`, in TH/day. This spatial mean is not the number of hours when thunder occurred anywhere in the full 1° cell.

**GLM and MTG:** The source grid is already 1°. `monthly_total` is the sum of `daily_flash_density` over available days, in flash/km². `mean_daily_value` is that sum divided by `days`, in flash/km²/day. It was checked against the original `monthly_avg_daily_density` field.

**GLD (GLD360):** The source grid is already 1°. `monthly_total = monthly_total_flashes / cell_area_km2`, in flash/km². `days = calendar_days`, and `mean_daily_value = monthly_total / days`, in flash/km²/day. The converter verifies `monthly_total_flashes = monthly_cg_flashes + monthly_ic_flashes` and checks the resulting daily mean against the source `monthly_avg_daily_density`. Both output data arrays are float32, as for the other datasets.

The GLD `daily_flash_density` arrays repeat the monthly daily mean; `daily_flashes` repeats integer-truncated daily-mean counts. Summing the latter would lose flashes. These arrays are not actual daily observations and are not used for conversion. The source date list must match the calendar month but is not evidence of daily measurement availability. GLD therefore uses `date_coverage = monthly_aggregate_only`, empty `available_dates` and `missing_dates`, and `time_basis = unspecified_in_source`. Zero known missing dates in the manifest does not prove complete coverage. CG/IC counts and the source date list remain available in the original file referenced by `source_file`.

**The common keys do not imply common physical units.** TH/day and flash/km²/day measure different quantities and must be interpreted separately.

ENTH and WWLLN provide only a day count, so empty `available_dates` and `missing_dates` arrays do **not** prove full daily coverage. GLM and MTG provide explicit daily dates. ENTH and WWLLN specify UT; the GLM and MTG source files do not specify a time basis.

## Python reading example

```python
import numpy as np

with np.load(path, allow_pickle=False) as data:
    print(data.files)
    print(data["mean_daily_value"].shape)  # (180, 360)
    print(data["mean_daily_unit"].item())   # TH/day
```
