Skip to content

Commit e322670

Browse files
committed
update READMEs and clean
1 parent 428aed1 commit e322670

File tree

7 files changed

+61
-47
lines changed

7 files changed

+61
-47
lines changed

README.md

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,18 @@
66
[![contributors badge](https://img.shields.io/github/contributors/openclimatefix/cloudcasting-app?color=FFFFFF)](https://github.com/openclimatefix/cloudcasting-app/graphs/contributors)
77
[![ease of contribution: hard](https://img.shields.io/badge/ease%20of%20contribution:%20hard-bb2629)](https://github.com/openclimatefix#how-easy-is-it-to-get-involved)
88

9-
This repo is used to run the OCF-ATI cloudcasting model live in production. This model takes
10-
previous frames of EUMETSAT satellite images and forecasts the future frames to come.
9+
This repo is used to run the OCF-ATI cloudcasting model live in production and meausure its
10+
performance. The model takes previous frames of EUMETSAT satellite images and forecasts the future
11+
frames to come.
1112

12-
The repo associated with training the models run here is https://github.com/openclimatefix/sat_pred
13-
14-
The model checkpoints are hosted at:
15-
https://huggingface.co/openclimatefix/cloudcasting_uk
16-
17-
## Environment Variables
18-
19-
The following environment variables are used in the app:
20-
21-
- `SATELLITE_ZARR_PATH`: The path to the satellite data in Zarr format.
22-
- `OUTPUT_PREDICTION_DIRECTORY`: The directory where results are saved.
23-
24-
### Optional Environment Variables
25-
26-
- `SATELLITE_SCALE_FACTOR`: The scale factor for the satellite data. Defaults to 1023.
27-
- `SATELLITE_15_ZARR_PATH`: The path to the 15 minute satellite data in Zarr format. If
28-
this is not set then the `SATELLITE_ZARR_PATH` is used by `.zarr` is repalced with `_15.zarr`
13+
This repo contains two different packages:
14+
- `cloudcasting_app`: Used to run inference
15+
- `cloudcasting_metrics`: Used to score the predictions against ground truth
2916

3017
## Installation
3118

19+
Both packages will be installed simultaneously using
20+
3221
## Setup / Installation
3322

3423
```bash
@@ -38,22 +27,21 @@ pip install .
3827
```
3928

4029

41-
## Example usage
30+
## Usage and environmental variables
4231

43-
### Running the app locally
44-
45-
It is possbile to run the app locally by setting the required environment variables listed at the top of the [app](src/cloudcasting_app/app.py), these should point to the relevant paths for loading satellite data
46-
and saving predicitons.
32+
See the READMEs in `src/cloudcasting_app` and `src/cloudcasting_metrics`.
4733

4834
## Development
4935

5036
### Running the test suite
5137

52-
The test suite is via pytest and can be run from command line using
38+
The test suite is via pytest and can be run from command line using.
5339

5440
```
5541
pytest
5642
```
43+
44+
This will run tests for both packages.
5745

5846

5947
## Contributing and community

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ dependencies = [
3636
"torchvision @ https://download.pytorch.org/whl/cpu/torchvision-0.18.1-cp312-cp312-macosx_11_0_arm64.whl ; platform_system == 'Darwin' and platform_machine == 'arm64'",
3737
"torch @ https://download.pytorch.org/whl/cpu/torch-2.3.1%2Bcpu-cp312-cp312-linux_x86_64.whl ; platform_system == 'Linux' and platform_machine == 'x86_64'",
3838
"torchvision @ https://download.pytorch.org/whl/cpu/torchvision-0.18.1%2Bcpu-cp312-cp312-linux_x86_64.whl ; platform_system == 'Linux' and platform_machine == 'x86_64'",
39-
"typer==0.15.1",
4039
"xarray==2025.7.1",
4140
"zarr==3.1.1",
4241
]
@@ -53,7 +52,8 @@ dev = [
5352

5453
[project.scripts]
5554
# Put entrypoints in here
56-
cloudcasting-app = "cloudcasting_app.app:main"
55+
cloudcasting-app = "cloudcasting_app.app:app"
56+
cloudcasting-metrics = "cloudcasting_metrics.app:app"
5757

5858
[project.urls]
5959
repository = "https://github.com/openclimatefix/cloudcasting-app"

src/cloudcasting_app/README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# cloudcasting-app
2+
3+
This package is used to run inference on the model. This model takes previous frames of EUMETSAT
4+
satellite images and forecasts the future frames to come.
5+
6+
The repo associated with training the models run here is https://github.com/openclimatefix/sat_pred
7+
8+
The model checkpoints are hosted at:
9+
https://huggingface.co/openclimatefix/cloudcasting_uk
10+
11+
## Environment Variables
12+
13+
The following environment variables are used in the app:
14+
15+
- `SATELLITE_ZARR_PATH`: The path to the satellite data in Zarr format.
16+
- `PREDICTION_SAVE_DIRECTORY`: The directory where predictions will be saved.
17+
18+
### Optional Environment Variables
19+
20+
- `SATELLITE_15_ZARR_PATH`: The path to the 15 minute satellite data in Zarr format. If
21+
this is not set then the `SATELLITE_ZARR_PATH` is used by `.zarr` is repalced with `_15.zarr`
22+
23+
## Example usage
24+
25+
### Running the app locally
26+
27+
It is possbile to run the app locally by setting the required environment variables listed at the
28+
top of the [app](src/cloudcasting_app/app.py), these should point to the relevant paths for loading
29+
satellite data and saving predicitons.

src/cloudcasting_app/__init__.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,4 @@ def structured_formatter(record: "loguru.Record") -> str:
4343
loguru.logger.add(
4444
sys.stdout, format=structured_formatter, backtrace=True,
4545
level=os.getenv("LOGLEVEL", "INFO").upper(),
46-
)
47-
48-
# Uncomment and change the list to quieten external libraries
49-
# for logger in ["aiobotocore", "cfgrib"]:
50-
# logging.getLogger(logger).setLevel(logging.WARNING)
51-
46+
)

src/cloudcasting_app/app.py

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
This app expects these environmental variables to be available:
44
SATELLITE_ZARR_PATH (str): The path of the input satellite data
5-
OUTPUT_PREDICTION_DIRECTORY (str): The path of the directory to save the predictions to
5+
PREDICTION_SAVE_DIRECTORY (str): The path of the directory to save the predictions to
66
"""
77

88
import os
@@ -12,7 +12,6 @@
1212
import hydra
1313
import pandas as pd
1414
import torch
15-
import typer
1615
import xarray as xr
1716
import yaml
1817
from huggingface_hub import snapshot_download
@@ -33,13 +32,11 @@
3332
# Model will use GPU if available
3433
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
3534

36-
3735
# Model revision on huggingface
3836
REPO_ID = "openclimatefix/cloudcasting_uk"
3937
REVISION = "47643e89000e64e0150f7359ccc0cb6524948712"
4038

4139

42-
4340
def app(t0=None):
4441
"""Inference function for production
4542
@@ -123,7 +120,7 @@ def app(t0=None):
123120
ds_y_hat.sat_pred.attrs.update(ds.data.attrs)
124121

125122
# Save predictions to the latest path and to path with timestring
126-
out_dir = os.environ["OUTPUT_PREDICTION_DIRECTORY"]
123+
out_dir = os.environ["PREDICTION_SAVE_DIRECTORY"]
127124

128125
if satellite_downloader.use_5_minute:
129126
latest_zarr_path = f"{out_dir}/latest.zarr"
@@ -141,11 +138,3 @@ def app(t0=None):
141138
fs.rm(path, recursive=True)
142139

143140
ds_y_hat.to_zarr(path)
144-
145-
146-
def main() -> None:
147-
"""Entrypoint to the application."""
148-
typer.run(app)
149-
150-
if __name__ == "__main__":
151-
main()

src/cloudcasting_metrics/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# cloudcasting-metrics
2+
3+
This package is used to score the predictions made by the model. By default, the scoring is run for
4+
all init-times made the day before.
5+
6+
## Environment Variables
7+
8+
The following environment variables are used in the app:
9+
10+
- `SATELLITE_ICECHUNK_ARCHIVE`: The path to the satellite archive in icechunk formast
11+
- `PREDICTION_SAVE_DIRECTORY`: The directory where the cloudcasting predictions are saved.
12+
i.e. set to the same as `PREDICTION_SAVE_DIRECTORY` in `cloudcasting_app`.
13+
- `METRIC_ZARR_PATH`: Where to save metrics zarr

tests/test_cloudcasting_app/test_app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def test_app(sat_5_data, tmp_path, init_time):
1414
# In production sat zarr is zipped
1515
os.environ["SATELLITE_ZARR_PATH"] = "temp_sat.zarr.zip"
1616

17-
os.environ["OUTPUT_PREDICTION_DIRECTORY"] = f"{tmp_path}"
17+
os.environ["PREDICTION_SAVE_DIRECTORY"] = f"{tmp_path}"
1818

1919
with zarr.storage.ZipStore("temp_sat.zarr.zip", mode="x") as store:
2020
sat_5_data.to_zarr(store)

0 commit comments

Comments
 (0)