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

Fix initial view #81

Merged
merged 22 commits into from
Dec 8, 2022
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
24e6fac
drop use of var to set variables throughout
hcorson-dosch-usgs Nov 30, 2022
eef7921
use this.days in place of repeated var day_seq
hcorson-dosch-usgs Nov 30, 2022
970d20c
fix error where first site not added to peaky array
hcorson-dosch-usgs Nov 30, 2022
ffad8a5
simplify d3 syntax for when site paths are added to map
hcorson-dosch-usgs Nov 30, 2022
aadf994
account for NAs when setting and transitioning paths
hcorson-dosch-usgs Nov 30, 2022
4920a2e
automated changes to package-lock.json
hcorson-dosch-usgs Nov 30, 2022
33e708f
Add states shp as dependency for gw_sites_sf_shifted
hcorson-dosch-usgs Dec 1, 2022
bd0aa71
Use default profile, per DSP manual
hcorson-dosch-usgs Dec 1, 2022
53157eb
Update svg and s3 ind files
hcorson-dosch-usgs Dec 1, 2022
a6daeda
Account for values outside of historic range
hcorson-dosch-usgs Dec 1, 2022
c9bd3d7
Drop sites w/ entirely NA GWL values during viz period
hcorson-dosch-usgs Dec 1, 2022
3ad8157
Fix typo in range fix
hcorson-dosch-usgs Dec 1, 2022
ee9f44b
Update data files on S3
hcorson-dosch-usgs Dec 1, 2022
70a950c
drop filepath named in function, since provided as argument
hcorson-dosch-usgs Dec 1, 2022
38bf198
Update site info file dependency in 1_fetch
hcorson-dosch-usgs Dec 1, 2022
6270404
Use approx rule = 2 instead of separate statement
hcorson-dosch-usgs Dec 6, 2022
8545ef3
drop now unused variables
hcorson-dosch-usgs Dec 6, 2022
93827bf
Auto update to package lock
hcorson-dosch-usgs Dec 8, 2022
3975c99
Add in map labels as separate imported svg
hcorson-dosch-usgs Dec 8, 2022
5eb3b7d
Separate svg with map sections and labels
hcorson-dosch-usgs Dec 8, 2022
f3a0894
Add svg transformation so that glow not cut off
hcorson-dosch-usgs Dec 8, 2022
7a39a24
Adjust transformation
hcorson-dosch-usgs Dec 8, 2022
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
2 changes: 1 addition & 1 deletion 1_fetch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ targets:

1_fetch:
depends:
- 1_fetch/out/gw_sites.rds
- 1_fetch/out/historic_gw_site_info_filtered.rds
- 1_fetch/out/gw_data.csv

##-- Historic GW sites and data --##
Expand Down
2 changes: 2 additions & 0 deletions 2_process.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ targets:
sites_sf = gw_sites_sf,
sites_info = gw_quantile_site_info,
proj_str = proj_str)
depends:
- '2_process/out/nws_states.shp'

# Prepare data for peaks SVG
gw_anomaly_data:
Expand Down
3 changes: 1 addition & 2 deletions 2_process/src/categorize_quantiles.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

categorize_quantiles <- function(target_name, quantile_data_fn, anomaly_bins, anomaly_categories) {

quantile_data_fn <- "2_process/out/gw_daily_quantiles.csv"

anomaly_bins <- scmake("anomaly_bins")
anomaly_categories <- scmake("anomaly_categories")

Expand Down
13 changes: 7 additions & 6 deletions 2_process/src/compare_to_historic.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,31 @@ compare_to_historic <- function(target_name, historic_quantile_fn, current_data_
# See this comment on GitHub for more detail/background:
# https://github.com/USGS-VIZLAB/gw-conditions/issues/9#issuecomment-854115170
daily_quantiles <- purrr::map(gw_sites, function(site, current_data, historic_quantiles, inverse_sites) {

site_quantiles <- historic_quantiles %>% filter(site_no == site)

if(nrow(site_quantiles) == 0) {
message(sprintf("Quantiles not available for %s, returning NA.", site))
}
}

# Get percentiles for current values based on historical record
site_current <- current_data %>%
filter(site_no == site) %>%
# Add flag for whether an inverse of the GWL value should be used
mutate(is_inverse = site_no %in% inverse_sites) %>%
# Figure out the corresponding quantile for each daily value
# If there are no non-NA quantiles available, return NA
# Account for values outside of historic range by using `rule = 2`.
# Repeats top or bottom known quantile for any values outside of historic range
rowwise() %>%
mutate(daily_quant = ifelse(
nrow(site_quantiles) > 0,
yes = approx(x = site_quantiles$quantile_va, y = site_quantiles$quantile_nm,
xout = GWL*ifelse(is_inverse, -1, 1))$y,
no = NA)) %>%
xout = GWL*ifelse(is_inverse, -1, 1), rule=2)$y,
no = NA)) %>%
ungroup() %>%
select(-is_inverse)

# TODO: Handle any new max or new min values when using dates outside of dates used to calculate historic vals

return(site_current)
}, current_data, historic_quantiles, inverse_sites) %>%
bind_rows() %>%
Expand Down
3 changes: 3 additions & 0 deletions 2_process/src/prep_data_for_visualizing.R
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,12 @@ generate_months <- function(file_out, data_in){

# Make sure the data being displayed and used to create labels
# fits within the time range asked for
# Filter out sites w/ all NA GWL levels
subset_to_date_range <- function(file_out, daily_data_fn, start_date, end_date) {
read_csv(daily_data_fn) %>%
filter(Date >= start_date,
Date <= end_date) %>%
group_by(site_no) %>%
filter(!all(is.na(GWL))) %>%
write_csv(file_out)
}
2 changes: 1 addition & 1 deletion 3_visualize/out/gw-conditions-peaks-timeseries-s3copy.ind
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
hash: 5231ce48f14301823508dafc1c6654fb
hash: d61ba692aad93452088af885f79f9b36

2 changes: 1 addition & 1 deletion lib/cfg/s3_config_viz.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
profile: 'prod'
profile: 'default'

bucket: 'water-visualizations-prod-website'
27 changes: 4 additions & 23 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading