-
Notifications
You must be signed in to change notification settings - Fork 59
Expand file tree
/
Copy pathwqp.py
More file actions
725 lines (560 loc) · 22.9 KB
/
Copy pathwqp.py
File metadata and controls
725 lines (560 loc) · 22.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
"""
Tool for downloading data from the Water Quality Portal (https://waterqualitydata.us)
See https://waterqualitydata.us/webservices_documentation for API reference
.. todo::
- implement other services like Organization, Activity, etc.
"""
from __future__ import annotations
import warnings
from io import StringIO
from typing import TYPE_CHECKING
import pandas as pd
from .utils import BaseMetadata, query
if TYPE_CHECKING:
from pandas import DataFrame
result_profiles_wqx3 = ["basicPhysChem", "fullPhysChem", "narrow"]
result_profiles_legacy = ["biological", "narrowResult", "resultPhysChem"]
activity_profiles_legacy = ["activityAll"]
services_wqx3 = ["Activity", "Result", "Station"]
services_legacy = [
"Activity",
"ActivityMetric",
"BiologicalMetric",
"Organization",
"Project",
"ProjectMonitoringLocationWeighting",
"Result",
"ResultDetectionQuantitationLimit",
"Station",
]
def get_results(
ssl_check=True,
legacy=True,
**kwargs,
) -> tuple[DataFrame, WQP_Metadata]:
"""Query the WQP for results.
Any WQP API parameter can be passed as a keyword argument to this function.
More information about the API can be found at:
https://www.waterqualitydata.us/#advanced=true
or the beta version of the WQX3.0 API at:
https://www.waterqualitydata.us/beta/#mimeType=csv&providers=NWIS&providers=STORET
or the Swagger documentation at:
https://www.waterqualitydata.us/data/swagger-ui/index.html?docExpansion=none&url=/data/v3/api-docs#/
Parameters
----------
ssl_check : bool, optional
Check the SSL certificate.
legacy : bool, optional
Return the legacy WQX data profile. Default is True.
dataProfile : string, optional
Specifies the data fields returned by the query.
WQX3.0 profiles include 'fullPhysChem', 'narrow', and 'basicPhysChem'.
Legacy profiles include 'resultPhysChem','biological', and
'narrowResult'. Default is 'fullPhysChem'.
siteid : string
Monitoring location identified by agency code, a hyphen, and
identification number (Example: "USGS-05586100").
statecode : string
US state FIPS code (Example: Illinois is "US:17").
countycode : string
US county FIPS code.
huc : string
Eight-digit hydrologic unit (HUC), delimited by semicolons.
bBox : string
Search bounding box (Example: bBox=-92.8,44.2,-88.9,46.0)
lat : string
Radial-search central latitude in WGS84 decimal degrees.
long : string
Radial-search central longitude in WGS84 decimal degrees.
within : string
Radial-search distance in decimal miles.
pCode : string
Five-digit USGS parameter code, delimited by semicolons.
NWIS only.
startDateLo : string
Date of earliest desired data-collection activity,
expressed as 'MM-DD-YYYY'
startDateHi : string
Date of last desired data-collection activity,
expressed as 'MM-DD-YYYY'
characteristicName : string
One or more case-sensitive characteristic names, separated by
semicolons (https://www.waterqualitydata.us/public_srsnames/).
mimeType : string
Output format. Only 'csv' is supported at this time.
Returns
-------
df : ``pandas.DataFrame``
Formatted data returned from the API query.
md : :obj:`dataretrieval.utils.Metadata`
Custom ``dataretrieval`` metadata object pertaining to the query.
Examples
--------
.. code::
>>> # Get results within a radial distance of a point
>>> df, md = dataretrieval.wqp.get_results(
... lat="44.2", long="-88.9", within="0.5"
... )
>>> # Get results within a bounding box
>>> df, md = dataretrieval.wqp.get_results(bBox="-92.8,44.2,-88.9,46.0")
>>> # Get results using a new WQX3.0 profile
>>> df, md = dataretrieval.wqp.get_results(
... legacy=False, siteid="UTAHDWQ_WQX-4993795", dataProfile="narrow"
... )
"""
kwargs = _check_kwargs(kwargs)
if legacy is True:
valid_profiles = result_profiles_legacy
kind = "legacy"
url = wqp_url("Result")
else:
valid_profiles = result_profiles_wqx3
kind = "WQX3.0"
url = wqx3_url("Result")
profile = kwargs.get("dataProfile")
if profile is not None and profile not in valid_profiles:
raise ValueError(
f"dataProfile {profile!r} is not a valid {kind} profile. "
f"Valid options are {valid_profiles}."
)
if legacy is not True and profile is None:
kwargs["dataProfile"] = "fullPhysChem"
response = query(url, kwargs, delimiter=";", ssl_check=ssl_check)
df = _read_wqp_response(response.text, kwargs)
return df, WQP_Metadata(response)
def what_sites(
ssl_check=True,
legacy=True,
**kwargs,
) -> tuple[DataFrame, WQP_Metadata]:
"""Search WQP for sites within a region with specific data.
Any WQP API parameter can be passed as a keyword argument to this function.
More information about the API can be found at:
https://www.waterqualitydata.us/#advanced=true
or the beta version of the WQX3.0 API at:
https://www.waterqualitydata.us/beta/#mimeType=csv&providers=NWIS&providers=STORET
or the Swagger documentation at:
https://www.waterqualitydata.us/data/swagger-ui/index.html?docExpansion=none&url=/data/v3/api-docs#/
Parameters
----------
ssl_check : bool, optional
Check the SSL certificate. Default is True.
legacy : bool, optional
If True, returns the legacy WQX data profile and warns the user of
the issues associated with it. If False, returns the new WQX3.0
profile, if available. Defaults to True.
**kwargs : optional
Accepts the same parameters as :obj:`dataretrieval.wqp.get_results`
Returns
-------
df : ``pandas.DataFrame``
Formatted data returned from the API query.
md : :obj:`dataretrieval.utils.Metadata`
Custom metadata object pertaining to the query.
Examples
--------
.. code::
>>> # Get sites within a radial distance of a point
>>> df, md = dataretrieval.wqp.what_sites(
... lat="44.2", long="-88.9", within="2.5"
... )
"""
kwargs = _check_kwargs(kwargs)
url = wqp_url("Station") if legacy is True else wqx3_url("Station")
response = query(url, payload=kwargs, delimiter=";", ssl_check=ssl_check)
df = _read_wqp_response(response.text, kwargs)
return df, WQP_Metadata(response)
def what_organizations(
ssl_check=True,
legacy=True,
**kwargs,
) -> tuple[DataFrame, WQP_Metadata]:
"""Search WQP for organizations within a region with specific data.
Any WQP API parameter can be passed as a keyword argument to this function.
More information about the API can be found at:
https://www.waterqualitydata.us/#advanced=true
or the beta version of the WQX3.0 API at:
https://www.waterqualitydata.us/beta/#mimeType=csv&providers=NWIS&providers=STORET
or the Swagger documentation at:
https://www.waterqualitydata.us/data/swagger-ui/index.html?docExpansion=none&url=/data/v3/api-docs#/
Parameters
----------
ssl_check : bool, optional
Check the SSL certificate. Default is True.
legacy : bool, optional
Return the legacy WQX data profile. Default is True.
**kwargs : optional
Accepts the same parameters as :obj:`dataretrieval.wqp.get_results`
Returns
-------
df : ``pandas.DataFrame``
Formatted data returned from the API query.
md : :obj:`dataretrieval.utils.Metadata`
Custom metadata object pertaining to the query.
Examples
--------
.. code::
>>> # Get all organizations in the WQP
>>> df, md = dataretrieval.wqp.what_organizations()
"""
kwargs = _check_kwargs(kwargs)
url = _legacy_only_url("Organization", legacy=legacy)
response = query(url, payload=kwargs, delimiter=";", ssl_check=ssl_check)
df = _read_wqp_response(response.text, kwargs)
return df, WQP_Metadata(response)
def what_projects(ssl_check=True, legacy=True, **kwargs):
"""Search WQP for projects within a region with specific data.
Any WQP API parameter can be passed as a keyword argument to this function.
More information about the API can be found at:
https://www.waterqualitydata.us/#advanced=true
or the beta version of the WQX3.0 API at:
https://www.waterqualitydata.us/beta/#mimeType=csv&providers=NWIS&providers=STORET
or the Swagger documentation at:
https://www.waterqualitydata.us/data/swagger-ui/index.html?docExpansion=none&url=/data/v3/api-docs#/
Parameters
----------
ssl_check : bool, optional
Check the SSL certificate. Default is True.
legacy : bool, optional
Return the legacy WQX data profile. Default is True.
**kwargs : optional
Accepts the same parameters as :obj:`dataretrieval.wqp.get_results`
Returns
-------
df : ``pandas.DataFrame``
Formatted data returned from the API query.
md : :obj:`dataretrieval.utils.Metadata`
Custom metadata object pertaining to the query.
Examples
--------
.. code::
>>> # Get projects within a HUC region
>>> df, md = dataretrieval.wqp.what_projects(huc="19")
"""
kwargs = _check_kwargs(kwargs)
url = _legacy_only_url("Project", legacy=legacy)
response = query(url, payload=kwargs, delimiter=";", ssl_check=ssl_check)
df = _read_wqp_response(response.text, kwargs)
return df, WQP_Metadata(response)
def what_activities(
ssl_check=True,
legacy=True,
**kwargs,
) -> tuple[DataFrame, WQP_Metadata]:
"""Search WQP for activities within a region with specific data.
Any WQP API parameter can be passed as a keyword argument to this function.
More information about the API can be found at:
https://www.waterqualitydata.us/#advanced=true
or the beta version of the WQX3.0 API at:
https://www.waterqualitydata.us/beta/#mimeType=csv&providers=NWIS&providers=STORET
or the Swagger documentation at:
https://www.waterqualitydata.us/data/swagger-ui/index.html?docExpansion=none&url=/data/v3/api-docs#/
Parameters
----------
ssl_check : bool, optional
Check the SSL certificate. Default is True.
legacy : bool, optional
Return the legacy WQX data profile. Default is True.
**kwargs : optional
Accepts the same parameters as :obj:`dataretrieval.wqp.get_results`
Returns
-------
df : ``pandas.DataFrame``
Formatted data returned from the API query.
md : :obj:`dataretrieval.utils.Metadata`
Custom metadata object pertaining to the query.
Examples
--------
.. code::
>>> # Get activities within Washington D.C.
>>> # during a specific time period
>>> df, md = dataretrieval.wqp.what_activities(
... statecode="US:11",
... startDateLo="12-30-2019",
... startDateHi="01-01-2020",
... )
>>> # Get activities within Washington D.C.
>>> # using the WQX3.0 profile during a specific time period
>>> df, md = dataretrieval.wqp.what_activities(
... legacy=False,
... statecode="US:11",
... startDateLo="12-30-2019",
... startDateHi="01-01-2020",
... )
"""
kwargs = _check_kwargs(kwargs)
url = wqp_url("Activity") if legacy is True else wqx3_url("Activity")
response = query(url, payload=kwargs, delimiter=";", ssl_check=ssl_check)
df = _read_wqp_response(response.text, kwargs)
return df, WQP_Metadata(response)
def what_detection_limits(
ssl_check=True,
legacy=True,
**kwargs,
) -> tuple[DataFrame, WQP_Metadata]:
"""Search WQP for result detection limits within a region with specific
data.
Any WQP API parameter can be passed as a keyword argument to this function.
More information about the API can be found at:
https://www.waterqualitydata.us/#advanced=true
or the beta version of the WQX3.0 API at:
https://www.waterqualitydata.us/beta/#mimeType=csv&providers=NWIS&providers=STORET
or the Swagger documentation at:
https://www.waterqualitydata.us/data/swagger-ui/index.html?docExpansion=none&url=/data/v3/api-docs#/
Parameters
----------
ssl_check : bool
Check the SSL certificate. Default is True.
legacy : bool
Return the legacy WQX data profile. Default is True.
**kwargs : optional
Accepts the same parameters as :obj:`dataretrieval.wqp.get_results`
Returns
-------
df : ``pandas.DataFrame``
Formatted data returned from the API query.
md : :obj:`dataretrieval.utils.Metadata`
Custom metadata object pertaining to the query.
Examples
--------
.. code::
>>> # Get detection limits for Nitrite measurements in Rhode Island
>>> # between specific dates
>>> df, md = dataretrieval.wqp.what_detection_limits(
... statecode="US:44",
... characteristicName="Nitrite",
... startDateLo="01-01-2021",
... startDateHi="02-20-2021",
... )
"""
kwargs = _check_kwargs(kwargs)
url = _legacy_only_url("ResultDetectionQuantitationLimit", legacy=legacy)
response = query(url, payload=kwargs, delimiter=";", ssl_check=ssl_check)
df = _read_wqp_response(response.text, kwargs)
return df, WQP_Metadata(response)
def what_habitat_metrics(
ssl_check=True,
legacy=True,
**kwargs,
) -> tuple[DataFrame, WQP_Metadata]:
"""Search WQP for habitat metrics within a region with specific data.
Any WQP API parameter can be passed as a keyword argument to this function.
More information about the API can be found at:
https://www.waterqualitydata.us/#advanced=true
or the beta version of the WQX3.0 API at:
https://www.waterqualitydata.us/beta/#mimeType=csv&providers=NWIS&providers=STORET
or the Swagger documentation at:
https://www.waterqualitydata.us/data/swagger-ui/index.html?docExpansion=none&url=/data/v3/api-docs#/
Parameters
----------
ssl_check : bool
Check the SSL certificate. Default is True.
legacy : bool
Return the legacy WQX data profile. Default is True.
**kwargs : optional
Accepts the same parameters as :obj:`dataretrieval.wqp.get_results`
Returns
-------
df : ``pandas.DataFrame``
Formatted data returned from the API query.
md : :obj:`dataretrieval.utils.Metadata`
Custom metadata object pertaining to the query.
Examples
--------
.. code::
>>> # Get habitat metrics for a state (Rhode Island in this case)
>>> df, md = dataretrieval.wqp.what_habitat_metrics(statecode="US:44")
"""
kwargs = _check_kwargs(kwargs)
url = _legacy_only_url("BiologicalMetric", legacy=legacy)
response = query(url, payload=kwargs, delimiter=";", ssl_check=ssl_check)
df = _read_wqp_response(response.text, kwargs)
return df, WQP_Metadata(response)
def what_project_weights(ssl_check=True, legacy=True, **kwargs):
"""Search WQP for project weights within a region with specific data.
Any WQP API parameter can be passed as a keyword argument to this function.
More information about the API can be found at:
https://www.waterqualitydata.us/#advanced=true
or the beta version of the WQX3.0 API at:
https://www.waterqualitydata.us/beta/#mimeType=csv&providers=NWIS&providers=STORET
or the Swagger documentation at:
https://www.waterqualitydata.us/data/swagger-ui/index.html?docExpansion=none&url=/data/v3/api-docs#/
Parameters
----------
ssl_check : bool
Check the SSL certificate. Default is True.
legacy : bool
Return the legacy WQX data profile. Default is True.
**kwargs : optional
Accepts the same parameters as :obj:`dataretrieval.wqp.get_results`
Returns
-------
df : ``pandas.DataFrame``
Formatted data returned from the API query.
md : :obj:`dataretrieval.utils.Metadata`
Custom metadata object pertaining to the query.
Examples
--------
.. code::
>>> # Get project weights for a state (North Dakota in this case)
>>> # within a set time period
>>> df, md = dataretrieval.wqp.what_project_weights(
... statecode="US:38",
... startDateLo="01-01-2006",
... startDateHi="01-01-2009",
... )
"""
kwargs = _check_kwargs(kwargs)
url = _legacy_only_url("ProjectMonitoringLocationWeighting", legacy=legacy)
response = query(url, payload=kwargs, delimiter=";", ssl_check=ssl_check)
df = _read_wqp_response(response.text, kwargs)
return df, WQP_Metadata(response)
def what_activity_metrics(ssl_check=True, legacy=True, **kwargs):
"""Search WQP for activity metrics within a region with specific data.
Any WQP API parameter can be passed as a keyword argument to this function.
More information about the API can be found at:
https://www.waterqualitydata.us/#advanced=true
or the beta version of the WQX3.0 API at:
https://www.waterqualitydata.us/beta/#mimeType=csv&providers=NWIS&providers=STORET
or the Swagger documentation at:
https://www.waterqualitydata.us/data/swagger-ui/index.html?docExpansion=none&url=/data/v3/api-docs#/
Parameters
----------
ssl_check : bool
Check the SSL certificate. Default is True.
legacy : bool
Return the legacy WQX data profile. Default is True.
**kwargs : optional
Accepts the same parameters as :obj:`dataretrieval.wqp.get_results`
Returns
-------
df : ``pandas.DataFrame``
Formatted data returned from the API query.
md : :obj:`dataretrieval.utils.Metadata`
Custom metadata object pertaining to the query.
Examples
--------
.. code::
>>> # Get activity metrics for a state (North Dakota in this case)
>>> # within a set time period
>>> df, md = dataretrieval.wqp.what_activity_metrics(
... statecode="US:38",
... startDateLo="07-01-2006",
... startDateHi="12-01-2006",
... )
"""
kwargs = _check_kwargs(kwargs)
url = _legacy_only_url("ActivityMetric", legacy=legacy)
response = query(url, payload=kwargs, delimiter=";", ssl_check=ssl_check)
df = _read_wqp_response(response.text, kwargs)
return df, WQP_Metadata(response)
def wqp_url(service):
"""Construct the WQP URL for a given service."""
base_url = "https://www.waterqualitydata.us/data/"
_warn_legacy_use()
if service not in services_legacy:
raise ValueError(
f"Legacy service not recognized. Valid options are {services_legacy}."
)
return f"{base_url}{service}/Search?"
def wqx3_url(service):
"""Construct the WQP URL for a given WQX 3.0 service."""
base_url = "https://www.waterqualitydata.us/wqx3/"
_warn_wqx3_use()
if service not in services_wqx3:
raise ValueError(
f"WQX3.0 service not recognized. Valid options are {services_wqx3}."
)
return f"{base_url}{service}/search?"
class WQP_Metadata(BaseMetadata):
"""Metadata class for WQP service, derived from BaseMetadata.
Attributes
----------
url : str
Response url
query_time : datetme.timedelta
Response elapsed time
header : requests.structures.CaseInsensitiveDict
Response headers
comments : None
Metadata comments. WQP does not return comments.
site_info : tuple[pd.DataFrame, NWIS_Metadata] | None
Site information if the query included `sites`, `site` or `site_no`.
"""
def __init__(self, response, **parameters) -> None:
"""Generates a standard set of metadata informed by the response with specific
metadata for WQP data.
Parameters
----------
response : Response
Response object from requests module
parameters : dict
Unpacked dictionary of the parameters supplied in the request
Returns
-------
md : :obj:`dataretrieval.wqp.WQP_Metadata`
A ``dataretrieval`` custom :obj:`dataretrieval.wqp.WQP_Metadata` object.
"""
super().__init__(response)
self._parameters = parameters
@property
def site_info(self):
if "sites" in self._parameters:
return what_sites(sites=parameters["sites"])
elif "site" in self._parameters:
return what_sites(sites=parameters["site"])
elif "site_no" in self._parameters:
return what_sites(sites=parameters["site_no"])
def _check_kwargs(kwargs):
"""Private function to check kwargs for unsupported parameters."""
mimetype = kwargs.get("mimeType")
if mimetype == "geojson":
raise NotImplementedError("GeoJSON not yet supported. Set 'mimeType=csv'.")
elif mimetype == "xlsx":
raise NotImplementedError(
"Excel format not yet supported. Set 'mimeType=csv' or 'mimeType=tsv'."
)
elif mimetype not in ("csv", "tsv", None):
raise ValueError("Invalid mimeType. Supported options: 'csv', 'tsv'.")
elif mimetype is None:
kwargs["mimeType"] = "csv"
return kwargs
def _read_wqp_response(text, kwargs):
"""Parse a WQP response into a DataFrame, respecting the requested mimeType."""
delimiter = "\t" if kwargs.get("mimeType") == "tsv" else ","
return pd.read_csv(StringIO(text), delimiter=delimiter, low_memory=False)
def _warn_wqx3_use():
message = (
"Support for the WQX3.0 profiles is experimental. "
"Queries may be slow or fail intermittently."
)
warnings.warn(message, UserWarning, stacklevel=2)
def _warn_legacy_use():
message = (
"This function call will return the legacy WQX format, "
"which means USGS data have not been updated since March 2024. "
"Please review the dataretrieval-python documentation for more "
"information on updated WQX3.0 profiles. Setting `legacy=False` "
"will remove this warning."
)
warnings.warn(message, DeprecationWarning, stacklevel=2)
def _warn_wqx3_unavailable():
# stacklevel=3: warn -> _warn_wqx3_unavailable -> _legacy_only_url -> what_*
warnings.warn(
"WQX3.0 profile not available, returning legacy profile.",
UserWarning,
stacklevel=3,
)
def _legacy_only_url(service: str, legacy: bool) -> str:
"""URL builder for WQP services that have no WQX3.0 equivalent.
When ``legacy=False`` is passed to one of these helpers we emit a
``UserWarning`` explaining the fallback and *also* suppress the legacy
``DeprecationWarning`` that ``wqp_url`` would otherwise raise — its
message claims setting ``legacy=False`` removes the warning, which is
a lie for endpoints that have no WQX3.0 alternative.
"""
with warnings.catch_warnings():
if not legacy:
_warn_wqx3_unavailable()
warnings.simplefilter("ignore", DeprecationWarning)
return wqp_url(service)