Skip to content

Commit

Permalink
robustify mokelumne for missing values
Browse files Browse the repository at this point in the history
  • Loading branch information
dwr-psandhu committed Dec 10, 2024
1 parent e6d84e8 commit 135d9a9
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion dms_datastore/download_mokelumne.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,17 @@
import requests
import glob
import pandas as pd
import numpy as np
from dms_datastore import store_utils as utils


def float_conversion_with_nan_default(value):
try:
return float(value)
except (ValueError, TypeError):
return np.nan


def build_filename(date_str, base_dir):
return base_dir + "/" + date_str.replace("/", "-") + ".html"

Expand All @@ -20,7 +28,7 @@ def parse_mokelumne_flow(fname):
df = tables[2]
date = os.path.basename(fname).split(".")[0]
val = df[df[0] == "Mokelumne River below WID"][4].values[0].split()[0]
return date, float(val.replace(",", ""))
return date, float_conversion_with_nan_default(val.replace(",", ""))


def update_last_7days(
Expand Down

0 comments on commit 135d9a9

Please sign in to comment.