本文整理汇总了Python中WRCCUtils.load_data_to_json_file方法的典型用法代码示例。如果您正苦于以下问题:Python WRCCUtils.load_data_to_json_file方法的具体用法?Python WRCCUtils.load_data_to_json_file怎么用?Python WRCCUtils.load_data_to_json_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WRCCUtils
的用法示例。
在下文中一共展示了WRCCUtils.load_data_to_json_file方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: station_meta_to_json
# 需要导入模块: import WRCCUtils [as 别名]
# 或者: from WRCCUtils import load_data_to_json_file [as 别名]
#.........这里部分代码省略.........
#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
if not stn['valid_daterange']:
continue
#check if we are looking for stations with particular variables
if el_list is not None and time_range is not None:
#Check if ACIS produced correct output, i.e. one valid_daterange per variable
if len(stn['valid_daterange']) < len(el_list):
continue
#Check if station is valid, if not, proceed to next station