def VisuSingleOptIteration(self, sim, name): """docstring.""" sim.name = name VisuNew = visualization.Visualization(sim) VisuNew.Residuals(save=False, show=False) VisuNew.Animate_Primal(show=False, save=False) VisuNew.Animate_Adjoint(show=False, save=False) VisuNew.Animate_Primal_and_Adjoint(show=False, save=False) VisuNew.PrimalAdjointSensitivitiesDiffusivity(show=False, save=True)
def VisualizeOptimizerVars(self, sim): """docstring.""" VisuNew = visualization.Visualization(sim) VisuNew.ObjectiveFunction(False, True, self.num_DesignCycles, self.ObjectiveFunction) VisuNew.Sensitivities(self.Sensitivities, show=False, save=True) VisuNew.DiffusionCoefficient(self.DiffusionCoefficients, show=False, save=True)
def __init__(self): super().__init__() # window settings self.window_settings = {"view_grouped":True} # create instances self.dispatcher = Dispatcher.Dispatcher() self.visualization = Visualization.Visualization(self.dispatcher,self.window_settings) # get default values self.file_name_bom = self.dispatcher.get_cad_system().get_default_file() self.path_database = self.dispatcher.get_cad_system().get_default_directory() # buil UI self.init_ui()
def plot(self): params = sa.attach('shm://params') eps = params[0] minpts = params[1] visuals = visualization.Visualization() for point in self.noise_points: visuals.OUTLIERS.append(visuals.dimension_reduction(point)) for point in self.core_points: visuals.NON_OUTLIERS.append(visuals.dimension_reduction(point)) for point in self.border_points: visuals.NON_OUTLIERS.append(visuals.dimension_reduction(point)) visuals.outlier_plot_numpy(save_path="./dbscan_plots/eps_" + str(eps) + "_minpts_" + str(minpts))
def __init__(self, options=None): self.settings = options or Option() self.checkpoint = None self.data_loader = None self.model = None self.optimizer_state = None self.trainer = None self.start_epoch = 0 self.model_analyse = None self.visualize = vs.Visualization(self.settings.save_path) self.logger = vs.Logger(self.settings.save_path) self.test_input = None self.lr_master = None self.prepare()
def __init__(self, options): self.algorithm = None self.gapPenalty = None self.includeGaps = None self.removePoor = None self.gapCutoff = None self.pairCutoff = None self.seqType = None self.distFunction = None self.parsIterCnt = None self.options = options self.parseOptions(self.options) self.alignment = self.cleanAlignment(self.alignment) self.checkAlignment() self.distanceMatrix = None self.tree = self.computeTree() self.visualization = visualization.Visualization(self.tree, self.options)
def __init__(self): self.settings = Option() self.checkpoint = None self.data_loader = None self.model = None self.trainer = None self.seg_opt_state = None self.fc_opt_state = None self.aux_fc_state = None self.start_epoch = 0 self.model_analyse = None self.visualize = vs.Visualization(self.settings.save_path) self.logger = vs.Logger(self.settings.save_path) self.prepare()
def polyphase_filter(self, over_sample, alpha, n_symbol): """ creates a root raised cosine polyphase shaping filter . defaults to 8 path and 8 samples per symbol """ # - 8-path Shaping Filter, 8-samples/symbols # matlab hhx=rcosine(1,OverSamp,'sqrt',alpha,n_symb); hhx = myrcf(1, over_sample, 'sqrt', alpha, n_symbol) # zero extend for length to a multiple of over_sample hh = np.append(hhx, np.zeros(over_sample - 1)) # normalize the filter to the maximum value of the filter weights hh_max = np.amax(hh) hh = hh / hh_max # reshape filter to use as a polyphase filter width = (n_symbol * 2) + 1 hh2 = np.reshape(hh, (over_sample, width), order='F') # polyphase filter if DEBUGDERIVATIVEFILTER: vis = visualization.Visualization() vis.plot_data([hh], ['hh'], points=True) nplots = hh2.shape[0] # npaths plots = [None] * nplots for i in range(nplots): plots[i] = [0] * len(hh) for j in range(hh2.shape[1]): plots[i][i + j * hh2.shape[0]] = hh2[i, j] plots.append(hh) vis.plot_data_1figure(plots, ['hh2_' + str(x) for x in range(nplots + 1)], points=False) vis.plot_data_1figure([plots[0], hh], ['plots 0', 'hh'], points=False) vis.plot_data(plots, ['hh2_' + str(x) for x in range(nplots)], points=False) return hh, hh2
def __init__(self, options=None): self.settings = options or Option() self.checkpoint = None self.train_loader = None self.test_loader = None self.model = None self.optimizer_state = None self.trainer = None self.start_epoch = 0 self.test_input = None self.model_analyse = None os.environ['CUDA_DEVICE_ORDER'] = "PCI_BUS_ID" os.environ['CUDA_VISIBLE_DEVICES'] = self.settings.visible_devices self.settings.set_save_path() self.logger = self.set_logger() self.settings.paramscheck(self.logger) self.visualize = vs.Visualization(self.settings.save_path, self.logger) self.tensorboard_logger = vs.Logger(self.settings.save_path) self.prepare()
def __init__(self): """ 主线程初始化函数: state: 表示状态机当前的状态 main_window: 可视化窗口 client_socket: 和服务器进行信息交互的封装好的socket类 """ # 初始化状态机的状态变量 self.state = 0 # 初始化主机号与端口号 self.HOST = "" self.PORT = 0 # 创建主窗口 self.main_window = vs.Visualization(self) self.main_window.initialization(1280, 720) # 对第一阶段可视化窗口进行初始化 self.main_window.connection_init() # 创建通信组件 self.client_socket = None # 调用主循环 self.mainLoop()
import pandas as pd import numpy as np from multiprocessing.pool import ThreadPool from multiprocessing import cpu_count import operator from collections import OrderedDict import itertools import time from sklearn.metrics import accuracy_score import visualization visuals = visualization.Visualization() class Local_Outlier_Factor: ''' @Author: Naren Surampudi ''' def __init__(self): self.K = 2 self.DATA = None self.SAMPLE_DATA = None self.DATA_FLAG = True self.THRESH = 1 self.REDUCED_POINTS = [] def neighborhood(self): if self.DATA_FLAG: val_data = self.DATA.values.tolist() else: val_data = self.SAMPLE_DATA # for sample sets
sim.calculateSensitivities() AdjointDerivative = copy.copy(sim.Dderivative) t3 = time.time() print(t1 - t0, t2 - t1, t3 - t2) #---------------------------------------------------------------------------------------# writeDataToFile = True if writeDataToFile: filename = 'Adjoint_sens.csv' data = np.stack([sim.mesh.X, sim.Dderivative], axis=1) df = pd.DataFrame(data, columns=['x', 'dJdalpha']) df.to_csv(filename) print("Sensitivity data written to: ", filename) #---------------------------------------------------------------------------------------# VisuNew = visualization.Visualization(sim) VisuNew.Residuals(save=True, show=False) VisuNew.Animate_Primal(show=False, save=False) VisuNew.Animate_Adjoint(show=False, save=False) VisuNew.Animate_Primal_and_Adjoint(show=False, save=False) VisuNew.PrimalAdjointSensitivitiesDiffusivity(show=False, save=True) #VisuNew.ObjectiveFunction(False, True, cycles, Objective_Function) VisuNew.Sensitivities([sim.Dderivative], show=True, save=True) #VisuNew.DiffusionCoefficient(DiffusionCoefficients, show=False, save=True) #---------------------------------------------------------------------------------------# adjoint_check = True if adjoint_check == True: #print(sim.dt, sim.Nt, D) eta = np.sqrt((1. + 4 * D * sim.dt * sim.Nt) / 1.) analytical_solution = -np.exp(-(
def visual_output(answer_list, size): v = visualization.Visualization(answer_list, size, master=Tk()) v.mainloop() return
sql = 'select genre.name, genre.id, count (*) as total, char_length(genre.name) from entity_has_genre join genre on genre.id = genre_id join entity on entity.id = entity_has_genre.entity_id where genre.id < 39 group by genre.name, genre.id order by total;' if(dbase.change(sql)): result = dbase.cursor.fetchall(); results.append(result) ''' sql = 'select name, count(*) as total, char_length(name) from (select people_id, create_type.name from people_create_goods join create_type on create_type.id = create_type_id where create_type_id <> 21 UNION select people_id, name from people_produces_entity join produces_type on produces_type_id = id) as temp_table group by name order by total desc;' if (dbase.change(sql)): result = dbase.cursor.fetchall() results.append(result) #Begin create visualization from results: new_view = v.Visualization() mask_array = None #Uncomment this line if you want use mask, the mask must be a png file with 2 color (black and white): #mask_array = imread("e-comp-2450.png") for index, result in enumerate(results): if index == 0: text = ('{0} litros', '{0} litro') elif index == 1: text = ('{0} m3', '{0} m3') elif index == 2: text = ('{0} m2', '{0} m2') elif index == 3: text = ('R$ {0}', 'R$ {0}') else: text = ('{0} itens', '{0} item')
def set_variables(self): # the following variables are used to determine what functions the # script calls and which it skips. The variables are automatically # update in the initialization depending on whether or not a camera # is detected and a tygron session is found. self.initialized = False self.reload_enabled = False self.start_new_turn = False self.test = False self.tygron = True self.update_count = 0 # save variables, adjust as you wish how to run Virtual River self.save = True self.model_save = False self.reloading = False self.debug = False # Virtual River variables. THESE ARE ADJUSTABLE! self.slope = 10**-3 # tested and proposed range: 10**-3 to 10**-4 self.vert_scale = 1 # setting matches current z scaling, testing. # Mixtype vegetation class ratio in % for natural grass/reed/brushwood # Currently not used, but can be passed to landuse_to_friction function # of the updateRoughness module. self.mixtype_ratio = [50, 20, 30] # Memory variables self.turn = 0 self.token = "" self.model = D3D.Model() self.turn_img = None #self.hexagons = None self.hexagons_sandbox = None self.hexagons_tygron = None self.hexagons_prev = None self.transforms = None self.node_grid = None self.node_grid_prev = None self.filled_node_grid = None self.filled_node_grid_prev = None self.flow_grid = None self.face_grid = None self.pers = None # may not be necessary to store these, but some methods would need to # be updated (in gridCalibration and processImage). self.img_x = None self.img_y = None self.origins = None self.radius = None # list that tracks updated hexagons in case hexagons are placed back. self.updated_hexagons = [] # list that tracks groyne/LTDs updates during a turn (both have to be # reset if changes are reverted). self.groyne_tracker = [] # water safety module self.water_module = water.Water() self.flood_safety_score = None # cost module self.cost_module = costs.Costs() # total costs made up until the end of the rounds ended self.total_costs = 0 # turn costs of the current round self.turn_costs = 0 self.cost_score = None # BIOSAFE module self.biosafe = biosafe.BiosafeVR() self.biosafe_score = None # visualization self.viz = visualize.Visualization(self.model) self.create_viz = overlays.createViz() app = pywinauto.application.Application().connect( title_re='visualizer') self.window = app.window(title_re='visualizer') return
circuits_cols = [ 'circuitId', 'name', 'location', 'country', 'lat', 'lng', 'alt' ] constructor_cols = [ 'constructorId', 'constructorRef', 'name', 'nationality' ] status_cols = ['statusId', 'status'] f_one = F1Home(raw_results_path, raw_races_path, raw_drivers_path, raw_circuits_path, raw_constructor_path, raw_status_path) f_one.select_desired_cols(results_cols, races_cols, drivers_cols, circuits_cols, constructor_cols, status_cols) f_one.apply_data_cleaning() f_one.save_csvs(False) vis = visualize.Visualization() plt.style.use('seaborn-deep') color_list = ['grey', 'green'] #df_driver_means_years_combined, t_score, p_val, df_driver_means_by_year_by_driver = f_one.end_user_home_adv_for_all_data() # vis.show_driver_country_vertical(plt, f_one) # vis.show_drivers_with_home_race_pie(plt, f_one) # vis.show_driver_country_pretty(plt, f_one) # vis.show_drivers_average_means(plt,df_driver_means_years_combined, 'All Years') # vis.show_home_away_comp(plt, df_driver_means_years_combined, 'All Years') # vis.show_home_away_ratio(plt, df_driver_means_years_combined, 'All Years') # By Season df_driver_means_years_combined, t_score_years_combined, p_val_years_combined, df_driver_means_by_year_by_driver = f_one.end_user_most_recent_grid( ) vis.show_drivers_average_means(plt, df_driver_means_years_combined,
def polyphase_derivative_filter(self, n_paths, over_sample, alpha, n_symbol): # --- 32-path Polyphase Matched filter, 2-samples per symbol ------------ # %hh_t=rcosine(1,64,'sqrt',0.5,6); % Matched filter hh = myrcf(1, over_sample, 'sqrt', alpha, n_symbol) # normally leave this as true unless debugging the window APPLY_WINDOW = True if APPLY_WINDOW: window = sig.windows.blackmanharris(len(hh)) hhw = hh * window else: hhw = hh x = n_paths - (len(hhw) % n_paths) hhw = np.append(hhw, np.zeros(x)) # zeros extending # hhw[0:len(hhw):] # scratch hhx = sig.firwin(len(hh), 13 / len(hh), window='blackmanharris') # end scratch # matlab code: Not sure how this scales for unity. hh is from the other filter # scl=hh_t[1::32]*hh(1:4:len(hh))'; #% scale for unity gain # hh_t=hh_t/scl; # normalize the filter to the maximum value of the filter weights hhw_max = np.amax(hh) scl = (hhw @ hhw.T) / n_paths hhwn = hhw / scl # scale for unity gain??? # note n_paths effectively adds gain to the derivative function, scales +-1 to gain value. dhh = np.convolve(hhwn, np.array([1, 0, -1]) * n_paths) # derivative matched filter # # hh2_length = (len(hhwn) + (n_paths - (len(hhwn)%n_paths)))/n_paths hh2_length = (len(hhwn) / n_paths) # matched filter and derivative matched filter outputs. # note: order='F' is to use the same order as matlab. reshape(row, column) # where n_paths are rows MF = hhwn.reshape((int(n_paths), int(hh2_length)), order='F') # 32 path polyphase MF dMF = dhh[2:].reshape((int(n_paths), int(hh2_length)), order='F') # 32 path polyphase dMF if DEBUGDERIVATIVEFILTER: vis = visualization.Visualization() vis.plot_data_1figure([hhwn], ['hhwn'], points=True) nplots = MF.shape[0] # npaths plots = [None] * nplots for i in range(nplots): plots[i] = [0] * len(hhwn) for j in range(MF.shape[1]): plots[i][i + j * MF.shape[0]] = MF[i, j] plots.append(hhwn) vis.plot_data_1figure(plots, ['MF_' + str(x) for x in range(nplots + 1)], points=False) vis.plot_data_1figure([plots[0], hhwn], ['plots 0', 'hhwn'], points=False) vis.plot_data_1figure(plots[:-1], ['MF_' + str(x) for x in range(nplots)], points=False) # ----------------------------------------------------------- vis.plot_data([dhh], ['dhh'], points=True) nplots = dMF.shape[0] # npaths plots = [None] * nplots for i in range(nplots): plots[i] = [0] * len(dhh[2:]) for j in range(dMF.shape[1]): plots[i][i + j * dMF.shape[0]] = dMF[i, j] plots.append(dhh[2:]) vis.plot_data_1figure(plots, ['dMF_' + str(x) for x in range(nplots + 1)], points=False) vis.plot_data_1figure([plots[0], dhh[2:]], ['plots 0', 'dhh[2:]'], points=False) vis.plot_data_1figure(plots[:-1], ['dMF_' + str(x) for x in range(nplots)], points=False) # ----------------------------------------------------------- # fig = go.Figure().set_subplots(2,2) # fig = make_subplots(rows=2, cols=2) # fig.add_trace(go.Scatter(y=hhwn, name="hhwn"), row=1, col=1) # fig.add_trace(go.Scatter(y=dhh, name="dhh"), row=1, col=2) # nplots = MF.shape[0] # npaths # for i in range(nplots): # fig.add_trace(go.Scatter(y=MF[i, :],mode="lines+markers"), row=2, col=1) # fig.add_trace(go.Scatter(y=dMF[i, :],mode="lines+markers"), row=2, col=2) # fig.update_layout(title="filters hhwn, dhh, MF, dMF") # pyo.plot(fig, filename="filters_hhwn_dhh_MF_dMF_plot.html") # ncol = 5 # nrow = int(np.ceil(nplots / ncol)) # fig = make_subplots(rows=nrow, cols=ncol) # for i in range(nplots): # fig.add_trace(go.Scatter(y=MF[i,:]), row=int(np.floor(i/ncol))+1, col=(int(i % ncol)+1)) # fig.update_layout(title="polyphase MF") # pyo.plot(fig, filename="polyphase_matched_filter_plot.html") return MF, dMF
def visualization(self): if self._visualization is None: self._visualization = visualization.Visualization() return self._visualization
def __init__(self): self.timestamp = int(time.time()) self.viz = V.Visualization()