File size: 11,970 Bytes
f175517
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
# Additional inputs for satellite cloud learning

## Recommendation and project context

Start with ERA5 temperature and humidity profiles, then test dynamics and additional
satellite channels separately. This is a proposed historical reconstruction experiment;
no change to the training pipeline is included in this download task.

The local folders are `ir10.5`, `vis0.6`, and `vfms`. They contain 2,168 IR PNGs,
1,252 visible PNGs, and 766 ATL09 HDF5 files (including multiple product releases).
IR coverage is 2024-11-01 through 2025-09-11. The downloader and training dataset
use 25–40°N, 24–43°E. Labels describe cloud occurrence, layer count and heights
along the three ICESat-2 beams. The current dataset can include earlier image frames
and latitude/longitude channels.

Two approaches are useful:

* **ERA5 historical context (implemented):** consistent archive covering this dataset,
  hourly fields on a 0.25° grid. Good for testing whether atmospheric structure
  improves cloud reconstruction. ERA5 is a reanalysis that assimilates observations;
  it is not a forecast available at the image acquisition time.
* **Archived operational forecasts (future work):** needed to reproduce real-time
  inference. Select a forecast cycle actually available before each image, retaining
  initialization time, lead time and valid time. This needs a separate archive and
  availability audit for 2024–2025, not merely a current forecast downloader.

ERA5's nominal atmospheric model resolution is about 31 km; the CDS grid is 0.25°.
It provides atmospheric context, not resolved cloud structure at satellite pixel scale.
Sources: [ERA5 pressure-level dataset](https://cds.climate.copernicus.eu/datasets/reanalysis-era5-pressure-levels),
[ECMWF ERA5 description](https://www.ecmwf.int/en/forecasts/dataset/ecmwf-reanalysis-v5).

## Prioritized features

| Priority | Inputs | Purpose / source |
| --- | --- | --- |
| First | Temperature, relative humidity, specific humidity, geopotential at pressure levels | Thermal structure, moisture and height correspondence; ERA5 pressure levels |
| First | Surface pressure, 2 m temperature/dewpoint, skin temperature, boundary-layer height | Below-ground masking, near-surface saturation and low-cloud environment; ERA5 single levels |
| First | Surface geopotential and land/sea fraction | Terrain/coastal context; included in single-level download |
| Next | Horizontal wind components and pressure vertical velocity | Advection, shear and ascent; script's `--dynamics` option |
| Next | Solar zenith angle, cyclic local solar time/day of year, satellite viewing angle | Illumination and viewing geometry; derive from time, location and satellite geometry |
| Next | FCI water-vapour 6.3/7.3 µm, IR 8.7/12.3/13.3 µm, NIR 1.6/2.2 µm and IR 3.8 µm | Test moisture, phase and cloud-height-sensitive spectral information; acquire calibrated FCI products |
| Later | Higher-resolution DEM, sea-surface temperature, CAPE and total-column water vapour | Evaluate additional terrain, stability and moisture context after the core ablation |

The channel proposal is based on the instrument and retrieval description in
[EUMETSAT's FCI Optimal Cloud Analysis ATBD](https://user.eumetsat.int/s3/eup-strapi-media/pdf_mtg_atbd_oca_b1ba8fc34c.pdf).
Actual historical product access and channel coverage must be checked before building
that downloader. Current WMS PNG values are rendered image intensities; do not treat
them as Kelvin or calibrated reflectance. Physical Level-1 products would allow
meaningful brightness-temperature differences and temperature-profile comparisons.

Default pressure levels, in hPa:
`1000 975 950 925 900 850 800 700 600 500 400 300 250 200 150 100`.
These emphasize the lower troposphere while spanning upper-tropospheric clouds.
Add intermediate levels (e.g. 750, 650, 550, 350, 225, 175, 125) if height performance
justifies the larger feature set. Pressure levels are not fixed altitudes.

Do not include ATL09 cloud flags, layer heights or confidence flags as input features:
they are labels or label-quality metadata unavailable away from the tracks. Keep
model cloud fraction/liquid/ice fields as a separate, explicitly named model-assisted
baseline rather than mixing them into the first environmental experiment.

## Download

The script uses the two CDS datasets above and
[ERA5 single levels](https://cds.climate.copernicus.eu/datasets/reanalysis-era5-single-levels).
No credentials are needed to prepare the complete manifest:

```bash
python download_era5.py --dry-run
```

Default source discovery unions timestamps from both image folders and deduplicates
them. It already includes the earlier frames present on disk. It does not validate
PNG content or restrict the inventory to matched/quality-approved training granules.
Use `--dates-json` with approved sample dates to narrow the download further.

For the present inventory the dry run produces **1,440 hourly grids and 626 requests**
(two requests per selected day). At 61 × 77 grid points, 16 levels, four profile
variables and seven surface variables, the fields represent approximately **1.92 GB
of float32 values** before GRIB compression and metadata. This is a planning estimate,
not a measured transfer size; CDS queue time may dominate. Avoid concurrent runs
writing the same output directory.

Follow the official [CDS API setup](https://cds.climate.copernicus.eu/how-to-api):
create an account, accept each dataset's terms on its download page, and put the
personal token in `~/.cdsapirc`:

```yaml
url: https://cds.climate.copernicus.eu/api
key: YOUR_PERSONAL_ACCESS_TOKEN
```

Install the client in your project environment and try one day before the full run:

```bash
python -m pip install 'cdsapi>=0.7.7'
python download_era5.py --start 2024-11-01 --end 2024-11-01
python download_era5.py
# Optional experiment with the additional profile variables:
python download_era5.py --dynamics
```

Other selections:

```bash
python download_era5.py --dates-json dates.json --offsets-minutes 0 -15 -30 -45 --dry-run
python download_era5.py --levels 1000 925 850 700 500 300 200 100 --dry-run
python download_era5.py --area 40 24 25 43 --output ./era5 --dry-run
```

Dates JSON follows the existing downloader's unusual ordering:
`[[year, day, month, hour, minute], ...]`, in UTC. Date filters select source samples
inclusively, not every hour of a continuous date range. Offsets and bracketing can
request the adjacent day outside the filter. Image paths default relative to the
script, independent of the shell working directory.

Each request fetches only the required hours for one day and a regional subset.
Files use native GRIB with JSON receipts and SHA-256 checksums. Request-specific
filenames prevent changed variables/levels/areas from silently reusing old files.
Interrupted transfers are not published; rerunning verifies completed files and
retries incomplete work. A failure stops the run with a nonzero exit status.
GRIB header/trailer checks detect basic transfer errors; ingestion must additionally
verify expected variables, levels, timestamps and coordinates. Changed time selections
can produce overlapping files: deduplicate valid times during ingestion.

## Alignment and experiment plan

1. **Time:** interpolate between the surrounding ERA5 hours at each image or beam
   observation time. The script requests floor/ceiling hours, including midnight
   rollover. For final track-level matching, retain each profile's actual timestamp;
   a filename start time or whole-granule mean is only an approximation. Audit the
   ATL09 GPS-to-UTC conversion against the product metadata before integration.
   If beam times exceed the image-time coverage, supply their times in a manifest too.
2. **Space:** bilinearly sample ERA5 at track coordinates, or interpolate to each
   satellite patch. Preserve north/south orientation and use coordinates, not assumed
   array indices. Prefer a coarse context encoder or patch-level feature vector over
   expanding every weather field to a full 4096² image. Upsampling adds no information.
3. **Vertical coordinates and units:** preserve temperature in K, RH in percent,
   specific humidity in kg/kg, winds in m/s, omega in Pa/s and pressure in Pa.
   Mask pressure levels where `level_hPa * 100 > surface_pressure` and provide the
   mask to the model. Convert geopotential to geopotential height with `z / 9.80665`;
   reconcile geometric/geopotential height and ATL09's vertical reference before
   comparing to cloud height. Use surface elevation when constructing AGL features.
   Keep missingness explicit. Do not blindly clamp ice-supersaturated RH to 100%.
4. **Derived features:** test temperature lapse rates, humidity maxima, wind shear,
   freezing-level height and lifting-condensation-level estimates after raw profiles.
   Fit normalization only on the training split. Missing/nighttime visible imagery
   needs an explicit mask; darkness is not evidence of clear sky.
5. **Ablations:** compare satellite-only; satellite + T/RH/geopotential; plus q and
   surface features; plus dynamics; plus extra spectral channels. Also train a
   weather-only baseline to quantify how much skill comes from meteorological context.
   Keep samples and splits identical across experiments.
6. **Evaluation:** split by contiguous days/orbits with a temporal gap, deduplicate
   ATL09 releases, and keep all neighboring frames of a sample in one split. The
   existing every-fifth-granule split can share weather systems across partitions.
   Report cloud precision/recall, height MAE/bias conditional on valid cloudy labels,
   and results by altitude, day/night and season. Quality/attenuation flags should
   control supervision; an obscured lower layer is not necessarily clear sky.

ERA5 uses retrospective information; even choosing only the preceding hour does
not make it an operationally available input. Any claim about real-time performance
requires a separate test using forecasts available at the actual inference time.

Offline checks: `python -m unittest -v test_download_era5.py`.
A live CDS download and scientific field inspection remain required after setup.

## Complete date range, all hours

`download_era5_all_hours.py` implements the complete-range request: every date from
2024-11-01 through 2025-09-11 inclusive, at all 24 UTC hours (7,560 timestamps).
It uses the same study area and 16 pressure levels, with all seven profile variables
(temperature, relative/specific humidity, geopotential, U/V wind and vertical velocity).
The seven surface variables listed above are included as separate single-level jobs.
This selection includes dates and hours without a local VFM observation.

```bash
python download_era5_all_hours.py --dry-run  # Prepare era5_all_hours/requests.json
python download_era5_all_hours.py            # Submit and download; rerun to resume
```

The manifest contains 154 requests, each covering one month and one parameter:
seven pressure-level and seven surface requests per month. Each pressure-level
request contains at most 11,904 fields (31 days × 24 hours × 16 levels), below the
120,000-field limit documented in the
[CDS documentation](https://confluence.ecmwf.int/pages/viewpage.action?pageId=656872232).
The prepared manifest has been checked offline for complete date coverage, valid
calendar dates, all hours, 16 levels and seven profile variables; it has not been
submitted to CDS as part of preparing the request.

Run `./download_era5_monthly.sh` to process each month separately. Add `--dry-run`
to prepare the 11 monthly manifests without submitting requests. Each parameter
is saved to its own GRIB file. Failed parameters are reported while remaining
parameters and months continue; rerunning verifies and skips completed files.
September still ends on September 11. Existing combined-variable files are retained,
but the new parameter-specific requests download their own files.