Skip to content

Instantly share code, notes, and snippets.

View djnavarro's full-sized avatar

Danielle Navarro djnavarro

View GitHub Profile
library(dplyr)
library(ambient)
intrusion <- function(filename, shade = "#b3b3ff", seed = 1,
frak_one = 3, frak_two = 2,
pixels_wide = 1000, pixels_high = 1000,
colors_used = 1000) {
# transformation functions ------------------------------------------------
library(flametree) # https://github.com/djnavarro/flametree
library(scopes) # https://github.com/djnavarro/scopes
library(ggforce)
library(ggplot2)
library(dplyr)
library(ambient)
# settings
pixels <- 1000
fname <- "~/Desktop/scopetree.png"
@djnavarro
djnavarro / bomrang.R
Last active April 20, 2020 07:29
Minimal use of bomrang and stars
library(tidyverse)
img <- bomrang::get_satellite_imagery(
product_id = "IDE00427.201912280400.tif",
cache = TRUE
) %>% stars::st_as_stars()
ggplot() +
stars::geom_stars(data = img)
@djnavarro
djnavarro / ou-model.R
Created April 16, 2020 20:42
toy example with leaky accumulator models
# illustrate that the temporally-accrued evidence in an Ornstein-
# Uhlenbeck model of perceptual decision-making is bounded
t <- 500 # length of time to run the process
drift <- .2 # drift rate measures the perceptual signal strength
leak <- .9 # evidence leakage rate
# momentary samples are presumed to generate normally distributed
# evidence with mean corresponding to drift rate, and (for reasons
# known but to Roger) standard deviation .1
library(flametree)
library(ggplot2)
library(gganimate)
dat <- flametree_grow(time = 13)
pic <- ggplot(
data = dat,
mapping = aes(
x = coord_x,
library(jasmines)
library(dplyr)
# data structure to plot
dat <- use_seed(1) %>%
scene_bubbles(n = 3, grain = 10000) %>%
mutate(x = x * 2, y = y * 2) %>%
unfold_tempest(
iterations = 4,
scale = .05,
@djnavarro
djnavarro / scope_05.R
Created March 30, 2020 08:51
draw a "scope" plot
library(ambient) # may need dev version: https://github.com/thomasp85/ambient
library(viridis)
# specify the seed and grain
seed <- 272
grain <- 1000
# specify the circle
origin_x <- .3
origin_y <- .5
# https://github.com/djnavarro/jasmines
library(jasmines)
library(dplyr)
simple_plot <- function(octaves) {
dat <- use_seed(259) %>%
scene_rows(
n = 5,
# name myself on git
system2(
'git config --global user.email "d.navarro@unsw.edu.au";
git config --global user.name "Danielle Navarro"'
)
@djnavarro
djnavarro / log_sign_trans
Created January 21, 2020 23:53
Custom ggplot2 log-scale transformation that preserves sign
library(ggplot2)
library(scales)
# transformation
log_sign_trans <- trans_new(
name = "log_sign",
transform = function(x) {sign(x) * log(abs(x))},
inverse = function(x){sign(x)} * exp(abs(x))
)