Skip to content

Commit

Permalink
update lake level and lake temp
Browse files Browse the repository at this point in the history
  • Loading branch information
trpa-mason committed Jan 13, 2025
1 parent ba555ea commit 8f8509b
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 34 deletions.
1 change: 1 addition & 0 deletions .ssh_tunnel/aws_emr.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
17 changes: 2 additions & 15 deletions climate_conditions.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,15 +491,13 @@ def plot_air_quality(df):
),
)


def calcAQI(Cp, Ih, Il, BPh, BPl):
a = Ih - Il
b = BPh - BPl
c = Cp - BPl
val = round((a / b) * c + Il)
return val


def get_data_lake_level(days):
site_number = 10337000

Expand All @@ -524,7 +522,6 @@ def get_data_lake_level(days):
weekly = df.groupby(pd.Grouper(key="dateTime", freq="W"))["value"].mean().reset_index()
return weekly


def plot_lake_level(df):
trendline(
df,
Expand All @@ -548,7 +545,6 @@ def plot_lake_level(df):
hovermode="x",
)


def plot_lake_level_with_high_water_mark(df):
path_html = "html/1.3.a_Lake_Level.html"
div_id = "1.3.a_Lake_Level"
Expand Down Expand Up @@ -644,18 +640,16 @@ def plot_lake_level_with_high_water_mark(df):
div_id=div_id,
)


def get_data_lake_temp():
lakeTempURL = "https://tepfsail50.execute-api.us-west-2.amazonaws.com/v1/report/ns-station-range?rptdate=20240130&rptend=20240202&id=4"
response = requests.get(lakeTempURL)
df = pd.DataFrame(response.json())
df = pd.DataFrame(response.json()).reset_index()
df["LS_Temp_Avg"] = df["LS_Temp_Avg"].astype(float)
return df


def get_all_temp_midlake():
# get start/end dates for the last year
start = datetime.now() - timedelta(days=365)
start = datetime.now() - timedelta(days=400)
start = start.strftime("%Y%m%d")
end = datetime.now().strftime("%Y%m%d")
dfMerge = pd.DataFrame()
Expand All @@ -680,7 +674,6 @@ def get_all_temp_midlake():
df["RBR_0p5_F_7_day_avg"] = df["RBR_0p5_F"].rolling(window=7).mean()
return df


def get_all_temp_shore():
# get all data from lake temp URL
start = datetime.now() - timedelta(days=365)
Expand All @@ -704,7 +697,6 @@ def get_all_temp_shore():
df = dfMerge.groupby("TmStamp")["LS_Temp_Avg_F"].mean().reset_index()
return df


def plot_lake_temp_midlake(df):
trendline(
df,
Expand Down Expand Up @@ -741,7 +733,6 @@ def plot_lake_temp_midlake(df):
),
)


def get_data_precip():
# snowlab precip data
url = "https://maps.trpa.org/server/rest/services/LTinfo_Climate_Resilience_Dashboard/MapServer/145"
Expand Down Expand Up @@ -780,7 +771,6 @@ def get_data_precip():
df = dfYearly[dfYearly["Year"] >= 1987]
return df


def plot_precip(df):
stackedbar(
df,
Expand Down Expand Up @@ -814,7 +804,6 @@ def plot_precip(df):
),
)


def get_data_temp():
# meteostat data
# Set time period
Expand All @@ -838,7 +827,6 @@ def get_data_temp():
df = df.assign(AvgTemp=lambda x: (9 / 5) * x["tavg"] + 32)
return df


def plot_temp(df):
# Plot daily temperature data
fig = px.scatter(
Expand All @@ -863,7 +851,6 @@ def plot_temp(df):
div_id=div_id,
)


def plot_extremeheat(df):
path_html = "html/1.2.a_ExtremeHeatDays.html"
div_id = "1.3.d_Precip"
Expand Down
9 changes: 8 additions & 1 deletion html/1.3.a_Lake_Level.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion html/1.3.b_Lake_Temp.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions html/3.3.a_Transit_Ridership.html

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions metadata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
project_uuid: f00582d0dcfc4343b2a57d5724cbcb96
10 changes: 5 additions & 5 deletions notebook.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -19,7 +19,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -137,7 +137,7 @@
"source": [
"# html\\1.3.b_Lake_Temp.html ### days is hard coded to 730\n",
"df = get_all_temp_midlake()\n",
"plot_lake_temp_midlake(df)"
"plot_lake_temp_midlake()"
]
},
{
Expand Down Expand Up @@ -481,7 +481,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "trpa",
"display_name": "arcgispro-py3",
"language": "python",
"name": "python3"
},
Expand All @@ -495,7 +495,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.8"
"version": "3.11.10"
}
},
"nbformat": 4,
Expand Down
20 changes: 10 additions & 10 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
pandas==2.1.3
numpy==1.26.2
plotly==5.18.0
arcgis==2.2.0.2
statsmodels==0.14.1
meteostat==1.6.7
pydeck==0.8.0
# pandas==2.1.3
# numpy==1.26.2
# plotly==5.18.0
# arcgis==2.2.0.2
# statsmodels==0.14.1
# meteostat==1.6.7
# pydeck==0.8.0

pre-commit==3.6.0
black==23.12.0
tqdm==4.66.1
# pre-commit==3.6.0
# black==23.12.0
# tqdm==4.66.1

0 comments on commit 8f8509b

Please sign in to comment.