def move(self, Data_Point): t0 = self.drone.location() max_Location = Data_Point.get_Location() max_Signal = Data_Point.get_Signal() direction_of_travel = [ max_Location[0] - t0[0], max_Location[1] - t0[1], max_Location[2] - t0[2] ] print( "\n\nDrone will move in %s --> %s direction and it is in %s location relative to its starting position" % (Data_Point.id, direction_of_travel, self.drone.location())) self.drone.moveFr(direction_of_travel[0] * 2) self.drone.moveRi(direction_of_travel[1] * 2) self.drone.moveUp(direction_of_travel[2] * 2) while (Signal(self.drone).calcSS() > max_Signal): max_Signal = Signal(self.drone).calcSS() self.drone.moveFr(direction_of_travel[0]) self.drone.moveRi(direction_of_travel[1]) self.drone.moveUp(direction_of_travel[2]) self.drone.moveFr(direction_of_travel[0] * -1) self.drone.moveRi(direction_of_travel[1] * -1) self.drone.moveUp(direction_of_travel[2] * -1)
def lorenz_example(): '''Time Setting''' T = 20 fs = 20 dt = 1/fs '''Training Signal Setting''' signal_type = Lorenz(dt=dt, X0=[1.,1.,1.]) signal = Signal(signal_type=signal_type, T=T) observer = Reservoir(dt=signal.dt, n=signal.Y.shape[0], m=signal.X.shape[0], alpha=0.2, beta=1e-8) observer.train(signal.Y, signal.X, show_time=False) '''Testing Signal Setting''' signal_type = Lorenz(dt=dt, X0=signal.X[:,-1]) # signal_type = Lorenz(dt=dt, X0=np.random.uniform(-1,1,3)) signal = Signal(signal_type=signal_type, T=T) X_hat = observer.run(signal.Y, show_time=False) fontsize = 20 fig, axes = plt.subplots(3,1,figsize=(8,8), sharex=True) axes[0].plot(signal.t, signal.X[0], label=r'$U=x_1$') axes[0].legend(fontsize=fontsize-5, loc='lower right') axes[0].tick_params(labelsize=fontsize) for n in range(2): axes[n+1].plot(signal.t, signal.X[n+1], label=r'$x_{}$'.format(n+2)) axes[n+1].plot(signal.t, X_hat[n+1], label=r'$\hat x_{}$'.format(n+2)) axes[n+1].legend(fontsize=fontsize-5, loc='lower right', ncol=2) axes[n+1].tick_params(labelsize=fontsize) fig.add_subplot(111, frameon=False) plt.tick_params(labelcolor='none', top=False, bottom=False, left=False, right=False) plt.xlabel('\ntime $t$ [s]', fontsize=fontsize) plt.show() pass
def aliases_figure(f0, fs): t = np.linspace(0, 1, 50*fs) y = np.sin(f0 * 2*np.pi * t) sig = Signal(t, y) alias_sig = Signal(t, y) fig = sig.get_fig(size=(1080,300),title="Aliases of {} Hz signal".format(f0)) alias_sig.update_line_opts({'line_color' : 'orange', 'line_alpha': 1}) alias_sig.create_line_renderer(fig) alias_x = np.linspace(0, 1, fs, endpoint=False) alias_y = np.sin(f0 * 2*np.pi * alias_x) alias_points = ColumnDataSource({ 'x' : alias_x, 'y' : alias_y, 'y0': np.zeros(alias_x.size) }) fig.circle(x='x', y='y', source=alias_points, fill_color='red', line_width=3, line_color='red') fig.segment(x0='x', x1='x', y0='y0', y1='y', source=alias_points,line_width=3, line_color='red') handle = show(fig, notebook_handle=True) def frame_gen(fv): return {'y': np.sin(fv*2*np.pi*t)} anim_sets = [] for k in range(1, 6): f_previous = f0 + (k-1)*fs f_alias = f0 + k*fs frame_values = np.linspace(f_previous, f_alias, 60) anim = FrameAnimation(alias_sig.data_source(), frame_gen, frame_values) anim_sets.append(AnimationSet([anim])) anim_sets.append(AnimationSet([Pause(1)])) AnimateSets(anim_sets, handle).run()
def __init__(self, fc, tfiltro): self.fc = fc self.tfiltro = tfiltro #Inicializo una señal S1 self.S1 = Signal() #Inicializo una señal S2 self.S2 = Signal()
def __init__(self): self.axes_changed = Signal() self.buttons_changed = Signal() self._axes = None self._buttons = None self._pressed_buttons = set() self._last_larm = None self._last_rarm = None self._last_lgrip = None self._last_rgrip = None rospy.Subscriber('korg_joy', Joy, self._joy_callback)
def quantization(signal, Ts, n_bits): result_signal = Signal(None, None, None, None) result_signal.points = signal.quantization(Ts, n_bits) signal_to_draw = Signal(None, None, None, None, False) signal_to_draw.points.append(signal.points[0]) new_ts = Ts / 2 for i in range(1, len(signal.points)): signal_to_draw.points.append( Point(signal.points[i - 1].x + new_ts, signal.points[i - 1].y)) signal_to_draw.points.append( Point(signal.points[i - 1].x + new_ts, signal.points[i].y)) signal_to_draw.points.append(signal.points[-1]) return result_signal, signal_to_draw
def scramble(signal, algorythm): scrambledsignal = Signal(signal) if algorythm == "B8ZS": i = 0 while i < (len(scrambledsignal.signal) - 7): if zeros(scrambledsignal, i, 8): scrambledsignal.voltage[i + 3] = 'V' scrambledsignal.voltage[i + 4] = 'B' scrambledsignal.voltage[i + 6] = 'B' scrambledsignal.voltage[i + 7] = 'V' i += 7 i += 1 else: i = 0 j = 0 while i < (len(scrambledsignal.signal) - 3): if scrambledsignal.signal[i] == '1': j += 1 if zeros(scrambledsignal, i, 4): if j % 2 == 0: scrambledsignal.voltage[i] = 'B' scrambledsignal.voltage[i + 3] = 'V' j = 0 i += 3 elif j % 2 == 1: scrambledsignal.voltage[i + 3] = 'V' j = 0 i += 3 i += 1 return scrambledsignal
def probe(self): print("Drone will start probing") if (Signal(self.drone).calcSS() > 0): print("\n\nThe drone found signal at %s" % (self.drone.location())) return self.run() self.drone.moveFr(100) if (Signal(self.drone).calcSS() > 0): print("\n\nThe drone found signal at %s" % (self.drone.location())) return self.run() self.drone.moveRi(100 * -1) if (Signal(self.drone).calcSS() > 0): print("\n\nThe drone found signal at %s" % (self.drone.location())) return self.run() self.drone.moveFr(100 * -1) if (Signal(self.drone).calcSS() > 0): print("\n\nThe drone found signal at %s" % (self.drone.location())) return self.run() self.drone.moveFr(100 * -1) if (Signal(self.drone).calcSS() > 0): print("\n\nThe drone found signal at %s" % (self.drone.location())) return self.run() self.drone.moveRi(100) if (Signal(self.drone).calcSS() > 0): print("\n\nThe drone found signal at %s" % (self.drone.location())) return self.run() self.drone.moveRi(100) if (Signal(self.drone).calcSS() > 0): print("\n\nThe drone found signal at %s" % (self.drone.location())) return self.run() self.drone.moveFr(100) if (Signal(self.drone).calcSS() > 0): print("\n\nThe drone found signal at %s" % (self.drone.location())) return self.run() self.drone.moveFr(100) if (Signal(self.drone).calcSS() > 0): print("\n\nThe drone found signal at %s" % (self.drone.location())) return self.run() self.drone.moveRi(100 * -1) self.drone.moveFr(100 * -1) print("No animal was found on probing\n\n")
def filter(self, input): output = Signal() output.y = sig.sosfilt(self.values, input.y) #print('***** Salida del filtro *****') #print(output.y) return output
def zoh(signal): reconstructed_signal = Signal(None, None, None, None, False) reconstructed_signal.points.append(signal.points[0]) for i in range(1, len(signal.points)): reconstructed_signal.points.append( Point(signal.points[i].x, signal.points[i - 1].y)) reconstructed_signal.points.append(signal.points[i]) return reconstructed_signal
def generate_signals(a_timer: PipelineTimer, arb_id_dict: dict, signal_pickle_filename: str, normalize_strategy, force=False): if path.isfile(signal_pickle_filename): if force: # Remove any existing pickled Signal dictionary and create one. remove(signal_pickle_filename) else: print( "\nSignal generation already completed and forcing is turned off. Using pickled data..." ) return load(open(signal_pickle_filename, "rb")) a_timer.start_function_time() signal_dict = {} for k, arb_id in arb_id_dict.items(): if not arb_id.static: for token in arb_id.tokenization: a_timer.start_iteration_time() signal = Signal(k, token[0], token[1]) # Convert the binary ndarray to a list of string representations of each row temp1 = [ ''.join(str(x) for x in row) for row in arb_id.boolean_matrix[:, token[0]:token[1] + 1] ] temp2 = zeros((temp1.__len__(), 1), dtype=uint64) # convert each string representation to int for i, row in enumerate(temp1): temp2[i] = int(row, 2) # create an unsigned integer pandas.Series using the time index from this Arb ID's original data. signal.time_series = Series(temp2[:, 0], index=arb_id.original_data.index, dtype=float64) # Normalize the signal and update its meta-data signal.normalize_and_set_metadata(normalize_strategy) # add this signal to the signal dictionary which is keyed by Arbitration ID if k in signal_dict: signal_dict[k][(arb_id.id, signal.start_index, signal.stop_index)] = signal else: signal_dict[k] = { (arb_id.id, signal.start_index, signal.stop_index): signal } a_timer.set_token_to_signal() a_timer.set_signal_generation() return signal_dict
class GameLoop(): """ Primary Game Loop class DO NOT USE ATTRIBUTES ON YOUR OWN! USE METHODS INSTEAD! """ __instance = None _update_signal = Signal() _cancelation_token = False @staticmethod def getInstance(): """Gets instance of GameLoop class. GameLoop is a singleton.""" if GameLoop.__instance==None: GameLoop() return GameLoop.__instance def __new__(cls): if cls.__instance is None: cls.__instance = super(GameLoop, cls).__new__(cls) cls.__instance._start_loop() return cls.__instance def connect_to_update(self, method): """Use this method to connect your method to primary game loop""" self._update_signal.connect(method) def disconnect_from_update(self,method): self._update_signal.disconnect(method) def _start_loop(self): """ Starts the game loop. Not necessary to start it yourself. It starts automatically on class creation. """ self.p = tread.Thread(target=self._loop) self.p.start() def cancel(self): """ Stops Game Loop. After this is called you will need to manualy call the _start_loop() method to restart the Game Loop. """ GameLoop.getInstance()._cancelation_token = True def _loop(self): """Do not call this method!""" while True: if GameLoop.getInstance()._cancelation_token==True: break self._update_signal.notify_all() sleep(1/60)
def __init__(self, path, annotations_path): self.file = pyedflib.EdfReader(path) self.number_of_signal = self.file.signals_in_file self.signals_list = [] for i in np.arange(self.number_of_signal): self.signals_list.append( \ Signal(self.file.getLabel(i), self.file.readSignal(i), \ self.file.getSampleFrequency(i))) self.annotations_file = pyedflib.EdfReader(annotations_path) self.annotations = self.annotations_file.readAnnotations()
def add_output(self, nm, **kwargs): """This will create a signal ending in _s and an output ending in _o, drive the signal with the expression, and drive the """ y0 = Signal(nm + "_s", **kwargs) y1 = Signal(nm + "_o", **kwargs) self.signals.add(y0) self.outputs.add(y1) if "clk" in kwargs: self.clocks_by_name[nm + "_s"] = kwargs["clk"] else: if self.disable_clk_rendering: pass else: self.clocks_by_name[nm + "_s"] = self.default_clk self.clocks_by_name[nm + "_o"] = "__async__" self.expressions_by_name[ nm + "_s"] = " (others => '0')" # todo: somehow put a useful expression in here self.expressions_by_name[nm + "_o"] = nm + "_s"
def step(self): """method to perform one step - propagate signals and update carrier state""" self.propagate() for station in self.connected_stations: signature = station.broadcast( self.carrier, self.get_signal(station.place_of_connection)) if signature is not None: signal_to_the_right = Signal( starting_pos=station.place_of_connection, signature=signature, direction=Directions.RIGHT) signal_to_the_left = Signal( starting_pos=station.place_of_connection, signature=signature, direction=Directions.LEFT) self.inserted_signals.append(signal_to_the_right) self.inserted_signals.append(signal_to_the_left) # apply changes to the carrier self.update_carrier()
def __init__(self, h5filename='test.h5', prime1=20, run_steps=10000, write_interval=5000, **kwargs): self.signal = Signal() self.exchange = orderbook.Orderbook(self.signal) self.h5filename = h5filename self.run_steps = run_steps + 1 self.liquidity_providers = {} self.noise = kwargs.pop('Noise') # Set up noise traders if self.noise: self.noise_traders = self.buildNoiseTraders( kwargs['numNoise'], kwargs["NoiseSigma"]) self.Lambda_nt = kwargs['Lambda_nt'] # Set up fundamental traders self.fundamental = kwargs.pop("Fundamental") if self.fundamental: self.fundamentals = self.buildFundamentalTraders( kwargs['numFund'], kwargs["omega_Fund"], kwargs["FundSigma"]) self.Lambda_ft = kwargs["Lambda_ft"] # Set up momentum traders self.momentum = kwargs.pop("Momentum") if self.momentum: self.momentums = self.buildMomentumTraders(kwargs["numMom"], kwargs["omega_Mom"], kwargs["MomInvLim"], kwargs["MomTimeWindow"], kwargs["shapeMom"]) self.Lambda_mt = kwargs["Lambda_mt"] # Set up Market Makers self.marketmaker = kwargs.pop("MarketMaker") if self.marketmaker: self.marketmakers = self.buildMarketMakers( kwargs["numMMs"], kwargs["KatRisk"], kwargs["MMgamma"], kwargs["K"], kwargs["MMa"], kwargs["MMr"], kwargs["MMn"], kwargs["MMs"], kwargs["MMdelta"], kwargs["MMwindow"], kwargs["MMc"]) self.Lambda_mm = kwargs["Lambda_mm"] self.traders, self.num_traders = self.makeAll() self.seedOrderbook() # if self.provider: # self.makeSetup(prime1, kwargs['Lambda0']) # if self.pj: # self.runMcsPJ(prime1, write_interval) # else: self.runMcs(prime1, write_interval) self.exchange.trade_book_to_h5(h5filename) self.qTakeToh5() self.mmProfitabilityToh5()
def __init__(self, signals_dict, selected_signal_name): self.signals_dict = signals_dict self.my_signal_name = selected_signal_name #Make a copy of the original signal self.my_signal = Signal(selected_signal_name, self.signals_dict[selected_signal_name]._signal_data.copy(), self.signals_dict[selected_signal_name]._signal_type, self.signals_dict[selected_signal_name]._signal_data_type) super(EditSignalWindow, self).__init__() self.setupUi(self) self.initUI()
def transmit_curtain_code(code, repeats): TX_HIGH = "008081FF" TX_LOW = "000081FF" wave_forms = [[Signal(800, TX_LOW), Signal(400, TX_HIGH)], [Signal(400, TX_LOW), Signal(800, TX_HIGH)], [Signal(6000, TX_LOW), Signal(800, TX_HIGH)]] square = [] # init pigpio pi = pigpio.pi() pi = pigpio.pi() # exit script if no connection if not pi.connected: print("pigpio not ready") exit() bin_code = '{0:08b}'.format(code) pulses = [] # translate pulses for i in range(0, len(bin_code)): #print(bin_code[i], end ='') if (bin_code[i] == "0"): pulses.extend(wave_forms[0]) elif bin_code[i] == "1": pulses.extend(wave_forms[1]) # sync-bit pulses.extend(wave_forms[2]) #build the wave pattern by pulses print("len(pulses)=%s" % len(pulses)) # signal[0] - timestamp, signal[1] - GPIO state for s in pulses: if str(s.state.rstrip()) == TX_HIGH: square.append(pigpio.pulse(1 << TX_GPIO1, 0, s.length)) else: square.append(pigpio.pulse(0, 1 << TX_GPIO1, s.length)) pi.set_mode(TX_GPIO1, pigpio.OUTPUT) # set output mode on select GPIO pi.wave_add_generic(square) # add the generated wave from wid = pi.wave_create() if wid >= 0: pi.wave_send_repeat(wid) time.sleep(1) pi.wave_tx_stop() pi.wave_delete(wid) # stop transmission pi.stop() return bin_code
def convolution(signal1, signal2): result_points = [] for n in range(len(signal1.points) + len(signal2.points) - 1): y = 0 for k in range(len(signal1.points)): if 0 <= n - k < len(signal2.points): y += signal1.points[k].y * signal2.points[n - k].y result_points.append(Point(n, y)) result_signal = Signal(None, 0, len(signal1.points) + len(signal2.points) - 1, 1) result_signal.points = result_points return result_signal
def ParseTurnIndcrByType(self, type): signal = Signal() signal.start = 0 signal.line_number = self.GetSignalLineNumber(signal.start) signal.value = self.GetSignalValue(signal.start, type) signal.num += 1 for i in range(1, len(self.canList)): if self.GetSignalValue(i, type) == self.GetSignalValue(i - 1, type): signal.num += 1 else: self.signlList.append(signal) # new signal signal = Signal() signal.line_number = self.GetSignalLineNumber(i) signal.start = i signal.value = self.GetSignalValue(i, type) signal.num += 1 if (self.GetSignalValue(i, type) == self.GetSignalValue( i - 1, type)) and signal: self.signlList.append(signal)
def read_file(file_path): with open(file_path, 'r') as file: start_time = file.readline() duration_time = file.readline() frequency = file.readline() points = file.readline() points = points.split() signal_points = [] for i in range(0, len(points), 2): signal_point = Point(float(points[i]), float(points[i + 1])) signal_points.append(signal_point) result = Signal(None, start_time, duration_time, frequency) result.points = signal_points return result
def __init__(self, app, call_id='GLOBAL', logfile='/var/log/sip.log'): self.app = app self.call_id = call_id bend = os.environ.get('SIPLOG_BEND', 'stderr').lower() if bend == 'stderr': self.log = sys.__stderr__ elif bend == 'none': self.write = self.donoting else: logfile = os.environ.get('SIPLOG_LOGFILE_FILE', logfile) self.log = file(logfile, 'a') self.flock = flock Signal(SIGUSR1, self.reopen, logfile) self.level = eval('SIPLOG_' + os.environ.get('SIPLOG_LVL', 'INFO'))
def __init__(self, master): self._job = None self.max_time = 500 # Create a container self.frame = Tkinter.Frame(master) self.master = master # Create 2 buttons self.kp = Tkinter.Scale(self.frame, from_=1., to=10., resolution=0.1, label="K ", command=self.resetparam) self.kp.pack() self.tau = Tkinter.Scale(self.frame, from_=1., to=10., resolution=0.1, label="τ ", command=self.resetparam) self.tau.pack() self.theta = Tkinter.Scale(self.frame, from_=1., to=9., resolution=0.5, label="θ", command=self.resetparam) self.theta.pack() self.fig = Figure((10, 5)) self.ax = self.fig.add_subplot(111) self.ax.set_xlim(0, 500) self.fig2 = Figure((10, 5)) self.ax2 = self.fig2.add_subplot(111) sig = Signal(1, 1, 2, numPlots=0) sig.sys_simulation() self.masterRS = RollingSignal() self.masterRS.load_model( sig, directory= '/Users/RileyBallachay/Documents/Fifth Year/RNNSystemIdentification/Model Validation/MIMO 1x1/Checkpoints/' ) self._roll_over(initial=True)
def sinc_recostruct(signal, frequency, neighbors_number): start_time = signal.points[0].x t_s = signal.points[1].x - start_time duration_time = signal.points[-1].x - start_time n = int(frequency * duration_time) + 1 distance_between_points = duration_time / (n - 1) signal_reconstructed = Signal(None, start_time, duration_time, frequency, False) for i in range(n): x = start_time + i * distance_between_points signal_reconstructed.points.append( Point( x, Converter.point_for_sinc_reconstruct( signal.points, t_s, x, neighbors_number))) return signal_reconstructed
def Box_mission(self): box_plots = [] box_plots.append( Data_Point("T0", self.drone.x, self.drone.y, self.drone.z, Signal(self.drone).calcSS())) self.drone.moveFr(self.length_of_box / 2) box_plots.append( Data_Point("T1", self.drone.x, self.drone.y, self.drone.z, Signal(self.drone).calcSS())) self.drone.moveRi((self.length_of_box / 2) * -1) box_plots.append( Data_Point("T2", self.drone.x, self.drone.y, self.drone.z, Signal(self.drone).calcSS())) self.drone.moveFr((self.length_of_box / 2) * -1) box_plots.append( Data_Point("T3", self.drone.x, self.drone.y, self.drone.z, Signal(self.drone).calcSS())) self.drone.moveFr((self.length_of_box / 2) * -1) box_plots.append( Data_Point("T4", self.drone.x, self.drone.y, self.drone.z, Signal(self.drone).calcSS())) self.drone.moveRi(self.length_of_box / 2) box_plots.append( Data_Point("T5", self.drone.x, self.drone.y, self.drone.z, Signal(self.drone).calcSS())) self.drone.moveRi(self.length_of_box / 2) box_plots.append( Data_Point("T6", self.drone.x, self.drone.y, self.drone.z, Signal(self.drone).calcSS())) self.drone.moveFr(self.length_of_box / 2) box_plots.append( Data_Point("T7", self.drone.x, self.drone.y, self.drone.z, Signal(self.drone).calcSS())) self.drone.moveFr(self.length_of_box / 2) box_plots.append( Data_Point("T8", self.drone.x, self.drone.y, self.drone.z, Signal(self.drone).calcSS())) self.drone.moveRi((self.length_of_box / 2) * -1) self.drone.moveFr((self.length_of_box / 2) * -1) return box_plots
def scale_time(title='Time scaling', size=(400, 400), animated=False): frames = 50 scale = 2*np.pi m = max(1, scale) + 0.5 t = np.linspace(-m*2, m*2, 256) y = np.sin(2 * np.pi * t) sig1 = Signal(t, y) sig1.remove_view('spans') fig = sig1.get_fig(title=title, size=size, scale='2pi') marker_source = ColumnDataSource({'x':[1, 1], 'y': [0, 1]}) marker_ref = fig.line(x=[1,1], y=[0,1], line_width=2, line_color='purple', line_dash='dashed') marker = fig.line(x='x', y='y', source=marker_source, line_width=2, line_color='purple') label = Label(x=1, y=1, text='1 second marker', render_mode='css') fig.add_layout(label) handle = show(fig, notebook_handle=True) if animated: def gen_marker_frame(frame_value): return {'x': [frame_value, frame_value]} def gen_sig_frame(frame_value): return {'x': t * frame_value} frame_values = np.linspace(1, scale, frames) a1 = FrameAnimation(marker_source, gen_marker_frame, frame_values) a2 = FrameAnimation(sig1.data_source(), gen_sig_frame, frame_values) aset = AnimationSet([a1, a2]) AnimateSets([aset], handle, fps=25).run() else: ones = np.asarray([1, 1]) def update(scale=1): marker_update = { 'x' : ones * scale } signal_update = { 'x' : t * scale } marker_source.data.update(marker_update) sig1.update(signal_update) push_notebook(handle=handle) interact(update, scale=(-1*np.pi, 2*np.pi))
def __init__(self, **kwargs): super().__init__(**kwargs) from copy import deepcopy new_kwargs = deepcopy(kwargs) del (new_kwargs["name"]) if "expression" in new_kwargs: del(new_kwargs["expression"]) if "central_name_gen" in new_kwargs: new_kwargs["central_name_gen"] = kwargs["central_name_gen"] self.taps = [] self.add_input(Input(name="clk", width=1, expression="", **new_kwargs)) self.input_list = kwargs["input_list"] num_resets = 0 num_sets = 0 num_toggles = 0 self.input_name_list = [] for one_char in kwargs["input_list"]: if one_char.lower() == "r": one_name = "rst_" + ("%04d" % num_resets) one_sig = Input(name=one_name, width=1, expression="", **new_kwargs) self.add_input(one_sig) self.add_device(one_sig) num_resets += 1 self.input_name_list.append(one_name) if one_char.lower() == "s": one_name = "set_" + ("%04d" % num_sets) one_sig = Input(name=one_name, width=1, expression="", **new_kwargs) self.add_input(one_sig) self.add_device(one_sig) num_sets += 1 self.input_name_list.append(one_name) if one_char.lower() == "t": one_name = "tog_" + ("%04d" % num_toggles) one_sig = Input(name=one_name, width=1, expression="", **new_kwargs) self.add_input(one_sig) self.add_device(one_sig) num_toggles += 1 self.input_name_list.append(one_name) out_sig = Signal(name="q_sig", width=1, expression="", **new_kwargs) self.signal_list.append(out_sig) self.add_output(Output(name="q", width=1, expression="", **new_kwargs))
def createMySignal(self): self.updateVariableSelection() if len(self.tableWidget_signal_preview.selectedIndexes()) == 0: mess = QtGui.QMessageBox.warning( self, 'Warning Message', "You must select at least one variable for the signal.") return False if str(self.lineEdit_signal_name.text()) == "": mess = QtGui.QMessageBox.warning(self, 'Warning Message', "You must define a signal name.") return False if str(self.lineEdit_signal_name.text()) in self.signals_dict.keys(): mess = QtGui.QMessageBox.warning( self, 'Warning Message', "This signal's name already exist.") return False # Keep input data in case of modifications self.my_signal_data = self.input_data.copy() # Modify signal to corresponds to selected type self.my_signal_data = self.my_signal_data.loc[:, self.selected_variables] self.my_signal_data = pd.DataFrame(self.my_signal_data.values, self.my_signal_data.index, self.selected_variables) # get signal's type if (len(self.my_signal_data.columns) == 1): self.my_signal_type = 0 # Monovariate signal else: self.my_signal_type = 1 # Multivariate signal # Get signal's name self.my_signal_name = str(self.lineEdit_signal_name.text()).strip() #Create a new Signal instance self.my_signal = Signal(self.my_signal_name, self.my_signal_data, self.my_signal_type, self.my_data_type) return True
def visualizeSignal(self): # Keep input data in case of modifications viz_signal_data = self.input_data.copy() if len(self.selected_variables) > 0: viz_signal_data = viz_signal_data.loc[:, self.selected_variables] viz_signal_data = pd.DataFrame(viz_signal_data.values, viz_signal_data.index, self.selected_variables) # get signal's type viz_signal_type = 0 if (len(viz_signal_data.columns) == 1) else 1 viz_signal = Signal(str(self.lineEdit_signal_name.text()), viz_signal_data, viz_signal_type, self.my_data_type) viz_signal.plot_signal() else: mess = QtGui.QMessageBox.warning( self, 'Warning Message', "You must define at least one variable to plot.") return
def readSignal(): count = 0 separator = ";" f = open( "C:/Users/FauxL/AppData/Roaming/MetaQuotes/Terminal/2E8DC23981084565FA3E19C061F586B2/MQL4/Files/SignalInfo.csv","r") n = f.readlines() SignalArray = [] for i in n: result = i.split(separator) print(result) id = result[1] pips= result[2] subs = result[3] name = result[4] currency = result[5] signal= Signal(id, pips, subs, name, currency) SignalArray.append(signal.__dict__) print(len(SignalArray)) return SignalArray