This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
direct <- read_csv("https://www.livingplanetindex.org/session/2ccf2bec98c16e6ee8f9ed6bbd8a514d/download/downloadData?w=") | |
direct |> | |
ggplot(aes(Year, LPI_final)) + geom_line() + geom_ribbon(aes(ymin=CI_low, ymax=CI_high), fill="blue", alpha=0.1) | |
direct |> rename(year = Year) |> mutate(sample = LPI_final + ((CI_high - CI_low)/2) * (runif(n(), -10,10))/10 ) |> | |
ggplot(aes(x = year, y = 1, fill = sample)) + | |
geom_tile(show.legend = FALSE) + | |
#scale_fill_steps2(low = "#c7cca5", mid="#ddff03", high="#53de02", midpoint = median(lpi_df$LPI_final)) + | |
scale_fill_stepsn(colors = c("#c7cca5", "#ddff03", "#53de02"), values = rescale(c(min(lpi_df$sample), 0, max(lpi_df$sample))), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(duckdb) | |
library(DBI) | |
library(glue) | |
library(dplyr) | |
conn <- DBI::dbConnect(duckdb(), ":memory:", | |
config=list("memory_limit"="12GB", | |
"temp_directory" = "/tmp")) | |
DBI::dbExecute(conn, "INSTALL 'httpfs';") | |
DBI::dbExecute(conn, "LOAD 'httpfs';") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#url <- "https://dap.tern.org.au/thredds/ncss/ecosystem_process/ozflux/AdelaideRiver/2022_v2/L5/default/AdelaideRiver_L5_20071017_20090524.nc" | |
library(tidync) | |
library(lubridate) | |
library(dplyr) | |
url <- "https://dap.tern.org.au/thredds/dodsC/ecosystem_process/ozflux/AdelaideRiver/2022_v2/L5/default/AdelaideRiver_L5_20071017_20090524.nc" | |
# peek at metadata for time units | |
nc_atts(url) |> filter(variable=="time") |> mutate(value = unlist(value)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(rstac) | |
library(gdalcubes) | |
library(stars) | |
library(tmap) | |
## STAC Search over 400 million assets. | |
box <- c(xmin=-122.51006, ymin=37.70801, xmax=-122.36268, ymax=37.80668) | |
start_date <- "2022-06-01" | |
end_date <- "2022-08-01" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# remotes::install_github("OldLipe/rstac@b-0.9.1") | |
# remotes::install_github("appelmar/gdalcubes_R") | |
# remotes::install_github("r-spatial/stars") | |
library(tidyverse) | |
library(rstac) | |
library(gdalcubes) | |
library(tmap) | |
library(stars) | |
data(World) #polygons |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(gdalcubes) | |
library(gefs4cast) # remotes::install_github("neon4cast/gefs4cast") | |
library(stringr) | |
library(lubridate) | |
## 3-hr period up to 10 days, (then every 6 hrs up to 35 day horizon) | |
gefs_cog("~/gefs_cog", ens_avg=TRUE, | |
max_horizon=240, date = Sys.Date() - 1) |> system.time() | |
# 000 file has different bands and so cannot be stacked into the collection |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#remotes::install_github("OldLipe/rstac@dev") | |
#remotes::install_github("appelmar/gdalcubes_R") | |
source("new_sign_planetary_computer.R") | |
sites <- readr::read_csv(paste0("https://github.com/eco4cast/neon4cast-noaa-download/", | |
"raw/master/noaa_download_site_list.csv")) | |
z <- sites |> dplyr::filter(site_id == "HARV") | |
y <- z$latitude |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
library(rstac) | |
library(httr) | |
library(stars) | |
library(spData) | |
box <- st_bbox(us_states) | |
# hack around rstac bug in signing | |
mysign <- function(href) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(score4cast) | |
library(arrow) | |
readRenviron(path.expand("~/.Renviron")) | |
Sys.setenv("AWS_EC2_METADATA_DISABLED"="TRUE") | |
Sys.unsetenv("AWS_DEFAULT_REGION") | |
endpoint = "data.ecoforecast.org" | |
s3_forecasts <- arrow::s3_bucket("neon4cast-forecasts", endpoint_override = endpoint) | |
s3_targets <- arrow::s3_bucket("neon4cast-targets", endpoint_override = endpoint) | |
s3_scores_path <- tempfile() # dummy location for testing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
title: "Demo" | |
format: html | |
editor: visual | |
jupyter: python3 | |
--- | |
```{bash} | |
python -m venv venv | |
source venv/bin/activate |