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

Downscale Function created for for hourly data in nc #3322

Merged
merged 23 commits into from
Aug 1, 2024

Conversation

Snafkin547
Copy link
Contributor

@Snafkin547 Snafkin547 commented Jul 2, 2024

Description

This new function, called 'NA_downscale_hrly', is extended from the original 'NA_downscale' function.
This newly created downscale function handles hourly data stored in nc file and generates outputs including the weights of each ensemble member for each observatory site. These weights are not currently used, however, they will be used effectively in the aggregation step in the future, once we come up with an idea of how to distribute to each coordinate.

Motivation and Context

In the previously developed 'NA_downscale' function, monthly-yearly data was handled. This newly developed downscale function enables to deal with the hourly data. Due to the difference in data structures and absence of weights in previous data structure, we needed this change.

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.

@Snafkin547
Copy link
Contributor Author

Example usage

# Set working directory
my_wd <- "<Your working directory>"
setwd(my_wd)

# Load necessary library
library(terra)
library(readr)
library(sf)
library(ncdf4)

nc_file <- "/Users/hishii/Desktop/PEcAn/osfstorage-archive/NCDF/NEE.nc"
nc_data <- nc_open(nc_file)
coords <- paste0(my_wd, "data/SDA/sites.csv")
covariates <- rast(paste0(my_wd, "data/covariates.tif"))
date <- "1986-01-01 00:00:00 EST"
downscale_output <- NA_downscale_hrly(nc_data, coords, date, covariates)

@Snafkin547 Snafkin547 changed the title v1 hourly downscale Downscale Function created for for hourly data in nc Jul 15, 2024
Copy link
Member

@mdietze mdietze left a comment

Choose a reason for hiding this comment

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

Overall, function is a good first start but doesn't really address the need to downscale timeseries, but instead provides a way to downscale a single time point. I'm happy to pull in this PR as an initial milestone without that generalization once the other smaller points are addressed.

modules/assim.sequential/R/downscale_function_hrly.R Outdated Show resolved Hide resolved
modules/assim.sequential/R/downscale_function_hrly.R Outdated Show resolved Hide resolved
modules/assim.sequential/R/downscale_function_hrly.R Outdated Show resolved Hide resolved
modules/assim.sequential/R/downscale_function_hrly.R Outdated Show resolved Hide resolved
modules/assim.sequential/R/downscale_function_hrly.R Outdated Show resolved Hide resolved
modules/assim.sequential/R/downscale_function_hrly.R Outdated Show resolved Hide resolved
@Snafkin547 Snafkin547 requested a review from mdietze July 29, 2024 18:33
modules/assim.sequential/R/downscale_function_hrly.R Outdated Show resolved Hide resolved
maps <- list()
predictions <- list()
ensembles <- list()
for (i in seq_along(carbon_data)) {
Copy link
Member

Choose a reason for hiding this comment

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

Doesn't need any change for this PR, but making a note for those doing future development that this would be a great place to either parallelize this work or to modify the ML model to take time into account explicitly.

modules/assim.sequential/R/downscale_function_hrly.R Outdated Show resolved Hide resolved
@Snafkin547 Snafkin547 requested a review from mdietze July 31, 2024 18:18
@Snafkin547 Snafkin547 requested a review from mdietze July 31, 2024 21:05
@mdietze mdietze merged commit c83a9b4 into PecanProject:develop Aug 1, 2024
12 of 13 checks passed
@infotroph
Copy link
Member

infotroph commented Sep 5, 2024

Hi, @Snafkin547! With this PR you became an author of the PEcAn.assim.sequential package, so we'd like to make sure we have your agreement to change the package license from NCSA to BSD-3. Commenting "yes" here is enough. More details are in #3364 if you want them.

We started the relicensing process (with notes in CHANGELOG.md) before you opened this PR, but at merge time we hadn't yet updated any license files in this package, so for full clarity we'd like to hear your explicit consent even if you had been assuming your contribution would be BSD-3 all along 😁

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

Successfully merging this pull request may close these issues.

3 participants