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

Conversation

hcorson-dosch-usgs
Copy link
Collaborator

@hcorson-dosch-usgs hcorson-dosch-usgs commented Dec 2, 2022

Summary

This PR addresses the observed problems with the initial view and animation, discussed here in PR #79. Key problems were

  1. The initial view did not seem to reflect starting conditions for wy 22
  2. Levels for sites in HI and FL appeared static throughout much of the year

The problems turned out to be tied to NA values in the data, stemming from 5 issues:

Issue Fix
In the Javascript, NA GWL values being automatically assigned a path and color equivalent to 'very low' Assign path value of null when data value NA
The first row of the gw-conditions-peaks-timeseries-wy22.csv on S3 (GWL values for 1st day) was nearly entirely NA Fixed when I had to re-run 1_fetch in order to dig into the steps in 2_process and 3_visualize
Values for HI and FL sites were NA from October-January and April-September Fixed when I had to re-run 1_fetch in order to dig into the steps in 2_process and 3_visualize
GWL values for some sites were assigned a daily_quant and quant_category of NA because they fell outside of the historical range Assign the value the max or min quantile as appropriate
Some sites had no groundwater data for the water year, but were still included When subset to viz period, filter out sites with no data - this dropped 5 sites

Updated view

There are now 2211 total sites for WY22. This is the new initial view:

  • image

To run

Pull this fork to your local clone and run npm run serve


Overview of key changes

Changes to JavaScript:

  • Both when drawing the initial view and during animation, path values are now set to null if the GWL value for that day for that site is NA
    • Previously, NA values had been assigned a value equivalent to the "very low" category:
    • image
    • This fixed the initial view and display of NA values in FL and HI from October- January and then again April-end of September.

Changes to R pipeline:

  • Not a change, but I had to re-run 1_fetch, 2_process and 3_visualize in order to work in the pipeline. This re-pulled the NWIS data, and resolved the NA values on day 1 and the NA values in HI and FL
  • Some sites w/ groundwater level data were being assigned a quantile of NA because the level fell outside of the historic range. I added a step in compare_to_historic to assign the value the max or min quantile as appropriate.
  • Some sites had no data for the water year but were still included. Those are now filtered out when we filter to the viz period.

Additional minor changes

Other minor JavaScript changes

Minor edits to the pipeline:

Comment on lines +557 to +562
// this.d3.selectAll(".ticker-date")
// .transition()
// .duration(this.day_length)
// .text(this.dates[start])
// .end()
// .then(() => this.animateLine(start))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this not getting used?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, the code that adds the date ticker was already commented out, as was the end animation for it, so I commented out this piece since it's not currently being used.

Comment on lines 587 to 596
this.peak_grp = map_svg.selectAll("path.gwl_glyph")
.data(data, function(d) { return d ? d.key : this.class; }) // binds data based on class/key
.join("path") // match with selection
.attr("transform", d => `translate(` + d.site_x + ' ' + d.site_y + `) scale(0.35 0.35)`)

// draws a path for each site, using the first date
this.peak_grp
// set up group to hold paths
const peakSvgGroup = map_svg.append("g")
.attr("id", "peak-map-grp")

// Add path for each site, using the first date
this.peak_grp = peakSvgGroup.selectAll("gwl")
.data(data)
.enter()
.append("path") // append path for each site
.attr("transform", d => `translate(` + d.site_x + ' ' + d.site_y + `) scale(0.35 0.35)`)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏼

Comment on lines +630 to +631
let today = d.gwl[start] == "NA" ? null : self.quant_path_gylph(d.gwl[start]) // set to null if value is NA
let yesterday = d.gwl[start-1] == "NA" ? null : self.quant_path_gylph(d.gwl[start-1]) // set to null if value is NA
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not register the difference of NA vs null

Copy link
Member

@cnell-usgs cnell-usgs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for writing this out so clearly. You caught some known issues plus some 💯 . The animation ran for me and reflects what I would expect with these edits. Ends on this view:
image

For the last fix noted in the table, "When subset to viz period, filter out sites with no data - this dropped 5 sites" this works for now, but when we start offering multiple time periods we will need to revisit. If the sites get filtered each time frame, we'll need to have corresponding site locations and in some way ensure that the sites on the map include all sites with data. That may mean moving filtering to vue, so it can be dynamic to the user.

Somewhere before this we lost the dotted lines that delineated and labelled all the islands are territories. I'm not sure why that is.

@hcorson-dosch-usgs
Copy link
Collaborator Author

For the last fix noted in the table, "When subset to viz period, filter out sites with no data - this dropped 5 sites" this works for now, but when we start offering multiple time periods we will need to revisit. If the sites get filtered each time frame, we'll need to have corresponding site locations and in some way ensure that the sites on the map include all sites with data. That may mean moving filtering to vue, so it can be dynamic to the user.

Ooh, good point. I think I'm going to start an issue re: switching to a monthly view w/ multiple time periods, and will include this consideration there.

Somewhere before this we lost the dotted lines that delineated and labelled all the islands are territories. I'm not sure why that is.

I noticed that, too! I'll take a poke back through and see if I can find where it dropped out

@hcorson-dosch-usgs
Copy link
Collaborator Author

hcorson-dosch-usgs commented Dec 8, 2022

Added back in the map labels and section lines, which I think maybe had been manually added to the R-generated svg before? I've now set them up so that they are in a separate svg, which is committed to the repo. Looks like this now:

image

@hcorson-dosch-usgs
Copy link
Collaborator Author

To keep the outer glow from being cut off at the top, I've also added in a transformation when the background map svg is written, the labels svg is overlaid, and the sites are added to the map. Now looks like this:
image

@cnell-usgs
Copy link
Member

Added back in the map labels and section lines, which I think maybe had been manually added to the R-generated svg before? I've now set them up so that they are in a separate svg, which is committed to the repo. Looks like this now:

image

sounds like something I did in a rush 😥

Copy link
Member

@cnell-usgs cnell-usgs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work, Hayley. You really went above and beyond here.

@hcorson-dosch-usgs hcorson-dosch-usgs merged commit 9d7005a into DOI-USGS:main Dec 8, 2022
@hcorson-dosch-usgs hcorson-dosch-usgs deleted the fix_initial_view branch December 8, 2022 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants