This file contains hidden or 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
m.stat <- function(mod, obs, ...) { | |
# model field = x; observed field = y | |
# mse the mean square error between x and y, | |
# V and G are spatial variance and domain mean of the respective fields | |
# https://doi.org/10.1002/(SICI)1097-0088(199604)16:4%3C379::AID-JOC18%3E3.0.CO;2-U | |
obs = na.omit(obs) | |
mod = na.omit(mod) | |
stopifnot(length(obs) == length(mod)) | |
se = (obs - mod)^2 | |
mse = mean(se) |
This file contains hidden or 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
cd /mnt/c/Users/Stu/Desktop/CMIP5/ | |
#CCSM4 | |
cd CCSM4 | |
cdo -ensmean tas_Amon_CCSM4_rcp26_r* CCSM4_rcp26_ensAvg.nc #6 seconds | |
#CSIRO | |
cd ../CSIRO-Mk3.6.0/ | |
cdo -ensmean tas_Amon_CSIRO-Mk3-6-0_rcp26_r* CSIRO-Mk3-6-0_rcp26_ensAvg.nc #2.5 seconds |
This file contains hidden or 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
library(tidyverse) | |
library(scales) | |
data(diamonds) | |
diamonds %>% | |
filter(str_detect(cut, "Fair|Ideal")) %>% | |
ggplot(aes(price, carat)) + | |
geom_point(color = "skyblue", alpha = 0.5) + | |
facet_wrap(~cut, strip.position = "bottom") + | |
scale_x_continuous(labels = comma) + |
This file contains hidden or 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
# how to run this thingy | |
# create a file on your mac called setup.sh | |
# run it from terminal with: sh setup.sh | |
# heavily inspired by https://twitter.com/damcclean | |
# https://github.com/damcclean/dotfiles/blob/master/install.sh | |
# faster dock hiding/showing (run in terminal) | |
# defaults write com.apple.dock autohide-delay -float 0; defaults write com.apple.dock autohide-time-modifier -int 0;killall Dock |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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
## Function for returning weighted centroid location | |
## currently hard-coded to return mean, q10, q20, q80 & q90. | |
weightedCentre <- function(x, y, z) { | |
require(matrixStats); require(Hmisc) | |
if (anyNA(c(x, y, z))) { | |
stop("There are missing values present in x, y, or z") | |
} | |
if (length(z) != length(x)) { | |
stop("Number of weights supplied not equal to number of coordinates") | |
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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
##################################################################################################### | |
# title : Machine learning exercise for Sentinel-2 data | |
# purpose : Implementing a machine learning workflow in R | |
# author : Abdulhakim M. Abdi (Twitter: @HakimAbdi / www.hakimabdi.com) | |
# input : A multi-temporal raster stack of Sentinel-2 data comprising scenes from four dates | |
# output : One classified land cover map from each of three machine learning algorithms | |
# Note 1 : This brief tutorial assumes that you are already well-grounded in R concepts and are | |
# : familiar with image classification procedure and terminology | |
# Reference : Please cite Abdi (2020): "Land cover and land use classification performance of machine learning | |
# : algorithms in a boreal landscape using Sentinel-2 data" in GIScience & Remote Sensing if you find this |
This file contains hidden or 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
# Use the Cumulative Relative Frequency Curve hotspot method | |
# to identify hotspots of high values | |
# Ref: | |
## Bartolino, V., Maiorano, L., & Colloca, F. (2011). | |
## A frequency distribution approach to hotspot identification. | |
## Population Ecology, 53(2), 351-359. doi:10.1007/s10144-010-0229-2 | |
library(raster) |
This file contains hidden or 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
# Use the Cumulative Relative Frequency Curve hotspot method | |
# to identify hotspots of high values | |
# Ref: | |
## Bartolino, V., Maiorano, L., & Colloca, F. (2011). | |
## A frequency distribution approach to hotspot identification. | |
## Population Ecology, 53(2), 351-359. doi:10.1007/s10144-010-0229-2 | |
# example array data | |
# could do with raster/terra, but wanted example in base r |