Home › Forums › Mayfly Data Logger › Parameter Threshold Notifications › Reply To: Parameter Threshold Notifications
2019-11-22 at 6:16 PM
#13390
Thanks for the front door 🙂 eTree was going down a whirly pooll!
This worked for me, though maybe there is a nicer way.
The output is value_num – which can be used for the threshold check.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
import ulmo #post_req='http://data.wikiwatershed.org/wofpy/rest/1_1/GetValues?location=envirodiy:TU-RC-01&variable=envirodiy:EnviroDIY_Mayfly_Batt' #post_req='http://data.wikiwatershed.org/wofpy/rest/1_1/GetValues?location=envirodiy:TU-RC-01&variable=envirodiy:All_ExternalVoltage_Battery' wsdl_url = 'https://monitormywatershed.org/wofpy/soap/cuahsi_1_1/.wsdl' site_code = 'TU-RC-01' variable_code ='All_ExternalVoltage_Battery' site_values_dict = ulmo.cuahsi.wof.get_values(wsdl_url, site_code, variable_code, start=None, end=None, suds_cache=('default', )) for key_svd in site_values_dict : elem_svd = site_values_dict[key_svd] if key_svd == 'values' : print('**elem_svd',elem_svd) # Fut may have multiple 'value' first_or_default = next((x for x in elem_svd if 'value'), None) if first_or_default : print('**full_value',first_or_default) value_txt = first_or_default['value'] if value_txt : value_num = float(value_txt) print('value (v)', value_num) else : print('err2:value not found') else: print('err1:value not found') |
The retrieved ‘sites_values_dict’ is
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
([('site', { 'code': 'TU-RC-01', 'name': 'TU-RC-01 LDSR PitTag Monitor', 'network': 'envirodiy', 'location': { 'latitude': '38.40731', 'longitude': '-122.81813', 'srs': 'EPSG:4236' } }), ('variable', { 'value_type': 'Instrument deployment', 'data_type': 'Average', 'general_category': 'Instrumentation', 'sample_medium': 'Surface water', 'no_data_value': '-9999.0000000000', 'code': 'All_ExternalVoltage_Battery', 'id': '215', 'name': 'Battery voltage', 'vocabulary': 'envirodiy', 'time': {}, 'units': { 'abbreviation': 'V', 'code': '369', 'name': 'Volt', 'type': 'Electromotive force' }, 'description': None }), ('values', [{ 'value': '16.0', 'method_code': '2', 'quality_control_level_code': '1', 'censor_code': 'nc', 'date_time_utc': '2019-11-23T03:51:02', 'source_code': '611', 'time_offset': '-08:00', 'datetime': '2019-11-22T19:51:02' }]), ('censor_codes', { 'nc': { 'censor_code': 'nc', 'description': 'nc' } }), ('methods', { '2': { 'id': '2', 'code': '2' } }), ('quality_control_levels', { '1': { 'id': '1', 'code': '1', 'definition': 'Raw Data' } }), ('sources', { '611': { 'id': '611', 'code': '611', 'organization': 'Trout Unlimited', 'description': 'Today TU is a national organization with about 300,000 members and supporters organized into over 400 chapters and councils from Maine to Montana to Alaska. This dedicated grassroots army is matched by a respected staff of lawyers, policy experts and scientists, who work out of more than 30 offices nationwide. These conservation professionals ensure that TU is at the forefront of fisheries restoration work at the local, state and national levels.', 'contact_name': 'Neil Hancock', 'email': 'neilh20+turc1910@wllw.net', 'link': 'https://www.tu.org/' } })]) |
The debug out looks like this
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
** elem_svd[{ 'value': '16.0', 'method_code': '2', 'quality_control_level_code': '1', 'censor_code': 'nc', 'date_time_utc': '2019-11-23T03:51:02', 'source_code': '611', 'time_offset': '-08:00', 'datetime': '2019-11-22T19:51:02' }] ** full_value { 'value': '16.0', 'method_code': '2', 'quality_control_level_code': '1', 'censor_code': 'nc', 'date_time_utc': '2019-11-23T03:51:02', 'source_code': '611', 'time_offset': '-08:00', 'datetime': '2019-11-22T19:51:02' } value(v) 16.0 |