使用ulmo usgs.nwis.get\ site\ data函数时出现错误

2024-10-02 02:30:07 发布

您现在位置: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".

我将方法指定为all,但仍然得到相同的错误。有什么办法解决吗


Tags: ininputdatagetparameterservicesitecode
1条回答
网友
1楼 · 发布于 2024-10-02 02:30:07

见Ulmo文件:

methods: ‘‘None‘‘, str or Python dict If None (default), it’s assumed that there is a single method for each parameter. This raises an error if more than one method ids are encountered. If str, this is the method id for the requested parameter/s and can use “all” if method ids are not known beforehand. If dict, provide the parameter_code to method id mapping. Parameter’s method id is specific to site.

所以加上methods = "all"

相关问题 更多 >

    热门问题