From ea306cd1afe78cb514c46bda08517e89f320e271 Mon Sep 17 00:00:00 2001 From: tonygardella Date: Wed, 15 Mar 2017 19:04:47 -0500 Subject: [PATCH 1/3] fixes to AmerifluxLBL and met2CF.csv cleanup --- modules/data.atmosphere/NAMESPACE | 6 +++++ .../data.atmosphere/R/download.AmerifluxLBL.R | 5 ++-- modules/data.atmosphere/R/met2CF.csv.R | 24 ++++++++++--------- modules/data.atmosphere/R/met2cf.module.R | 4 ++-- .../data.atmosphere/man/download.CRUNCEP.Rd | 7 ++---- modules/data.atmosphere/man/download.GLDAS.Rd | 2 +- modules/data.atmosphere/man/download.NARR.Rd | 5 +--- modules/data.atmosphere/man/download.NLDAS.Rd | 5 +--- modules/data.atmosphere/man/met2CF.csv.Rd | 2 +- 9 files changed, 30 insertions(+), 30 deletions(-) diff --git a/modules/data.atmosphere/NAMESPACE b/modules/data.atmosphere/NAMESPACE index 617cce63f52..7424fd47e34 100644 --- a/modules/data.atmosphere/NAMESPACE +++ b/modules/data.atmosphere/NAMESPACE @@ -59,6 +59,9 @@ importFrom(PEcAn.utils,logger.debug) importFrom(PEcAn.utils,logger.error) importFrom(PEcAn.utils,logger.severe) importFrom(PEcAn.utils,logger.warn) +importFrom(lubridate,year) +importFrom(lubridate,ymd_hm) +importFrom(lubridate,ymd_hms) importFrom(ncdf4,ncatt_get) importFrom(ncdf4,ncatt_put) importFrom(ncdf4,ncdim_def) @@ -66,3 +69,6 @@ importFrom(ncdf4,ncvar_add) importFrom(ncdf4,ncvar_def) importFrom(ncdf4,ncvar_get) importFrom(ncdf4,ncvar_put) +importFrom(udunits2,ud.are.convertible) +importFrom(udunits2,ud.convert) +importFrom(udunits2,ud.is.parseable) diff --git a/modules/data.atmosphere/R/download.AmerifluxLBL.R b/modules/data.atmosphere/R/download.AmerifluxLBL.R index 8e2ff8f465b..51c810bc5fa 100644 --- a/modules/data.atmosphere/R/download.AmerifluxLBL.R +++ b/modules/data.atmosphere/R/download.AmerifluxLBL.R @@ -39,7 +39,7 @@ download.AmerifluxLBL <- function(sitename, outfolder, start_date, end_date, # need to query to get full file name #this is Ameriflux version url <- "http://wile.lbl.gov:8080/AmeriFlux/DataDownload.svc/datafileURLs" json_query <- paste0("{\"username\":\"", username, "\",\"siteList\":[\"", site, "\"],\"intendedUse\":\"Research - Land model/Earth system model\",\"description\":\"PEcAn download\"}") - result <- httr::POST(url, body = json_query, encode = "json", add_headers(`Content-Type` = "application/json")) + result <- httr::POST(url, body = json_query, encode = "json", httr::add_headers(`Content-Type` = "application/json")) link <- httr::content(result) ftplink <- NULL @@ -164,5 +164,6 @@ download.AmerifluxLBL <- function(sitename, outfolder, start_date, end_date, results$formatname[rows] <- "AMERIFLUX_BASE_HH" # return list of files downloaded - return(invisible(results)) + + return(results) } # download.AmerifluxLBL diff --git a/modules/data.atmosphere/R/met2CF.csv.R b/modules/data.atmosphere/R/met2CF.csv.R index 7a2f8d5a382..211137ce49b 100644 --- a/modules/data.atmosphere/R/met2CF.csv.R +++ b/modules/data.atmosphere/R/met2CF.csv.R @@ -35,18 +35,20 @@ ##' in.prefix <- 'FLX_US-WCr_FLUXNET2015_SUBSET_HH_1999-2014_1-1' ##' outfolder <- '~/' ##' input.id <- 5000000005 -##' format <- query.format.vars(input.id=input.id,con) +##' format <- query.format.vars(input.id=input.id,bety = bety) ##' start_date <- ymd_hm('200401010000') ##' end_date <- ymd_hm('200412312330') ##' PEcAn.data.atmosphere::met2CF.csv(in.path,in.prefix,outfolder,start_date,end_date,format,overwrite=TRUE) ##' } ##' @importFrom ncdf4 ncvar_get ncdim_def ncvar_add ncvar_put +##' @importFrom lubridate year ymd_hm ymd_hms +##' @importFrom udunits2 ud.is.parseable ud.convert ud.are.convertible met2CF.csv <- function(in.path, in.prefix, outfolder, start_date, end_date, format, lat = NULL, lon = NULL, nc_verbose = FALSE, overwrite = FALSE, ...) { library(PEcAn.utils) - start_year <- lubridate::year(start_date) - end_year <- lubridate::year(end_date) + start_year <- year(start_date) + end_year <- year(end_date) if (!file.exists(outfolder)) { dir.create(outfolder) } @@ -171,9 +173,9 @@ met2CF.csv <- function(in.path, in.prefix, outfolder, start_date, end_date, form ## Only run if years > start_date < end_date ## if both are provided, clip data to those dates ## Otherwise set start/end to first/last datetime of file - years <- lubridate::year(alldatetime) + years <- year(alldatetime) if (!missing(start_date) && !missing(end_date)) { - availdat <- which(years >= lubridate::year(start_date) & years <= lubridate::year(end_date)) + availdat <- which(years >= year(start_date) & years <= year(end_date)) if (length(availdat) == 0) { logger.error("data does not contain output after start_date or before end_date") } @@ -210,7 +212,7 @@ met2CF.csv <- function(in.path, in.prefix, outfolder, start_date, end_date, form ### create time dimension days_since_1700 <- datetime - ymd_hm("1700-01-01 00:00") t <- ncdim_def("time", "days since 1700-01-01", as.numeric(days_since_1700)) #define netCDF dimensions for variables - timestep <- as.numeric(mean(udunits2::ud.convert(diff(days_since_1700), "d", "s"))) + timestep <- as.numeric(mean(ud.convert(diff(days_since_1700), "d", "s"))) ## create lat lon dimensions x <- ncdim_def("longitude", "degrees_east", lon) # define netCDF dimensions for variables @@ -473,10 +475,10 @@ met2CF.csv <- function(in.path, in.prefix, outfolder, start_date, end_date, form rain <- rain / timestep "Mg m-2 s-1" }, `in` = { - rain <- udunits2::ud.convert(rain / timestep, "in", "mm") + rain <- ud.convert(rain / timestep, "in", "mm") "kg m-2 s-1" }, `mm h-1` = { - rain <- udunits2::ud.convert(rain / timestep, "h", "s") + rain <- ud.convert(rain / timestep, "h", "s") "kg m-2 s-1" }) ncvar_put(nc, varid = precip.var, @@ -595,14 +597,14 @@ met2CF.csv <- function(in.path, in.prefix, outfolder, start_date, end_date, form ncdf4::nc_close(nc) } ## end loop over years } ## end else file found - return(invisible(results)) + return(results) } # met2CF.csv datetime <- function(list) { date_string <- sapply(list, as.character) datetime <- paste(list, "00") - return(ymd_hms(datetime)) + return(lubridate::ymd_hms(datetime)) } # datetime met.conv <- function(x, orig, bety, CF) { @@ -615,7 +617,7 @@ met.conv <- function(x, orig, bety, CF) { } if (ud.is.parseable(orig)) { if (ud.are.convertible(orig, bety)) { - return(udunits2::ud.convert(udunits2::ud.convert(x, orig, bety), bety, CF)) + return(ud.convert(ud.convert(x, orig, bety), bety, CF)) } else { logger.error(paste("met.conv could not convert", orig, bety, CF)) } diff --git a/modules/data.atmosphere/R/met2cf.module.R b/modules/data.atmosphere/R/met2cf.module.R index decc2a9028b..039b9cda845 100644 --- a/modules/data.atmosphere/R/met2cf.module.R +++ b/modules/data.atmosphere/R/met2cf.module.R @@ -1,5 +1,5 @@ .met2cf.module <- function(raw.id, register, met, str_ns, dir, machine, site.id, lat, lon, start_date, end_date, - con, host, overwrite = FALSE, format.vars) { + con, host, overwrite = FALSE, format.vars, bety) { logger.info("Begin change to CF Standards") @@ -75,7 +75,7 @@ exact.dates = FALSE) } else if (exists(fcn2)) { fcn <- fcn2 - format <- query.format.vars(input.id, con) + format <- query.format.vars(input.id = input.id, bety = bety) cf.id <- convert.input(input.id = input.id, outfolder = outfolder, formatname = formatname, diff --git a/modules/data.atmosphere/man/download.CRUNCEP.Rd b/modules/data.atmosphere/man/download.CRUNCEP.Rd index c4a5c47ba8d..732ba408d17 100644 --- a/modules/data.atmosphere/man/download.CRUNCEP.Rd +++ b/modules/data.atmosphere/man/download.CRUNCEP.Rd @@ -2,16 +2,13 @@ % Please edit documentation in R/download.CRUNCEP_Global.R \name{download.CRUNCEP} \alias{download.CRUNCEP} -\title{download.CRUNCEP} +\title{Download CRUNCEP data} \usage{ download.CRUNCEP(outfolder, start_date, end_date, site_id, lat.in, lon.in, overwrite = FALSE, verbose = FALSE, ...) } -\arguments{ -\item{lon}{} -} \description{ -Download and conver to CF CRUNCEP single grid point from MSTIMIP server using OPENDAP interface +Download and convert to CF CRUNCEP single grid point from MSTIMIP server using OPENDAP interface } \author{ James Simkins, Mike Dietze diff --git a/modules/data.atmosphere/man/download.GLDAS.Rd b/modules/data.atmosphere/man/download.GLDAS.Rd index 04ac82ffc8d..325d352eda5 100644 --- a/modules/data.atmosphere/man/download.GLDAS.Rd +++ b/modules/data.atmosphere/man/download.GLDAS.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/download.GLDAS.R \name{download.GLDAS} \alias{download.GLDAS} -\title{download.GLDAS} +\title{Download GLDAS data} \usage{ download.GLDAS(outfolder, start_date, end_date, site_id, lat.in, lon.in, overwrite = FALSE, verbose = FALSE, ...) diff --git a/modules/data.atmosphere/man/download.NARR.Rd b/modules/data.atmosphere/man/download.NARR.Rd index 6f2921b4a5e..fdb35ceb483 100644 --- a/modules/data.atmosphere/man/download.NARR.Rd +++ b/modules/data.atmosphere/man/download.NARR.Rd @@ -2,14 +2,11 @@ % Please edit documentation in R/download.NARR.R \name{download.NARR} \alias{download.NARR} -\title{download.NARR} +\title{Download NARR files} \usage{ download.NARR(outfolder, start_date, end_date, overwrite = FALSE, verbose = FALSE, ...) } -\arguments{ -\item{end_year}{} -} \description{ Download NARR files } diff --git a/modules/data.atmosphere/man/download.NLDAS.Rd b/modules/data.atmosphere/man/download.NLDAS.Rd index adae9aebe5f..152023b946d 100644 --- a/modules/data.atmosphere/man/download.NLDAS.Rd +++ b/modules/data.atmosphere/man/download.NLDAS.Rd @@ -2,14 +2,11 @@ % Please edit documentation in R/download.NLDAS.R \name{download.NLDAS} \alias{download.NLDAS} -\title{download.NLDAS} +\title{Download NLDAS met data} \usage{ download.NLDAS(outfolder, start_date, end_date, site_id, lat.in, lon.in, overwrite = FALSE, verbose = FALSE, ...) } -\arguments{ -\item{lon}{} -} \description{ Download and convert single grid point NLDAS to CF single grid point from hydro1.sci.gsfc.nasa.gov using OPENDAP interface } diff --git a/modules/data.atmosphere/man/met2CF.csv.Rd b/modules/data.atmosphere/man/met2CF.csv.Rd index 6f562952463..5937813a84a 100644 --- a/modules/data.atmosphere/man/met2CF.csv.Rd +++ b/modules/data.atmosphere/man/met2CF.csv.Rd @@ -38,7 +38,7 @@ in.path <- '/home/carya/sites/willow/' in.prefix <- 'FLX_US-WCr_FLUXNET2015_SUBSET_HH_1999-2014_1-1' outfolder <- '~/' input.id <- 5000000005 -format <- query.format.vars(input.id=input.id,con) +format <- query.format.vars(input.id=input.id,bety = bety) start_date <- ymd_hm('200401010000') end_date <- ymd_hm('200412312330') PEcAn.data.atmosphere::met2CF.csv(in.path,in.prefix,outfolder,start_date,end_date,format,overwrite=TRUE) From 7b630e884eb646586a0dedb62dea40aca7dc0461 Mon Sep 17 00:00:00 2001 From: tonygardella Date: Thu, 16 Mar 2017 10:52:50 -0500 Subject: [PATCH 2/3] fix external function calls --- modules/data.atmosphere/NAMESPACE | 3 -- modules/data.atmosphere/R/met2CF.csv.R | 67 +++++++++++++------------- 2 files changed, 33 insertions(+), 37 deletions(-) diff --git a/modules/data.atmosphere/NAMESPACE b/modules/data.atmosphere/NAMESPACE index 7424fd47e34..c461aa2f9f9 100644 --- a/modules/data.atmosphere/NAMESPACE +++ b/modules/data.atmosphere/NAMESPACE @@ -59,9 +59,6 @@ importFrom(PEcAn.utils,logger.debug) importFrom(PEcAn.utils,logger.error) importFrom(PEcAn.utils,logger.severe) importFrom(PEcAn.utils,logger.warn) -importFrom(lubridate,year) -importFrom(lubridate,ymd_hm) -importFrom(lubridate,ymd_hms) importFrom(ncdf4,ncatt_get) importFrom(ncdf4,ncatt_put) importFrom(ncdf4,ncdim_def) diff --git a/modules/data.atmosphere/R/met2CF.csv.R b/modules/data.atmosphere/R/met2CF.csv.R index 211137ce49b..ffe069fbed2 100644 --- a/modules/data.atmosphere/R/met2CF.csv.R +++ b/modules/data.atmosphere/R/met2CF.csv.R @@ -41,14 +41,13 @@ ##' PEcAn.data.atmosphere::met2CF.csv(in.path,in.prefix,outfolder,start_date,end_date,format,overwrite=TRUE) ##' } ##' @importFrom ncdf4 ncvar_get ncdim_def ncvar_add ncvar_put -##' @importFrom lubridate year ymd_hm ymd_hms ##' @importFrom udunits2 ud.is.parseable ud.convert ud.are.convertible met2CF.csv <- function(in.path, in.prefix, outfolder, start_date, end_date, format, lat = NULL, lon = NULL, nc_verbose = FALSE, overwrite = FALSE, ...) { - library(PEcAn.utils) + - start_year <- year(start_date) - end_year <- year(end_date) + start_year <- lubridate::year(start_date) + end_year <- lubridate::year(end_date) if (!file.exists(outfolder)) { dir.create(outfolder) } @@ -68,7 +67,7 @@ met2CF.csv <- function(in.path, in.prefix, outfolder, start_date, end_date, form files <- files[grep("*.csv", files)] if (length(files) == 0) { return(NULL) - logger.warn("No met files named ", in.prefix, "found in ", in.path) + PEcAn.utils::logger.warn("No met files named ", in.prefix, "found in ", in.path) } files <- files[1] @@ -97,11 +96,11 @@ met2CF.csv <- function(in.path, in.prefix, outfolder, start_date, end_date, form # If all the files already exist, then skip the conversion unless overwrite=TRUE if (!overwrite && all(file.exists(all_files))) { - logger.debug("File '", all_files, "' already exist, skipping.") + PEcAn.utils::logger.debug("File '", all_files, "' already exist, skipping.") } else { # If some of the files already exist, skip those, but still need to read file if (!overwrite && any(file.exists(all_files))) { - logger.debug("Files ", all_files[which(file.exists(all_files))], " already exist, skipping those") + PEcAn.utils::logger.debug("Files ", all_files[which(file.exists(all_files))], " already exist, skipping those") all_years <- all_years[which(!file.exists(all_files))] all_files <- all_files[which(!file.exists(all_files))] } @@ -109,7 +108,7 @@ met2CF.csv <- function(in.path, in.prefix, outfolder, start_date, end_date, form ## Read the CSV file some files have a line under the header that lists variable units ## search for NA's after conversion to numeric if (is.null(format$header)) { - logger.warn("please specify number of header rows in file") + PEcAn.utils::logger.warn("please specify number of header rows in file") alldat <- read.csv(files, skip = format$skip, na.strings = format$na.strings, @@ -158,7 +157,7 @@ met2CF.csv <- function(in.path, in.prefix, outfolder, start_date, end_date, form alldatetime <- as.POSIXct(yyddhhmm) } else { ## Does not match any of the known date formats, add new ones here! - logger.error("datetime column is not specified in format") + PEcAn.utils::logger.error("datetime column is not specified in format") } } else { datetime_units <- format$vars$input_units[datetime_index] #lubridate function to call such as ymd_hms @@ -173,11 +172,11 @@ met2CF.csv <- function(in.path, in.prefix, outfolder, start_date, end_date, form ## Only run if years > start_date < end_date ## if both are provided, clip data to those dates ## Otherwise set start/end to first/last datetime of file - years <- year(alldatetime) + years <- lubridate::year(alldatetime) if (!missing(start_date) && !missing(end_date)) { - availdat <- which(years >= year(start_date) & years <= year(end_date)) + availdat <- which(years >= lubridate::year(start_date) & years <= lubridate::year(end_date)) if (length(availdat) == 0) { - logger.error("data does not contain output after start_date or before end_date") + PEcAn.utils::logger.error("data does not contain output after start_date or before end_date") } alldat <- alldat[availdat, ] alldatetime <- alldatetime[availdat] @@ -197,7 +196,7 @@ met2CF.csv <- function(in.path, in.prefix, outfolder, start_date, end_date, form this.year <- all_years[i] availdat.year <- which(years == this.year) if (length(availdat.year) == 0) { - logger.debug("File ", all_files, " has no data for year ", this.year) + PEcAn.utils::logger.debug("File ", all_files, " has no data for year ", this.year) next } new.file <- all_files[i] @@ -210,7 +209,7 @@ met2CF.csv <- function(in.path, in.prefix, outfolder, start_date, end_date, form results$enddate[this.year - start_year + 1] <- as.character(datetime[length(datetime)]) ### create time dimension - days_since_1700 <- datetime - ymd_hm("1700-01-01 00:00") + days_since_1700 <- datetime - lubridate::ymd_hm("1700-01-01 00:00") t <- ncdim_def("time", "days since 1700-01-01", as.numeric(days_since_1700)) #define netCDF dimensions for variables timestep <- as.numeric(mean(ud.convert(diff(days_since_1700), "d", "s"))) @@ -230,13 +229,13 @@ met2CF.csv <- function(in.path, in.prefix, outfolder, start_date, end_date, form if (any(colnames(format$vars) == "column_number")) { arrloc <- format$vars$column_number[k] } else { - logger.error("Cannot find column location for airT by name or column number") + PEcAn.utils::logger.error("Cannot find column location for airT by name or column number") } } ncvar_put(nc, varid = airT.var, vals = met.conv(dat[, arrloc], format$vars$input_units[k], "celsius", "K")) } else { - logger.error("No air temperature found in met file") + PEcAn.utils::logger.error("No air temperature found in met file") } ## air_pressure (Pa) => air_pressure (Pa) @@ -250,7 +249,7 @@ met2CF.csv <- function(in.path, in.prefix, outfolder, start_date, end_date, form if (any(colnames(format$vars) == "column_number")) { arrloc <- format$vars$column_number[k] } else { - logger.error("Cannot find column location for air_pressure by name or column number") + PEcAn.utils::logger.error("Cannot find column location for air_pressure by name or column number") } } ncvar_put(nc, varid = Psurf.var, @@ -270,7 +269,7 @@ met2CF.csv <- function(in.path, in.prefix, outfolder, start_date, end_date, form if (any(colnames(format$vars) == "column_number")) { arrloc <- format$vars$column_number[k] } else { - logger.error("Cannot find column location for co2atm by name or column number") + PEcAn.utils::logger.error("Cannot find column location for co2atm by name or column number") } } ncvar_put(nc, @@ -291,7 +290,7 @@ met2CF.csv <- function(in.path, in.prefix, outfolder, start_date, end_date, form if (any(colnames(format$vars) == "column_number")) { arrloc <- format$vars$column_number[k] } else { - logger.error("Cannot find column location for soilM by name or column number") + PEcAn.utils::logger.error("Cannot find column location for soilM by name or column number") } } ncvar_put(nc, @@ -310,7 +309,7 @@ met2CF.csv <- function(in.path, in.prefix, outfolder, start_date, end_date, form if (any(colnames(format$vars) == "column_number")) { arrloc <- format$vars$column_number[k] } else { - logger.error("Cannot find column location for soilT by name or column number") + PEcAn.utils::logger.error("Cannot find column location for soilT by name or column number") } } ncvar_put(nc, @@ -329,7 +328,7 @@ met2CF.csv <- function(in.path, in.prefix, outfolder, start_date, end_date, form if (any(colnames(format$vars) == "column_number")) { arrloc <- format$vars$column_number[k] } else { - logger.error("Cannot find column location for relative_humidity by name or column number") + PEcAn.utils::logger.error("Cannot find column location for relative_humidity by name or column number") } } ncvar_put(nc, @@ -348,7 +347,7 @@ met2CF.csv <- function(in.path, in.prefix, outfolder, start_date, end_date, form if (any(colnames(format$vars) == "column_number")) { arrloc <- format$vars$column_number[k] } else { - logger.error("Cannot find column location for specific_humidity by name or column number") + PEcAn.utils::logger.error("Cannot find column location for specific_humidity by name or column number") } } ncvar_put(nc, @@ -378,7 +377,7 @@ met2CF.csv <- function(in.path, in.prefix, outfolder, start_date, end_date, form if (any(colnames(format$vars) == "column_number")) { arrloc <- format$vars$column_number[k] } else { - logger.error("Cannot find column location for VPD by name or column number") + PEcAn.utils::logger.error("Cannot find column location for VPD by name or column number") } } ncvar_put(nc, @@ -400,7 +399,7 @@ met2CF.csv <- function(in.path, in.prefix, outfolder, start_date, end_date, form if (any(colnames(format$vars) == "column_number")) { arrloc <- format$vars$column_number[k] } else { - logger.error("Cannot find column location for surface_downwelling_longwave_flux_in_air by name or column number") + PEcAn.utils::logger.error("Cannot find column location for surface_downwelling_longwave_flux_in_air by name or column number") } } ncvar_put(nc, @@ -421,7 +420,7 @@ met2CF.csv <- function(in.path, in.prefix, outfolder, start_date, end_date, form if (any(colnames(format$vars) == "column_number")) { arrloc <- format$vars$column_number[k] } else { - logger.error("Cannot find column location for solar_radiation by name or column number") + PEcAn.utils::logger.error("Cannot find column location for solar_radiation by name or column number") } } ncvar_put(nc, @@ -442,7 +441,7 @@ met2CF.csv <- function(in.path, in.prefix, outfolder, start_date, end_date, form if (any(colnames(format$vars) == "column_number")) { arrloc <- format$vars$column_number[k] } else { - logger.error("Cannot find column location for PAR by name or column number") + PEcAn.utils::logger.error("Cannot find column location for PAR by name or column number") } } ncvar_put(nc, @@ -463,7 +462,7 @@ met2CF.csv <- function(in.path, in.prefix, outfolder, start_date, end_date, form if (any(colnames(format$vars) == "column_number")) { arrloc <- format$vars$column_number[k] } else { - logger.error("Cannot find column location for precipitation_flux by name or column number") + PEcAn.utils::logger.error("Cannot find column location for precipitation_flux by name or column number") } } rain <- dat[, arrloc] @@ -497,7 +496,7 @@ met2CF.csv <- function(in.path, in.prefix, outfolder, start_date, end_date, form if (any(colnames(format$vars) == "column_number")) { arrloc <- format$vars$column_number[k] } else { - logger.error("Cannot find column location for eastward_wind by name or column number") + PEcAn.utils::logger.error("Cannot find column location for eastward_wind by name or column number") } } ncvar_put(nc, @@ -513,7 +512,7 @@ met2CF.csv <- function(in.path, in.prefix, outfolder, start_date, end_date, form if (any(colnames(format$vars) == "column_number")) { arrloc <- format$vars$column_number[k] } else { - logger.error("Cannot find column location for northward_wind by name or column number") + PEcAn.utils::logger.error("Cannot find column location for northward_wind by name or column number") } ncvar_put(nc, varid = Ewind.var, @@ -531,7 +530,7 @@ met2CF.csv <- function(in.path, in.prefix, outfolder, start_date, end_date, form if (any(colnames(format$vars) == "column_number")) { arrloc_wd <- format$vars$column_number[k_wd] } else { - logger.error("Cannot find column location for wind_direction by name or column number") + PEcAn.utils::logger.error("Cannot find column location for wind_direction by name or column number") } } arrloc_ws <- as.character(format$vars$input_name[k_ws]) @@ -539,7 +538,7 @@ met2CF.csv <- function(in.path, in.prefix, outfolder, start_date, end_date, form if (any(colnames(format$vars) == "column_number")) { arrloc_ws <- format$vars$column_number[k_ws] } else { - logger.error("Cannot find column location for wind_speed by name or column number") + PEcAn.utils::logger.error("Cannot find column location for wind_speed by name or column number") } } wind <- met.conv(dat[, arrloc_ws], format$vars$input_units[k_ws], "m s-1", "m s-1") @@ -566,7 +565,7 @@ met2CF.csv <- function(in.path, in.prefix, outfolder, start_date, end_date, form if (any(colnames(format$vars) == "column_number")) { arrloc <- format$vars$column_number[k] } else { - logger.error("Cannot find column location for Wspd by name or column number") + PEcAn.utils::logger.error("Cannot find column location for Wspd by name or column number") } } ncvar_put(nc, @@ -619,9 +618,9 @@ met.conv <- function(x, orig, bety, CF) { if (ud.are.convertible(orig, bety)) { return(ud.convert(ud.convert(x, orig, bety), bety, CF)) } else { - logger.error(paste("met.conv could not convert", orig, bety, CF)) + PEcAn.utils::logger.error(paste("met.conv could not convert", orig, bety, CF)) } } else { - logger.error(paste("met.conv could not parse units:", orig), "Please check if these units conform to udunits") + PEcAn.utils::logger.error(paste("met.conv could not parse units:", orig), "Please check if these units conform to udunits") } } # met.conv From eb818a93a3355ad99c45fc85eec43aef9e9db356 Mon Sep 17 00:00:00 2001 From: tonygardella Date: Thu, 16 Mar 2017 11:06:20 -0500 Subject: [PATCH 3/3] move logger.warn before return statement --- modules/data.atmosphere/R/met.process.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/data.atmosphere/R/met.process.R b/modules/data.atmosphere/R/met.process.R index c8043ab6c81..9deea94c55c 100644 --- a/modules/data.atmosphere/R/met.process.R +++ b/modules/data.atmosphere/R/met.process.R @@ -172,7 +172,8 @@ met.process <- function(site, input_met, start_date, end_date, model, start_date = start_date, end_date = end_date, con = con, host = host, overwrite = overwrite$met2cf, - format.vars = format.vars) + format.vars = format.vars, + bety = bety) } #--------------------------------------------------------------------------------------------------#