Skip to content

Instantly share code, notes, and snippets.

View dlebauer's full-sized avatar
😀

David LeBauer dlebauer

😀
View GitHub Profile
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.',
insert into attributes (container_type, container_id, value) VALUES ('experiments', 6000000012, '{"brapi":{"trialDbId":"6"}}');
insert into attributes (container_type, container_id, value) VALUES ('experiments', 6000000001, '{"brapi":{"trialDbId":"1"}}');
insert into attributes (container_type, container_id, value) VALUES ('experiments', 6000000002, '{"brapi":{"trialDbId":"3"}}');
insert into attributes (container_type, container_id, value) VALUES ('experiments', 6000000003, '{"brapi":{"trialDbId":"6"}}');
insert into attributes (container_type, container_id, value) VALUES ('experiments', 6000000004, '{"brapi":{"trialDbId":"6"}}');
insert into attributes (container_type, container_id, value) VALUES ('experiments', 6000000005, '{"brapi":{"trialDbId":"6"}}');
insert into attributes (container_type, container_id, value) VALUES ('experiments', 6000000006, '{"brapi":{"trialDbId":"6"}}');
insert into attributes (container_type, container_id, value) VALUES ('experiments', 6000000007, '{"brapi":{"trialDbId":"6
#!/usr/bin/env Rscript
if(!file.exists('biocro_helpers.R')){
download.file('https://gist.githubusercontent.com/dlebauer/8010fc210ea6552b8f6df66f22d00c6c/raw/e99240b0607bf8c88eb053a40a2906aec46e06f1/biocro_helpers.R',
destfile = 'biocro_helpers.R')
}
source('biocro_helpers.R')
"result": {
"data": [
{
"germplasmDbId": "6000000862",
"germplasmName": "RIL-CS3_(TX2910/(Macia/R07007)-CS44)-CSF1-PRF2-CS3",
"observationLevel": "plot",
"observationUnitDbId": "6000000002",
"observationUnitName": "MAC Field Scanner Season 1 Field Plot 861",
"observations": [
{
{
"dimensions": {
"wavelength": 955,
"wvl_nvr": 1024,
"x": 1600,
"y": 468
},
"flx_dwn": {
"dims": ["wavelength"],
"type": "float",
@dlebauer
dlebauer / vnir_netcdf_L1_ua-mac_2017-10-23__09-50-13-395_ind.nc
Created February 15, 2019 20:21
Dump of TERRA REF hyperspectral indices file
netcdf vnir_netcdf_L1_ua-mac_2017-10-23__09-50-13-395_ind {
dimensions:
x = 1600 ;
y = 2089 ;
wavelength = 955 ;
variables:
double x(x) ;
x:algorithm = "Based on https://github.com/terraref/computing-pipeline/issues/144, x is derived from camera geometry including the Aperature Field-of-View (AFOV), the Horizontal Field-of-View (HFOV), and the height of the camera above the canopy(aka the Working Distance, or WD). We take WD = 2 m. Focal length (about 25 mm) is ignored in this estimate because it is much smaller than the WD. The camera geometry implies that AFOV[degrees]=2*atan(HFOV/WD). We use AFOV=21 and 44.6 degress for SWIR and VNIR, respectively. Then we solve for HFOV, and that distance is equally apportioned to 384 or 1600 pixels for SWIR or VNIR, respectively. For SWIR x = 1.93mm, for VNIR x = 1.025mm." ;
x:long_name = "North distance from southeast corner of field" ;
x:orientation = "The x-dimension (which runs north-south) spans what are called samples or pixels. The y-dimension (which run
@dlebauer
dlebauer / docker-compose.override.yml
Created February 11, 2019 22:14
set postgres ports for github.com:pecanproject/bety
version: "3"
services:
postgres:
ports:
- 5432:5432
@dlebauer
dlebauer / all_s4_6_traits.sql
Last active May 4, 2022 16:07
two approaches to retrieving canopy height + canopy cover data
\copy (select raw_date, sitename, cultivar, trait, method, mean
from traits_and_yields_view_private
sitename like '%Season 4%' and sitename ~ 'Range (20|30)$')
to ~/season4traits.csv delimiter ',' csv header;
\copy (select raw_date, sitename, cultivar, trait, method, mean
from traits_and_yields_view_private
sitename like '%Season 6%' and sitename ~ 'Range (20|30)$')
to ~/season6traits.csv delimiter ',' csv header;
trait n
surface_temperature 598409
canopy_cover 451470
canopy_height 259237
seedling_vigor 6246
stem_elongated_internodes_number 4982
emergence_score 4556
leaf_desiccation_present 4200
emergence_count 4166