-
Notifications
You must be signed in to change notification settings - Fork 241
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
Updated load_data.R #1592 #2771
Merged
Merged
Changes from 11 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
5bccee8
Updated load_data.R
moki1202 3cfbe7d
automated documentation update
13a02a1
updated Load_data.R
moki1202 e9c1c1d
updated modules/benchmark/DESCRIPTION
moki1202 bd90f29
updated DESCRIPTION
moki1202 9ba0cf3
automated documentation update
6ac602d
trivial whitespace change to trigger CI build
infotroph 8fabcd8
updated DESCRIPTION
moki1202 603d20e
Fix commas in benchmark DESCRIPTION
ashiklom 566d329
Update DESCRIPTION
moki1202 f1e3ee9
Remove blank space in modules/benchmark/DESCRIPTION
ashiklom cce02fb
Update DESCRIPTION
moki1202 be7586b
Update load_data.R
moki1202 3fb5364
Merge branch 'develop' into patch-1
infotroph File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ wanted <- c( | |
'binaryLogic', | ||
'BioCro', | ||
'bit64', | ||
'BrownDog', | ||
'coda', | ||
'corrplot', | ||
'data.table', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -9,6 +9,7 @@ | |||||
##' @author Betsy Cowdery, Istem Fer, Joshua Mantooth | ||||||
##' Generic function to convert input files containing observational data to | ||||||
##' a common PEcAn format. | ||||||
#' @importFrom magrittr %>% | ||||||
|
||||||
load_data <- function(data.path, format, start_year = NA, end_year = NA, site = NA, | ||||||
vars.used.index=NULL, ...) { | ||||||
|
@@ -30,12 +31,6 @@ load_data <- function(data.path, format, start_year = NA, end_year = NA, site = | |||||
vars.used.index <- setdiff(seq_along(format$vars$variable_id), format$time.row) | ||||||
} | ||||||
|
||||||
library(PEcAn.utils) | ||||||
library(PEcAn.benchmark) | ||||||
library(lubridate) | ||||||
library(udunits2) | ||||||
library(dplyr) | ||||||
|
||||||
# Determine the function that should be used to load the data | ||||||
mimetype <- gsub("-", "_", format$mimetype) | ||||||
fcn1 <- paste0("load_", format$file_name) | ||||||
|
@@ -44,13 +39,13 @@ load_data <- function(data.path, format, start_year = NA, end_year = NA, site = | |||||
fcn <- match.fun(fcn1) | ||||||
} else if (exists(fcn2)) { | ||||||
fcn <- match.fun(fcn2) | ||||||
} else if (!exists(fcn1) & !exists(fcn2) & require(bd)) { | ||||||
} else if (!exists(fcn1) & !exists(fcn2) & requireNamespace(bd, quietly = TRUE)) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
#To Do: call to DAP to see if conversion to csv is possible | ||||||
#Brown Dog API call through BDFiddle, requires username and password | ||||||
key <- get_key("https://bd-api.ncsa.illinois.edu",username,password) | ||||||
token <- get_token("https://bd-api.ncsa.illinois.edu",key) | ||||||
key <- BrownDog::get_key("https://bd-api.ncsa.illinois.edu",username,password) | ||||||
token <- BrownDog::get_token("https://bd-api.ncsa.illinois.edu",key) | ||||||
#output_path = where are we putting converted file? | ||||||
converted.data.path <- convert_file(url = "https://bd-api.ncsa.illinois.edu", input_filename = data.path, | ||||||
converted.data.path <- BrownDog::convert_file(url = "https://bd-api.ncsa.illinois.edu", input_filename = data.path, | ||||||
output = "csv", output_path = output_path, token = token) | ||||||
if (is.na(converted.data.path)){ | ||||||
PEcAn.logger::logger.error("Converted file was not returned from Brown Dog") | ||||||
|
@@ -94,11 +89,11 @@ load_data <- function(data.path, format, start_year = NA, end_year = NA, site = | |||||
vars_used$pecan_name[i], vars_used$pecan_units[i])) | ||||||
out[col] <- udunits2::ud.convert(as.numeric(x), u1, u2) | ||||||
colnames(out)[col] <- vars_used$pecan_name[i] | ||||||
} else if (misc.are.convertible(u1, u2)) { | ||||||
} else if (PEcAn.utils::misc.are.convertible(u1, u2)) { | ||||||
print(sprintf("convert %s %s to %s %s", | ||||||
vars_used$input_name[i], u1, | ||||||
vars_used$pecan_name[i], u2)) | ||||||
out[col] <- as.vector(misc.convert(x, u1, u2)) # Betsy: Adding this because misc.convert returns vector with attributes original agrument x, which causes problems later | ||||||
out[col] <- as.vector(PEcAn.utils::misc.convert(x, u1, u2)) # Betsy: Adding this because misc.convert returns vector with attributes original agrument x, which causes problems later | ||||||
colnames(out)[col] <- vars_used$pecan_name[i] | ||||||
} else { | ||||||
PEcAn.logger::logger.warn(paste("Units cannot be converted. Removing variable. please check the units of",vars_used$input_name[i])) | ||||||
|
@@ -115,7 +110,7 @@ load_data <- function(data.path, format, start_year = NA, end_year = NA, site = | |||||
names(out)[col] <- format$vars$pecan_name[time.row] | ||||||
|
||||||
# Need a much more spohisticated approach to converting into time format. | ||||||
y <- dplyr::select(out, one_of(format$vars$pecan_name[time.row])) | ||||||
y <- dplyr::select(out, tidyselect::one_of(format$vars$pecan_name[time.row])) | ||||||
|
||||||
if(!is.null(site$time_zone)){ | ||||||
tz = site$time_zone | ||||||
|
@@ -145,4 +140,3 @@ load_data <- function(data.path, format, start_year = NA, end_year = NA, site = | |||||
|
||||||
return(out) | ||||||
} # load_data | ||||||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@infotroph ill get on this ASAP. also, the pleasure was mine, got to learn so much from you guys. thanks for being patient with me hehe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also please suggest any error fix that I can start working on after this.