本文整理汇总了Python中WRCCUtils.get_el_and_base_temp方法的典型用法代码示例。如果您正苦于以下问题:Python WRCCUtils.get_el_and_base_temp方法的具体用法?Python WRCCUtils.get_el_and_base_temp怎么用?Python WRCCUtils.get_el_and_base_temp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WRCCUtils
的用法示例。
在下文中一共展示了WRCCUtils.get_el_and_base_temp方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_el_and_base_temp
# 需要导入模块: import WRCCUtils [as 别名]
# 或者: from WRCCUtils import get_el_and_base_temp [as 别名]
def test_get_el_and_base_temp(self):
for unit in self.units:
for el in self.variables:
el, base_temp = WRCCUtils.get_el_and_base_temp(el,units=unit)
self.assertIsInstance(el, basestring)
self.assertIn(el,WRCCData.ACIS_ELEMENTS_DICT.keys())
try:
int(base_temp)
except:
self.assertEqual(base_temp,None)
示例2: run_station_finder
# 需要导入模块: import WRCCUtils [as 别名]
# 或者: from WRCCUtils import get_el_and_base_temp [as 别名]
def run_station_finder(self, form_cleaned):
vX_list = []
for el_idx, variable in enumerate(form_cleaned['variables']):
el,base_temp = WRCCUtils.get_el_and_base_temp(variable)
vX_list.append(str(WRCCData.ACIS_ELEMENTS_DICT[el]['vX']))
by_type = WRCCData.ACIS_TO_SEARCH_AREA[form_cleaned['area_type']]
val = form_cleaned[WRCCData.ACIS_TO_SEARCH_AREA[form_cleaned['area_type']]]
dr = [form_cleaned['start_date'],form_cleaned['end_date']]
ec = form_cleaned['variables_constraints']
dc = form_cleaned['dates_constraints']
edc = ec + '_' + dc
station_json, f_name = AcisWS.station_meta_to_json(by_type, val, el_list=vX_list,time_range=dr, constraints=edc)
return station_json, f_name
示例3: get_station_data
# 需要导入模块: import WRCCUtils [as 别名]
# 或者: from WRCCUtils import get_el_and_base_temp [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