def orders(): if request.method == 'GET': return render_template('searchorders.html') else: # build the skiplist orderskiplist = helpers.makePresidentialOrderlist() if request.form['title_cont'] != '': app.vars['title_cont'] = request.form['title_cont'] if request.form['category'] != '': app.vars['category'] = request.form['category'] if len(app.vars) == 1: searchtype = app.vars.keys()[0] filters.filter(orderskiplist, app.vars, searchtype, 'title', 2) # resets the request dictionary app.vars = {} return render_template('download.html') else: app.vars = {} return render_template('error.html')
def grants(): if request.method == 'GET': # build the skiplist and pass in as argument grantskiplist = helpers.makeGrantlist() return render_template('searchgrants.html') else: # for post request do the searching and redirect # build the skiplist grantskiplist = helpers.makeGrantlist() if request.form['name_cont'] != '': app.vars['name_cont'] = request.form['name_cont'] if request.form['category'] != '': app.vars['category'] = request.form['category'] if len(app.vars) == 1: searchtype = app.vars.keys()[0] filters.filter(grantskiplist, app.vars, searchtype, 'Awardee', 3) # resets the request dictionary app.vars = {} return render_template('download.html') else: app.vars = {} return render_template('error.html')
def population(): if request.method == 'GET': return render_template('searchpopulation.html') else: # build the skiplist and pass in as argument populationskiplist = helpers.makePopulationlist() # for post request do the searching and redirect # to the download page and pass in file as arg #request was a POST if request.form['initial'] != '': app.vars['initial'] = request.form['initial'] if request.form['popgreater'] != '': app.vars['popgreater'] = request.form['popgreater'] if request.form['poplesser'] != '': app.vars['poplesser'] = request.form['poplesser'] if len(app.vars) == 1: # checks for errors in the post request searchtype = app.vars.keys()[0] filters.filter(populationskiplist, app.vars, searchtype, 'NAME', 1) # resets the request dictionary app.vars = {} return render_template('download.html') else: app.vars = {} return render_template('error.html')
def plot_tau(x_test, y_test, y_predict, plot_folder, filter_type, y_predict2=None): """Plot Reynolds stresses tau fields and pdf.""" dimension = len(y_test[0]['u'].shape) k = filters.filter_size(filter_type, dimension) if len(y_test[0]['u'].shape) == 3: logging.info('Plot tau') for test_example in range(3): tau = dict() tau2 = dict() tau_true = dict() for u_i in ['u', 'v', 'w']: for u_j in ['u', 'v', 'w']: tmp = y_predict[test_example][u_i]*y_predict[test_example][u_j] tmp = filters.filter(tmp, filter_type, k=k[test_example]) tau[u_i+u_j] = x_test[test_example][u_i]*x_test[test_example][u_j] - tmp tmp = y_test[test_example][u_i]*y_test[test_example][u_j] tmp = filters.filter(tmp, filter_type, k=k[test_example]) tau_true[u_i + u_j] = x_test[test_example][u_i] * x_test[test_example][u_j] - tmp if y_predict2: tmp = y_predict2[test_example][u_i]*y_predict2[test_example][u_j] tmp = filters.filter(tmp, filter_type, k=k[test_example]) tau2[u_i + u_j] = x_test[test_example][u_i] * x_test[test_example][u_j] - tmp imagesc([tau_true['uu'][:, :, 32], tau_true['uv'][:, :, 32], tau_true['uw'][:, :, 32]], titles=[r'$\tau^{true}_{11}$', r'$\tau^{true}_{12}$', r'$\tau^{true}_{13}$'], name=os.path.join(plot_folder, 'tau_true{}'.format(test_example)), limits=[-0.07, 0.07]) imagesc([tau['uu'][:, :, 32], tau['uv'][:, :, 32], tau['uw'][:, :, 32]], titles=[r'$\tau_{11}$', r'$\tau_{12}$', r'$\tau_{13}$'], name=os.path.join(plot_folder, 'tau{}'.format(test_example)), limits=[-0.07, 0.07]) fig, axarr = plt.subplots(nrows=1, ncols=3, sharex=True, sharey=True, figsize=(6.5, 2.4)) titles = [r'$\tau_{11}$', r'$\tau_{12}$', r'$\tau_{13}$'] for ind, key in enumerate(['uu', 'uv', 'uw']): x, y = utils.pdf_from_array_with_x(tau_true[key], bins=100, range=[-0.1, 0.1]) axarr[ind].semilogy(x, y, 'r-', lw=2, label='true') x, y = utils.pdf_from_array_with_x(tau[key], bins=100, range=[-0.1, 0.1]) axarr[ind].semilogy(x, y, 'b-', label='modeled') if y_predict2: x, y = utils.pdf_from_array_with_x(tau2[key], bins=100, range=[-0.1, 0.1]) axarr[ind].semilogy(x, y, 'g-', label='modeled 2') axarr[ind].set_xlabel(titles[ind]) axarr[0].axis(xmin=-0.1, xmax=0.1, ymin=1e-3) axarr[0].set_ylabel('pdf') axarr[0].set_yscale('log') plt.legend(loc=0) fig.subplots_adjust(left=0.1, right=0.95, wspace=0.16, bottom=0.2, top=0.9) fig.savefig(os.path.join(plot_folder, 'tau_pdf{}'.format(test_example))) # print(os.path.join(plot_folder, 'tau_pdf{}'.format(test_example))) plt.close('all')
def user_achievements(device_id, db): f = filters.filter(bottle.request.query.filter) return {a: handlers.dispatch(handlers=handlers.handlers.user.achievements, config=f(c), achievement_id=a, db=db, params={'device_id': device_id}) for a, c in conf.achievements.items()}
def user_achievement_by_id(device_id, achievement_id, db): f = filters.filter(bottle.request.query.filter) c = conf.achievements.get_or_raise(key=achievement_id, error=errors.UnknownAchievementId(achievement_id)) return handlers.dispatch(handlers=handlers.handlers.user.achievements, config=f(c), achievement_id=achievement_id, db=db, params={'device_id': device_id})
def user_achievement_by_id(device_id, achievement_id, db): f = filters.filter(bottle.request.query.filter) c = conf.achievements.get_or_raise( key=achievement_id, error=errors.UnknownAchievementId(achievement_id)) return handlers.dispatch(handlers=handlers.handlers.user.achievements, config=f(c), achievement_id=achievement_id, db=db, params={'device_id': device_id})
def test_should_return_list_with_only_bosse_items(): result = filter(["bosse", "daniel", "edvard", "bosse", "bosse"], "bosse") length = len(result) # should be 3 for name in result: assert_equal(name, "bosse") assert_equal(length, 3)
def ranking_all(db): f = filters.filter(bottle.request.query.filter) return {a: handlers.dispatch(handlers=handlers.handlers.ranking, config=f(c), achievement_id=a, db=db, params={'from': bottle.request.query.get("from"), 'to': bottle.request.query.to}) for a, c in conf.achievements.items()}
def user_achievements(device_id, db): f = filters.filter(bottle.request.query.filter) return { a: handlers.dispatch(handlers=handlers.handlers.user.achievements, config=f(c), achievement_id=a, db=db, params={'device_id': device_id}) for a, c in conf.achievements.items() }
def test_should_return_list_with_only_bosse_items(): result = filter(["bosse", "daniel", "edvard", "bosse", "bosse"], "bosse") length = len(result) # should be 3 for name in result: assert_equal(name, "bosse") assert_equal(length,3)
def ranking_by_id(achievement_id, db): f = filters.filter(bottle.request.query.filter) c = conf.achievements.get_or_raise(key=achievement_id, error=errors.UnknownAchievementId(achievement_id)) return handlers.dispatch(handlers=handlers.handlers.ranking, config=f(c), achievement_id=achievement_id, db=db, params={'from': bottle.request.query.get("from"), 'to': bottle.request.query.to})
def ranking_by_id(achievement_id, db): f = filters.filter(bottle.request.query.filter) c = conf.achievements.get_or_raise( key=achievement_id, error=errors.UnknownAchievementId(achievement_id)) return handlers.dispatch(handlers=handlers.handlers.ranking, config=f(c), achievement_id=achievement_id, db=db, params={ 'from': bottle.request.query.get("from"), 'to': bottle.request.query.to })
def ranking_all(db): f = filters.filter(bottle.request.query.filter) return { a: handlers.dispatch(handlers=handlers.handlers.ranking, config=f(c), achievement_id=a, db=db, params={ 'from': bottle.request.query.get("from"), 'to': bottle.request.query.to }) for a, c in conf.achievements.items() }
def make_filter(filter_type=['none','snp', 'outgroup_other','outgroup', 'all_pops'], outgroup_name='', covariance_pipeline=[]): filter_type=initor(filter_type) #taking care of special cases if 23 in covariance_pipeline and filter_type=='snp': filter_type='none' if 6 in covariance_pipeline and (7 in covariance_pipeline or 8 in covariance_pipeline) and filter_type=='snp': filter_type='none' if filter_type=='outgroup': return outgroup_filter(outgroup_name) elif filter_type=='outgroup_other': return outgroup_other_filter(outgroup_name) elif filter_type=='snp': return snp_filter() elif filter_type=='none': return filter() elif filter_type=='all_pops': return all_pops() else: assert False, 'Unexpected behaviour of make_filter because filter type is: '+str(filter_type)
#Average #img1=cv2.imread('./image_1.jpg',0) #img=filters.padding(img1,15) #img=filters.filter(img,15,0) #img=filters.removepadd(img,15) #blur=cv2.blur(img1,(15,15)) #blur=filters.sub(img,blur) #blur=blur*5 #cv2.imshow("Average filter",blur) ##Median img1=cv2.imread('./image_2.png',0) img1=filters.addnoise(img1,10) img=filters.padding(img1,15) img=filters.filter(img,15,1) img=filters.removepadd(img,15) print(img) img=img.astype(np.uint8) blur=cv2.medianBlur(img1,15) blur=filters.sub(img,blur) blur=blur*5 cv2.imshow("Median filter",blur) ###Gaussian #img1=cv2.imread('./image_3.png',0) #img=filters.padding(img1,15) #img=filters.filter(img,15,2) #img=filters.removepadd(img,15) #print(img)
def test_takes_a_list_and_object_as_argument(): filter(1337, 45) filter() filter("kjkj") filter([1, 2, 3])
def test_takes_a_list_and_object_as_argument(): filter(1337, 45) filter() filter("kjkj") filter([1, 2, 3])
def test_should_return_list(): result = filter([1, 2, 3], 4) # result should be a list assert_true(isinstance(result, list))
def test_should_return_list(): result = filter([1, 2, 3], 4) # result should be a list assert_true(isinstance(result, list))
#cv2.imshow("Average filter",img) # ##5x5 Gaussian filter #img2=cv2.imread('./image_3.png',0) #img2=filters.padding(img2,5) #img2=filters.filter(img2,5,2) #img2=filters.removepadd(img2,5) #print(img2[98]) #img2=img2.astype(np.uint8) # #cv2.imshow("Average filter",img2) #11x11 Gaussian filter img = cv2.imread('./image_3.png', 0) img = filters.padding(img, 11) img = filters.filter(img, 11, 2) img = filters.removepadd(img, 11) img = img.astype(np.uint8) cv2.imshow("Average filter", img) ##15x15 Gaussian filter #img=cv2.imread('./image_3.png',0) #img=filters.padding(img,15) #img=filters.filter(img,15,2) #img=filters.removepadd(img,15) #img=img.astype(np.uint8) #cv2.imshow("Average filter",img) #Question4 ##Laplacian level 1