Skip to content

Commit

Permalink
feat: define separate collections for each product, define GRIB layer…
Browse files Browse the repository at this point in the history
…s with byte ranges in 'grib:layers' asset metadata (#6)

* define collection + item + asset structure
* add grib:layers asset property for describing layers within GRIB2 files
  • Loading branch information
hrodmn committed Jun 20, 2024
1 parent 6f8c09b commit efa2d5c
Show file tree
Hide file tree
Showing 51 changed files with 282,397 additions and 981 deletions.
2 changes: 2 additions & 0 deletions .codespellignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pres
parm
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Steps to reproduce the behavior:

> Ex.
>
> 1. Install stactools-ephemeral
> 1. Install stactools-noaa-hrrr
> 2. Run `scripts/test`
> 3. See error
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.9", "3.10", "3.11", "3.12"]
defaults:
run:
shell: bash -l {0}
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,8 @@ dmypy.json

# Cython debug symbols
cython_debug/

scratch
.Trash-0
.virtual_documents

7 changes: 5 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ number as needed.

### Added

- Nothing.
- Initial package setup
- Collection creation
- Item creation
- `grib:layers` asset property for describing individual layers within a GRIB2 file

### Deprecated

Expand All @@ -25,4 +28,4 @@ number as needed.

- Nothing.

[Unreleased]: <https://github.com/stactools-packages/ephemeral/tree/main/>
[Unreleased]: <https://github.com/stactools-packages/noaa-hrrr/tree/main/>
2 changes: 1 addition & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
level of experience, education, socioeconomic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.

## Our Standards
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
This software is licensed under the Apache 2 license, quoted below.

Copyright 2022 COMPANY [COMPANY WEBPAGE URL]
Copyright 2024 Development Seed [https://developmentseed.org/]

Licensed under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance with the License. You may obtain a copy of
Expand Down
67 changes: 0 additions & 67 deletions README-template.md

This file was deleted.

147 changes: 124 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,124 @@
# stactools-template

This is a template repo used for creating new packages for `stactools`.

## How to use

1. Clone this template repository as your package name, e.g. `landsat`.
This name should be short, memorable, and a valid Python package name (i.e.
it shouldn't start with a number, etc). It can, however, include a hyphen, in
which case the name for Python imports will be the underscored version, e.g.
`landsat-8` goes to `stactools.landsat_8`. Your name will be used on PyPI to
publish the package in the stactools namespace, e.g. `stactools-landsat`.
2. Change into the top-level directory of your package and run `scripts/rename`.
This will update _most_ of the files in the repository with your new package name.
3. Update `pyproject.toml` with your package description and such.
4. Install with the development requirements (`pip install -e '.[dev]'`).
5. Update the LICENSE with your company's information (or whomever holds the copyright).
6. Edit or replace the existing functions to create stac Items and Collections
for your dataset.
7. Add example Items (and Collections and Catalogs, if included) to an
`examples/` directory.
8. Delete this file, and rename `README-template.md` to `README.md`. Update your
new README to provide information about how to use your package.
# stactools-noaa-hrrr

[![PyPI](https://img.shields.io/pypi/v/stactools-noaa-hrrr?style=for-the-badge)](https://pypi.org/project/stactools-noaa-hrrr/)
![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/stactools-packages/noaa-hrrr/continuous-integration.yml?style=for-the-badge)

- Name: noaa-hrrr
- Package: `stactools.noaa_hrrr`
- [stactools-noaa-hrrr on PyPI](https://pypi.org/project/stactools-noaa-hrrr/)
- Owner: @hrodmn
- [Dataset homepage](https://rapidrefresh.noaa.gov/hrrr/)
- STAC extensions used:
- [forecast](https://github.com/stac-extensions/forecast)
- [item-assets](https://github.com/stac-extensions/item-assets)
- [datacube](https://github.com/stac-extensions/datacube) (coming soon)
- Extra fields:
- `noaa-hrrr:forecast_cycle_type`: either standard (18-hour) or extended (48-hour)
- `noaa-hrrr:region`: either `conus` or `alaska`
- [Browse the example in human-readable form](https://radiantearth.github.io/stac-browser/#/external/raw.githubusercontent.com/stactools-packages/noaa-hrrr/main/examples/collection.json)
- [Browse a notebook demonstrating the example item and collection](https://github.com/stactools-packages/noaa-hrrr/tree/main/docs/example.ipynb)

A short description of the package and its usage.

## STAC examples

- [Collection](examples/collection.json)
- [Item](examples/item/item.json)

## Installation

Install `stactools-noaa-hrrr` with pip:

```shell
pip install stactools-noaa-hrrr
```

## Command-line usage

To create a collection object:

```shell
stac noaahrrr create-collection {region} {product} {cloud_provider} {destination_file}
```

e.g.

```shell
stac noaahrrr create-collection conus sfc azure example-collection.json
```

To create an item:

```shell
stac noaahrrr create-item \
{region} \
{product} \
{cloud_provider} \
{reference_datetime} \
{forecast_hour} \
{destination_file}
```

e.g.

```shell
stac noaahrrr create-item conus sfc azure 2024-05-01T12 10 example-item.json
```

To create all items for a date range:

```shell
stac noaahrrr create-item-collection \
{region} \
{product} \
{cloud_provider} \
{start_date} \
{end_date} \
{destination_folder}
```

e.g.

```shell
stac noaahrrr create-item-collection conus sfc azure 2024-05-01 2024-05-31 /tmp/items
```

### Docker

You can launch a jupyterhub server in a docker container with all of the
dependencies installed using these commands:

```shell
docker/build
docker/jupyter
```

Use `stac noaahrrr --help` to see all subcommands and options.

## Contributing

We use [pre-commit](https://pre-commit.com/) to check any changes.
To set up your development environment:

```shell
pip install -e '.[dev]'
pre-commit install
```

To check all files:

```shell
pre-commit run --all-files
```

To run the tests:

```shell
pytest -vv
```

If you've updated the STAC metadata output, update the examples:

```shell
scripts/update-examples
```
22 changes: 10 additions & 12 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,49 +9,47 @@ RUN conda update conda && \
FROM base as dependencies

ENV PATH="/opt/venv/bin:$PATH"
WORKDIR /opt/stactools-ephemeral
WORKDIR /opt/stactools-noaa-hrrr
COPY --from=base /opt/conda /opt/conda
COPY pyproject.toml ./
COPY src/stactools/ephemeral/__init__.py src/stactools/ephemeral/
COPY src/stactools/noaa_hrrr/__init__.py src/stactools/noaa_hrrr/
RUN apt-get -y -q update \
&& apt-get -y -q install build-essential \
&& rm -rf /var/lib/apt/lists/
RUN python -m venv /opt/venv
RUN pip install . \
&& ls /opt/venv \
&& rm -r /opt/venv/lib/python3.11/site-packages/stactools/ephemeral

&& ls /opt/venv/lib/ \
&& rm -r /opt/venv/lib/python3.12/site-packages/stactools/noaa_hrrr

FROM dependencies as builder

ENV PATH="/opt/venv/bin:$PATH"
WORKDIR /opt/stactools-ephemeral
WORKDIR /opt/stactools-noaa-hrrr
COPY --from=base /opt/conda /opt/conda
COPY --from=dependencies /opt/venv /opt/venv
COPY pyproject.toml ./
COPY src ./src
RUN pip install -U pip \
&& pip install .
WORKDIR /
RUN rm -rf /opt/stactools-ephemeral
CMD [ "stac", "ephemeralcmd" ]
RUN rm -rf /opt/stactools-noaa-hrrr
CMD [ "stac", "noaahrrr" ]


FROM dependencies as dev-dependencies

ENV PATH="/opt/venv/bin:$PATH"
WORKDIR /opt/stactools-ephemeral
WORKDIR /opt/stactools-noaa-hrrr
COPY --from=dependencies /opt/venv /opt/venv
COPY pyproject.toml .
RUN pip install -e '.[dev]' \
&& git init


FROM dev-dependencies as dev-builder

ENV PATH="/opt/venv/bin:$PATH"
WORKDIR /opt/stactools-ephemeral
WORKDIR /opt/stactools-noaa-hrrr
COPY --from=base /opt/conda /opt/conda
COPY --from=dependencies /opt/venv /opt/venv
COPY . .
CMD [ "stac", "ephemeralcmd" ]
CMD [ "stac", "noaahrrr" ]
4 changes: 2 additions & 2 deletions docker/build
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ if [ "${BASH_SOURCE[0]}" = "${0}" ]; then
usage
else
docker build $PULL \
-t stactools-packages/ephemeral:latest \
-t stactools-packages/noaa-hrrr:latest \
-f docker/Dockerfile \
--target builder \
.
docker build $PULL \
-t stactools-packages/ephemeral:dev \
-t stactools-packages/noaa-hrrr:dev \
-f docker/Dockerfile \
--target dev-builder \
.
Expand Down
5 changes: 3 additions & 2 deletions docker/cibuild
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ Runs CI in the docker dev container.

if [ "${BASH_SOURCE[0]}" = "${0}" ]; then
docker build $PULL \
-t stactools-packages/ephemeral:dev \
-t stactools-packages/noaa-hrrr:dev \
-f docker/Dockerfile \
--target dev-builder \
.
docker run --rm \
-e DOCKER=true \
--entrypoint scripts/cibuild \
stactools-packages/ephemeral:dev
stactools-packages/noaa-hrrr:dev
fi
4 changes: 2 additions & 2 deletions docker/console
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ Run a console in a docker container with all prerequisites installed.

if [ "${BASH_SOURCE[0]}" = "${0}" ]; then
docker run --rm -it \
-v "$(pwd)":/opt/stactools-ephemeral \
-v "$(pwd)":/opt/stactools-noaa-hrrr \
-p 8000:8000 \
--entrypoint /bin/bash \
stactools-packages/ephemeral:dev
stactools-packages/noaa-hrrr:dev
fi
Loading

0 comments on commit efa2d5c

Please sign in to comment.