Readme updated 12 July 2022.
This repo contains code to (1) use the iNaturalist API to download species observations based on phenology annotations, by modifying code from the rinat
package, and (2) model the relationship between flowering and weather using spatially interpolated records from PRISM and Bayesian additive regression tree methods implemented in embarcadero
.
Subfolder names and contents:
data
--- raw data, as output by theinat_phenology_download.R
scriptoutput
--- processed data, figures, etcprotocol_manual
--- a PDF document describing our protocol for adding phenology annotations to the iNaturalist database, with supporting Markdown and image filesscripts
--- all project scriptsR
--- all R scripts, notablyget_inat.R
--- script to loadrinat
and modify theget_inat
function to allow searches on phenology state annotation.inat_phenology_download.R
--- script to useget_inat.R
to download phenology-annotated observations using the iNaturalist APIPRISM_data-management.R
--- downloads monthly climate data by year, summarizes to quarterly, normalizes to 1981-2010, and crops to the Mojave extent to build a repository for downstream workinat_phenology_data-management.R
--- organization of data output frominat_phenology_download.R
, and pairing with PRISM data with functionality from theprism
package.phenology_modeling.R
--- modeling annualized, rasterized observations of flowering (or no flowering) predicted with weather data using Bayesian additive regression tree (BART) methodsphenology_prediction.R
--- fits random intercept models based on the best-fit fromphenology_modeling.R
, with year as the random effect, uses that to predict flowering from PRISM data for 1900-presenthistoric_flowering_analysis.R
--- analysis of the historic flowering prediction fromphenology_modeling.R
data
--- raw datainat_phenology_data.csv
--- cleaned iNat observations with phenology annotation, output frominat_phenology_download.R
PRISM
--- folder for PRISM data, downloaded and modified withPRISM_data-management.R
output
--- transitional data products, modeling results, analysis and figuresflowering_obs_rasterized.csv
--- flowering observations, rendered binary (flowering/no) and rasterized to the 4km PRISM resolution, output frominat_phenology_data-management.R
flowering_obs_climate.csv
--- rasterized binary flowering observations merged with predictors generated from PRISM weather data, and annotated for Joshua tree species (eastern Yucca jaegeriana or western Yucca brevifolia), output frominat_phenology_data-management.R
BART
--- saved BART models, prediction layersfigures
--- what it says on the tin
Some of these steps can be skipped once data is downloaded/organized, but to perform the full analysis for the first time, use the scripts in this order:
- First use
inat_phenology_download.R
to download all of the iNaturalist observations with flowering status annotated; - Then use
PRISM_data-management.R
to download spatially interpolated weather data at 4km resolution and process it into quarterly aggregates, normalized to 1981-2010; - Then, use
inat_phenology_data-management.R
to match iNat observations to weather results for the years leading up to each observation; - Finally, use
phenology_modeling.R
to builds a BART model predicting flowering status with weather data, which are stored inoutput/flowering_obs_climate_normed.csv
; and usephenology_prediction.R
with the resulting model to predict what flowering was like in years when we have weather data but no iNaturalist observations.