-
Notifications
You must be signed in to change notification settings - Fork 6
monthly_anomaly
This script allows user to compute anomaly on given period (months and years) using the full Sentinel 2 or Landsat 5,7,8 imagery based on user defined baseline (years).
The following workflow is applied:
- Extract a mini dataset for selected area and month
- Apply a mask
- Split the dataset in two (baseline, period of anomaly calculation)
- Apply mathematical expression & calculate means
- Calculate anomaly the inverse way of CEOS ((example: selected - baseline) / baseline)
- Compute quality and add it to dataset_out
- byears: years to compute baseline
- anom_years & anom_months: years and months to compute anomaly (mean compared with mean of baseline scenes for the selected month)
- bands: bands needed by the mathematical expression
- math_expr: mathematical expression to apply on bands
- cat_band: band containing the classification (either slc or cf_mask for respectively Sentinel 2 or Landsat products
- keep_cats: categories of cat_band considered as data (see table below)
- chunk_size = chunk area (benchmark showed 0.15 is the best value (in used hardware) in the case of a 2 bands expression)
- dis_range: values range to display (to be zero centered it has to be symetrical) on figures
- logname: log name (used by printanlog function)
- user_mail: User mail (to be filled in the case the user need to be informed by email on process completion)
For example
- using cat_band = 'slc' with keep_cats = [4] with Sentinel 2 will compute the anomaly on pixel classified as vegetated only (see below figure with French Geoportail Ortophoto as a background).
- using cat_band = 'cf_mask' with keep_cats = [0] with Landsat will compute the anomaly on pixel classified as clear only.
For more details see Configuration section and expr_anom function below
- Percentage of change (anomaly)
- Output quality (percentage of pixel with data (through time) baseline * selected)
Outputs are available as
- geotiff (full dataset, integer format using "deflate" compression (compress="deflate" added to utils/dc_utilities.py write_geotiff_from_xr))
- figures (in script): maps & histograms (restricted to dis_range values)
This script is the first implementation of printandlog function. Each time the function is used it will print a message on the notebook, an write it in a log file defined by logname.
A .COMPLETED file will also be generated containing the processing time (see Inform processing completion section).
Finally, if the user_mail parameter is filled, an email will be send containing the log file and the processing time.
If you have credentials for the Swiss Data Cube, you can play with a demo script at
http://calc.unepgrid.ch:8080/notebooks/monthly_anomaly.ipynb
or
http://sdc.unepgrid.ch:8080/notebooks/monthly_anomaly.ipynb
The code and the demo jupyter notebook script can be found here