Skip to content

Instantly share code, notes, and snippets.

View khufkens's full-sized avatar

Koen Hufkens khufkens

View GitHub Profile
@khufkens
khufkens / equi2polar.sh
Created July 1, 2021 11:49
Convert equirectangular files to polar projections (upward looking)
#!/bin/bash
# convert equirectangular 2 fisheye
files=`ls *.jpg`
for i in $files;
do
noext=`echo $i | cut -d'.' -f1`
echo $noext
@khufkens
khufkens / format_phenor_data.R
Created May 28, 2021 11:36
Download and format phenocam sites in phenor
# required libraries
library(phenor)
# where to store the data
out_dir <- "data-raw/"
# sites to process, stored in a csv file
# with columns site, veg_type, roi (check for extra spaces
# which can mess with name formatting)
sites <- read.table("data/sites.csv", sep = ",", header = TRUE)
@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
@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 / 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 / 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 / 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 / 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 / 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 / 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")