Skip to content

Instantly share code, notes, and snippets.

View dlebauer's full-sized avatar
😀

David LeBauer dlebauer

😀
View GitHub Profile
@dlebauer
dlebauer / events_3sites.json
Last active September 17, 2025 18:23
Example events.json for three sites
[
{
"pecan_events_version": "0.1.0",
"site_id": "02f8ecd6d492badc",
"events": [
{
"event_type": "irrigation",
"date": "2016-01-05",
"amount_mm": 40,
"method": "soil"
This file has been truncated, but you can view the full file.
0 2004 1 0.0 0.02083 -6.260e+00 -6.891852 0.000000 0.000000 235.0 264.344 148.33 1 0.6
0 2004 1 0.5 0.02083 -6.400e+00 -6.892737 0.000000 0.000000 230.0 264.034 149.26 1 0.6
0 2004 1 1.0 0.02083 -6.490e+00 -6.893408 0.000000 0.000000 229.0 264.579 147.67 1 0.6
0 2004 1 1.5 0.02083 -6.640e+00 -6.893958 0.000000 0.000000 222.0 262.528 150.38 1 0.6
0 2004 1 2.0 0.02083 -6.770e+00 -6.894324 0.000000 0.000000 215.0 260.710 153.69 1 0.6
0 2004 1 2.5 0.02083 -6.720e+00 -6.894507 0.000000 0.000000 223.0 264.893 147.10 1 0.6
0 2004 1 3.0 0.02083 -6.790e+00 -6.894751 0.000000 0.000000 219.0 263.478 149.13 1 0.6
0 2004 1 3.5 0.02083 -6.820e+00 -6.894873 0.000000 0.000000 220.0 264.593 147.28 1 0.6
0 2004 1 4.0 0.02083 -6.760e+00 -6.894995 0.000000 0.000000 231.0 270.481 137.97 1 0.6
0 2004 1 4.5 0.02083 -6.930e+00 -6.895178 0.000000 0.000000 226.0 270.428 138.20 1 0.6
@dlebauer
dlebauer / 01-events_spec.md
Last active July 1, 2025 20:32
Specification for PEcAn events format

Events format

This specification defines a model-agnostic intermediate format for events, analogous to the PEcAn met standard. It is intended to:

  • Consolidate events from diverse sources (e.g. RS, farmer surveys, literature)
  • Represent ensemble-reesolved realizations of events that can be used in modeling workflows.
  • Be consumed by a model specific event parser like parse.events.<model> that can be called by write.configs.<model>.

This format for events that is based on the format used in the fieldactivity nested within a geoJSON data structure[^1], but has been modified to be more generalized, and focused on aggregating data from many sources that have varied types of information.

@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;