diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f196b8da1fe377eb6f35c6a1359948be726023fe..760146ed81125961ab4f56a8534563a67fa8f161 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,3 +1,5 @@ +image: ${CI_REGISTRY_IMAGE}:latest + workflow: rules: - if: $CI_COMMIT_TAG @@ -52,7 +54,6 @@ build-image: buildcheck: stage: check - image: ${CI_REGISTRY_IMAGE}:latest dependencies: - build-image script: @@ -65,7 +66,6 @@ buildcheck: unittests: stage: test - image: ${CI_REGISTRY_IMAGE}:latest dependencies: - build-image - buildcheck @@ -81,7 +81,6 @@ unittests: covertests: stage: test - image: ${CI_REGISTRY_IMAGE}:latest dependencies: - build-image - buildcheck @@ -97,7 +96,6 @@ covertests: pages: stage: end - image: ${CI_REGISTRY_IMAGE}:latest only: - main script: diff --git a/DESCRIPTION b/DESCRIPTION index 948657f53391fa22619a66c403bdabe7cc6cb519..a7744bc714c371dfb9ddfad48392fd2b01ae1530 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: HASP Type: Package Title: Hydrologic AnalySis Package -Version: 1.0.3 +Version: 1.0.4 Authors@R: c(person("Laura", "DeCicco", role = c("aut", "cre"), email = "ldecicco@usgs.gov", @@ -19,8 +19,7 @@ Authors@R: c(person("Laura", "DeCicco", email = "chopkins@usgs.gov", comment=c(ORCID="0000-0003-3207-7267")), person("Lindsay", "Platt", - role = c("ctr"), - email = "lplatt@usgs.gov"), + role = c("ctr")), person("Tara", "Root", role = "ctr")) Description: Data aggregation and plotting of USGS groundwater level data. @@ -67,4 +66,4 @@ BuildVignettes: true LazyLoad: yes LazyData: yes Encoding: UTF-8 -RoxygenNote: 7.3.1 +RoxygenNote: 7.3.2 diff --git a/R/chloride.R b/R/chloride.R index a00b6702690562665ff2066b79c7dcb35322abd6..6694bec6c46badfb542cbb84516cd700ffa5f2fb 100644 --- a/R/chloride.R +++ b/R/chloride.R @@ -111,7 +111,7 @@ trend_plot <- function(qw_data, plot_title, plot_out <- ggplot() + geom_point(data = qw_sub, - aes(x = year, y = ResultMeasureValue, + aes(x = ActivityStartDate, y = ResultMeasureValue, shape = condition, color = condition)) @@ -127,7 +127,7 @@ trend_plot <- function(qw_data, plot_title, hasp_framework("Date", y_label, plot_title, subtitle = subtitle, zero_on_top = on_top, include_y_scale = TRUE) + - scale_x_continuous(sec.axis = dup_axis(labels = NULL, + scale_x_date(sec.axis = dup_axis(labels = NULL, name = NULL)) + scale_color_manual(name = "EXPLANATION", breaks = col_values, @@ -153,7 +153,8 @@ trend_plot <- function(qw_data, plot_title, trend_results$intercept <- signif(trend_results$intercept, digits = 4) plot_out <- plot_out + - ggpp::geom_table(aes(x = -Inf, y = Inf, + ggpp::geom_table(aes(x = min(qw_sub$ActivityStartDate, na.rm = TRUE), + y = Inf, label = list(trend_results)), vjust = 1, hjust = 0) } @@ -184,9 +185,9 @@ create_segs <- function(trend_results, y1 = decimalDate(x1) * slope + intercept, y2 = decimalDate(x2) * slope + intercept) %>% dplyr::filter(!is.na(y2), - trend != "Not significant") %>% - dplyr::mutate(x2 = decimalDate(x2), - x1 = decimalDate(x1)) + trend != "Not significant") + # dplyr::mutate(x2 = decimalDate(x2), + # x1 = decimalDate(x1)) return(df_seg) diff --git a/R/get_data.R b/R/get_data.R index 09e55b359d818f96231e8f7616292d47b6305a68..25099894c225e177083647dbd757be66faf035e6 100644 --- a/R/get_data.R +++ b/R/get_data.R @@ -45,7 +45,7 @@ get_aquifer_data <- function(aquiferCd, startDate, endDate, if(inherits(state_data, "error")) next if(!all(is.na(state_data$site_no))){ - state_data_sites <- dataRetrieval::readNWISsite(unique(state_data$site_no)) + state_data_sites <- attr(state_data, "siteInfo") state_data_sites <- state_data_sites %>% dplyr::select(station_nm, site_no, dec_lat_va, dec_long_va) @@ -102,6 +102,11 @@ get_state_data <- function(state, aquiferCd, endDate = endDate, aquiferCd = aquiferCd) + site_info <- dataRetrieval::whatNWISdata(stateCd = state, + startDate= startDate, + endDate = endDate, + service = "gwlevels") + if(nrow(levels) + nrow(levels_dv) == 0){ return(data.frame()) } @@ -158,6 +163,11 @@ get_state_data <- function(state, aquiferCd, state_data_tots <- dplyr::bind_rows(state_data, state_dv) + site_info <- site_info |> + dplyr::filter(site_no %in% unique(state_data_tots$site_no)) + + attr(state_data_tots, "siteInfo") <- site_info + return(state_data_tots) } diff --git a/R/gwl_single_sites.R b/R/gwl_single_sites.R index 5a18c6a2c94f4c033cdb1dfbd3fe03c067bcbd58..2e7f3f027cd3e25a838b6ac23dd10fa07d5d68a2 100644 --- a/R/gwl_single_sites.R +++ b/R/gwl_single_sites.R @@ -235,12 +235,12 @@ gwl_plot_all <- function(gw_level_dv, plot_out <- ggplot() + geom_path(data = gw_complete, - aes(x = year, color = Approve, y = Value)) + aes(x = Date, color = Approve, y = Value)) if(sum(gw_complete$is_point) > 0){ plot_out <- plot_out + geom_point(data = dplyr::filter(gw_complete, is_point), - aes(x = year, color = Approve, y = Value), size = 0.2) + aes(x = Date, color = Approve, y = Value), size = 0.2) } plot_out <- plot_out + @@ -257,7 +257,7 @@ gwl_plot_all <- function(gw_level_dv, if(data_list$includes["gwl"]){ plot_out <- plot_out + geom_point(data = gwl_data, - aes(x = year, y = Value, + aes(x = Date, y = Value, fill = Approve), size = 1.5, shape = 21, color = "transparent") + scale_fill_manual("EXPLANATION\nWater-Level\nMeasurement", @@ -270,8 +270,8 @@ gwl_plot_all <- function(gw_level_dv, hasp_framework("Years", y_label, plot_title = plot_title, subtitle = subtitle) + - scale_x_continuous(sec.axis = dup_axis(labels = NULL, - name = NULL)) + scale_x_date(sec.axis = dup_axis(labels = NULL, + name = NULL)) if(add_trend){ diff --git a/man/HASP-package.Rd b/man/HASP-package.Rd index 9dd935ed389923fcfdb453a1179efef9ac8ebae9..4ac7a648f6256b9ab05309c13d0300321d362266 100644 --- a/man/HASP-package.Rd +++ b/man/HASP-package.Rd @@ -41,7 +41,7 @@ Authors: Other contributors: \itemize{ - \item Lindsay Platt \email{lplatt@usgs.gov} [contractor] + \item Lindsay Platt [contractor] \item Tara Root [contractor] } diff --git a/tests/testthat/test_statistics.R b/tests/testthat/test_statistics.R index c97fd99dacc640780e82ab6120a72a80a521867c..207292c96d7892f0d3ed8015871d97bd3daa7f96 100644 --- a/tests/testthat/test_statistics.R +++ b/tests/testthat/test_statistics.R @@ -208,8 +208,8 @@ test_that("trend segments",{ value_col = "ResultMeasureValue", date_col = "ActivityStartDateTime") - expect_true(all(signif(seg_df$x1, digits = 5) == c(2011.3, 1978.7))) - expect_true(all(signif(seg_df$x2, digits = 5) == c(2021.3, 2021.3))) + expect_true(all(seg_df$x1 == as.Date(c("2011-04-29", "1978-09-16")))) + expect_true(all(seg_df$x2 == as.Date(c("2021-04-27", "2021-04-27")))) expect_true(all(seg_df$years == c("10-year trend", "Period of record"))) expect_true(all(seg_df$trend == c("Up", "Up"))) @@ -224,8 +224,8 @@ test_that("trend segments",{ date_col = "Date", value_col = "X_62610_00001") - expect_true(all(signif(seg_df$x1, digits = 5) == c(2011.3, 1978.7))) - expect_true(all(signif(seg_df$x2, digits = 5) == c(2021.3, 2021.3))) + expect_true(all(seg_df$x1 == c("2011-04-29", "1978-09-16"))) + expect_true(all(seg_df$x2 == c("2021-04-27", "2021-04-27"))) expect_true(all(seg_df$years == c("10-year trend", "Period of record"))) @@ -251,8 +251,8 @@ test_that("trend segments",{ date_col = "mid_date", value_col = "mean_va") - expect_true(all(signif(seg_df_month$x1, digits = 5) == c(2011.7, 1978.8))) - expect_true(all(signif(seg_df_month$x2, digits = 5) == c(2021.7, 2021.7))) + expect_true(all(seg_df_month$x1 == c("2011-09-17", "1978-10-25"))) + expect_true(all(seg_df_month$x2 == c("2021-09-15", "2021-09-15"))) expect_true(all(seg_df_month$years == c("10-year trend", "Period of record")))