Home

Awesome

pyATSA

pyatsa finds clouds in satellite imagery.

This repo contains the pyatsa package that ports the original ATSA method and code by Zhu and Helmer 2018, as well as example notebooks. Currently the python version produces nearly equivalent results to Planet Lab's Usable Data Mask for Planetscope 4-band images across Ghana. In cases where there are lots of bright impervious surface, bright soils, or water, pyatsa generates substantial false positives in the cloud shadow class and speckles of false positives from clouds. These are the primary issues being worked on.

Install

pip install pyatsa

Install from source with dependencies

conda env create -f environment.yaml
conda activate pyatsa
# or anaconda3 if you use anaconda or whatever the path to your python file is
flit install --symlink --python ~/miniconda3/envs/pyatsa/bin/python3.7

Differences between pyatsa and original ATSA by Zhu and Helmer 2018

Comparing with the original ATSA IDL code

The original ATSA program is distributed by the authors at https://xiaolinzhu.weebly.com/open-source-code.html. To run, it is necessary to have IDL and ENVI installed. then:

  1. Start the idl ide by calling idlde in the terminal

  2. Run ENVI in the idlde, isnce ENVI functions are required to open the time series file

  3. run CD, "<path to directory with ATSA-Planet.pro>"

  4. Compile the ATSA-Planet.pro file with .r ATSA-Planet.pro

  5. Call the idl script with ATSA from idlde

The IDL script will save out a file that ends in ".sav" (you need to edit the script to change the output path of this file on your computer). It will contain all the variables and results from the script. The file can be read with scipy.io.readsav as a python dictionary where each key is the origianl idl variable name. This can then be used in the pytests to check for agreement.

To run tests, navigate to the atsa-python folder and run pytest test_pyatsa.py. pytest will check for any functions that contain the word "test" and execute that function, producing times and test results for each test function. pytest fixtures are used to define variables that are shared between tests. These tests currently use two fixtures, one for the configsfor the python version (which are copied from the idl version) and a fixture for the ~3Gb .sav file that contains all the variables from the idl version.

Notes on the IDL version to assist with debugging

The IDL code has separate for loops that operate on water regions (identified by a pre-existing water mask) and land regions.

The water mask is 0 value where water, 1 where there is not water. The mask values for land classes are as follows.