当前位置: 首页>>代码示例>>Python>>正文


Python WRCCUtils.get_windowed_data方法代码示例

本文整理汇总了Python中WRCCUtils.get_windowed_data方法的典型用法代码示例。如果您正苦于以下问题:Python WRCCUtils.get_windowed_data方法的具体用法?Python WRCCUtils.get_windowed_data怎么用?Python WRCCUtils.get_windowed_data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WRCCUtils的用法示例。


在下文中一共展示了WRCCUtils.get_windowed_data方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: str

# 需要导入模块: import WRCCUtils [as 别名]
# 或者: from WRCCUtils import get_windowed_data [as 别名]
        if err is not None:return results, err
        form_cleaned, err = self.setFormCleaned(initial)
        if err is not None:return results, err
        try:
            results = WRCCUtils.request_and_format_data(form_cleaned)
        except Exception, e:
            err = 'FAIL request_and_format_data. ERROR: ' + str(e) + ' PARAMS: ' + str(params)
            return results, err
        if 'data_summary' in params.keys() and params['data_summary'] == 'windowed_data':
            d = copy.deepcopy(results['data'][0])
            sd = params['start_date']
            ed = params['end_date']
            sw = params['start_window']
            ew = params['end_window']
            try:
                results['data'] = WRCCUtils.get_windowed_data(d, sd, ed, sw, ew)
            except Exception, e:
                results = {}
                err = 'FAIL get_windowed_data. ERROR: ' + str(e) + ' PARAMS: ' + str(params)
                return results, err
        return results, err

    def test_single_lister_results(self, utClass,results, err):
        if err is not None:
            logger.error(err + '\n')
        try:
            utClass.assertIsNone(err)
        except AssertionError as err:
            logger.error('AssertionError ' + str(err) + '\n')
        try:
            utClass.assertIsInstance(results, dict)
开发者ID:bdaudert,项目名称:my-python-lib,代码行数:33,代码来源:FunctionalTestSCENIC.py

示例2: get_sodlist_data

# 需要导入模块: import WRCCUtils [as 别名]
# 或者: from WRCCUtils import get_windowed_data [as 别名]
def get_sodlist_data(form_input, program):
    '''
    Data acquisition for sodlist,sodmonline(my), sodcnv

    Keyword arguments:
    form_input -- parameter file for data request obtained from user of WRCC SOD pages
    program -- specifies program that is making the request.
    '''
    s_date, e_date = WRCCUtils.start_end_date_to_eight(form_input)
    station_id = form_input['station_id']
    if program in ['sodlist', 'sodcnv']:
        if 'include_tobs_evap' in form_input.keys():
            params = dict(sid='%s' % station_id, sdate=s_date, edate=e_date, \
            elems=[dict(name='pcpn', add='f,t'), dict(name='snow', add='f,t'), dict(name='snwd', add='f,t'),
            dict(name='maxt', add='f,t'), dict(name='mint', add='f,t'), dict(name='obst', add='f,t')])

            params_e = dict(sid='%s' % station_id, sdate=s_date, edate=e_date, elems=[dict(vX=7,add='f,t', prec=2)])
        else:
            if not program == 'sodcnv':
                params = dict(sid='%s' % station_id, sdate=s_date, edate=e_date, \
                elems=[dict(name='pcpn', add='f,t'), dict(name='snow', add='f,t'), dict(name='snwd', add='f,t'),
                dict(name='maxt', add='f,t'), dict(name='mint', add='f,t')])
            else:
                params = dict(sid='%s' % station_id, sdate=s_date, edate=e_date, \
                elems=[dict(name='pcpn', add='f,t'), dict(name='snow', add='f,t'), dict(name='snwd', add='f,t'),
                dict(name='maxt', add='f,t'), dict(name='mint', add='f,t'), dict(name='obst', add='f,t')])
    elif program in ['sodmonline', 'sodmonlinemy']:
        #sodmonline(my) only available for full years
        s_date = '%s%s' % (s_date[0:4], '0101')
        e_date = '%s%s' % (e_date[0:4], '1231')
        if form_input['variable'] == 'evap':
            vXvN = 7
        elif form_input['variable'] == 'wdmv':
            vXvN = 12
        elif form_input['variable'] in ['wesf']:
            vXvN = 13

        if form_input['variable'] in ['evap','wdmv', 'wesf' ]: #need to work with var major (vX) and var minor (vN)
            params = dict(sid='%s' % station_id, sdate=s_date, edate=e_date, elems=[vXvN])
        elif form_input['variable'] in ['dtr', 'mmt']:
            params = dict(sid='%s' % station_id, sdate=s_date, edate=e_date, elems=[dict(name='maxt'), dict(name='mint')])
        else:
            params = dict(sid='%s' % station_id, sdate=s_date, edate=e_date, elems=[dict(name='%s' % form_input['variable'])])
    else:
        print 'Program %s not supported in get_sodlist_data. Program should be one out of [sodlist, sodcnv, sodmonline, sodmonlinemy]!' % program
        sys.exit(0)

    #Request evap, wind and water equivalent data
    #NOTE: these data need to be obtained via var major:
    if program == 'sodlist' and 'include_tobs_evap' in form_input.keys():
        request_evap = StnData(params_e)

        if not request_evap:
            request_evap = {'error':'Bad request, check parameters.'}

        try:
            request_evap['data']
            evap_data = request_evap['data']
        except:
            evap_data = None
    else:
        evap_data = None

    #retrieve data via Acis webservices
    request = StnData(params)

    if not request:
        request = {'error':'Bad request, check parameters.'}

    #Test for successful data retrieval and get metadata information
    try:
        request['meta']
        stn_name = request['meta']['name']
    except:
        if request['error']:
            stn_name = ' '

    try:
        request['data']
        req_data = request['data']
    except:
        req_data = None

    #get windowed data is program is sodlist
    if program == 'sodlist':
        if 'start_window' not in form_input.keys():
            s_window = '0101'
        else:
            s_window = form_input['start_window']
        if 'end_window' not in form_input.keys():
            e_window = '1231'
        else:
            e_window = form_input['end_window']


        if s_window!= '0101' or e_window != '1231':
            if req_data:
                data = WRCCUtils.get_windowed_data(req_data, s_date, e_date, s_window, e_window)
            else:
                data = None
#.........这里部分代码省略.........
开发者ID:bdaudert,项目名称:my-python-lib,代码行数:103,代码来源:AcisWS.py


注:本文中的WRCCUtils.get_windowed_data方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。