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
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
50cca2c
v1 hourly downscale
Snafkin547 Jul 2, 2024
bf7adcb
Merge branch 'develop' into downscale/hourly
Snafkin547 Jul 15, 2024
95e9691
changelog updated
Snafkin547 Jul 15, 2024
32115a4
Merge branch 'downscale/hourly' of https://github.com/Snafkin547/peca…
Snafkin547 Jul 15, 2024
a214027
man file created created
Snafkin547 Jul 15, 2024
502bf89
import package list updated
Snafkin547 Jul 15, 2024
29272cf
Merge branch 'develop' into downscale/hourly
Snafkin547 Jul 17, 2024
df6de03
Merge branch 'develop' into downscale/hourly
Snafkin547 Jul 24, 2024
e143b38
Name added to CITATION
Snafkin547 Jul 24, 2024
c418c86
Merge branch 'downscale/hourly' of https://github.com/Snafkin547/peca…
Snafkin547 Jul 24, 2024
9c840cc
Merge branch 'develop' into downscale/hourly
Snafkin547 Jul 25, 2024
85ed698
Suggested change in namespace and file input style modified
Snafkin547 Jul 29, 2024
c6bb0d0
Time units uses lubridate
Snafkin547 Jul 29, 2024
16b84a4
Merge branch 'develop' into downscale/hourly
Snafkin547 Jul 29, 2024
900acee
downscale func takes time series
Snafkin547 Jul 29, 2024
8c4234a
downscale func takes time series
Snafkin547 Jul 29, 2024
a23e600
Merge branch 'downscale/hourly' of https://github.com/Snafkin547/peca…
Snafkin547 Jul 29, 2024
bfeb8e5
Time Zone Checked
Snafkin547 Jul 29, 2024
8cad31f
Merge branch 'develop' into downscale/hourly
Snafkin547 Jul 29, 2024
f56fd9c
Updated downscale based on comment
Snafkin547 Jul 31, 2024
30de7b9
Merge branch 'downscale/hourly' of https://github.com/Snafkin547/peca…
Snafkin547 Jul 31, 2024
6ca6b65
name space added
Snafkin547 Jul 31, 2024
84780a7
Merge branch 'develop' into downscale/hourly
mdietze Aug 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ For more information about this file see also [Keep a Changelog](http://keepacha
- Added GEDI AGB preparation workflow.
- Added new feature of downloading datasets from the NASA DAAC ORNL database.
- Extended downscale function and created 'downscale_hrly' so that it handles more frequent data
- Added 'aggregate' as a new feature for downscaled data

### Fixed

Expand Down
13 changes: 11 additions & 2 deletions modules/assim.sequential/R/downscale_function_hrly.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#' @param covariates SpatRaster stack, used as predictors in randomForest. Layers within stack should be named. Recommended that this stack be generated using 'covariates' instructions in assim.sequential/inst folder
#' @return It returns the `downscale_output` list containing lists for the training and testing data sets, models, and predicted maps for each ensemble member.
#' @import ncdf4
#' @import lubridate
Snafkin547 marked this conversation as resolved.
Show resolved Hide resolved
#' @export

SDA_downscale_hrly <- function(nc_file, coords, date, covariates){
Expand All @@ -20,8 +21,16 @@ SDA_downscale_hrly <- function(nc_file, coords, date, covariates){
# Timereadable
time <- nc_data$dim$time$vals
time_units <- nc_data$dim$time$units
time_origin <- as.POSIXct(substr(time_units, 12, 31), format="%Y-%m-%dT%H:%M")
time_readable <- time_origin + time * 3600 # Convert hours to seconds
time_origin_str <- substr(time_units, 12, 31)
time_origin <- ymd_hm(time_origin_str, tz="EST")
Snafkin547 marked this conversation as resolved.
Show resolved Hide resolved
# Check if time units are in hours and convert appropriately
if (grepl("hours", time_units)) {
time_readable <- time_origin + dhours(time)
Snafkin547 marked this conversation as resolved.
Show resolved Hide resolved
} else if (grepl("seconds", time_units)) {
time_readable <- time_origin + dseconds(time)
} else {
stop("Unsupported time units")
}

# Extract predictors from covariates raster using site coordinates
site_coordinates <- terra::vect(readr::read_csv(coords), geom=c("lon", "lat"), crs="EPSG:4326")
Expand Down
Loading