Skip to content

Instantly share code, notes, and snippets.

View dlebauer's full-sized avatar
😀

David LeBauer dlebauer

😀
View GitHub Profile
# to get the original version of the eCO2 file
download.file('https://github.com/cran/SoilR/raw/1.1-23/data/eCO2.rda',
'eCO2.rda')
load('eCO2.rda')
library(SoilR)
library(rstan)
totalC_t0 <- 7.7; # not included in data, so hard code here
t0 <- 0;
N_t <- 25; # calculated by inspection
library(tidyverse)
# x <- read_csv('C:/Users/David/Downloads/Untitled spreadsheet - Sheet1.csv')
#
# colnames(x)
# dim(x)
#
# xx <- x %>%
# rename(organ = `Plant tissue`,
# soil = `Soil \n Concentration`,
# bcf = BCF) %>%
@dlebauer
dlebauer / summarize_dbfiles.sql
Created November 2, 2022 18:57
figuring out why the dbfiles table gets so big
select extract(year from created_at) as year, container_type, count(*) as n from dbfiles where id between 1000000000 and 2000000000 group by container_type, year order by container_type, year;
select created_user_id, container_type, count(*) as n from dbfiles where id between 1000000000 and 2000000000 group by container_type, created_user_id order by n desc;
select * from dbfiles where created_user_id is not null;
select extract(year from created_at) as year, created_user_id, container_type, count(*) as n from dbfiles where id between 9000000000 and 10000000000 group by container_type, created_user_id, year order by year, container_type, created_user_id;
select null as year, created_user_id, container_type, count(*) as n from dbfiles where id between 9000000000 and 10000000000 group by container_type, created_user_id order by container_type, created_user_id;
We can't make this file beautiful and searchable because it's too large.
"site_id","sitename","lon","lat","format_name","file_path","filename","start_date","end_date","duration","created_at"
"1000026939","Moody AFB","-83.1753","30.984401","ed.met_driver_header files format","/projectnb/dietzelab/mccabete/test_pecan/cogongrass_projections/GFDL/moody_AFB/only_co2/ED_driver/Ed_driver/","Cmip5_RCP8.5_Present_day_temp","1/1/2006 06:00:00","1/1/2100 05:59:00","93 years 11 mons 30 days 23:59:00","6/4/2022 18:19:38.277567"
"1000026939","Moody AFB","-83.1753","30.984401","ed.met_driver_header files format","/projectnb/dietzelab/mccabete/test_pecan/cogongrass_projections/GFDL/moody_AFB/with_co2/ED_driver/","CMIP5_RCP8.5_with_Co2","1/1/2006 06:00:00","13/12/2100 05:59:00","94 years 11 mons 11 days 23:59:00","6/4/2022 18:17:08.145333"
"1000026939","Moody AFB","-83.1753","30.984401","ed.met_driver_header files format","/projectnb/dietzelab/mccabete/test_pecan/cogongrass_projections/GFDL/moody_AFB/resampled_present_day/ED_driver","Cmip5_Present_day","1/1/2006 06:00:00","1/1/2100 05:59:00","93 y
library(traits)
library(dplyr)
library(ggplot2)
options(betydb_url = 'https://www.betydb.org/',
betydb_api_version = 'v1'
)
yields <- betydb_search(result_type = 'yields', genus = 'Panicum', limit = 'none')
treatments <- betydb_query(table = 'treatments', limit = 'none') %>%
dplyr::mutate(treatment_id = id) %>%
@dlebauer
dlebauer / find_cohort_and_met_files.sql
Last active October 4, 2022 00:04
Find cohort files in BETYdb
select
site_id,
sites.sitename,
st_X(sites.geometry) as lon,
st_y(sites.geometry) as lat,
formats.name as format_name,
dbfiles.file_path as file_path,
inputs.name as filename,
inputs.start_date,
inputs.end_date,
@dlebauer
dlebauer / ma_ensemble_examples.R
Created August 18, 2022 16:25
meta analysis and ensemble examples
library(PEcAn.DB)
# given PFT name but no model name???
#
# if select count(*) from pfts where name= <PFT name> > 1 then
# select modeltype_id from pfts where name = <PFT name>
# if > 1 modeltype_id
# select name from modeltypes where id = modeltype_id
# return these model names as messsage asking which one user wants
We can make this file beautiful and searchable if this error is corrected: It looks like row 2 should actually have 38 columns, instead of 19. in line 1.
"ensemble","npp","site","mort2","growth_resp_factor","leaf_turnover_rate","leaf_width","nonlocal_dispersal","fineroot2leaf","root_turnover_rate","seedling_mortality","stomatal_slope","quantum_efficiency","Vcmax","r_fract","cuticular_cond","root_respiration_rate","Vm_low_temp","SLA","mean_annual_temp","mean_diurnal_range","isothermality","temp_seasonality","max_temp_warmest month","min_temp_coldest_month","temp_annual_range","mean_temp_wettest_quarter","mean_temp_driest_quarter","mean_temp_warmest_quarter","mean_temp_coldest_quarter","mean_annual_precip","precip_wettest_month","precip_driest_month","precip_seasonality","precip_wettest_quarter","precip_driest_quarter","precip_warmest_quarter","precip_coldest_quarter"
"1",3.28794455528259,"WL",13.4941024361116,0.199588976581073,5.22541143636259,4.54482864260038,0.160406564989664,2.80249135407987,0.158750654546649,0.964989573638797,3.78549864797161,0.0563503122493127,20.7691338359971,0.230258975287167,20938.2246204727,7.90012049814983,10.8950676841584,39.22618746
@dlebauer
dlebauer / vnir_wavelengths.json
Last active June 7, 2022 18:29
wavelengths for TERRA REF VNIR hyperspectral camera
{
"dimensions": {
"wavelength": 939
},
"variables": {
"wavelength": {
"shape": ["wavelength"],
"type": "double",
"attributes": {
"long_name": "Hyperspectral Wavelength",
@dlebauer
dlebauer / map.geojson
Last active May 27, 2022 16:22
TERRA REF Season 4 irrigation treatments
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.