Skip to content

Instantly share code, notes, and snippets.

View dlebauer's full-sized avatar
😀

David LeBauer dlebauer

😀
View GitHub Profile
@dlebauer
dlebauer / southwest_usa.R
Created April 1, 2020 22:44
plot of states in southwest US using rnaturalearth and sf packages based on https://www.r-spatial.org/r/2018/10/25/ggplot2-sf.html
library(rnaturalearth)
library(rnaturalearthdata)
devtools::install_github('ropensci/rnaturalearthhires')
library(rnaturalearthhires)
library(ggspatial)
usa_states <- ne_states(country = 'United States of America', returnclass = 'sf')
state_points <- data.frame(state = usa_states$name,
st_coordinates(st_centroid(usa_states$geometry)))
name ecotype notes species
DP_075 Sorghum bicolor
@dlebauer
dlebauer / cleanbety200.sql
Created January 30, 2020 23:58
rough approximation of statements used to clean up bety200
begin;
delete from sites where id < 200000000001 and sitename not like '%Season 10%' and id != 1160 and id != 6000000001;
commit;
delete from benchmarks_benchmarks_reference_runs
delete from benchmarks_ensembles_scores
delete from benchmarks_ensembles
delete from reference_runs;
delete from benchmarks;
delete from inputs;
delete from pfts_species where id < 200000000001
{
"cropping_variable_metadata":{
"origin_timestamp":"2017-05-05__00-41-45-258",
"crop_bbox":{
"img_row":{
"min":16076,
"max":17625
},
"img_col":{
"min":1463,
@dlebauer
dlebauer / daylight.R
Last active December 9, 2019 19:15 — forked from hrbrmstr/daylight.R
daylight for tucson ... still needs work
library(maptools)
library(ggplot2)
library(gridExtra)
library(scales)
library(lubridate)
# adapted from http://r.789695.n4.nabble.com/maptools-sunrise-sunset-function-td874148.html
ephemeris <- function(lat, lon, date, span=1, tz="UTC") {
lon.lat <- matrix(c(lon, lat), nrow=1)
@dlebauer
dlebauer / candidates.R
Created October 23, 2019 16:31
Candidate screening script
library(tidyr)
library(dplyr)
x <- readr::read_csv('~/Downloads/Candidate Scores (Responses) - Form Responses 1 (2).csv')
x2 <- x %>% dplyr::select(evaluator = `Email Address`,
candidate = `Candidate's name`,
collaboration_communication = `Collaboration and Communication Skills`,
software = `Software development / production code`,
organization = `Organization and Planning`,
@dlebauer
dlebauer / examples.R
Created October 16, 2019 20:06
plotting parameters, sensitivity, variance decomposition, and ensemble predictions
### Parameters
library(dplyr)
library(ggplot2)
theme_set(theme_minimal() +
theme(axis.text.x =
element_text(size = fontsize$axis,
vjust = -1),
axis.text.y = element_blank(),
axis.ticks = element_blank(),
axis.line = element_blank(),
BEGIN;
UPDATE experiments
SET description = 'Season 7 RIL experiment closely replicates the RIL experiment from Season 2 in 2016. The description is the same https://terraref.ncsa.illinois.edu/bety/experiments/6000000008
Bi-parental grain sorghum population provided by W. Rooney (Texas A&M), comprised of 158 RILs plus parental lines (TX7000 and SC56-14) that are polymorphic for stay-green (associated with post-flowering drought tolerance) and grain traits. RILs are F-10 or higher generation. Plots planted as 2-row plots. The experiment includes 3 replicates, and each replicate includes checks, including BTX623, P_84G62, and P_86Y89.',
design = 'Resolvable row-column design, 3 replicates, each replicate includes checks BTX623, P_84G62, and P_86Y89.',
start_date = '2018-08-23',
end_date = '2018-11-01'
WHERE
ID = 6000000036;
library(ggplot2)
library(lubridate)
library(dplyr)
library(knitr)
library(traits)
options(betydb_url = "https://terraref.ncsa.illinois.edu/bety/",
betydb_api_version = 'v1',
betydb_key = 'YouRSecRETkeY')
BEGIN;
UPDATE citations
SET url = 'https://github.com/terraref/extractors-stereo-rgb/blob/master/canopycover/README.md'
WHERE
ID = ( SELECT citation_id FROM methods WHERE NAME = 'Canopy Cover Estimation from Field Scanner RGB images' );
INSERT INTO methods ( NAME, description, citation_id )
VALUES
(
'Visual percent lodging estimate',
'Visually score percentage of plants in a plot that are lodged. 0 means no plant is lodged and 100 means all plants are completely lodged. The score is a subjective combination of the fraction of the plants lodged and the severity of lodging.',