Skip to main content

Estimate cyanobacteria density in small, inland water bodies using Sentinel-2 satellite imagery.

Project description

CyFi: Cyanobacteria Finder

PyPI conda-forge tests codecov

CyFi is a command line tool that uses satellite imagery and machine learning to estimate cyanobacteria levels in small, inland water bodies. The goal of CyFi is to help water quality managers better allocate resources for in situ sampling, and make more informed decisions around public health warnings for critical resources like lakes and reservoirs.

Read more at cyfi.drivendata.org

Quickstart

Install

[!NOTE] There is a known issue with the pip installation on M1 Macs due to LightGBM. If you're on a Mac, we recommend installing CyFi with conda, shown in the second option below.

Install CyFi with pip:

pip install cyfi

Alternatively, CyFi can be installed with conda:

conda install -c conda-forge cyfi

For detailed instructions for those installing python for the first time, see the Installation page.

Generate batch predictions

Generate batch predictions at the command line with cyfi predict.

First, specify your sample points in a csv with the following columns:

  • latitude
  • longitude
  • date

For example,

# sample_points.csv
latitude,longitude,date
41.424144,-73.206937,2023-06-22
36.045,-79.0919415,2023-07-01
35.884524,-78.953997,2023-08-04

Then run:

cyfi predict sample_points.csv

This will output a preds.csv that contains a column for cyanobacteria density and a column for the associated severity level based on WHO thresholds.

# preds.csv
sample_id,date,latitude,longitude,density_cells_per_ml,severity
7ff4b4a56965d80f6aa501cc25aa1883,2023-06-22,41.424144,-73.206937,34173.0,moderate
882b9804a3e28d8805f98432a1a9d9af,2023-07-01,36.045,-79.0919415,7701.0,low
10468e709dcb6133d19a230419efbb24,2023-08-04,35.884524,-78.953997,4053.0,low

To see all of the available options, run cyfi predict --help.

Generate prediction for a single point

Or, generate a cyanobacteria estimate for a single point on a single date using cyfi predict-point.

Just specify the latitude, longitude, and date as arguments at the command line.

cyfi predict-point --lat 41.2 --lon -73.2 --date 2023-09-14

This will print out the estimated cyanobacteria density and associated severity level based on WHO thresholds.

2023-10-04 16:25:40.581 | SUCCESS  | cyfi.cli:predict_point:154 - Estimate generated:
date                    2023-09-14
latitude                      41.2
longitude                    -73.2
density_cells_per_ml        32,820
severity                  moderate

To see all of the available options, run cyfi predict-point --help.

A note on severity levels

Severity levels are based on World Health Organization (WHO) cyanobacteria density thresholds.

  • Low: 0 - 20,000 cells/ml
  • Moderate: 20,000 - 100,000 cells/ml
  • High: > 100,000 cells/ml

However users should feel free to to use their own thresholds as makes sense for their needs.

Visualizing predictions

Launch the CyFi Explorer to view the Sentinel-2 imagery used to generate each cyanobacteria estimate!

Screenshot of CyFi explorer showing the predictions table along with the Sentinel-2 imagery.

Reference paper

Dorne, E., Wetstone, K., Cerquera, T. B., & Gupta, S. (2024). Cyanobacteria detection in small, inland water bodies with CyFi. In Proceedings of the 23nd Python in Science Conference (pp. 154–173). https://doi.org/10.25080/pdhk7238

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cyfi-1.1.5.tar.gz (942.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cyfi-1.1.5-py3-none-any.whl (949.1 kB view details)

Uploaded Python 3

File details

Details for the file cyfi-1.1.5.tar.gz.

File metadata

  • Download URL: cyfi-1.1.5.tar.gz
  • Upload date:
  • Size: 942.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.20

File hashes

Hashes for cyfi-1.1.5.tar.gz
Algorithm Hash digest
SHA256 57ee49ca13572d77ab0bd1800dd0b79bb6e79add2a8a0fcff6fadb88598ebdd7
MD5 684c5a03fc58759d02c0e7b2da2e4384
BLAKE2b-256 797cbae70ab4a30f8407809b7f41be5bb5c89f3946c4631d61f27694183b649e

See more details on using hashes here.

File details

Details for the file cyfi-1.1.5-py3-none-any.whl.

File metadata

  • Download URL: cyfi-1.1.5-py3-none-any.whl
  • Upload date:
  • Size: 949.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.20

File hashes

Hashes for cyfi-1.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 c6ba589add5d1ff1a72c97417c85d2ecc639d57c40b5f413095acec126c3f9e6
MD5 bff0196b1c7cbc0c884bef09c4220ac1
BLAKE2b-256 b72cb502bf33ae403e8ef5dc432b9882e9e33ff0e1e796227e80c417b21ba75f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page