olm.USGS.WQXtoPandas.WQXtoPandas

olm.USGS.WQXtoPandas.WQXtoPandas(xmlLocation, charDict, outputPath='.', fromFile=False, outputDirName='Processed-Sites', RUN_PHREEQC=False, PHREEQC_PATH='/home/mcoving/phreeqc-2.18.0/bin/', DATABASE_FILE='/home/mcoving/phreeqc-2.18.0/database/phreeqc.dat', LOG_FILE='Result.log', START_FILE=None, splittag='', bracket_charge_balance=False, max_xml_query_tries=20, restart=False)[source]

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.

Parameters:
xmlLocationstring

Content depends on mode in which WQXtoPandas is run. When fromFile is set to False (input methods 2 or 3 in excel file) this string contains the html for a query to the USGS NWIS database to obtain an xml file of the desired data. Alternatively, if fromFile is True (input method 1 in excel file) then this string contains the name of the xml file from which to read the data.

charDictdict

A dictionary containing information about the characteristics to be processed. Keys are EPA SRS characteristic names. Each entry in the dictionary is a second dictionary that contains keys IsRequired, pcode, fraction, and quality. These entries tell WQXtoPandas whether a given characteristic is required in order to process a sample, and whether a specific pcode, fraction, or quality should be required. See excel example file for more details.

outputPathstring

path to directory that will contain output directory

fromFileboolean

True if data will be read from an xml file already present on computer. False if xml file should be queried from NWIS. (Default=False)

outputDirNamestring

Name of output directory where all site data will be written out. (Default=’Processed-Sites’)

RUN_PHREEQCboolean

Set to true if samples should be processed through PHREEQC. (Default=False)

PHREEQC_PATHstring

Path to PHREEQC executable (folder only, not executable file name)

DATABASE_FILEstring

Path to database file that PHREEQC should use, including database file name.

LOG_FILEstring

Name of log file that WQXtoPandas will create. (Default=’Result.log’)

START_FILEstring

Name of xls start file that was used to run this instance of WQXtoPandas. Name will be written out in log file.

bracket_charge_balancebool

If set to true, WQXtoPandas will alternately force charge balance on calcium and alkalinity, while the latter is not physically meaningful, this provides a useful estimate of uncertainty for cases with high charge balance errors. This is most useful for water that is very dilute or with high organic content, such that titrated alkalinity values are artificially high.

max_xml_query_triesint

Maximum number of times to try to retreive an xml file using a query to the Water Quality Portal database. Default = 20.

restartbool

Boolean to enable restarting failed run. If set to True, then the function will skip over any queries that already have an xml file created. Default = False.

Returns:
Returns 0 if execution successful. Returns -1 in case of error.

Notes

Designed to be run through convenience function runWQXtoPandas().