From 689a44c6ba60cd4590996265c81a0337d04d7fe3 Mon Sep 17 00:00:00 2001 From: Andrew E Slaughter Date: Thu, 16 Apr 2026 12:43:27 -0600 Subject: [PATCH 1/4] Patch for missing snow course collection dates --- metloom/pointdata/snotel_client.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/metloom/pointdata/snotel_client.py b/metloom/pointdata/snotel_client.py index ff4451c..52df680 100644 --- a/metloom/pointdata/snotel_client.py +++ b/metloom/pointdata/snotel_client.py @@ -200,6 +200,18 @@ def get_data(self, element_cd: str, **extra_params): mapped_params = self._get_params(**extra_params) params = {**self.params, **mapped_params} data = self._make_request(**params) + + # In some cases, in particlular for snow course data prior to 2011, the collection dates + # are not included in the reponse for the SWE variable, but are included in the depth (SNWD). + # This is a workaround to make a second request if the collection data are missing. + if ( + (len(data) > 0) + and ("collectionDates" in data[0]) + and all(c is None for c in data[0]["collectionDates"]) + ): + data2 = self._make_request(**{**params, "elementCd": "SNWD"}) + data[0]["collectionDates"] = data2[0]["collectionDates"] + return self._parse_data(data) From c222e758e1b7826acb1c762807f849ee6456dfca Mon Sep 17 00:00:00 2001 From: Andrew E Slaughter Date: Thu, 16 Apr 2026 13:18:28 -0600 Subject: [PATCH 2/4] Update to 'h' for pandas interval --- metloom/dataframe_utils.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/metloom/dataframe_utils.py b/metloom/dataframe_utils.py index 7684f29..c397760 100644 --- a/metloom/dataframe_utils.py +++ b/metloom/dataframe_utils.py @@ -116,6 +116,8 @@ def resample_df(raw_df: pd.DataFrame, desired interval """ name = variable.name + if interval == 'H': + interval = 'h' # pandas uses lowercase for hourly resampling if name in raw_df.columns: if variable.accumulated: result = raw_df[name].resample(interval).sum() From 5fa56d9e2ac565890f2b6cb4b7739699bf548363 Mon Sep 17 00:00:00 2001 From: Andrew E Slaughter Date: Mon, 27 Apr 2026 13:49:09 -0600 Subject: [PATCH 3/4] Check beginDate and endData when estimating snow course dates --- metloom/pointdata/snotel_client.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/metloom/pointdata/snotel_client.py b/metloom/pointdata/snotel_client.py index 52df680..2ac381c 100644 --- a/metloom/pointdata/snotel_client.py +++ b/metloom/pointdata/snotel_client.py @@ -212,6 +212,23 @@ def get_data(self, element_cd: str, **extra_params): data2 = self._make_request(**{**params, "elementCd": "SNWD"}) data[0]["collectionDates"] = data2[0]["collectionDates"] + # Furthermore, in some cases the collectionDates are not included at all, so we need to assume the collection dates. + # Based on our analsysis the target date is the first of the month. The API returns the beginDate and endData for the + # period. Thus, using the 'beginDate' and 'endDate' the range of dates can be estimated. The 'collectionDates' + # can then be estimated using the data with 'values' (i.e. not None). + if ( + (len(data) > 0) + and ("collectionDates" in data[0]) + and all(c is None for c in data[0]["collectionDates"]) + and data[0]["beginDate"] is not None + and data[0]["endDate"] is not None + ): + start_date = pd.to_datetime(data[0]["beginDate"]) + end_date = pd.to_datetime(data[0]["endDate"]) + date_list = pd.date_range(start=start_date, end=end_date, freq="MS") + collection_dates = [d for d in date_list for _ in range(2)] + data[0]["collectionDates"] = [collection_dates[i] if (v is not None) else None for i, v in enumerate(data[0]['values'])] + return self._parse_data(data) From b399cb6289b93eeeebcb5c9f431229e577ced03b Mon Sep 17 00:00:00 2001 From: Andrew E Slaughter Date: Thu, 16 Apr 2026 12:57:40 -0600 Subject: [PATCH 4/4] =?UTF-8?q?Bump=20version:=200.9.1=20=E2=86=92=200.9.2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- metloom/__init__.py | 2 +- setup.cfg | 2 +- setup.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/metloom/__init__.py b/metloom/__init__.py index deb2751..1d74f00 100644 --- a/metloom/__init__.py +++ b/metloom/__init__.py @@ -2,4 +2,4 @@ __author__ = """M3Works""" __email__ = "m3worksllc@gmail.com" -__version__ = '0.9.1' +__version__ = '0.9.2' diff --git a/setup.cfg b/setup.cfg index 5b60b01..b832916 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.9.1 +current_version = 0.9.2 commit = True tag = True diff --git a/setup.py b/setup.py index e9d4725..0e8b1dd 100644 --- a/setup.py +++ b/setup.py @@ -54,6 +54,6 @@ test_suite='tests', tests_require=test_requirements, url='https://github.com/M3Works/metloom', - version='0.9.1', + version='0.9.2', zip_safe=False, )