Skip to content

Instantly share code, notes, and snippets.

View khufkens's full-sized avatar

Koen Hufkens khufkens

View GitHub Profile
@khufkens
khufkens / el_nino_precip_analysis.r
Created May 10, 2018 09:04
CHIRP drought / precipitation differences between the Amazon and Congo Basin during the 2015 El Nino
# map El Nino drought in the Amazon and Africa
library(raster)
library(tidyverse)
library(maps)
library(RColorBrewer)
# set colour theme
colours = brewer.pal(11,"RdBu")
# download CHIRP data
@khufkens
khufkens / modify_pdf_exif_data.sh
Last active December 23, 2019 13:38
Correct PDF author / title meta-data
#!/bin/bash
# Insert PDF meta-data into exif header
# for pdf files with format author - year - title.pdf.
# This allows e-readers to query meta-data for proper
# display and sorting of authors and titles
# (note: relies on exiftool)
for filename in *.pdf; do
noext=`echo "${filename%.*}"`
@khufkens
khufkens / essential_climate_variable_plot.R
Last active April 12, 2019 07:33
Downloads and plots essential climate variable resembling the ECWMF plot
# Before you start install all the referenced packages below
# including the development release of ecmwfr you will also
# need the rnaturalearthdata in addition to the normal package
# To run the code copy and paste segments as this is still
# rough around the edges and requires user interaction to
# set your CDS API key.
# load libraries
if(!require(devtools)){install.packages("devtools")}
devtools::install_github("khufkens/ecmwfr")
@khufkens
khufkens / essential_climate_variables_animation.R
Last active April 3, 2020 12:43
Downloads and animates CDS essential climate variables
# Before you start install all the referenced packages below
# including the development release of ecmwfr you will also
# need the rnaturalearthdata in addition to the normal package
# To run the code copy and paste segments as this is still
# rough around the edges and requires user interaction to
# set your CDS API key.
# load libraries
if(!require(devtools)){install.packages("devtools")}
devtools::install_github("khufkens/ecmwfr")
@khufkens
khufkens / cold_front_geopotential_transect.R
Last active April 19, 2019 14:27
Cold front transect along geopotential heights
# Before you start install all the referenced packages below
# including the development release of ecmwfr you will also
# need the rnaturalearthdata in addition to the normal package
# To run the code copy and paste segments as this is still
# rough around the edges and requires user interaction to
# set your CDS API key.
# load libraries
if(!require(devtools)){install.packages("devtools")}
devtools::install_github("khufkens/ecmwfr")
@khufkens
khufkens / ghent_air_quality_vmm.R
Created June 12, 2019 12:49
Ghent air quality study VMM rehash
# Ghent air pollution analysis
# parametric t-tests
# non-parametric Mann-Whitney U test
# download and collate the data
pdf_data <- paste0(pdftools::pdf_text("https://klimaat.stad.gent/sites/default/files/nota_circulatieplangent_3.pdf")[2],
collapse = " ")
# some regular expression moving about
subset <- gsub(',', ".", pdf_data)
@khufkens
khufkens / montage.sh
Last active June 19, 2020 20:24
Montage of example numbers for zooniverse project
montage *.png -bordercolor White -border 5x5 -colorspace Gray -gravity center -tile 7x -geometry +10+0 ~/montage.jpg
@khufkens
khufkens / orient_images.sh
Created November 19, 2019 20:52
Line to run on all images before CV processing
# aligns virtual orientation with physical orientation
mogrify -auto-orient *.png
@khufkens
khufkens / MODIS_arctic_sites_download.R
Last active August 21, 2020 20:06
MODIS arctic sites data request
# download NDVI time series
library(MODISTools)
df <- data.frame(
site_name =
c("US-Bes",
"US-Atq",
"US-Ivo",
"US-ICt",
"DK-ZaH",
@khufkens
khufkens / crop_and_animate.sh
Created April 3, 2021 10:11
Animate virtual forest images
#!/bin/bash
# crop section of images
mogrify -crop 2770x2304+3560+296 *.jpg
# compile into animated gif
convert -delay 100 -loop 0 -depth 8 -resize '640x' -quality 75% *.jpg anim.gif