Skip to content

Commit

Permalink
Merge pull request #1 from ClimeTrend/fix-errs
Browse files Browse the repository at this point in the history
Add back working download script
  • Loading branch information
phinate authored Jul 17, 2024
2 parents 3ec6514 + 5269961 commit 7969d79
Show file tree
Hide file tree
Showing 11 changed files with 486 additions and 25 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [3.10, 3.12] # test oldest and latest supported versions
python-version: ["3.10", "3.12"] # test oldest and latest supported versions
runs-on: [ubuntu-latest] # can be extended to other OSes, e.g. [ubuntu-latest, macos-latest]

steps:
Expand All @@ -43,7 +43,7 @@ jobs:
allow-prereleases: true

- name: Install package
run: python -m pip install .[test]
run: python -m pip install .[dev]

- name: Test package
run: >-
Expand Down
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,10 @@ repos:
args: []
additional_dependencies:
- pytest
- xarray
- pandas-stubs
- types-all
- typer
- dask
- pyproj
- pyresample
79 changes: 74 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,87 @@ Tooling and infrastructure to enable cloud nowcasting.

## Installation

From source (development mode):
```bash
python -m pip install cloudcast
git clone https://github.com/climetrend/cloudcast
cd cloudcast
python -m pip install ".[dev]"
```

From source:
Install pre-commit before making development changes:

```bash
git clone https://github.com/climetrend/cloudcast
cd cloudcast
python -m pip install .
pre-commit install
```

For making changes, see the [guidance on development](https://github.com/alan-turing-institute/python-project-template?tab=readme-ov-file#setting-up-a-new-project) from the template that generated this project.

## Usage
```bash
 cloudcast download --help

Usage: cloudcast download [OPTIONS] START_DATE END_DATE OUTPUT_DIRECTORY

Download a selection of the available EUMETSAT data.
Each calendar year of data within the supplied date range will be saved to a
separate file in the output directory.
Args: start_date: First datetime (inclusive) to download. end_date: Last
datetime (inclusive) to download. data_inner_steps: Data will be sliced into
data_inner_steps*5minute chunks. output_directory: Directory to which the
satellite data should be saved. lon_min: The west-most longitude (in
degrees) of the bounding box to download. lon_max: The east-most longitude
(in degrees) of the bounding box to download. lat_min: The south-most
latitude (in degrees) of the bounding box to download. lat_max: The
north-most latitude (in degrees) of the bounding box to download. get_hrv:
Whether to download the HRV data, else non-HRV is downloaded.
override_date_bounds: Whether to override the date range limits.
Raises: FileNotFoundError: If the output directory doesn't exist.
ValueError: If there are issues with the date range or if output files already
exist.
╭─ Arguments ────────────────────────────────────────────────────────────────────╮
│ * start_date TEXT Start date in 'YYYY-MM-DD HH:MM' format │
│ [default: None] │
│ [required] │
│ * end_date TEXT End date in 'YYYY-MM-DD HH:MM' format │
│ [default: None] │
│ [required] │
│ * output_directory TEXT Directory to save the satellite data │
│ [default: None] │
│ [required] │
╰────────────────────────────────────────────────────────────────────────────────╯
╭─ Options ──────────────────────────────────────────────────────────────────────╮
│ --data-inner-steps INTEGER Data will be sliced │
│ into │
│ data_inner_steps*5mi… │
│ chunks │
│ [default: 3] │
│ --get-hrv --no-get-hrv Whether to download │
│ HRV data │
│ [default: no-get-hrv] │
│ --override-date-boun… --no-override-date… Whether to override │
│ date range limits │
│ [default: │
│ no-override-date-bou… │
│ --lon-min FLOAT Minimum longitude │
│ [default: -16] │
│ --lon-max FLOAT Maximum longitude │
│ [default: 10] │
│ --lat-min FLOAT Minimum latitude │
│ [default: 45] │
│ --lat-max FLOAT Maximum latitude │
│ [default: 70] │
│ --help Show this message and │
│ exit. │
╰────────────────────────────────────────────────────────────────────────────────╯
```
Example:
```bash
cloudcast download "2020-06-01 00:00" "2020-06-30 23:55" "path/to/my/dir/data.zarr"
```
## Contributing
Expand Down
123 changes: 123 additions & 0 deletions notebooks/plotting.ipynb

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions notebooks/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ipykernel
matplotlib
seaborn
47 changes: 30 additions & 17 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,18 +1,7 @@
[build-system]
requires = ["setuptools>=61"]
build-backend = "setuptools.build_meta"
license = "MIT"
description = "Tooling and infrastructure to enable cloud nowcasting."
readme = "README.md"

classifiers = [
"Development Status :: 1 - Planning",
"Intended Audience :: Science/Research",
"Intended Audience :: Developers",
"Operating System :: OS Independent",
"Topic :: Scientific/Engineering",
"Typing :: Typed",
]

[project]
name = "cloudcast"
Expand All @@ -32,22 +21,33 @@ classifiers = [
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Scientific/Engineering",
"Typing :: Typed",
]
dependencies = []

dependencies = [
"gcsfs",
"zarr",
"xarray",
"dask",
"pyresample",
"pyproj",
"ocf-blosc2",
"typer"
]
[project.optional-dependencies]
dev = [
"pytest >=6",
"pytest-cov >=3",
"pre-commit",

]

[project.scripts]
cloudcast = "cloudcast.cli:app"

[project.urls]
Homepage = "https://github.com/climetrend/cloudcast"
"Bug Tracker" = "https://github.com/climetrend/cloudcast/issues"
Expand Down Expand Up @@ -75,7 +75,7 @@ port.exclude_lines = [
]

[tool.mypy]
files = ["src", "tests"]
files = ["src"]
python_version = "3.10"
show_error_codes = true
warn_unreachable = true
Expand All @@ -90,10 +90,23 @@ module = "cloudcast.*"
disallow_untyped_defs = true
disallow_incomplete_defs = true

[[tool.mypy.overrides]]
module = [
"ocf_blosc2",
]
ignore_missing_imports = true

[[tool.mypy.overrides]]
module = [
"cloudcast.download",
"cloudcast.cli",
]
disallow_untyped_calls = false

[tool.ruff]
src = ["src"]
exclude = []
line-length = 88 # how long you want lines to be
line-length = 100 # how long you want lines to be

[tool.ruff.format]
docstring-code-format = true # code snippets in docstrings will be formatted
Expand Down Expand Up @@ -128,4 +141,4 @@ unfixable = [
"F401", # Would remove unused imports
"F841", # Would remove unused variables
]
flake8-unused-arguments.ignore-variadic-names = true # allow unused *args/**kwargsisort.required-imports = ["from __future__ import annotations"]
flake8-unused-arguments.ignore-variadic-names = true # allow unused *args/**kwargs
4 changes: 3 additions & 1 deletion src/cloudcast/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@

from importlib.metadata import version

__all__ = ("__version__",)
from cloudcast import cli, download

__all__ = ("__version__", "download", "cli")
__version__ = version(__name__)
3 changes: 3 additions & 0 deletions src/cloudcast/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from cloudcast.cli import app

app()
8 changes: 8 additions & 0 deletions src/cloudcast/cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import typer

from cloudcast.download import download_satellite_data

# typer app code
app = typer.Typer()
app.command("download")(download_satellite_data)
app.command("validate")(lambda x: x) # placeholder
Loading

0 comments on commit 7969d79

Please sign in to comment.