Skip to content

Commit

Permalink
Merge pull request #37 from sentinel-hub/feat/package-updates
Browse files Browse the repository at this point in the history
Feat/package updates
  • Loading branch information
zigaLuksic authored Apr 4, 2022
2 parents 2d291e0 + 5eed12f commit 3589b34
Show file tree
Hide file tree
Showing 25 changed files with 515 additions and 279 deletions.
10 changes: 0 additions & 10 deletions .coveragerc

This file was deleted.

42 changes: 42 additions & 0 deletions .github/ISSUE_TEMPLATE/bug-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
name: 'Bug report'
about: Help us improve
title: '[BUG]'
labels: bug
assignees: ''

---

**Describe the bug**

A clear and concise description of what the bug is.

NOTE: Remove any confidential information, such as Sentinel Hub credentials!

**To Reproduce**

Steps to reproduce the behavior:

1.
2.
3.

**Expected behavior**

A clear and concise description of what you expected to happen.

**Environment**

Details of the python environment

**Stack trace or screenshots**

If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**

- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

**Additional context**
24 changes: 24 additions & 0 deletions .github/ISSUE_TEMPLATE/feature-request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
name: 'Feature request'
about: What feature is missing?
title: '[FEAT]'
labels: enhancement
assignees: ''

---

**What is the problem? Please describe.**

A clear and concise description of what the problem is.

**Here's the solution**

A clear and concise description of what you want to happen.

**Alternatives**

A clear and concise description of any alternative solutions or features you've considered.

**Additional context**

Add any other context or screenshots about the feature request here.
22 changes: 22 additions & 0 deletions .github/ISSUE_TEMPLATE/help-support.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
name: 'Help/Support'
about: 'Need help?'
title: '[HELP]'
labels: help wanted, question
assignees: ''

---

**Resources**

Before opening an issue for help/support, make sure you have checked [existing issues](https://github.com/sentinel-hub/sentinel2-cloud-detector/issues) and the Sentinel Hub [forum](https://forum.sentinel-hub.com/).

**Question**

Formulate your question in a clear and structured way, providing context and links to the resources raising issues.

NOTE: Remove any confidential information, such as Sentinel Hub credentials!

**Additional context**

Add any information that would help us supporting you.
88 changes: 88 additions & 0 deletions .github/workflows/ci_action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: build

on:
push:
schedule:
- cron: '0 0 * * *'

jobs:

check-code-black:
runs-on: ubuntu-latest
steps:
- name: Check out current branch
if: github.event_name == 'push'
uses: actions/checkout@v2

- name: Check code compliance with black
if: github.event_name == 'push'
run: |
pip install black[jupyter]
black . --check --diff
check-code-isort:
runs-on: ubuntu-latest
steps:
- name: Check out current branch
if: github.event_name == 'push'
uses: actions/checkout@v2

- name: Check code compliance with isort
if: github.event_name == 'push'
run: |
pip install isort
isort **/*.py --check --diff
test-on-github:
runs-on: ubuntu-latest
strategy:
matrix:
python-version:
- '3.7'
- '3.8'
- '3.9'
- '3.10'
steps:
- name: Check out current branch in case of a push event
if: github.event_name == 'push'
uses: actions/checkout@v2

- name: Check out develop branch in case of a scheduled event
if: github.event_name == 'schedule'
uses: actions/checkout@v2
with:
ref: develop

- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
architecture: x64

- name: Install packages
run: |
sudo apt-get update
sudo apt-get install -y build-essential libopenjp2-7
pip install -e .[DEV]
- name: Run full tests and code coverage
if: matrix.python-version == '3.9'
run: |
sentinelhub.config \
--sh_client_id "${{ secrets.SH_CLIENT_ID }}" \
--sh_client_secret "${{ secrets.SH_CLIENT_SECRET }}"
pytest --cov --cov-report=term --cov-report=xml
- name: Run pylint and reduced tests
if: matrix.python-version != '3.9'
run: |
pylint s2cloudless
pytest -m "not sh_integration"
- name: Upload code coverage
if: matrix.python-version == '3.9'
uses: codecov/codecov-action@v2
with:
files: coverage.xml
fail_ci_if_error: true
verbose: false
37 changes: 0 additions & 37 deletions .travis.yml

This file was deleted.

1 change: 0 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ include README.md
include LICENSE.md
include setup.py
include s2cloudless/models/*
include s2cloudless/TestInputs/*
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ help:


upload:
$(PYTHON) setup.py sdist
rm -r dist build | true
$(PYTHON) setup.py sdist bdist_wheel
twine upload dist/*

# For testing:
test-upload:
$(PYTHON) setup.py sdist
rm -r dist build | true
$(PYTHON) setup.py sdist bdist_wheel
twine upload --repository testpypi dist/*
17 changes: 7 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[![Package version](https://badge.fury.io/py/s2cloudless.svg)](https://pypi.org/project/s2cloudless)
[![Conda version](https://img.shields.io/conda/vn/conda-forge/s2cloudless.svg)](https://anaconda.org/conda-forge/s2cloudless)
[![Supported Python versions](https://img.shields.io/pypi/pyversions/s2cloudless.svg?style=flat-square)](https://pypi.org/project/s2cloudless)
[![Build Status](https://www.travis-ci.com/sentinel-hub/sentinel2-cloud-detector.svg?branch=master)](https://app.travis-ci.com/github/sentinel-hub/sentinel2-cloud-detector/builds)
[![Build Status](https://github.com/sentinel-hub/sentinel2-cloud-detector/actions/workflows/ci_action.yml/badge.svg?branch=master)](https://github.com/sentinel-hub/sentinel2-cloud-detector/actions)
[![Overall downloads](https://pepy.tech/badge/s2cloudless)](https://pepy.tech/project/s2cloudless)
[![Last month downloads](https://pepy.tech/badge/s2cloudless/month)](https://pepy.tech/project/s2cloudless)
[![Code coverage](https://codecov.io/gh/sentinel-hub/sentinel2-cloud-detector/branch/master/graph/badge.svg)](https://codecov.io/gh/sentinel-hub/sentinel2-cloud-detector)
Expand All @@ -11,12 +12,12 @@

The **s2cloudless** Python package provides automated cloud detection in
Sentinel-2 imagery. The classification is based on a *single-scene pixel-based cloud detector*
developed by Sentinel Hub's research team and is described in more details
developed by Sentinel Hub's research team and is described in more detail
[in this blog](https://medium.com/sentinel-hub/improving-cloud-detection-with-machine-learning-c09dc5d7cf13).

## Installation

The package requires a Python version >= 3.6. The package is available on
The package requires a Python version >= 3.7. The package is available on
the PyPI package manager and can be installed with

```
Expand All @@ -36,17 +37,13 @@ Before installing `s2cloudless` on **Windows**, it is recommended to install pac

## Input: Sentinel-2 scenes

The inputs to the cloud detector are Sentinel-2 images. In particular, the cloud detector requires the following 10
Sentinel-2 band reflectances: B01, B02, B04, B05, B08, B8A, B09, B10, B11, B12, which are obtained from raw
reflectance value in the following way: `B_i/10000`.
The inputs to the cloud detector are Sentinel-2 images. In particular, the cloud detector requires the following 10 Sentinel-2 band reflectances: B01, B02, B04, B05, B08, B8A, B09, B10, B11, B12, which are obtained from raw reflectance values in the following way: `B_i/10000`. From product baseline `04.00` onward additional harmonization factors have to be applied to data according to [instructions from ESA](https://sentinels.copernicus.eu/en/web/sentinel/-/copernicus-sentinel-2-major-products-upgrade-upcoming).

You don't need to worry about any of this, if you're doing classification of scenes obtained using [Sentinel Hub
Process API](https://docs.sentinel-hub.com/api/latest/api/process/). The API is supported in Python with
[sentinelhub-py](https://github.com/sentinel-hub/sentinelhub-py) package.
You don't need to worry about any of this, if you are using Sentinel-2 data obtained from [Sentinel Hub Process API](https://docs.sentinel-hub.com/api/latest/api/process/). By default, the data is already harmonized according to [documentation](https://docs.sentinel-hub.com/api/latest/data/sentinel-2-l1c/#harmonize-values). The API is supported in Python with [sentinelhub-py](https://github.com/sentinel-hub/sentinelhub-py) package and used within `s2cloudless.CloudMaskRequest` class.

## Examples

Jupyter notebook on how to use the cloud detector to produce cloud mask or cloud probability map
A Jupyter notebook on how to use the cloud detector to produce cloud mask or cloud probability map
can be found in the [examples folder](https://github.com/sentinel-hub/sentinel2-cloud-detector/tree/master/examples).

## License
Expand Down
13 changes: 5 additions & 8 deletions examples/plotting_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,16 @@
import numpy as np


def plot_image(image=None, mask=None, ax=None, factor=3.5/255, clip_range=(0, 1), **kwargs):
""" Utility function for plotting RGB images and masks.
"""
def plot_image(image=None, mask=None, ax=None, factor=3.5 / 255, clip_range=(0, 1), **kwargs):
"""Utility function for plotting RGB images and masks."""
if ax is None:
_, ax = plt.subplots(nrows=1, ncols=1, figsize=(15, 15))

mask_color = [255, 255, 255, 255] if image is None else [255, 255, 0, 100]

if image is None:
if mask is None:
raise ValueError('image or mask should be given')
raise ValueError("image or mask should be given")
image = np.zeros(mask.shape + (3,), dtype=np.uint8)

ax.imshow(np.clip(image * factor, *clip_range), **kwargs)
Expand All @@ -28,12 +27,10 @@ def plot_image(image=None, mask=None, ax=None, factor=3.5/255, clip_range=(0, 1)
ax.imshow(cloud_image)


def plot_probabilities(image, proba, factor=3.5/255):
""" Utility function for plotting a RGB image and its cloud probability map next to each other.
"""
def plot_probabilities(image, proba, factor=3.5 / 255):
"""Utility function for plotting a RGB image and its cloud probability map next to each other."""
plt.figure(figsize=(15, 15))
ax = plt.subplot(1, 2, 1)
ax.imshow(np.clip(image * factor, 0, 1))
ax = plt.subplot(1, 2, 2)
ax.imshow(proba, cmap=plt.cm.inferno)

Loading

0 comments on commit 3589b34

Please sign in to comment.