diff --git a/deploy.sh b/deploy.sh new file mode 100644 index 0000000..1517295 --- /dev/null +++ b/deploy.sh @@ -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 diff --git a/hydroshift/__init__.py b/hydroshift/__init__.py index ae73625..bbab024 100644 --- a/hydroshift/__init__.py +++ b/hydroshift/__init__.py @@ -1 +1 @@ -__version__ = "0.1.3" +__version__ = "0.1.4" diff --git a/hydroshift/_pages/changepoint.py b/hydroshift/_pages/changepoint.py index f5d1bc2..2d6acf3 100644 --- a/hydroshift/_pages/changepoint.py +++ b/hydroshift/_pages/changepoint.py @@ -1,5 +1,6 @@ """A tool to identify changepoints in hydrologic timeseries.""" +from pydoc import doc import traceback import uuid from collections import defaultdict @@ -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 ( @@ -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) diff --git a/hydroshift/_pages/summary.py b/hydroshift/_pages/summary.py index 70fe791..4c14ed3 100644 --- a/hydroshift/_pages/summary.py +++ b/hydroshift/_pages/summary.py @@ -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: diff --git a/hydroshift/consts.py b/hydroshift/consts.py index a092df6..143d235 100644 --- a/hydroshift/consts.py +++ b/hydroshift/consts.py @@ -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 ### @@ -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") diff --git a/hydroshift/images/bug.svg b/hydroshift/images/bug.svg new file mode 100644 index 0000000..f8d05fd --- /dev/null +++ b/hydroshift/images/bug.svg @@ -0,0 +1,4 @@ + + + + diff --git a/hydroshift/images/dewberry_full_logo.jpg b/hydroshift/images/dewberry_full_logo.jpg new file mode 100644 index 0000000..b35128e Binary files /dev/null and b/hydroshift/images/dewberry_full_logo.jpg differ diff --git a/hydroshift/templates/changepoint_description.md b/hydroshift/templates/changepoint_description.md index 8668eae..4b17005 100644 --- a/hydroshift/templates/changepoint_description.md +++ b/hydroshift/templates/changepoint_description.md @@ -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. diff --git a/hydroshift/templates/data_sources_side_bar.html b/hydroshift/templates/data_sources_side_bar.html index 6246c67..ee22941 100644 --- a/hydroshift/templates/data_sources_side_bar.html +++ b/hydroshift/templates/data_sources_side_bar.html @@ -50,9 +50,12 @@ {{ GITHUB_SVG | safe }} - + {{ MAIL_SVG | safe }} + + {{ BUG_SVG | safe }} + {{ DEWBERRY_SVG | safe }} diff --git a/hydroshift/utils/ffa.py b/hydroshift/utils/ffa.py index 3b69d4c..b5ffe13 100644 --- a/hydroshift/utils/ffa.py +++ b/hydroshift/utils/ffa.py @@ -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]) @@ -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 diff --git a/hydroshift/utils/plots.py b/hydroshift/utils/plots.py index 07ff532..372e307 100644 --- a/hydroshift/utils/plots.py +++ b/hydroshift/utils/plots.py @@ -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(