Skip to content

Commit 5709cd5

Browse files
thodson-usgsclaude
andcommitted
Document CQL filter usage on get_continuous
Follow the existing ``time`` date-range example with two CQL-text ``filter`` examples: a two-interval OR expression (the common "pull several disjoint windows in one call" case), and a longer programmatically-built chain that shows the pattern used when pairing many discrete-measurement timestamps with surrounding instantaneous data (which is what the client's transparent chunking is there to support). Both examples were verified against the live Water Data OGC API on USGS-02238500 (00060). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent a65e94d commit 5709cd5

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

dataretrieval/waterdata/api.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,37 @@ def get_continuous(
399399
... parameter_code="00065",
400400
... time="2021-01-01T00:00:00Z/2022-01-01T00:00:00Z",
401401
... )
402+
403+
>>> # The ``time`` parameter accepts a single instant or a single
404+
>>> # interval. To pull several disjoint windows in one call, pass a
405+
>>> # CQL-text ``filter`` expression instead:
406+
>>> df, md = dataretrieval.waterdata.get_continuous(
407+
... monitoring_location_id="USGS-02238500",
408+
... parameter_code="00060",
409+
... filter=(
410+
... "(time >= '2023-06-01T12:00:00Z' "
411+
... "AND time <= '2023-06-01T13:00:00Z') "
412+
... "OR (time >= '2023-06-15T12:00:00Z' "
413+
... "AND time <= '2023-06-15T13:00:00Z')"
414+
... ),
415+
... filter_lang="cql-text",
416+
... )
417+
418+
>>> # Long top-level ``OR`` chains (e.g. one window per discrete
419+
>>> # measurement timestamp) are built up the same way. If the
420+
>>> # resulting URL would exceed the server's length limit, the
421+
>>> # client transparently splits it into multiple sub-requests and
422+
>>> # returns the concatenated, deduplicated result.
423+
>>> windows = [
424+
... f"(time >= '2023-{m:02d}-15T00:00:00Z' "
425+
... f"AND time <= '2023-{m:02d}-15T00:30:00Z')"
426+
... for m in range(1, 13)
427+
... ]
428+
>>> df, md = dataretrieval.waterdata.get_continuous(
429+
... monitoring_location_id="USGS-02238500",
430+
... parameter_code="00060",
431+
... filter=" OR ".join(windows),
432+
... )
402433
"""
403434
service = "continuous"
404435
output_id = "continuous_id"

0 commit comments

Comments
 (0)