Skip to content

Instantly share code, notes, and snippets.

View bennyistanto's full-sized avatar

Benny Istanto bennyistanto

View GitHub Profile
@bennyistanto
bennyistanto / precip_pettitt.md
Last active June 12, 2024 13:46
Simulate how Pettitt test detects inhomogeneous or homogeneous on precipitation data

xkcd-style Pettitt's illustration on Homogeneity testing

The script below try to simulate how Pettitt test detects inhomogeneous or homogeneous on precipitation data. Here's the updated approach:

  1. Daily Precipitation Data:

    • We have daily precipitation.
  2. Generate Monthly Maximum Precipitation Values:

  • Create synthetic monthly maxima with distinct differences to ensure inhomogeneity.
@bennyistanto
bennyistanto / imerg_thresholdbymonth.py
Created June 8, 2024 07:04
Calculates the thresholds for extreme rainfall events using both percentile-based and Generalized Extreme Value (GEV) methods
import xarray as xr
import numpy as np
import os
import glob
import pandas as pd
from tqdm import tqdm
from scipy.stats import genextreme
# Define directories and filenames for threshold calculations
threshold_calculations = [
@bennyistanto
bennyistanto / imerg_dailymaxbydekad.py
Last active June 8, 2024 12:48
Computes the maximum precipitation values for each dekad from the daily and multi-day accumulated datasets
import xarray as xr
import numpy as np
import os
import glob
import pandas as pd
from tqdm import tqdm
# Define the input and output directories
max_calculations = [
{"days": 1, "input_dir": "/mnt/d/temp/imerg/data/fdd_1day", "output_dir": "/mnt/d/temp/imerg/data/fddmaxd_1day"},
@bennyistanto
bennyistanto / imerg_dailymaxbymonth.py
Created June 8, 2024 07:01
Computes the maximum precipitation values for each month from the daily and multi-day accumulated datasets
import xarray as xr
import os
import glob
from tqdm import tqdm
import pandas as pd
# Define directories and filenames for max value calculations
max_calculations = [
{"days": 1, "input_dir": "/mnt/d/temp/imerg/data/fdd_1day", "output_dir": "/mnt/d/temp/imerg/data/fddmaxm_1day"},
{"days": 2, "input_dir": "/mnt/d/temp/imerg/data/fdd_2day", "output_dir": "/mnt/d/temp/imerg/data/fddmaxm_2day"},
@bennyistanto
bennyistanto / imerg_rollingdays.py
Created June 8, 2024 06:59
Generating IMERG 2-day, 3-day, 4-day, and 5-day rolling accumulations
import xarray as xr
import numpy as np
import os
import glob
from tqdm import tqdm
import pandas as pd
# Define the rolling day output directories
rolling_days = [2, 3, 4, 5]
input_dir = "/mnt/d/temp/imerg/data/fdd_1day"
@bennyistanto
bennyistanto / imerg_precipextract.py
Created June 8, 2024 06:57
Extract IMERG precipitation variable
import xarray as xr
import os
import glob
from tqdm import tqdm
# Define the input and output directories
input_dir = "/mnt/d/temp/imerg/data/nc4_final"
output_dir = "/mnt/d/temp/imerg/data/fdd_1day"
# Check if input folder exists
@bennyistanto
bennyistanto / xkcd_idn_map.md
Last active May 28, 2024 02:33
Custom xkcd-style map for Indonesia

Custom xkcd-style map for Indonesia

Label setting for capital, country name and the ocean, and the red-dot is manually set, the value is calculate from top-left main map area.

You can paste the below code into an online Python compiler like https://python-fiddle.com/ and grab the result instantly.

map_idn_xkcd_style

@bennyistanto
bennyistanto / xkcd_countrymap.md
Last active December 17, 2025 09:34
xkcd style for country map

xkcd style for country map

This is example of Python script that could generate a xkcd-style for Country Map.

Example:

map_indonesia_xkcd_style

map_philippines_xkcd_style

@bennyistanto
bennyistanto / xkcd_lseqm.md
Last active April 9, 2025 05:01
Graph illustrating the linear scaling and empirical quantile mapping (LSEQM) method for daily precipitation bias correction.

xkcd style for LSEQM illustration

This is example of Python script that could generate a xkcd graph-style to illustrate concept of Linear Scaling and Empirical Quantile Mapping (LSEQM) method for daily precipitation bias correction.

You can paste the below code into an online Python compiler like https://python-fiddle.com/ and grab the result instantly.

version a

lseqm_xkcd_style_a

@bennyistanto
bennyistanto / ipb_en.csl
Last active May 21, 2024 06:44
IPB Pedoman Penulisan Karya Ilmiah Edisi ke-4 (PPKI) style - English version
<?xml version="1.0" encoding="utf-8"?>
<!-- Modified by: Benny Istanto/KLI/G2501222008, bennyistanto@apps.ipb.ac.id -->
<!-- English version available on: https://gist.github.com/bennyistanto/ef6b1a2bb1ed303a7832f789ac7e7a70 -->
<style xmlns="http://purl.org/net/xbiblio/csl" class="in-text" version="1.0" demote-non-dropping-particle="sort-only" default-locale="en-US">
<!-- changed default-locale to en-US -->
<info>
<title>Institut Pertanian Bogor: Pedoman Penulisan Karya Ilmiah Edisi ke-4 (English)</title>
<!-- updated title -->
<title-short>IPB PPKI 4</title-short>
<id>http://www.zotero.org/styles/institut-pertanian-bogor</id>