Metadata-Version: 2.5
Name: biomassage
Version: 2026.11.24
Summary: CLI and Python package to query and download BIOMASS L1B products from MAAP
Project-URL: Homepage, https://github.com/umr-lops/biomassage
Project-URL: Repository, https://github.com/umr-lops/biomassage
Project-URL: Issues, https://github.com/umr-lops/biomassage/issues
Author-email: Antoine Grouazel <antoine.grouazel@ifremer.fr>
License-Expression: MIT
License-File: LICENSE
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Scientific/Engineering
Classifier: Typing :: Typed
Requires-Python: >=3.10
Requires-Dist: boto3
Requires-Dist: cartopy
Requires-Dist: folium
Requires-Dist: geodatasets
Requires-Dist: geopandas
Requires-Dist: maap-py
Requires-Dist: matplotlib
Requires-Dist: numpy
Requires-Dist: pandas
Requires-Dist: pyarrow
Requires-Dist: pystac-client
Requires-Dist: pyyaml
Requires-Dist: requests
Requires-Dist: s3fs
Requires-Dist: shapely
Requires-Dist: tqdm
Provides-Extra: dev
Requires-Dist: black; extra == 'dev'
Requires-Dist: coverage; extra == 'dev'
Requires-Dist: isort; extra == 'dev'
Requires-Dist: mypy; extra == 'dev'
Requires-Dist: pytest; extra == 'dev'
Requires-Dist: pytest-cov; extra == 'dev'
Requires-Dist: regionmask; extra == 'dev'
Requires-Dist: ruff; extra == 'dev'
Provides-Extra: docs
Requires-Dist: furo; extra == 'docs'
Requires-Dist: myst-parser; extra == 'docs'
Requires-Dist: sphinx; extra == 'docs'
Description-Content-Type: text/markdown

# biomassage

<div align="center">

[![Python Version](https://img.shields.io/pypi/pyversions/biomassage.svg)](https://pypi.org/project/biomassage/)
[![License](https://img.shields.io/github/license/umr-lops/biomassage)](https://github.com/umr-lops/biomassage/blob/main/LICENSE)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)

`biomassage` is a Python CLI and package to query, filter, and visualise BIOMASS L1B products from the MAAP STAC catalog.

</div>

## Overview

BIOMASS is an ESA Earth Explorer mission with a P‑band SAR. This tool helps you:

- **Query** the MAAP STAC API for BIOMASS L1B Detected Ground Multi‑look (DGM) footprints.
- **Filter** by temporal range, bounding box, WKT polygon, and sea‑coverage percentage.
- **Cache** results as GeoPackage (`.gpkg`) with sidecar JSON metadata (including the land mask).
- **Visualise** the footprints on a map and generate daily bar charts with mission timeline overlays.

All scripts are designed to be used both interactively and in batch processing.

## Installation

Clone the repository and install in development mode:

```bash
git clone https://github.com/umr-lops/biomassage.git
cd biomassage
pip install -e .
```

> **Note** : The package uses `hatchling` as the build backend. Dependencies are listed in `pyproject.toml`.

## Usage

The tool consists of two main scripts.

### 1. `biomass_download.py` – Query and filter metadata

```bash
python biomass_download.py --outputdir ./my_data --min_sea 10 --start_date 2026-01-01 --end_date 2026-02-15 --bbox "-180 -60 180 60"
```

- `--outputdir` (required) : directory where all outputs will be stored.
- `--min_sea` : keep only footprints with ≥ this percentage of sea (optional).
- `--start_date` / `--end_date` : ISO date range.
- `--bbox` : bounding box as `west south east north`.
- `--polygon_wkt` : alternative polygon in WKT format (cannot be used together with `--bbox`).
- `-v` : verbose logging.

**Outputs** (in the specified directory):

- `biomass_l1b_raw_<hash>.gpkg` – all footprints that match the spatial/temporal query.
- `biomass_l1b_raw_<hash>.json` – user query parameters.
- `biomass_l1b_filtered_<hash>_sea<X>.gpkg` – footprints that passed the sea‑percentage filter.
- `biomass_l1b_filtered_<hash>_sea<X>.json` – same user parameters plus the simplified land mask geometry (WKT).

The raw GPKG is cached; re‑running the same query will skip the download.

### 2. `biomass_figure_inventory.py` – Generate visualisations

```bash
python biomass_figure_inventory.py --gdf_all ./my_data/biomass_l1b_raw_...gpkg --gdf_filtered ./my_data/biomass_l1b_filtered_...gpkg --min_sea 10 --output-dir-png ./figures
```

- `--gdf_all` : path to the raw (unfiltered) GPKG.
- `--gdf_filtered` : path to the filtered GPKG.
- `--min_sea` : threshold (for legend and title).
- `--output-dir-png` : where to save PNG figures (default current directory).
- `--start_date` / `--end_date` : optional annotation; otherwise derived from the data.

**Figures**:

- `<filtered_basename>.png` – map with footprints (accepted = green, rejected = red) and user polygon/bbox.
- `<filtered_basename>_daily_counts.png` – bar chart showing total vs accepted products, with coloured major cycles and dashed vertical lines for sub‑periods (SW1_1, SW2_1, …).

The map uses the land mask geometry stored in the filtered JSON sidecar – no recomputation is needed.

## Mission timeline

The plot automatically adds the Tomographic Phase timeline (major cycles and sub‑periods) based on the official BIOMASS mission schedule. Only phases that intersect the date range of your filtered data are displayed.

## Dependencies

Main requirements:

- `geopandas`, `pandas`, `numpy`
- `matplotlib`, `cartopy`
- `shapely`, `regionmask`
- `tqdm`, `requests`
- `geodatasets` (for land mask)

See `pyproject.toml` for the full list.

## Contributing

Issues and pull requests are welcome. Please follow the code style (`black`, `isort`) and include tests where applicable.

## License

This project is licensed under the MIT License – see the [LICENSE](LICENSE) file for details.

## Citation

If you use `biomassage` in your research, please cite:

```bibtex
@misc{biomassage,
  author = {umr-lops},
  title = {biomassage – query, filter and visualise BIOMASS L1B products from MAAP},
  year = {2026},
  publisher = {GitHub},
  journal = {GitHub repository},
  howpublished = {\url{https://github.com/umr-lops/biomassage}}
}
```

## Acknowledgements

This project was initialised with the [python-package-template](https://github.com/TezRomacH/python-package-template) and relies on the ESA MAAP platform and its STAC API.
