Skip to content

Instantly share code, notes, and snippets.

View dlebauer's full-sized avatar
😀

David LeBauer dlebauer

😀
View GitHub Profile
@dlebauer
dlebauer / 01-events_spec.md
Last active June 25, 2025 19:34
Specification for PEcAn events format

Events format

This document outlines an updated format for events that follows the format used in the fieldactivity nested within a geoJSON data structure.

The format is a GeoJSON FeatureCollection. Each Feature in the collection represents a single site. The properties of each feature contain an array of events that occurred at that site.

The properties are aligned with the fieldactivity schema defined in ui_structure.json.

Structure

@dlebauer
dlebauer / 01_git_fix_summary.md
Last active June 4, 2025 21:47
Errors & fixes during initial deploy of hugoblox website
# Category / File Symptom / Error (abridged) Root Cause / Context Fix applied (see commit/patch)
1 GitHub Pages deploy
.github/workflows/publish.yaml
deploy-pages 404 – “Getting signed artifact URL failed” Deploy job could not find a Pages‑type artifact Switched to actions/upload-artifact@v4 and named it github-pages, which deploy-pages@v4 accepts
2 Actions tag mismatch “Missing download info for actions/upload‑artifact@v3” Referenced tag never existed Bumped to `upl
@dlebauer
dlebauer / assign_uniqueid_to_design_points.R
Created May 14, 2025 20:28
One-off code used to join different versions of LandIQ DWR Land Cover datasets
library(tidyverse)
# system.time(load("~/ccmmf/LandIQ_data/crops_all_years.RData"))
crops_all <- data.table::fread( # ~50% faster than load!
"~/ccmmf/LandIQ_data/crops_all_years.csv"
)
dwr_2018 <- terra::vect(
"~/ccmmf/LandIQ_data/LandIQ_shapefiles/i15_Crop_Mapping_2018_SHP/i15_Crop_Mapping_2018.shp"
) |>
terra::project("epsg:3310")
@dlebauer
dlebauer / hpc_job_stats.md
Created February 4, 2025 07:43
Slurm and SGE Job Stats

Equivalent Commands: Slurm vs SGE/OGS

1. Equivalent of seff (Job Efficiency Report)

Slurm:

seff <job_id>

SGE/OGS:

qacct -j 
library(xml2)
library(yaml)
# note: does not handle XML attributes or namespaces.
# should work for simple xml structure used by PEcAn
# Convert XML to YAML
xml2yml <- function(xml_string) {
yaml_string <- xml_string |>
read_xml() |>
# 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) %>%