olm.USGS package

This package contains functions for retrieving and processing data from the USGS National Water Information System database (NWIS). Using these modules it is possible to retrieve water quality data, discharge data, and site metadata. These data are then converted into Pandas data objects and stored in pickled and spreadsheet format for later usage. The package also contains functions for processing the Pandas data objects through the USGS water chemistry code PHREEQC. For this, an installation of PHREEQC is required.

The most typical entry point is to use the convenience function runWQXtoPandas. This function can be used from within python by importing it from the olm.USGS.WQXtoPandas module. It can additionally be used from the command line using:

$./WQXtoPandas.py <name of input xls file>

Most functionality can be controlled from within the Excel file. A template is provided with the olm package in the examples directory. The examples file also contains some brief code illustrating how data can be read in from the pickled outputs of WQXtoPandas and plotted.

olm.USGS.WQXtoPandas module

runWQXtoPandas(startfilename[, ...])

Runs WQXtoPandas on an excel format input file where parameters can be set for an automatic query of data from the USGS NWIS database.

WQXtoPandas(xmlLocation, charDict[, ...])

Processes a WQX xml data file and loads data for each site in the WQX file into Pandas data objects that are stored in directories for each site.

olm.USGS.PhreeqcPandas module

processMidf(site_midf, site_dir, ...[, ...])

Takes a WQXtoPandas site multi-indexed DataFrame and runs all samples through PHREEQC, returning a DataFrame of the outputs that is indexed by date.

readPhreeqcOutput(phreeqcOutputFile)

Reads the output file from a PHREEQC simulation run.

writePhreeqcInput(sample_row, phreeqc_file_name)

Writes a PHREEQC input file using the row from a site DataFrame.

findPCO2atCalciteSaturation(...[, ...])

Finds the PCO2 where calcite would be saturated by modifing PCO2 of a PHREEQC input file.

phreeqcRunSetPCO2(logPCO2, phreeqcInputFile, ...)

Reads a PHREEQC input file, modifies it to a set PCO2 and runs the modified file.

calciteSaturationAtFixedPCO2(logPCO2, ...[, ...])

Function used in root finding of saturation PCO2.

olm.USGS.DataRetrieval module

GetDailyDischarge(location, date)

Retrieve daily average discharge value from USGS database for given date and USGS site.

GetDailyDischargeRecord(location, start_date)

Retrieve daily average discharge values from USGS database for given date range and USGS site.

GetSiteData(location)

Retrieves meta data about a Water Quality portal site using the site identifier.

querySiteList(siteList, charList)

olm.USGS.loadWaterQualityData module

loadSiteListData([siteListText, siteFile, ...])

Retrieves site data for multiple sites within a processed sites directory.

loadSiteData(site[, processedSitesDir])

Retrieves site data for an individual site from a directory of processed sites.

loadSitePhreeqcData(site[, processedSitesDir])

Retrieves site PHREEQC data for an individual site from a directory of processed sites.

olm.USGS.siteListExtraction module

extractSitesFromText(textFile)

extractSitesFromXML(xmlFile)