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


Python WRCCUtils.get_bbox方法代码示例

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


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

示例1: get_station_data

# 需要导入模块: import WRCCUtils [as 别名]
# 或者: from WRCCUtils import get_bbox [as 别名]
def get_station_data(form_input, program):
    '''
    Retrieves Station Data from ACIS.
    Keyword arguments:
    form_input -- parameter file for data request obtained from user of CSC pages
    program -- specifies program that is making the request.
    Returns python dictionary with keys:
        meta
        data
    '''
    request = {'data':[]}
    s_date, e_date = WRCCUtils.start_end_date_to_eight(form_input)
    #Sanity check for valid date input:
    if (s_date.lower() == 'por' or e_date.lower() == 'por') and ('station_id' not in form_input.keys()):
        error = 'Parameter error. Start/End date ="por" not supported for multi station call.'
        resultsdict['error'] = error
        return resultsdict

    variables = WRCCUtils.get_variable_list(form_input, program)
    elems_list = []
    elems_list_short  = []
    resultsdict = {}
    for el in variables:
        el_strip, base_temp = WRCCUtils.get_el_and_base_temp(el)
        elems_list_short.append(el_strip)
        if el_strip in ['gdd', 'hdd', 'cdd'] and base_temp is not None:
            d = dict(vX=WRCCData.ACIS_ELEMENTS_DICT[el_strip]['vX'], base=int(base_temp), add='f,t')
            elems_list.append(d)
        else:
            d = dict(vX=WRCCData.ACIS_ELEMENTS_DICT[el]['vX'],add='f,t')
            elems_list.append(d)
    params = {
            'sdate':s_date,
            'edate':e_date,
            'meta':'name,state,sids,ll,elev,uid,valid_daterange',
            'elems':elems_list
            }
    shape_type = None
    #Deal with POR input dates
    if 'station_id' in form_input.keys():
        sid = form_input['station_id']
        s = s_date.lower()
        e = e_date.lower()
        l = elems_list_short
        vd, no_vd_els = WRCCUtils.find_valid_daterange(sid, start_date=s, end_date=e, el_list=l, max_or_min='max')
        params['sdate'] = v[0]; params['edate'] = v[1]
        if params['sdate']  == '9999-99-99' or params['edate'] == '9999-99-99':
            error = 'No start/end date could be found for this station in the metadata database.'
            resultsdict['error'] = error
            return resultsdict
    #Set area parameter
    try:
        key = WRCCData.STN_AREA_FORM_TO_PARAM[form_input['select_stations_by']]
        val = form_input[form_input['select_stations_by']]
    except:
        key = WRCCData.STN_AREA_FORM_TO_PARAM[form_input['area_type']]
        val = form_input[form_input['area_type']]
    params[key] = val
    #Find bbox if custom shape and update params['bbox']
    if 'shape' in form_input.keys():
        shape_type,bbox = WRCCUtils.get_bbox(form_input['shape'])
        params['bbox'] = bbox
    #Data request
    try:
        req = MultiStnData(params)
    except Exception, e:
        request['error'] = 'StnData request failed. Error: %s. Pameters: %s.' %(str(e), params)
        return request
开发者ID:bdaudert,项目名称:my-python-lib,代码行数:70,代码来源:AcisWS.py

示例2: get_grid_data

# 需要导入模块: import WRCCUtils [as 别名]
# 或者: from WRCCUtils import get_bbox [as 别名]
def get_grid_data(form_input, program):
    '''
    Retrieves Grid Data from ACIS.
    Keyword arguments:
    form_input -- parameter file for data request obtained from user of CSC pages
    program -- specifies program that is making the request.
    Returns python dictionary with keys:
    meta
    data or smry (if data_summary)
    lats   -- lists of latitudes for grid points
    lons   -- lists of longitudes for grid points
    '''
    #datalist[date_idx] = [[date1,lat1, lon1, elev1, el1_val1, el2_val1, ...],
    #[date2, lat2, ...], ...]
    s_date, e_date = WRCCUtils.start_end_date_to_eight(form_input)
    #grid data calls do not except list of variables, need to be string of comma separated values
    el_list = WRCCUtils.get_variable_list(form_input, program)
    if 'data_summary' in form_input.keys() and form_input['data_summary'] == 'temporal_summary':
        variables = [{'name':str(el),'smry':str(form_input['temporal_summary']),'smry_only':1} for el in el_list]
    else:
        variables = ','.join(el_list)
    params = {
        'sdate': s_date,
        'edate': e_date,
        'grid': form_input['grid'],
        'elems': variables,
        'meta': 'll,elev'
    }
    #Set area parameter
    try:
        key = WRCCData.GRID_AREA_FORM_TO_PARAM[form_input['select_grid_by']]
        val = form_input[form_input['select_grid_by']]
    except:
        key = WRCCData.GRID_AREA_FORM_TO_PARAM[form_input['area_type']]
        val = form_input[form_input['area_type']]
    params[key] = val
    #Override area parameter if needed
    #Find bbox if custom shape
    if 'shape' in form_input.keys():
        #Need to find enclosing bbox
        shape_type,bbox = WRCCUtils.get_bbox(form_input['shape'])
        if shape_type == 'location':params['loc'] = form_input['shape']
        else:params['bbox'] = bbox
    #Find enclosing bbox via General ACIS call if climdiv, cwa, county, basin
    #Note: gridACIS currently does not support direct calls for these options
    #FIX me : when gridACIS supports calls for climdiv, cwa, county, basin
    if form_input['select_grid_by'] in ['county_warning_area', 'climate_division', 'basin', 'county']:
        try:
            a = WRCCData.STN_AREA_FORM_TO_PARAM[form_input['select_grid_by']]
            v = form_input[form_input['select_grid_by']]
        except:
            a = WRCCData.STN_AREA_FORM_TO_PARAM[form_input['area_type']]
            v = form_input[form_input['area_type']]
        bbox = get_acis_bbox_of_area(a,v)
        params['bbox'] = bbox
    request = {}
    try:
        request = GridData(params)
    except Exception, e:
        error = 'GridData request failed with ERROR: %s.' %(str(e))
        request['error'] = error
开发者ID:bdaudert,项目名称:my-python-lib,代码行数:63,代码来源:AcisWS.py

示例3: station_meta_to_json

# 需要导入模块: import WRCCUtils [as 别名]
# 或者: from WRCCUtils import get_bbox [as 别名]

#.........这里部分代码省略.........
                    break
            elif constraints == 'any_all':
                #At least one variables has data records for all dates within given date_range
                if user_start >= por_start and user_end <= por_end:
                    flag_invalid_station = False
                    break
        return flag_invalid_station

    #Settings
    stn_list = []
    stn_json={
        'network_codes': WRCCData.KELLY_NETWORK_CODES,
        'network_icons': WRCCData.KELLY_NETWORK_ICONS,
        'overlay_type':by_type,
        'overlay_val':val
    }

    if el_list:
        vX_list = [str(el) for el in el_list]
        vX_tuple = ','.join(vX_list)
    else:
        vX_list= ['1','2','43','3','4','10','11','7','45','44','12']
        vX_tuple = '1,2,43,3,4,10,11,7,45,44,12'
    shape_type = None
    time_stamp = datetime.datetime.now().strftime('%Y_%m_%d_%H_%M_%S_')
    f_name = time_stamp + 'stn.json'
    f_dir = settings.TEMP_DIR
    #Set up metedata request
    params = {'meta':'name,state,sids,ll,elev,uid,valid_daterange','elems':vX_tuple}
    params[WRCCData.STN_AREA_FORM_TO_PARAM[by_type]] = val
    if by_type == 'sw_states':params['state'] = 'az,ca,co,nm,nv,ut'
    #Find bbox for custom shapes
    if by_type == 'shape':
        shape_type,bbox = WRCCUtils.get_bbox(val)
        params['bbox'] = bbox

    #Acis Metadata call and sanity checks on results
    try:
        request = StnMeta(params)
    except:
        stn_json['error'] = 'Metadata request failed. Please check your parameters!'
        WRCCUtils.load_data_to_json_file(f_dir + f_name, stn_json)
        return stn_json, f_name

    if request is None:
        stn_json['error'] = 'No metadata found.'
        WRCCUtils.load_data_to_json_file(f_dir + f_name, stn_json)
        return stn_json, f_name
    if not 'meta' in request.keys() or not request['meta'] or 'error' in request.keys():
        stn_json['error'] = 'No metadata found.'
        WRCCUtils.load_data_to_json_file(f_dir + f_name, stn_json)
        return stn_json, f_name
    stn_meta_list = []
    #For alphabetic ordering of station names
    sorted_list =[]
    #Keep track of duplicates
    unique_stations = []
    for i, stn in enumerate(request['meta']):
        #if custom shape, check if  stn lies within shape
        if by_type == 'shape':
            if shape_type in ['bbox','location']:shape = bbox.split(',')
            elif shape_type == 'polygon':shape = WRCCUtils.orient_shape_ccw(val).split(',')
            else:shape = val.split(',')
            if not stn_in_poly(by_type, shape_type, shape, stn):
                continue
        #sanity check
开发者ID:bdaudert,项目名称:my-python-lib,代码行数:70,代码来源:AcisWS.py


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