Skip to content

Instantly share code, notes, and snippets.

Avatar
😀

David LeBauer dlebauer

😀
View GitHub Profile
View phytoremediation.r
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
View summarize_dbfiles.sql
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;
View cohort_met_files.csv
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
View query_planting.R
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
View find_cohort_and_met_files.sql
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
View ma_ensemble_examples.R
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
View ens_plus_data.csv
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
View vnir_wavelengths.json
{
"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
View map.geojson
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View srer_priors.tsv
pft variable phylogeny distn parama paramb n citation
forb_priors mort2 plants gamma 1.47 0.0578 0 LeBauer 2010 Expert Prior
forb_priors growth_resp_factor grass beta 2.63 6.52 0 LeBauer 2010 Expert Prior
forb_priors fineroot2leaf grass lnorm 0.811 0.843 0 Chapin 2002 Principles of Terrestrial Ecosystem Ecology
forb_priors root_turnover_rate grass weibull 1.67 0.657 66 Gill 2000 Global patterns of root turnover for terrestrial ecosystems
forb_priors seedling_mortality monocots beta 3.61 0.433 0 LeBauer 2010 Expert Prior
forb_priors Vcmax lnorm 4.51 0.64 19 Wullschleger 1993 Biochemical Limitations to Carbon Assimilation in C3 Plants: A Retrospective Analysis of the A/Ci Curves from 109 Species
forb_priors root_respiration_rate angiosperm gamma 4.95 0.762 36 George 2003 Fine-root respiration in a loblolly pine and sweetgum forest growing in elevated CO2
forb_priors r_fract plants beta 2 4 0 LeBauer 2010 Expert Prior
forb_priors c2n_leaf grass gamma 4.18 0.13 95 Wright 2004 The world-wide leaf economics spectr