Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 12 additions & 0 deletions deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

set -euo pipefail

source .env

aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin ${ECR_AWS_ACCOUNT_ID}.dkr.ecr.${ECR_AWS_REGION}.amazonaws.com


docker compose -f docker-compose.yml pull
docker compose -f docker-compose.yml up -d
docker compose -f docker-compose.yml logs -f
2 changes: 1 addition & 1 deletion hydroshift/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.1.3"
__version__ = "0.1.4"
8 changes: 8 additions & 0 deletions hydroshift/_pages/changepoint.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""A tool to identify changepoints in hydrologic timeseries."""

from pydoc import doc
import traceback
import uuid
from collections import defaultdict
Expand All @@ -10,6 +11,7 @@
import streamlit as st
from docx import Document
from docx.shared import Inches
from docx.enum.text import WD_PARAGRAPH_ALIGNMENT
from plotly.graph_objects import Figure

from hydroshift.consts import (
Expand Down Expand Up @@ -195,6 +197,12 @@ def references(self) -> str:
def word_data(self) -> BytesIO:
"""Export text as MS word."""
document = Document()
s = document.sections[0]
s.header_distance = Inches(0.2)
p = s.header.add_paragraph()
p.alignment = WD_PARAGRAPH_ALIGNMENT.RIGHT
r = p.add_run()
r.add_picture('hydroshift/images/dewberry_full_logo.jpg', height=Inches(0.3))
document.add_heading(self.title, level=1)
document.add_heading("Summary", level=2)
self.add_markdown_to_doc(document, self.summary_text)
Expand Down
6 changes: 3 additions & 3 deletions hydroshift/_pages/summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ def section_lp3(gage: Gage):
}[est_method]
with opt_col_2:
with st.container():
use_map = st.toggle("Use regional skew", value=False, disabled=not gage.has_regional_skew)
lp3 = LP3Analysis(gage.gage_id, gage.ams_vals, use_map, est_method, "")
st.badge(f"Using skew value of {round(lp3.parameters[2], 2)}", color="blue")
skew_mode = st.radio("Skew Source", options=["Station Skew", "Regional Skew", "Weighted Skew"], horizontal=True, disabled=not gage.has_regional_skew)
lp3 = LP3Analysis(gage.gage_id, gage.ams_vals, skew_mode, est_method, "")
st.badge(f"Using skew value of {str(round(lp3.parameters[2], 2))}", color="blue")

# Analysis and display
if gage.missing_dates_ams is not None and len(gage.missing_dates_ams) > 0:
Expand Down
2 changes: 2 additions & 0 deletions hydroshift/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
PEAKFQ_URL = "https://www.usgs.gov/tools/peakfq"
DEWBERRY_URL = "https://www.dewberry.com/"
GITHUB_URL = "https://github.com/Dewberry/hydroshift"
BUG_URL = "https://github.com/Dewberry/hydroshift/issues"
ADMIN_EMAIL = "klawson@dewberry.com"

### Text snippets ###
Expand Down Expand Up @@ -73,4 +74,5 @@ def svg2text(path: str) -> str:

GITHUB_SVG = svg2text("hydroshift/images/github_logo.svg")
DEWBERRY_SVG = svg2text("hydroshift/images/dewberry_logo.svg")
BUG_SVG = svg2text("hydroshift/images/bug.svg")
MAIL_SVG = svg2text("hydroshift/images/mail_logo.svg")
4 changes: 4 additions & 0 deletions hydroshift/images/bug.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added hydroshift/images/dewberry_full_logo.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion hydroshift/templates/changepoint_description.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ These test statistics were utilized in two distinct ways in this analysis. A st
A streaming analysis was performed by treating the data as a stream of values and repeating the static analysis after each new value was added. If the test statistic exceeds a specified threshold at any point within the subseries, a changepoint is marked, and a new data series is initialized for all further test statistics. The resulting change points are shown as dashed red lines in the top panel of Figure 1.

- The threshold for identifying changepoints in the streaming analysis is defined using an Average Run Length (ARL0) parameter. ARL0 reflects the frequency with which a false positive would be raised on a stationary timeseries (e.g., for an ARL0 of 1,000 a false changepoint would be identified on a stationary timeseries on average every 1,000 samples.). For this analysis, an ARL0 of {{ arl0 }} was used.
- A burn-in period of {{ burn_in }} years was selected to ignore singificant change points in the first {{ burn_in }} years of the record due to the influence of small sample sizes.
- A burn-in period of {{ burn_in }} years was selected to ignore significant change points in the first {{ burn_in }} years of the record due to the influence of small sample sizes.

If the flood peak series contained any gaps, the data around the gap was joined as if there was no gap between the data points. For large data gaps, this assumption could lead to inaccurate results.

5 changes: 4 additions & 1 deletion hydroshift/templates/data_sources_side_bar.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,12 @@
<a href="{{ GITHUB_URL }}" target="_blank" title="GitHub Repository">
{{ GITHUB_SVG | safe }}
</a>
<a href="mailto:{{ ADMIN_EMAIL }}" target="_blank" title="Report a bug">
<a href="mailto:{{ ADMIN_EMAIL }}" target="_blank" title="Contact Authors">
{{ MAIL_SVG | safe }}
</a>
<a href="{{ BUG_URL }}" target="_blank" title="Report a bug">
{{ BUG_SVG | safe }}
</a>
<a href="{{ DEWBERRY_URL }}" target="_blank" title="Dewberry">
{{ DEWBERRY_SVG | safe }}
</a>
Expand Down
6 changes: 4 additions & 2 deletions hydroshift/utils/ffa.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class LP3Analysis:

gage_id: str
peaks: list
use_map_skew: bool = False
skew_mode: str = "Station Skew"
est_method: str = "MLE"
label: str = ""
return_periods: List[str] = field(default_factory=lambda: [1.1, 2, 5, 10, 25, 50, 100, 500])
Expand All @@ -41,8 +41,10 @@ def parameters(self) -> tuple[float]:
elif self.est_method == "LMOM":
mean_log, std_log, l3 = l_moments(self.log_peaks)
skew_log = l3 / (std_log * 0.7797) # pseudo-stdev
if self.use_map_skew:
if self.skew_mode == "Weighted Skew":
skew_log = self.weighted_skew
elif self.skew_mode == "Regional Skew":
skew_log = self.map_skew
return mean_log, std_log, skew_log

@property
Expand Down
5 changes: 1 addition & 4 deletions hydroshift/utils/plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,7 @@ def plot_lp3(data: LP3Analysis | list[LP3Analysis]):

# Formatting
return_periods = [int(i) if i.is_integer() else round(i, 1) for i in i.return_periods]
if i.use_map_skew:
skew_txt = ""
else:
skew_txt = " (No Regional Skew)"
skew_txt = f" ({i.skew_mode})"
fig.update_layout(
title=f"{i.gage_id} | Log-Pearson Type III Estimates{skew_txt}",
xaxis=dict(
Expand Down