This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env Rscript | |
library(htmlwidgets) | |
library(leaflet) | |
library(raster) | |
library(viridis) | |
path <- 'example-footprint.nc' | |
footprint <- brick(path) | |
footprint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# source <(wget https://gist.github.com/benfasoli/c1ed43c7350a6253fed3bfd4e17743ef/raw/ -O -) | |
set -e | |
# Configure miniconda installation within user scope | |
source <(wget https://gist.githubusercontent.com/benfasoli/a7193b2bdd59e1b930efcb7facd6d12e/raw/ -O -) | |
conda update --all -y | |
conda install -y -c conda-forge --strict-channel-priority proj4 gdal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# curl -sL https://gist.github.com/benfasoli/a7193b2bdd59e1b930efcb7facd6d12e/raw/ | bash | |
set -e | |
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda3.sh | |
bash miniconda3.sh -b -p $HOME/.miniconda3 | |
rm miniconda3.sh | |
cp $HOME/.bashrc $HOME/.bashrc-miniconda-backup | |
echo ' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# wget https://gist.github.com/benfasoli/268c55ba75f33a997c58f8fcc46dd3af/raw/ -O - | bash | |
mkdir -p $HOME/.Rpackages && \ | |
echo "system('source $HOME/.bashrc') | |
.libPaths( | |
c( | |
'$HOME/.Rpackages', | |
.libPaths() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env Rscript | |
n <- 5 | |
# fill matrix of distances | |
d <- matrix(nrow = n, ncol = n) | |
d[1:n, 1] <- 0:(n-1) | |
d[1, 1:n] <- 0:(n-1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env Rscript | |
# Ben Fasoli | |
# | |
# Interpolation utilities for STILT footprints to predict footprints for | |
# finely gridded receptors using coarse STILT-calculated footprints for | |
# intermediate receptor locations. | |
# | |
# Uses weights derived from 2d Gaussian kernels to average footprints from | |
# the surrounding spatial area | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from multiprocessing import cpu_count, Pool | |
import pandas as pd | |
def parallel_apply(df, fun, n_chunks: int = None): | |
"""Apply function to batches of dataframe rows | |
Parameters | |
---------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Ben Fasoli | |
const int n = 6; | |
const int pins[n] = {A0, A1, A2, A3, A4, A5}; | |
const float slope[n] = {1, 1, 1, 1, 1, 1}; | |
const float intercept[n] = {0, 0, 0, 0, 0, 0}; | |
// Board reference voltage measured on aref pin | |
const float refVoltage = 4.93; // V |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env Rscript | |
library(raster) | |
# Create gridded example data | |
xyz <- expand.grid(x = seq(-112.4, -111.6, by = 0.03), | |
y = seq(40.3, 40.9, by = 0.03)) | |
xyz$z <- with(xyz, abs(x * y)) | |
r_coarse <- rasterFromXYZ(xyz, crs = '+proj=longlat') | |
r_coarse |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env Rscript | |
# Ben Fasoli | |
library(ncdf4) | |
library(raster) | |
files <- dir('raw', full.names = T) | |
data <- 0 | |
for (file in files) { |