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 9 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.

Copy link
Member

Choose a reason for hiding this comment

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

Looks like it was added by terra::extract on line 34 above, and could be suppressed by by passing ID = FALSE there

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?

@mdietze mdietze mentioned this pull request May 21, 2024
13 tasks
@mdietze
Copy link
Member

mdietze commented May 22, 2024

@JoshuaPloshay I believe you have code that loads up existing PEcAn output, calls your downscale function, and does some analyses and visualizations of the outputs (including quantile checks). It would be good to add such code to this PR (e.g. in the /inst folder) so that others don't need to recreate this to be able to pick up on where your analyses left off.

Joshua Ploshay and others added 4 commits May 24, 2024 11:26
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

3 participants