Auxiliary Module
Helper Functions used in the WaterML module
- class pywaterml.auxiliaryMod.GetSoapsPlugin[source]
This class represents the GetSoapsPlugin object for the WaterMLOperations class. The GetSoapsPlugin provides two functions of the MessagePlugin: the reveived and sending functions. It helps for debugging purposesrealted to the SOAP protocol.
- Parameters:
MessagePlugin – The MessagePlugin currently has (5) hooks: - marshalled():: Provides the plugin with the opportunity to inspect/modify the envelope Document before it is sent. - sending():: Provides the plugin with the opportunity to inspect/modify the message text before it is sent. - received():: Provides the plugin with the opportunity to inspect/modify the received XML text before it is SAX parsed. - parsed():: Provides the plugin with the opportunity to inspect/modify the sax parsed DOM tree for the reply before it is unmarshalled. - unmarshalled():: Provides the plugin with the opportunity to inspect/modify the unmarshalled reply before it is returned to the caller.
- class pywaterml.auxiliaryMod.Auxiliary[source]
This class represents the Auxiliary object for the WaterMLOperations class. The Auxiliary provides functions related to parsing data from XML to JSON format, and the creation of JSON responses to have a more digested output. However, this is a helper class for the main WaterMLOperations class.
- _parseJSON()[source]
Helper function to parse JSON data into a python dictionary. It is used in the WaterMLOperations GetSites() function. :param json: json object
- Returns:
- Dictionary from all the sites of an specific URL with the following data:
latitude = The WGS84 latitude in decimal degrees
longitude = The WGS84 longitude in decimal degrees
site_name = The name of the site
network = Network that the site belongs to
sitecode = A short unique code of the site
siteID = The site ID in the original database
fullSiteCode = full site code of the current site. The fullSiteCode of every site is the following string: “network: sitecode”
- Return type:
hs_sites
- _parseWML(bbox)[source]
Helper function to parse JSON data from a bounding box into a python dictionary . It is used in the WaterMLOperations GetSitesByBoxObject() function. :param bbox: json object from belonging to the bounding box
- Returns:
- Dictionary from all the sites of an specific WaterOneFlow web service with the following data:
latitude = The WGS84 latitude in decimal degrees
longitude = The WGS84 longitude in decimal degrees
site_name = The name of the site
network = Network that the site belongs to
sitecode = A short unique code of the site
siteID = The site ID in the original database
fullSiteCode = full site code of the current site. The fullSiteCode of every site is the following string: “network: sitecode”
- Return type:
hs_sites
- _recursive_asdict(d)[source]
Helper function to make Suds object into serializable format recurvesively . It is used in the _parseJSON and _parseWML functions. :param d: json object
- Returns:
None
- _getValuesHelper(k, return_obj)[source]
Helper function to parse and store the content of the dictionary response from the GetValues at the level ([‘timeSeriesResponse’][‘timeSeries’][‘values’][‘value’]) into a new dictionary. The data stored into this dictionary from the GetValues response is the following:
dateTimeUTC: The UTC time of the observation.
dateTime: The local date/time of the observation.
dataValue: Data value from the observation.
censorCode: The code for censored observations. Possible values are nc (not censored), gt(greater than), lt (less than), nd (non-detect), pnq (present but not quantified)
methodCode: The code of the method or instrument used for the observation
qualityControlLevelCode: The code of the quality control level. Possible values are -9999(Unknown), 0 (Raw data), 1 (Quality controlled data), 2 (Derived products), 3 (Interpretedproducts), 4 (Knowledge products)
sourceCode: The code of the data source
timeOffSet: The difference between local time and UTC time in hours.
This function is only stores half of the reponse from the GetValues method, and it is usually used with the _getValuesHelper2 function that stores the other half of the function. :param k: GetValues response dictionary at level -> ([‘timeSeriesResponse’][‘timeSeries’][‘values’][‘value’]) :param return_obj: python dictionary that will store the data from teh GetValues response.
- Returns:
python dictionary containing data from the GetValues response.
- Return type:
return_obj
- _getValuesHelper2(times_series, return_object)[source]
- Helper function to parse and store the content of the dictionary response from the GetValues at the level ([‘timeSeriesResponse’][‘timeSeries’][‘values’][‘value’]) into a new dictionary. The data stored into this dictionary from the GetValues response is the following:
siteName: Name of the site.
siteCode: Code of the site.
network: observation network that the site belongs to
siteID: ID of the site
latitude: latitude of the site
longitude: longitude of the site
variableName: Name of the variable
unitName: Name of the units of the values associated to the given variable and site
unitAbbreviation: unit abbreviation of the units from the values associated to the given variable and site
dataType: Type of data
noDataValue: value associated to lack of data.
isRegular: Boolean to indicate whether the observation measurements and collections regular
timeSupport: Boolean to indicate whether the values support time
timeUnitName: Time Units associated to the observation
timeUnitAbbreviation: Time units abbreviation
sampleMedium: the sample medium, for example water, atmosphere, soil.
speciation: The chemical sample speciation (as nitrogen, as phosphorus..)
This function is only stores half of the reponse from the GetValues method, and it is usually used with the _getValuesHelper function that stores the other half of the function. :param times_series: GetValues response dictionary at level -> ([‘timeSeriesResponse’][‘timeSeries’][‘values’][‘value’]) :param return_object: python dictionary that will store the data from teh GetValues response.
- Returns:
python dictionary containing data from the GetValues response.
- Return type:
return_object
- _getSiteInfoHelper(object_siteInfo, object_methods)[source]
Helper function to parse and store the content of two dictionaries:
object_methods = GetSiteInfoResponse [‘sitesResponse’][‘site’][‘seriesCatalog’][‘series’]
object_siteInfo = GetSiteInfoResponse [‘sitesResponse’][‘site’][‘siteInfo’]
Both dictionaries containing the response from the GetSiteInfo at store the following content into a new dictionary:
siteName: Name of the site.
siteCode: Code of the site.
network: observation network that the site belongs to
fullVariableCode: The full variable code, for example: SNOTEL:SNWD.Use this value as the variableCode parameter in GetValues().
siteID: ID of the site
latitude: latitude of the site
longitude: longitude of the site
variableName: Name of the variable
unitName: Name of the units of the values associated to the given variable and site
unitAbbreviation: unit abbreviation of the units from the values associated to the given variable and site
dataType: Type of data
noDataValue: value associated to lack of data.
isRegular: Boolean to indicate whether the observation measurements and collections regular
timeSupport: Boolean to indicate whether the values support time
timeUnitName: Time Units associated to the observation
timeUnitAbbreviation: Time units abbreviation
sampleMedium: the sample medium, for example water, atmosphere, soil.
speciation: The chemical sample speciation (as nitrogen, as phosphorus..)
beginningDateTimeUTC: The UTC date and time of the first available
EndDateTimeUTC: The UTC date and time of the last available
beginningDateTime: The local date and time of the first available
EndDateTime: The local date and time of the last available
censorCode: The code for censored observations. Possible values are nc (not censored), gt(greater than), lt (less than), nd (non-detect), pnq (present but not quantified)
methodCode: The code of the method or instrument used for the observation
methodID: The ID of the sensor or measurement method
qualityControlLevelCode: The code of the quality control level. Possible values are -9999(Unknown), 0 (Raw data), 1 (Quality controlled data), 2 (Derived products), 3 (Interpretedproducts), 4 (Knowledge products)
qualityControlLevelID: The ID of the quality control level. Usually 0 means raw data and 1 means quality controlled data.
sourceCode: The code of the data source.
timeOffSet: The difference between local time and UTC time in hours.
- Parameters:
object_siteInfo – Contains metadata associated to the site.
object_methods – Contains a list of <series>, which are unique combinations of site, variable and time intervals that specify a sequence of observations.
- Returns:
python dictionary containing data from the GetSiteInfo response.
- Return type:
return_obj
- _getVariablesHelper(one_variable, return_object)[source]
Helper function to parse and store the content of the GetValues response dictionary at the level:
one_variable = GetVariablesResponse [‘variablesResponse’][‘variables’][‘variable’]
The dictionary containing the response from the GetValues method stores the following content into a new dictionary:
variableName: Name of the variable
unitName: Name of the units of the values associated to the given variable and site
unitAbbreviation: unit abbreviation of the units from the values associated to the given variable and site
noDataValue: value associated to lack of data.
isRegular: Boolean to indicate whether the observation measurements and collections regular
timeSupport: Boolean to indicate whether the values support time
timeUnitName: Time Units associated to the observation
timeUnitAbbreviation: Time units abbreviation
sampleMedium: the sample medium, for example water, atmosphere, soil.
speciation: The chemical sample speciation (as nitrogen, as phosphorus..)
- Parameters:
one_variable – Contains metadata associated to the different variables of the site.
return_object – python dictionary that will store the data from the GetVariables response.
- Returns:
python dictionary containing data from the GetVariables response.
- Return type:
return_object
- _parseService(centralUrl)[source]
Helper function to parse JSON data into a python dictionary. It is used in the WaterMLOperations GetWaterOneFlowServiceInfo() function. If the WaterOneFlow web service endpoint is not accesible though the suds library. :param centralUrl: URL from a WaterOneFlow web servicee to access a HIS catalog
- Returns:
- Dictionary from all the web services contained in the WaterOneFlow web service endpoint. The folllowing data is returned for each service:
servURL: URL of the WaterOneFlow web service
Title: title of the WaterOneFlow web service
organization: supervising organization of the WaterOneFlow web service
aabstract: abstract of the WaterOneFlow web service
- Return type:
services
- _giveServices(services, filter_serv=None)[source]
Helper function to retrieve the WaterOneFlow web services of a catalog as a python dictionary. It is used in the WaterMLOperations GetWaterOneFlowServiceInfo() function to parse the different services. :param services: Array of URL WaterOneFlow web services. :param filter_serv: Filter to only parse some services that meet a condition.
- Returns:
- Dictionary from all the web services contained in the WaterOneFlow web service endpoint. The folllowing data is returned for each service:
url: URL of the WaterOneFlow web service
title: title of the WaterOneFlow web service
description: abstract of the WaterOneFlow web service
- Return type:
json_response