Skip to content

Commit

Permalink
Merge pull request #102 from NIEHS/0.8.1
Browse files Browse the repository at this point in the history
0.8.2 update
  • Loading branch information
sigmafelix committed Sep 11, 2024
2 parents d6d8f0d + 9413efe commit e816594
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 8 deletions.
6 changes: 3 additions & 3 deletions codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"codeRepository": "https://github.com/NIEHS/chopin",
"issueTracker": "https://github.com/NIEHS/chopin/issues",
"license": "https://spdx.org/licenses/MIT",
"version": "0.8.1",
"version": "0.8.2",
"programmingLanguage": {
"@type": "ComputerLanguage",
"name": "R",
Expand Down Expand Up @@ -366,9 +366,9 @@
},
"sameAs": "https://CRAN.R-project.org/package=lifecycle"
},
"SystemRequirements": "NetCDF4"
"SystemRequirements": "netcdf"
},
"fileSize": "27896.87KB",
"fileSize": "27888.915KB",
"releaseNotes": "https://github.com/NIEHS/chopin/blob/master/NEWS.md",
"readme": "https://github.com/NIEHS/chopin/blob/main/README.md",
"contIntegration": ["https://github.com/NIEHS/chopin/actions", "https://github.com/NIEHS/chopin/actions/workflows/check-standard.yaml"],
Expand Down
34 changes: 29 additions & 5 deletions vignettes/v04_climate_examples.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,14 @@ statemain <-
state[!state$STUSPS %in% c("AK", "HI", "PR", "VI", "GU", "MP", "AS"), ]
target_states <- statemain$GEOID

# prepared populated places
popplace <- readRDS("./input/populated_place_2022.rds")
# download populated places
options(tigris_use_cache = TRUE)
popplace <-
lapply(target_states, function(x) {
tigris::places(year = 2022, state = x)
})
popplace <- do.call(rbind, popplace)


# generate circular buffers with 10 km radius
popplacep <- sf::st_centroid(popplace, of_largest_polygon = TRUE) %>%
Expand All @@ -115,6 +121,27 @@ popplaceb <- sf::st_buffer(popplacep, dist = units::set_units(10, "km"))

TerraClimate data are provided in yearly NetCDF files, each of which contains monthly layers. We will read the data with the [`terra`](https://cran.r-project.org/web/packages/terra/index.html) package and preprocess the data to extract the annual mean and sum of the bands by types of columns.

For reproducibility, run the code below with our companion package `amadeus` to download terraClimate data. Please note that it will take a while depending on the internet speed.

```r
rlang::check_installed("amadeus")

tcli_variables <- c(
"aet", "def", "pet", "ppt", "q", "soil", "swe",
"PDSI", "srad", "tmax", "tmin", "vap", "vpd", "ws"
)

amadeus::download_terraclimate(
variables = tcli_variables,
year = c(2000, 2022),
directory_to_save = "./input/terraClimate",
acknowledgement = TRUE,
download = TRUE,
remove_command = TRUE
)

```


```r
# wbd
Expand Down Expand Up @@ -248,7 +275,6 @@ We have 14 data elements for 23 years with 12 months each. Below demonstrates th

```r
tic("multi threads (grid)")
doFuture::registerDoFuture()
future::plan(future::multicore, workers = 8L)
grid_init <-
chopin::par_pad_grid(
Expand Down Expand Up @@ -783,5 +809,3 @@ system.time(

- [Garnett, R. (2023). Geospatial distributed processing with furrr](https://posit.co/blog/geospatial-distributed-processing-with-furrr/)
- [Dyba, K. (n.d.). Parallel raster processing in *stars*](https://kadyb.github.io/stars-parallel/Tutorial.html)


0 comments on commit e816594

Please sign in to comment.