Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add downscale_function and covariates scripts #3272

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from

Conversation

JoshuaPloshay
Copy link
Collaborator

Description

Motivation and Context

Review Time Estimate

  • Immediately
  • Within one week
  • When possible

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My change requires a change to the documentation.
  • My name is in the list of CITATION.cff
  • I have updated the CHANGELOG.md.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

modules/assim.sequential/R/downscale_function.R Outdated Show resolved Hide resolved
modules/assim.sequential/R/downscale_function.R Outdated Show resolved Hide resolved
data <- input_data[[index]]
carbon_data <- as.data.frame(t(data[which(names(data) == C_pool)]))
names(carbon_data) <- paste0("ensemble",seq(1:ncol(carbon_data)))

# Extract predictors from covariates raster using site coordinates
predictors <- as.data.frame(terra::extract(covariates, site_coordinates))
predictors <- dplyr::select(predictors, -1)
predictors <- dplyr::select(predictors, -ID)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see where ID is being defined/calculated in the code above.

modules/assim.sequential/R/downscale_function.R Outdated Show resolved Hide resolved
# 2023 REU project used 10 minute spatial resolution

## Solar Radiation (kJ m-2 day-1)
srad <- terra::rast(list.files(path = "/projectnb/dietzelab/jploshay/pecan_copy/jploshay/10m_srad",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For anyone to be able to reuse this script they will have to redefine a LOT of local paths. Better would be to define ONE folder where all the data is located at the top of the script and then express all the other paths relative to that (e.g. using file.path())


#### Land Cover ####
GLanCE_extract <- function(pattern, path) {
files <- list.files(path = "/projectnb/dietzelab/dietze/glance2012/e4ftl01.cr.usgs.gov/MEASURES/GLanCE30.001/2012.07.01", #make this path default
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure you don't want to hard code a file path within a function. Much better to make it an argument. indeed, this function already has a path argument that doesn't seem to be used anywhere.

sand <- geodata::soil_world(var = "sand", depth = 5, stat = "mean", path = tempdir())


#### Land Cover ####
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For files that are manually downloaded, your earlier examples provided some indication of where the data is located and how to download it. Equivalent info is missing here.


#### Resample and Stack Maps ####
# Define the extent to crop the covariates to North America
NA_extent <- terra::ext(-178.19453125, -10, 7.22006835937502, 83.5996093750001)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be good to have at the top of the script in case a user wants/needs to set a different extent.

modules/assim.sequential/R/downscale_function.R Outdated Show resolved Hide resolved
modules/assim.sequential/R/downscale_function.R Outdated Show resolved Hide resolved
modules/assim.sequential/R/downscale_function.R Outdated Show resolved Hide resolved
@mdietze
Copy link
Member

mdietze commented May 16, 2024

@JoshuaPloshay this PR is failing because of a conflict between the updated Roxygen and the not-yet-updated man page. Could you pull the changes I've made into your local branch, then rerun make document, then commit the updated NA_downscale.Rd?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants