Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EPA Water Quality Exchange Plugin #177

Merged
merged 2 commits into from
Oct 11, 2023
Merged

EPA Water Quality Exchange Plugin #177

merged 2 commits into from
Oct 11, 2023

Conversation

dschristianson
Copy link
Contributor

@dschristianson dschristianson commented Oct 6, 2023

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

Type of change

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

How Has This Been Tested?

  • Unit tests
    - [ ] Integration tests
  • Test coverage >= 90%
  • Flake8 Tests
  • Mypy Tests
  • Other - manual testing hitting actual data source see forthcoming comment for queries

Test Configuration

  • Python Version: 3.9

PR Self Evaluation

  • My code follows the agreed upon best practices
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests or modified existing tests that prove my fix is effective or that my feature works
  • Existing unit tests pass locally with my changes
    - [ ] Any dependent changes have been merged and published in the appropriate modules
  • I have performed a self-review of my own code

@dschristianson dschristianson force-pushed the epa-plugin-dev branch 2 times, most recently from 7ae5008 to 25a71e7 Compare October 7, 2023 03:39
@dschristianson
Copy link
Contributor Author

dschristianson commented Oct 7, 2023

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
Copy link
Contributor Author

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

- Plugin and mapping modules
- Tests
- Documentation updated
Copy link
Contributor

@vchendrix vchendrix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dschristianson I ran the tests (unit and integration). All looked great! I then walked through code examples in the plugin documentation and have a few comments and feedback. Feel free address what you feel is appropriate. Some feedback can be considered for future issue tickets.

I then saw you PR comment with code examples and walked through those. Thanks! The measurement tvp example might be good for the epa plugin examples.

docs/plugins.rst Outdated Show resolved Hide resolved
docs/plugins.rst Show resolved Hide resolved
docs/plugins.rst Outdated Show resolved Hide resolved
docs/plugins.rst Outdated Show resolved Hide resolved
docs/plugins.rst Outdated Show resolved Hide resolved
Changed doc example in basin3d/synthesis.py b/c the epa plugin gets imported in the plugins.rst tests which happen in the basin3d/synthesis tests. Add epa in the synthesis.py doc example to make it explicit.
@dschristianson
Copy link
Contributor Author

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

@vchendrix vchendrix merged commit dba3a06 into main Oct 11, 2023
3 checks passed
@vchendrix vchendrix deleted the epa-plugin-dev branch October 11, 2023 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants