Skip to content

Instantly share code, notes, and snippets.

View bennyistanto's full-sized avatar

Benny Istanto bennyistanto

View GitHub Profile
@bennyistanto
bennyistanto / csvzonal_concat.py
Created February 9, 2022 08:21
Concatenate CSV files by column, and use the date on filename as column name
#!/usr/bin/python
"""
NAME
csvzonal_concat.py
Concatenate CSV files by column, and use the date on filename as column name
DESCRIPTION
Input data for this script will use CSV result from dbf2csv translation
Some notes:
(i) All files required to follow the naming convention "_yyyymmdd.ext"
(ii) ArcGIS Zonal Statistics as Table is use to generate DBF file based on a zone
@bennyistanto
bennyistanto / mk_gpl2_points_ETH.R
Created February 14, 2022 08:21
google plus level 2 polygons extracted from file previously compiled for MENA/global study
# google plus level 2 polygons extracted from file previously compiled for MENA/global study
# source https://grid.plus.codes/
setwd("D:/sm2/MENA/ge")
reg <- "AFR"
iso = "ETH"
x <- as.list(c("sp","sf","rgdal","rgeos","raster","readxl","dplyr","data.table"))
lapply(x, require, character.only = TRUE)
@bennyistanto
bennyistanto / IMERG_cdd_1mm.py
Created March 3, 2022 09:29
Global IMERG daily consecutive dry days data extraction
# -*- coding: utf-8 -*-
"""
NAME
imerg_cdd_1mm.py
Global IMERG daily indices data extraction
DESCRIPTION
Input data for this script will use IMERG daily data generated by imerg_nc2tif.py
This script can do Consecutive Dry Days (CDD) calculation with threshold 1mm of rainfall as a rainy day
PROCESS
(i) Extract IMERG's daily rainfall with value greater/less than 1mm (threshold for a day categoried as rainy day)
@bennyistanto
bennyistanto / IMERG_cdd_5mm.py
Created March 3, 2022 09:29
Global IMERG daily consecutive dry days data extraction
# -*- coding: utf-8 -*-
"""
NAME
imerg_cdd_5mm.py
Global IMERG daily indices data extraction
DESCRIPTION
Input data for this script will use IMERG daily data generated by imerg_nc2tif.py
This script can do Consecutive Dry Days (CDD) calculation with threshold 5mm of rainfall as a rainy
PROCESS
(i) Extract IMERG's daily rainfall with value greater/less than 5mm (threshold for a day categoried as rainy day)
@bennyistanto
bennyistanto / IMERG_cwd_1mm.py
Last active March 4, 2022 13:56
Global IMERG daily consecutive wet days data extraction
# -*- coding: utf-8 -*-
"""
NAME
imerg_cwd_1mm.py
Global IMERG daily indices data extraction
DESCRIPTION
Input data for this script will use IMERG daily data generated by imerg_nc2tif.py
This script can do Consecutive Wet Days (CWD) calculation with threshold 1mm of rainfall as a rainy day
PROCESS
(i) Extract IMERG's daily rainfall with value greater/less than 1mm (threshold for a day categoried as rainy day)
@bennyistanto
bennyistanto / IMERG_cwd_5mm.py
Last active August 28, 2022 05:17
Global IMERG daily consecutive wet days data extraction
# -*- coding: utf-8 -*-
"""
NAME
imerg_cwd_5mm.py
Global IMERG daily indices data extraction
DESCRIPTION
Input data for this script will use IMERG daily data generated by imerg_nc2tif.py
This script can do Consecutive Wet Days (CWD) calculation with threshold 5mm of rainfall as a rainy day
PROCESS
(i) Extract IMERG's daily rainfall with value greater/less than 5mm (threshold for a day categoried as rainy day)
@bennyistanto
bennyistanto / lagrange-interpolation.py
Created August 29, 2022 04:09
Lagrange interpolation
# Python3 program for implementation
# of Lagrange's Interpolation
# To represent a data point corresponding to x and y = f(x)
class Data:
def __init__(self, x, y):
self.x = x
self.y = y
# function to interpolate the given data points
@bennyistanto
bennyistanto / imerg_runningsum_daily.py
Created September 22, 2022 10:37
IMERG 2 days or more precipitation running sum
# -*- coding: utf-8 -*-
"""
NAME
imerg_runningsum_daily.py
Global IMERG daily running sum.
DESCRIPTION
Input data for this script will use IMERG daily data generated by imerg_nc2tif.py
This script can do calculation on consecutive 2 days or more precipitation running sum
REQUIREMENT
ArcGIS must installed before using this script, as it required arcpy module.
@bennyistanto
bennyistanto / spei-terraclimate.md
Last active October 10, 2022 14:23
Procedure to calculate TerraClimate-based Standardized Precipitation-Evapotranspiration Index with area of interest Indonesia

TerraClimate-based Standardized Precipitation-Evapotranspiration Index in Indonesia

This section will explain on how to download TerraClimate's precipitation (ppt) and potential evapotranspiration (pet) monthly data in netCDF format and prepare it as input for Standardized Precipitation-Evapotranspiration Index (SPEI) calculation.

This step-by-step guide was tested using Mac mini Server - Late 2012, 2.3 GHz Quad-Core Intel Core i7, 16 GB 1600 MHz DDR3, running on macOS Catalina 10.15.7 and Windows 10 with Windows Subsystem for Linux enabled running on Thinkpad T480 2019, i7-8650U 1.9GHz, 64 GB 2400 MHz DDR4.

Index

@bennyistanto
bennyistanto / data_pet.sh
Created October 10, 2022 14:20
TerraClimate's potential evapotranspiration
wget -c http://thredds.northwestknowledge.net:8080/thredds/fileServer/TERRACLIMATE_ALL/data/TerraClimate_pet_1958.nc
wget -c http://thredds.northwestknowledge.net:8080/thredds/fileServer/TERRACLIMATE_ALL/data/TerraClimate_pet_1959.nc
wget -c http://thredds.northwestknowledge.net:8080/thredds/fileServer/TERRACLIMATE_ALL/data/TerraClimate_pet_1960.nc
wget -c http://thredds.northwestknowledge.net:8080/thredds/fileServer/TERRACLIMATE_ALL/data/TerraClimate_pet_1961.nc
wget -c http://thredds.northwestknowledge.net:8080/thredds/fileServer/TERRACLIMATE_ALL/data/TerraClimate_pet_1962.nc
wget -c http://thredds.northwestknowledge.net:8080/thredds/fileServer/TERRACLIMATE_ALL/data/TerraClimate_pet_1963.nc
wget -c http://thredds.northwestknowledge.net:8080/thredds/fileServer/TERRACLIMATE_ALL/data/TerraClimate_pet_1964.nc
wget -c http://thredds.northwestknowledge.net:8080/thredds/fileServer/TERRACLIMATE_ALL/data/TerraClimate_pet_1965.nc
wget -c http://thredds.northwestknowledge.net:8080/thredds/fileServer/TERRACLIMATE_ALL/d