Skip to content

Commit

Permalink
finally got a set of models to run, very preliminary.
Browse files Browse the repository at this point in the history
  • Loading branch information
RobJamesRamos committed Nov 19, 2024
1 parent a5fe037 commit 377687d
Show file tree
Hide file tree
Showing 8 changed files with 1,509 additions and 375 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,9 @@ po/*~

# RStudio Connect folder
rsconnect/

# Some GIS files I dont want on github
processing/gis/*/
processing/gis/gssurgo_1km.nc
processing/gis/gssurgo_1km.nc.aux.xml
processing/gis/gis_data_1km.nc
11 changes: 10 additions & 1 deletion analysis/requirements.yml → analysis/biotic_analysis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
name: base
name: biotic_analysis
channels:
- conda-forge
- r
dependencies:
- jupyter
- r-base
- r-irkernel
- r-cairo
- r-dplyr
- r-tidyr
Expand All @@ -11,5 +14,11 @@ dependencies:
- r-ggplot2
- r-rnaturalearth
- r-rnaturalearthdata
- r-devtools
- r-sf
- r-terra
- r-rastervis
- r-tidyterra
- r-gdalcubes
- r-car
- r-corrplot
1,436 changes: 1,229 additions & 207 deletions analysis/globalamfungi_analysis.ipynb

Large diffs are not rendered by default.

Empty file removed processing/amfungi_lsu.duckdb.wal
Empty file.
215 changes: 124 additions & 91 deletions processing/daymet/daymet.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 2,
"metadata": {
"vscode": {
"languageId": "r"
Expand Down Expand Up @@ -44,19 +44,136 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 3,
"metadata": {
"vscode": {
"languageId": "r"
}
},
"outputs": [],
"source": [
"if(!dir.exists(\"/data-store/iplant/home/rjramos/daymet\")) dir.create(\"/data-store/iplant/home/rjramos/daymet\")\n",
"download_dir <- \"../gis/daymet/\"\n",
"# download_dir <- \"/data-store/iplant/home/rjramos/daymet/\"\n",
"if(!dir.exists(download_dir)) dir.create(download_dir)\n",
"url <- \"https://thredds.daac.ornl.gov/thredds/fileServer/ornldaac/2130/\" # base url for thredds data server\n",
"options(timeout = 1200) # Set the maximum download time to 20min"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"vscode": {
"languageId": "r"
}
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"Warning message in download.file(url = x, destfile = paste0(download_dir, last(unlist(strsplit(x, :\n",
"“downloaded length 310066927 != reported length 442579946”\n",
"Warning message in download.file(url = x, destfile = paste0(download_dir, last(unlist(strsplit(x, :\n",
"“URL 'https://thredds.daac.ornl.gov/thredds/fileServer/ornldaac/2130/daymet_v4_prcp_annttl_na_2015.nc': Timeout of 1200 seconds was reached”\n"
]
},
{
"ename": "ERROR",
"evalue": "\u001b[1m\u001b[33mError\u001b[39m in `map()`:\u001b[22m\n\u001b[1m\u001b[22m\u001b[36mℹ\u001b[39m In index: 36.\n\u001b[1mCaused by error in `download.file()`:\u001b[22m\n\u001b[33m!\u001b[39m download from 'https://thredds.daac.ornl.gov/thredds/fileServer/ornldaac/2130/daymet_v4_prcp_annttl_na_2015.nc' failed\n",
"output_type": "error",
"traceback": [
"\u001b[1m\u001b[33mError\u001b[39m in `map()`:\u001b[22m\n\u001b[1m\u001b[22m\u001b[36mℹ\u001b[39m In index: 36.\n\u001b[1mCaused by error in `download.file()`:\u001b[22m\n\u001b[33m!\u001b[39m download from 'https://thredds.daac.ornl.gov/thredds/fileServer/ornldaac/2130/daymet_v4_prcp_annttl_na_2015.nc' failed\nTraceback:\n",
"1. map_(\"list\", .x, .f, ..., .progress = .progress)",
"2. with_indexed_errors(i = i, names = names, error_call = .purrr_error_call, \n . call_with_cleanup(map_impl, environment(), .type, .progress, \n . n, names, i))",
"3. withCallingHandlers(expr, error = function(cnd) {\n . if (i == 0L) {\n . }\n . else {\n . message <- c(i = \"In index: {i}.\")\n . if (!is.null(names) && !is.na(names[[i]]) && names[[i]] != \n . \"\") {\n . name <- names[[i]]\n . message <- c(message, i = \"With name: {name}.\")\n . }\n . else {\n . name <- NULL\n . }\n . cli::cli_abort(message, location = i, name = name, parent = cnd, \n . call = error_call, class = \"purrr_error_indexed\")\n . }\n . })",
"4. call_with_cleanup(map_impl, environment(), .type, .progress, \n . n, names, i)",
"5. .f(.x[[i]], ...)",
"6. download.file(url = x, destfile = paste0(download_dir, last(unlist(strsplit(x, \n . \"/\")))))",
"7. .handleSimpleError(function (cnd) \n . {\n . if (i == 0L) {\n . }\n . else {\n . message <- c(i = \"In index: {i}.\")\n . if (!is.null(names) && !is.na(names[[i]]) && names[[i]] != \n . \"\") {\n . name <- names[[i]]\n . message <- c(message, i = \"With name: {name}.\")\n . }\n . else {\n . name <- NULL\n . }\n . cli::cli_abort(message, location = i, name = name, parent = cnd, \n . call = error_call, class = \"purrr_error_indexed\")\n . }\n . }, \"download from 'https://thredds.daac.ornl.gov/thredds/fileServer/ornldaac/2130/daymet_v4_prcp_annttl_na_2015.nc' failed\", \n . base::quote(download.file(url = x, destfile = paste0(download_dir, \n . last(unlist(strsplit(x, \"/\")))))))",
"8. h(simpleError(msg, call))",
"9. cli::cli_abort(message, location = i, name = name, parent = cnd, \n . call = error_call, class = \"purrr_error_indexed\")",
"10. rlang::abort(message, ..., call = call, use_cli_format = TRUE, \n . .frame = .frame)",
"11. signal_abort(cnd, .file)",
"12. signalCondition(cnd)"
]
}
],
"source": [
"prcp_files <- map(\n",
" seq(1980, 2022, 1),\n",
" \\(x) paste0(url, \"daymet_v4_prcp_annttl_na_\", x, \".nc\")\n",
")\n",
"map(\n",
" prcp_files,\n",
" function(x) {\n",
" download.file(\n",
" url = x,\n",
" destfile = paste0(\n",
" download_dir,\n",
" last(unlist(strsplit(x, \"/\")))\n",
" )\n",
" )\n",
" }\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"vscode": {
"languageId": "r"
}
},
"outputs": [],
"source": [
"prcp_files <- map(\n",
" seq(1980, 2022, 1),\n",
" \\(x) paste0(url, \"daymet_v4_swe_annavg_na_\", x, \".nc\")\n",
")\n",
"map(\n",
" prcp_files,\n",
" function(x) {\n",
" download.file(\n",
" url = x,\n",
" destfile = paste0(\n",
" download_dir,\n",
" last(unlist(strsplit(x, \"/\")))\n",
" )\n",
" )\n",
" }\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"vscode": {
"languageId": "r"
}
},
"outputs": [],
"source": [
"prcp_files <- map(\n",
" seq(1980, 2022, 1),\n",
" \\(x) paste0(url, \"daymet_v4_tmax_annavg_na_\", x, \".nc\")\n",
")\n",
"map(\n",
" prcp_files,\n",
" function(x) {\n",
" download.file(\n",
" url = x,\n",
" destfile = paste0(\n",
" download_dir,\n",
" last(unlist(strsplit(x, \"/\")))\n",
" )\n",
" )\n",
" }\n",
")"
]
},
{
"cell_type": "code",
"execution_count": 3,
Expand Down Expand Up @@ -344,90 +461,6 @@
"output_type": "display_data"
}
],
"source": [
"prcp_files <- map(\n",
" seq(1980, 2022, 1),\n",
" \\(x) paste0(url, \"daymet_v4_prcp_annttl_na_\", x, \".nc\")\n",
")\n",
"map(\n",
" prcp_files,\n",
" function(x) {\n",
" download.file(\n",
" url = x,\n",
" destfile = paste0(\n",
" \"/data-store/iplant/home/rjramos/daymet/\",\n",
" last(unlist(strsplit(x, \"/\")))\n",
" )\n",
" )\n",
" }\n",
")"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"vscode": {
"languageId": "r"
}
},
"outputs": [],
"source": [
"prcp_files <- map(\n",
" seq(1980, 2022, 1),\n",
" \\(x) paste0(url, \"daymet_v4_swe_annavg_na_\", x, \".nc\")\n",
")\n",
"map(\n",
" prcp_files,\n",
" function(x) {\n",
" download.file(\n",
" url = x,\n",
" destfile = paste0(\n",
" \"/data-store/iplant/home/rjramos/daymet/\",\n",
" last(unlist(strsplit(x, \"/\")))\n",
" )\n",
" )\n",
" }\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"vscode": {
"languageId": "r"
}
},
"outputs": [],
"source": [
"prcp_files <- map(\n",
" seq(1980, 2022, 1),\n",
" \\(x) paste0(url, \"daymet_v4_tmax_annavg_na_\", x, \".nc\")\n",
")\n",
"map(\n",
" prcp_files,\n",
" function(x) {\n",
" download.file(\n",
" url = x,\n",
" destfile = paste0(\n",
" \"/data-store/iplant/home/rjramos/daymet/\",\n",
" last(unlist(strsplit(x, \"/\")))\n",
" )\n",
" )\n",
" }\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"vscode": {
"languageId": "r"
}
},
"outputs": [],
"source": [
"prcp_files <- map(\n",
" seq(1980, 2022, 1),\n",
Expand All @@ -439,7 +472,7 @@
" download.file(\n",
" url = x,\n",
" destfile = paste0(\n",
" \"/data-store/iplant/home/rjramos/daymet/\",\n",
" download_dir,\n",
" last(unlist(strsplit(x, \"/\")))\n",
" )\n",
" )\n",
Expand All @@ -449,7 +482,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 6,
"metadata": {
"vscode": {
"languageId": "r"
Expand Down Expand Up @@ -745,7 +778,7 @@
" download.file(\n",
" url = x,\n",
" destfile = paste0(\n",
" \"/data-store/iplant/home/rjramos/daymet/\",\n",
" download_dir,\n",
" last(unlist(strsplit(x, \"/\")))\n",
" )\n",
" )\n",
Expand All @@ -766,7 +799,7 @@
"mimetype": "text/x-r-source",
"name": "R",
"pygments_lexer": "r",
"version": "4.3.3"
"version": "4.4.1"
}
},
"nbformat": 4,
Expand Down
13 changes: 13 additions & 0 deletions processing/daymet/daymet.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: daymet
channels:
- conda-forge
- bioconda
dependencies:
- jupyter
- r-base
- r-irkernel
- r-languageserver
- r-Cairo
- r-dplyr
- r-tidyr
- r-purrr
188 changes: 127 additions & 61 deletions processing/gis/gis.ipynb

Large diffs are not rendered by default.

15 changes: 0 additions & 15 deletions processing/requirements.yml

This file was deleted.

0 comments on commit 377687d

Please sign in to comment.