Skip to content
Open
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
41 changes: 41 additions & 0 deletions src/synoptic/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,45 @@
}
)

params_percentiles = (
station_selectors
| {"token"}
| {
"vars",
"data",
"complete",
"daily_min",
"daily_max",
"obtimezone", # IGNORED
"hourly",
"start",
"end",
"percentiles",
"complete",
"fields",
"showemptystations",
"showemptyvars",
"units",
"sitinghistory",
}
)
params_statistics = (
station_selectors
| {"token", "start", "end", "recent"}
| {
"vars",
"period",
"statistic",
"complete",
"fields",
"obtimezone", # IGNORED
"showemptystations",
"showemptyvars",
"units",
"sitinghistory",
}
)

params_qcsegments = (
station_selectors
| {"token", "start", "end", "recent"}
Expand Down Expand Up @@ -148,6 +187,8 @@ def validate_params(service, **params):
"latest": params_latest,
"nearesttime": params_nearesttime,
"precipitation": params_precipitation,
"percentiles": params_percentiles,
"statistics": params_statistics,
"qcsegments": params_qcsegments,
"latency": params_latency,
"metadata": params_metadata,
Expand Down
50 changes: 50 additions & 0 deletions src/synoptic/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
"latest",
"nearesttime",
"precipitation",
"statistics",
"percentiles",
"qcsegments",
"latency",
"metadata",
Expand All @@ -52,6 +54,8 @@
"latest",
"nearesttime",
"precipitation",
"statistics",
"percentiles",
"qcsegments",
"latency",
"metadata",
Expand Down Expand Up @@ -488,6 +492,52 @@ def df(self) -> pl.DataFrame:
return df


class Percentiles(SynopticAPI):
"""
Request station percentiles.

Refer to the official documentation: https://docs.synopticdata.com/services/percentiles


Parameters
----------
# TODO: I can't develop this capability because
# TODO: "Account associated with this token does not have access to the statistics service."
"""

def __init__(self, **params):
super().__init__("percentiles", **params)

@lru_cache
def df(self) -> pl.DataFrame:
"""Stations percentile DataFrame."""
timer = datetime.now()
self.timers["parse_to_polars_dataframe"] = datetime.now() - timer


class Statistics(SynopticAPI):
"""
Request station statistics.

Refer to the official documentation: https://docs.synopticdata.com/services/statistics


Parameters
----------
# TODO: I can't develop this capability because
# TODO: "Account associated with this token does not have access to the statistics service."
"""

def __init__(self, **params):
super().__init__("statistics", **params)

@lru_cache
def df(self) -> pl.DataFrame:
"""Stations statistics DataFrame."""
timer = datetime.now()
self.timers["parse_to_polars_dataframe"] = datetime.now() - timer


class QCSegments(SynopticAPI):
"""Get quality control segments. NOT IMPLEMENTED.

Expand Down
Loading