Using Python to Retrieve Data from the CUAHSI HIS Web Services Jeffery S. Horsburgh Hydroinformatics Fall 2015 This work was funded by National Science.

Slides:



Advertisements
Similar presentations
HydroServer A Platform for Publishing Space- Time Hydrologic Datasets Support EAR CUAHSI HIS Sharing hydrologic data Jeffery.
Advertisements

ICEWATER: INRA Constellation of Experimental Watersheds Cyberinfrastructure to Support Publication of Water Resources Data Jeffery S. Horsburgh, Utah State.
C van Ingen, D Agarwal, M Goode, J Gupchup, J Hunt, R Leonardson, M Rodriguez, N Li Berkeley Water Center John Hopkins University Lawrence Berkeley Laboratory.
Linking HIS and GIS How to support the objective, transparent and robust calculation and publication of SWSI? Jeffery S. Horsburgh CUAHSI HIS Sharing hydrologic.
This work is funded by National Science Foundation Grant EAR Accessing and Sharing Data Using the CUAHSI Hydrologic Information System CUAHSI HIS.
CUAHSI HIS Data Services Project David R. Maidment Director, Center for Research in Water Resources University of Texas at Austin (HIS Project Leader)
Components of an Integrated Environmental Observatory Information System Cyberinfrastructure to Support Publication of Water Resources Data Jeffery S.
This work was funded by the U.S. National Science Foundation under grant EAR Any opinions, findings and conclusions or recommendations expressed.
1 Chapter 12 Working With Access 2000 on the Internet.
Time Series Analyst An Internet Based Application for Viewing and Analyzing Environmental Time Series Jeffery S. Horsburgh Utah State University David.
Development of a Community Hydrologic Information System Jeffery S. Horsburgh Utah State University David G. Tarboton Utah State University.
Integrating Historical and Realtime Monitoring Data into an Internet Based Watershed Information System for the Bear River Basin Jeff Horsburgh David Stevens,
Introducing the CUAHSI Hydrologic Information System Desktop Application (HydroDesktop) and Open Development Community Jiří Kadlec, Daniel Ames, Teva Velupillai.
Deployment and Evaluation of an Observations Data Model Jeffery S Horsburgh David G Tarboton Ilya Zaslavsky David R. Maidment David Valentine
ASP.NET Programming with C# and SQL Server First Edition
An End-to-End System for Publishing Environmental Observations Data Jeffery S. Horsburgh David K. Stevens, David G. Tarboton, Nancy O. Mesner, Amber Spackman.
Tools for Publishing Environmental Observations on the Internet Justin Berger, Undergraduate Researcher Jeff Horsburgh, Faculty Mentor David Tarboton,
Using HydroServer Organize, Manage, and Publish Your Data Support EAR CUAHSI HIS Sharing hydrologic data Jeffery S. Horsburgh.
HydroShare: Advancing Hydrology through Collaborative Data and Model Sharing David Tarboton, Ray Idaszak, Jeffery Horsburgh, Dan Ames, Jon Goodall, Larry.
Ocean Sciences What is CUAHSI? CUAHSI – Consortium of Universities for the Advancement of Hydrologic Science, Inc Formed in 2001 as a legal entity Program.
Exercises: Organizing, Loading, and Managing Point Observations Using HydroServer Support EAR CUAHSI HIS Sharing hydrologic data
Water Web Services David R. Maidment Center for Research in Water Resources University of Texas at Austin Open Waters Symposium Delft, the Netherlands.
HydroShare: An online collaborative environment for the sharing of hydrologic data and models IN11A-1510 We envision that HydroShare will enable more rapid.
Data Interoperability in the Hydrologic Sciences The CUAHSI Hydrologic Information System David Tarboton, David Maidment, Ilya Zaslavsky, Dan Ames, Jon.
James Seppi CE394K Hydrology, Spring 2010 University of Texas.
ITGS Case Study Theatre Booking System Ayushi Pradhan.
H43H-1325 Kimberly A.T. Schreuders, David G. Tarboton, Jeffery S. Horsburgh, Avirup Sen Gupta, and Stephanie Reeder Utah State University CUAHSI HIS
Water and Catchment Data Services David R. Maidment Center for Research in Water Resources University of Texas at Austin River Science Symposium Swansea,
OOSSE Week 8 JSP models Format of lecture: Assignment context JSP models JSPs calling other JSPs i.e. breaking up work Parameter passing JSPs with Add.
Chapter 5 Introduction To Form Builder. Lesson A Objectives  Display Forms Builder forms in a Web browser  Use a data block form to view, insert, update,
The CUAHSI Observations Data Model Jeff Horsburgh David Maidment, David Tarboton, Ilya Zaslavsky, Michael Piasecki, Jon Goodall, David Valentine,
Data Model / Database Implementation (continued) Jeffery S. Horsburgh Hydroinformatics Fall 2014 This work was funded by National Science Foundation Grants.
Service-Oriented Architectures Peter Varhol Product Manager, Compuware Columnist, Java Pro June 7, 2004.
Lecture 11 Introduction to R and Accessing USGS Data from Web Services Jeffery S. Horsburgh Hydroinformatics Fall 2013 This work was funded by National.
Lecture 9 Using Structured Query Language (SQL) Jeffery S. Horsburgh Hydroinformatics Fall 2012 This work was funded by National Science Foundation Grant.
Using Python to Retrieve and Visualize Data (part 1 of 2) Jon Goodall Hydroinformatics Fall 2014 This work was funded by National Science Foundation Grants.
Lecture 5 Data Model Design Jeffery S. Horsburgh Hydroinformatics Fall 2012 This work was funded by National Science Foundation Grant EPS
Hydroinformatics Lecture 15: HydroServer and HydroServer Lite The CUAHSI HIS is Supported by NSF Grant# EAR CUAHSI HIS Sharing hydrologic data.
UNIVERSITY OF UTAH GREEN INFRASTRUCTURE MONITORING DATABASE CVEEN 7970 Hydroinformatics Semester Project Zachary Magdol, Jai Kanth Panthail, Pratibha Sapkota,
Using Structured Query Language (SQL) Jeffery S. Horsburgh Hydroinformatics Fall 2014 This work was funded by National Science Foundation Grants EPS
Database Principles: Fundamentals of Design, Implementation, and Management Chapter 1 The Database Approach.
1 of 42 Lecture 5 Data Model Design Jeffery S. Horsburgh Hydroinformatics Fall 2013 This work was funded by National Science Foundation Grants EPS
Using Python to Retrieve Data from the CUAHSI HIS Web Services Jon Goodall Hydroinformatics Fall 2014 This work was funded by National Science Foundation.
Developing a community hydrologic information system David G Tarboton David R. Maidment (PI) Ilya Zaslavsky Michael Piasecki Jon Goodall
Jeffery S. Horsburgh Hydroinformatics Fall 2014
The CUAHSI Hydrologic Information System Spatial Data Publication Platform David Tarboton, Jeff Horsburgh, David Maidment, Dan Ames, Jon Goodall, Richard.
Hydroinformatics Lecture: HydroServer .NET/PHP
Using GIS in Creating an End-to-End System for Publishing Environmental Observations Data Jeffery S. Horsburgh David G. Tarboton, David R. Maidment, Ilya.
Python for data analysis Prakhar Amlathe Utah State University
SQL 2016 R Services a.k.a. leveraging your local data lake
Sharing Hydrologic Data with the CUAHSI* Hydrologic Information System
Python Programming Challenge
Lecture 19 Automating Preparing and Entering Model Data in WEAP
R: Packages and Data Retrieval
R: Packages and Data Retrieval
Jeffery S. Horsburgh Utah State University
Using Python to Interact with the EPA WATERS Web Services
Data Virtualization Community Edition
Using Structured Query Language (SQL) (continued)
Lecture 8 Database Implementation
CUAHSI HIS Sharing hydrologic data
Hydroinformatics Lecture 15: HydroServer (and HydroServer Lite)
Data Acquisition, Management and Manipulation
Using Python to Interact with the EPA WATERS Web Services (part 2)
HydroDesktop: A Key Component of the CUAHSI/CZO HIS for Hydrologic Data Discovery, Visualization, and Analysis Daniel P. Ames, Ph.D. P.E. Idaho State University.
Network Visualization
Chapter 12: Automated data collection methods
David Tarboton, Dan Ames, Jeffery S. Horsburgh, Jon Goodall
MANAGING DATA RESOURCES
Web Application Development Using PHP
Presentation transcript:

Using Python to Retrieve Data from the CUAHSI HIS Web Services Jeffery S. Horsburgh Hydroinformatics Fall 2015 This work was funded by National Science Foundation Grants EPS and EPS Slides adapted from original version by Jon Goodall University of Virginia, Hydroinformatics, Fall 2014

Objectives Discover and access data from major hydrologic data sources Create reproducible data visualizations Write and execute computer code to automate difficult and repetitive data related tasks Manipulate data and transform it across file systems, flat files, databases, programming languages, etc. Retrieve and use data from Web services

Class Plan Introduction (setting this material within context) Set up – Software requirements In class demos – Example 1: Getting the site name for a USGS NWIS station using the CUAHSI HIS Web Services – Example 2: Getting the minimum streamflow over the past 5 days for a USGS NWIS station using the CUAHSI HIS Web Services – Example 3: Making a plot of the streamflow data for the past 5 days Challenge problems Wrap up

Big Picture Context 1.Data life cycle 2.Data modeling 3.Database design 4.Database implementation and ODM 5.SQL Querying of an ODM database 6.Python programming against an ODM database 7.Sharing data from an ODM using CUAHSI HIS Web services (WaterOneFlow) and WaterML 8.Accessing CUAHSI HIS Web services using HydroDesktop 9.This week: Accessing CUAHSI HIS Web services using Python

Set up …

Required Packages “suds” – a package for making requests to SOAP web services ( “pandas” – A data analysis library with high performance data structures ( “matplotlib” – A package for scientific plotting (

What is the “suds” package? “Suds is a lightweight SOAP Python client for consuming Web Services.” SOAP and WSDL are standards for creating web services. You don’t need to know the details behind these standards, but if you are interested, Wikipedia has a good summary of both: – SOAP: – WSDL: scription_Languagehttp://en.wikipedia.org/wiki/Web_Services_De scription_Language

What is the “pandas” package? pandas is an open source library providing high performance data structures Some pandas data structures you may be interested in: – Series – a one-dimensional, labeled array capable of holding any data type – axis labels are collectively referred to as the “index” – DataFrame – a 2-dimensional data structure with columns of potentially different types (essentially a high performance table object)

In class examples …

Example 1: Get the site name for a USGS NWIS gage station using the CUAHSI HIS Web Services Use the GetSiteInfoObject method on the CUAHSI HIS WaterOneFlow USGS Unit Values web service: – Use the suds Client object to call the web service method – We will use siteCode = “USGSUV: ” – Suds will automatically parse the WaterML response from the web service call. – We will need to find the siteName property in the response and print it to the console. The answer for “NWISUV: ” is: LOGAN RIVER ABOVE STATE DAM, NEAR LOGAN, UT

Example 2: Getting the minimum streamflow over the past five days for a USGS NWIS station using the CUAHSI HIS Web Services Use the GetValuesObject method on the CUAHSI HIS WaterOneFlow web services – Like example 1, use the suds Client object to call the web service method We will use siteCode = “USGSUV: and ParameterCode = USGSUV: DateTimes should be in the format “YYYY-MM-DD”. – Example GetValuesObject web service call in a browser that returns a WaterML file: 00&variable=NWISUV:00060&startDate= &endDate= &authToken= 00&variable=NWISUV:00060&startDate= &endDate= &authToken We will extract the values and dateTimes and create a pandas Series object to store the time series We will use the min() and idxmin() methods on the Series object to get the minimum streamflow and datetime when the minimum streamflow occurred. – Note: I tested this with Pandas version If you get an error, check your version of Pandas in the PyCharm Package Manager and upgrade the version of Pandas if needed.

Example 3: Create a Time Series Plot of Streamflow Values for the Past 5 Days Use the GetValuesObject method on the CUAHSI HIS WaterOneFlow web services – Like examples 1 and 2, use the suds client object to call the web service method We will use SiteCode = USGSUV: and ParameterCode = USGSUV: DateTimes should be in the format YYYY-MM-DD. We will extract the values and dateTimes and create a Pandas Series object to store the time series. We will create a “figure” object within which we can create our time series plot – We will use the plot() method on the pandas Series object to plot the time series. – Note: I tested this with Pandas version If you get an error, check your version of Pandas in the PyCharm Package Manager and upgrade the version of Pandas if needed.

Using these principles for other WaterOneFlow Web services CUAHSI HIS Central lists other available web services that can be accessed in a similar way – – There are over 400 billion observations available through HIS Central! The HydroServers you created last week with Dr. Ames can also be accessed using this same approach

Challenge problems …

Coding Challenges For the same station (NWISUV: ), modify the example 2 script so that it prints the daily min, max, and average streamflow for the past 5 days. (time permitting) Modify your script so that it prints out the min, max, and average streamflow for EACH DAY during the past 5 days  this is part of what you will need to do for Assignment 8.

Wrap up …

Pros and Cons of using Web Services vs. a local ODM database Pros: – Access to the entire database on which the service is based without the need to store the data locally – No need to keep local local in sync with USGS version Cons: – Requires Internet connection – Speed: Getting data via web services will almost certainly be slower than getting data from your own database – Data is outside your control: breaking changes, unavailable services, etc. – (Some of these could be improved with a data caching strategy)

Summary You can use Python to automate the retrieval of hydrologic data via web services The “suds” package enables you to retrieve data as Python objects “pandas” has some nice data structures that make analysis and visualization easier “matplotlib” allows you to make nice plots

Thursday’s Class Introduce Assignment 7 Work on the assignment in class