使用ulmo usgs.nwis.get_site_data函数时出现错误

时间:2018-05-16 16:07:38

标签: python

当我尝试使用ulmo库从USGS检索沉积物排放数据时出现错误

ulmo.usgs.nwis.get_site_data('08332010', parameter_code='80155', \
service="daily", start='1969-10-01', end='2016-09-30')

它返回

   processing data from request: https://waterservices.usgs.gov/nwis/dv/? 
   format=waterml&site=08332010&parameterCd=80155&startDT=1969-10- 
   01&endDT=2016-09-30
   ------------------------------------------------------------------------ 
   ValueError                         Traceback (most recent call last)
   <ipython-input-184-3ae1371577c1> in <module>()
   ----> 1 df = ulmo.usgs.nwis.get_site_data('08332010', 
   parameter_code='80155', service="daily", start='1969-10-01', end='2016- 
   09-30')

   /usr/local/lib/python3.6/dist-packages/ulmo/usgs/nwis/core.py in 
   get_site_data(site_code, service, parameter_code, statistic_code, start, 
   end, period, modified_since, input_file, methods, **kwargs)
   259         url_params.update(kwargs)
   260         values = _get_site_values(service, url_params, 
   input_file=input_file,
   --> 261                                   methods=methods)
   262     else:
   263         kw = dict(parameter_code=parameter_code, 
   statistic_code=statistic_code,

   /usr/local/lib/python3.6/dist-packages/ulmo/usgs/nwis/core.py in 
   _get_site_values(service, url_params, input_file, methods)
   336     with _open_input_file(input_file) as content_io:
    337         data_dict = wml.parse_site_values(content_io, query_isodate,
--> 338             methods=methods)
    339 
    340         for variable_dict in list(data_dict.values()):

/usr/local/lib/python3.6/dist-packages/ulmo/waterml/v1_1.py in parse_site_values(content_io, query_isodate, methods)
     14     return common.parse_site_values(
     15         content_io, WATERML_V1_1_NAMESPACE, query_isodate=query_isodate,
---> 16         methods=methods)
     17 
     18 

/usr/local/lib/python3.6/dist-packages/ulmo/waterml/common.py in parse_site_values(content_io, namespace, query_isodate, methods)
     41                     raise ValueError(
     42                         'found more than one method for %s. need to specify'
---> 43                         'specify code or "all".' % variable['code'])
     44                 values_element = values_elements[0]
     45                 values = _parse_values(values_element, namespace)

ValueError: found more than one method for 80155. need to specifyspecify code or "all".

我为所有人指定了方法,但仍然遇到了同样的错误。关于如何解决它的任何想法?

1 个答案:

答案 0 :(得分:0)

请参见Ulmo文档:

  

方法:'None',str或Python dict如果为None(默认),则假定每个参数只有一个方法。这引发了一个错误   如果遇到多个方法ID。如果为str,则为   所请求参数的方法ID,如果方法可以使用“ all”   id事先未知。如果是dict,请提供parameter_code以   方法ID映射。参数的方法ID特定于站点。

因此添加methods = "all"