BASIN-3D / basin3d

The core BASIN-3D application that uses a generalized data synthesis model that applies across a variety of earth science observation types (hydrology, geochemistry, climate etc.). https://basin3d.readthedocs.io/
Other
12 stars 4 forks source link

EPA Water Quality Exchange Plugin #177

Closed dschristianson closed 11 months ago

dschristianson commented 11 months ago

Add plugin for EPA Water Quality eXchange Data acquired thru the Water Quality Portal: https://www.waterqualitydata.us/

Type of change

How Has This Been Tested?

Test Configuration

PR Self Evaluation

dschristianson commented 11 months ago

A sample of manual tests. Comment / uncomment the various versions.

Setup

from basin3d.plugins import epa
from basin3d import monitor
from basin3d.core.models import MonitoringFeature

monitor.configure(loggers={"basin3d": {"level": "DEBUG"}})
synthesizer = synthesis.register()

Monitoring Feature queries:

# USGS huc
monitoring_features = synthesizer.monitoring_features(parent_feature='EPA-14020001')
# EPA site ids
# monitoring_features = synthesizer.monitoring_features(monitoring_feature=['EPA-CORIVWCH_WQX-176', 'EPA-11NPSWRD_WQX-BLCA_09128000'])

mf: MonitoringFeature
for mf in monitoring_features:
    lat = mf.coordinates.absolute.horizontal_position[0].latitude
    long = mf.coordinates.absolute.horizontal_position[0].longitude
    alt = 'Nope'
    if mf.coordinates.absolute.vertical_extent:
        alt = mf.coordinates.absolute.vertical_extent[0].value
    depth = 'Nope'
    if mf.coordinates.representative:
        depth = mf.coordinates.representative.vertical_position.value
    mf_details = f'{mf.id}; {mf.name}; LAT {lat}; LON {long}; DEPTH {depth}; ELEV {alt}'
    mf_list.update({mf.id: {'details': mf_details, 'desc': mf.description, 'mf': mf}})
    print(f'{mf.id}-{mf.name}')

MeasurementTVPObservation queries

# 4 objects returned
# measurement_timeseries_tvp_observations = synthesizer.measurement_timeseries_tvp_observations(
#     monitoring_feature=["EPA-11NPSWRD_WQX-BLCA_09128000", "EPA-11NPSWRD_WQX-CURE_09127000", "11NPSWRD_WQX-CURE_38193410713350"], observed_property=['SWL'], start_date='2005-01-01', end_date='2010-01-01', aggregation_duration='NONE')
# 5 objects returned
measurement_timeseries_tvp_observations = synthesizer.measurement_timeseries_tvp_observations(
    monitoring_feature=['EPA-CCWC-COAL-26', 'EPA-CCWC-MM-29 WASH #3'], observed_property=['As', 'WT', 'DO'], start_date='2010-01-01', end_date='2011-01-01', aggregation_duration='NONE')

for mvp in measurement_timeseries_tvp_observations:
    foi: MonitoringFeature = mvp.feature_of_interest
    lat = foi.coordinates.absolute.horizontal_position[0].latitude
    lon = foi.coordinates.absolute.horizontal_position[0].longitude
    depth = 'Nope'
    if foi.coordinates.representative:
        depth = f'{foi.coordinates.representative.vertical_position.type}: {foi.coordinates.representative.vertical_position.value}'
    elev = 'Nope'
    if foi.coordinates.absolute.vertical_extent:
        elev = f'{foi.coordinates.absolute.vertical_extent[0].type}: {foi.coordinates.absolute.vertical_extent[0].value}'
    mvp_ids = f'{mvp.id}; {mvp.observed_property}; {foi.id}; LAT {lat}; LONG {lon}; depth {depth}; elev {elev}'
    print(mvp_ids)
dschristianson commented 11 months ago

@vchendrix: please have a look at the new readthedoc plugins page in the documentation. The build is under this branch.

dschristianson commented 11 months ago

Thanks for the great comments, @vchendrix! Address them all plus the few we found during today's discussion.