Skip to content

Instantly share code, notes, and snippets.

View dlebauer's full-sized avatar
😀

David LeBauer dlebauer

😀
View GitHub Profile
@dlebauer
dlebauer / organic_ag_data_nass_quickstats.R
Created July 27, 2021 18:24
start to wrangle NASS quickstats organic survey data
#CSV downloaded from https://quickstats.nass.usda.gov/results/12827E57-2B20-368C-A91F-1B97FF8F7B35#E2E0BF24-9F88-35DB-8526-8E47D941FDBF
library(dplyr)
library(tidyr)
nass_data <- readr::read_csv("raw_data/E2E0BF24-9F88-35DB-8526-8E47D941FDBF.csv",na = '(D)',
skip = 1,
col_names = c(
"program", "period", "week_ending", "geo_level", "state", "state_ansi",
"ag_district", "ag_district_code", "county", "county_ansi", "zip_code",
"region", "watershed_code", "watershed", "commodity", "data_item",
@dlebauer
dlebauer / download_terraref_from_dryad.R
Created July 27, 2021 18:21
code to download and unzip trait data from Dryad and then plot it
library(ggplot2)
library(dplyr)
download.file(url = 'https://datadryad.org/stash/downloads/file_stream/624637', destfile = 'trait_data.zip', mode = 'wb')
unzip(zipfile = 'trait_data.zip', unzip = 'unzip')
s6heights <- readr::read_csv('traits/season_6_traits/season_6_canopy_height_sensor.csv')
s4heights <- readr::read_csv('traits/season_4_traits/season_4_canopy_height_sensor.csv')
heights <- bind_rows(s4heights, s6heights)
select
t.treatment_id :: text as treatmentDbId,
t.site_id :: text as observationUnitDbId,
t.variable_id :: text as observationVariableDbId,
v.name as observationVariableName,
t.id :: text as observationDbId,
t.mean :: text as value,
t.date as observationTimeStamp,
s.sitename as observationUnitName,
t.cultivar_id :: text as germplasmDbId,
@dlebauer
dlebauer / MAB.R
Last active April 10, 2021 01:47
how much easier is it to estimate a mean than a minimum?
n_sim <- 10000
mu <- -10
sd <- 2
n <- 30
z <- array(NA, c(3,n_sim))
for(i in 1:n_sim){
x <- rnorm(n, mu, sd)
z[1, i] <- mean(x)

Environment comparisons

This folder contains code used to compare setaria growth in different environments.

Contents:

  • inputs/

  • scripts/ folder:

@dlebauer
dlebauer / pecan.xml
Created January 28, 2021 20:03
testing out met workflow from web interface
<?xml version="1.0"?><pecan>
<info>
<notes/>
<userid>-1</userid>
<username/>
<date>2021/01/28 19:56:08 +0000</date>
</info>
<outdir>/data/workflows/PEcAn_99000000009</outdir>
<database>
<bety>
@dlebauer
dlebauer / simple_purple_shaker.py
Last active January 16, 2021 18:07
Pyzero implementation of the purple shaker guy from scratch
import pgzrun
import time
import random
WIDTH = 400
HEIGHT = 400
guy = Actor("purple_guy")
guy.pos = (200, 200)
guy.angle = -25
library(tidyverse)
library(wesanderson)
library(cowplot)
library(lubridate)
allfields <- read_csv('~/Downloads/canopycover_ratiomask.csv') %>%
mutate(method = 'French')
field3 <- read_csv('~/Downloads/canopycover_ratiomask_field3.csv') %>%
mutate(method = 'French')
all_tr <- read_csv('~/Downloads/allcanopycover (1).csv') %>% select(-X1) %>%
mutate(method = 'Li')
---
title: "Meta analysis plot organization"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## Lets look at what MA outputs look like
# from https://pygame-zero.readthedocs.io/en/stable/introduction.html
import pgzrun
#import random
WIDTH = 500
HEIGHT = 1000
alien = Actor('alien')
alien.pos = WIDTH/2, HEIGHT/2