Skip to content

Instantly share code, notes, and snippets.

View bennyistanto's full-sized avatar

Benny Istanto bennyistanto

View GitHub Profile
@bennyistanto
bennyistanto / SPI-based drought characteristics.ipynb
Last active May 16, 2024 14:44
SPI or SPEI based Drought Characteristics
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bennyistanto
bennyistanto / GetGeoTransform.md
Created July 13, 2023 00:20
Creating arrays from GeoTIFFs

From below script:

ds = gdal.Open('../SPI/mar/orig_geotiff/mar_cli_chirps_precip_month1_198101.tif') # Data location

a = ds.ReadAsArray()
nlat,nlon = np.shape(a)

b = ds.GetGeoTransform() #bbox, interval
lon = np.arange(nlon)*b[1]+b[0]
@bennyistanto
bennyistanto / download_era5_agromet.py
Created May 4, 2023 02:11
Download ERA5 Agrometeorological Indicators and save as 1 month data in 1 netCDF file
"""
NAME
download_era5_agromet.py
DESCRIPTION
Download ERA5 Agrometeorological Indicators and save as 1 month data in 1 netCDF file.
REQUIREMENT
You must registered as CDS Copernicus user, and access your profile to get UID and Api Key
You need to install `cdsapi` python package
EXAMPLES
python download_era5_agromet.py
@bennyistanto
bennyistanto / PhenoMetrics_Merge_Output.ipynb
Last active April 21, 2023 13:29
Merge output from Seasonality data extraction process
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# -*- coding: utf-8 -*-
"""
NAME
chirps_dekad_update.py
Update Global CHIRPS's dekad collection in a folder, gunzip, rename and compress
DESCRIPTION
This script will do:
1. Check the exisiting file in the Dekad folder, match the date `..._YYYY.MM.D.tif`
with collection files in BASE_URL
2. If the file exist in the Dekad folder, then skipped, proceed to next date.
@bennyistanto
bennyistanto / spi_monthly_blend.py
Last active March 30, 2023 23:28
Global CHIRPS's SPI-based dry/wet indicators blend
# -*- coding: utf-8 -*-
"""
NAME
spi_monthly_blend.py
Global CHIRPS's SPI-based dry/wet indicators blend.
DESCRIPTION
Input data for this script will use CHIRPS SPI monthly data in GeoTIFF format
This experimental SPI blends integrate several SPI scales into a single product.
The combines 3-, 6-, 9-, 12-, and 24-month SPI to estimate the overall dry/wet conditions.
METHOD
@bennyistanto
bennyistanto / chirps_longterm_stats.py
Last active March 27, 2023 01:30
CHIRPS precipitation statistics data 1991-2020, long-term average, max, min and stdev
# -*- coding: utf-8 -*-
"""
NAME
chirps_longterm_stats.py
CHIRPS precipitation statistics data 1991-2020, long-term average, max, min and stdev
DESCRIPTION
Input data for this script will use data generated from chirps_precip_accumulation.py
REQUIREMENT
ArcGIS must installed before using this script, as it required arcpy module.
EXAMPLES
@bennyistanto
bennyistanto / chirps_precip_accumulation.py
Last active March 31, 2023 15:20
Calculate running dekad of 1-,3-,6-,9-,12- and 24-month accumulation precipitation using dekad data
# -*- coding: utf-8 -*-
"""
NAME
chirps_precip_accumulation.py
Calculate running dekad of 1-,3-,6-,9-,12- and 24-month accumulation precipitation using dekad data
DESCRIPTION
Input data for this script will use https://data.chc.ucsb.edu/products/CHIRPS-2.0/global_dekad/tifs/
REQUIREMENT
ArcGIS must installed before using this script, as it required arcpy module.
EXAMPLES
@bennyistanto
bennyistanto / download_era5land_precipitation.py
Created March 23, 2023 02:58
Download ERA5-Land daily total precipitation and save as 1 year data in 1 netCDF file
# -*- coding: utf-8 -*-
"""
NAME
download_era5land_precipitation.py
DESCRIPTION
Download ERA5-Land daily total precipitation and save as 1 year data in 1 netCDF file.
REQUIREMENT
You must registered as CDS Copernicus user, and access your profile to get UID and Api Key
EXAMPLES
python download_era5land_precipitation.py
@bennyistanto
bennyistanto / precip_improvement_plots.py
Created March 17, 2023 11:42
Generate plots on improvements daily rainfall after the bias correction
# -*- coding: utf-8 -*-
"""
NAME
precip_improvement_plots.py
Generate plots on improvements daily rainfall after the bias correction
DESCRIPTION
Input data for this script will use the gauge and satellite-based precipitation
estimates data, and corrected precipitation from bias-correction process.
REQUIREMENT
It required numpy, pandas, scipy, matplotlib, seaborn and xarray module.