def main(path_normalised_file, path_target_file, path_prepro_file, path_xlsx_output, path_integr_output=None): # call object integr = Integrator(path_normalised_file=path_normalised_file, path_target_file=path_target_file, path_prepro_file=path_prepro_file, path_xlsx_output=path_xlsx_output, path_integr_output=path_integr_output) # load input dataframe data = integr.load_normalised() # load target dataframe data_target = integr.load_target() data = integrate_datasets(data_norm=data, data_target=data_target, path_xlsx_output=path_xlsx_output, integrator=integr) # write output csv file if path_integr_output: data.to_csv(path_integr_output, index=True)
def finalize(self): """ Cleanup. """ Integrator.finalize(self) self.materialObj.finalize() self.output.close() self.output.finalize() self._modelMemoryUse() return
class PLL(object): def __init__(self, k1=2.0/3.0, k2=1.0/16.0, k3=1.0/32.0, fc = 5E3, fs = 44.1E3): self.k1 = k1 self.k2 = k2 self.k3 = k3 self.integrator1 = Integrator() self.integrator2 = Integrator() self.vco_integrator = Integrator() self.ilp = LowPass(1E3, fs) self.qlp = LowPass(1E3, fs) self.F = fc/fs self.mu = 0.01 self.costa_phase = Integrator() def work(self, input): cos_vco = cos(self.vco_integrator.value() + self.costa_phase.value()) sin_vco = sin(self.vco_integrator.value() + self.costa_phase.value()) #COSTA SECTION in_phase = self.ilp.work(sin_vco*input) qu_phase = self.qlp.work(cos_vco*input) phase_adj = -self.mu * in_phase * qu_phase self.costa_phase.work(phase_adj) #PLL SECTION pll_error = input * cos_vco s1 = pll_error s3 = self.k1*s1 + self.integrator1.work(s1*self.k1*self.k2+self.integrator2.work(s1*self.k1*self.k2*self.k3)) self.vco_integrator.work(s3 + 2.0*pi*self.F) return (cos_vco, pll_error, in_phase, qu_phase, self.costa_phase.value())
def __init__(self, a, b, n, seed=-1): """ Overloading the initializer to now add a seed, since random computations are now involved """ if seed == -1: self.RNG = np.random.RandomState( int(time.time() * 100000) % 4294967295) else: self.RNG = np.random.RandomState(seed) Integrator.__init__(self, a, b, n)
def __init__(self, k1=2.0/3.0, k2=1.0/16.0, k3=1.0/32.0, fc = 5E3, fs = 44.1E3): self.k1 = k1 self.k2 = k2 self.k3 = k3 self.integrator1 = Integrator() self.integrator2 = Integrator() self.vco_integrator = Integrator() self.ilp = LowPass(1E3, fs) self.qlp = LowPass(1E3, fs) self.F = fc/fs self.mu = 0.01 self.costa_phase = Integrator()
def __init__(self, name="integratorelasticity"): """ Constructor. """ Integrator.__init__(self) self.output = None self.availableFields = None self.name = "Integrator Elasticity" # Setup journal (not a Component, so not setup already) import journal self._info = journal.info(name) return
def initialize(self, totalTime, numTimeSteps, normalizer): """ Initialize material properties. """ logEvent = "%sinit" % self._loggingPrefix self._eventLogger.eventBegin(logEvent) from pylith.mpi.Communicator import mpi_comm_world comm = mpi_comm_world() if 0 == comm.rank: self._info.log("Initializing integrator for material '%s'." % \ self.materialObj.label()) Integrator.initialize(self, totalTime, numTimeSteps, normalizer) self.materialObj.normalizer(normalizer) self._eventLogger.eventEnd(logEvent) return
def integrate_datasets(data_norm, data_target, path_xlsx_output, integrator=None, df_prepro=None, df_norm=None): """ Integrates the supplier dataset into the target schema. INPUT: - data_norm: preprocessed and normalised supplier dataset, must be in wide format - data_target: target dataset - path_xlsx_output: full path where to save the final xlsx file OUTPUT: - pandas dataframe """ if integrator is None: integrator = Integrator(path_normalised_file=None, path_target_file=None, path_prepro_file=None, path_xlsx_output=path_xlsx_output, path_integr_output=None) # renames the columns in the normalised dataframe so they can be appended to the target dataframe data = integrator.rename_columns(data_norm) # drops the columns in the normalised dataframe that have no match in the target dataframe data = integrator.drop_columns(data, data_target) # appends the supplier dataset to the target dataset data = integrator.append_supplier_to_target(data, data_target) # saves all the files in this task in one single xlsx file with each step in a different sheet integrator.save_xlsx(data, df_prepro=df_prepro, df_norm=df_norm) return data
def preinitialize(self, mesh, material): """ Setup integrator. """ import weakref self.mesh = weakref.ref(mesh) self.output = material.output self.availableFields = material.availableFields self.materialObj = material Integrator.preinitialize(self, mesh) material.preinitialize(mesh) self.output.preinitialize(self) # Set integrator's quadrature using quadrature from material self.quadrature(material.quadrature) self.material(material) return
def costa_lp_filter_sim(): M = 101; fs = 44.1E3; msg = letters2pam('dead beef') baseband = pulseshape(msg, M) times = np.arange(0,len(baseband))/fs fc = fs/4.0 tx = np.cos(2.0*pi*fc*times)*baseband #plotspec(tx, 1.0/fs, True) in_phase_lp = LowPass(1E3, fs) qu_phase_lp = LowPass(1E3, fs) in_phase_out = np.zeros(len(tx)) qu_phase_out = np.zeros(len(tx)) phases = np.zeros(len(tx)) mu = 0.01 vco_phase_integrator = Integrator(2.0*pi*(fc-5)/fs) for phase_off in np.arange(8, -1, -1)*pi/8.0: for n in range(0, len(tx)-1): t = times[n] #vco_phase = 2.0*np.pi*fc*t vco_phase = vco_phase_integrator.work(1.0) in_vco = 2.0*np.cos(vco_phase - phase_off + phases[n]) qu_vco = 2.0*np.sin(vco_phase - phase_off + phases[n]) in_phase_out[n] = in_phase_lp.work(in_vco*tx[n]) qu_phase_out[n] = qu_phase_lp.work(qu_vco*tx[n]) phases[n+1] = phases[n] - mu*in_phase_out[n]*qu_phase_out[n] plt.figure(1) plt.subplot(311) plt.title('Phase: %.3f'%(phase_off/pi)) plt.plot(times, baseband) plt.ylim([-3, 3]) plt.subplot(312) plt.plot(times, in_phase_out) plt.ylim([-3, 3]) plt.subplot(313) plt.plot(times, qu_phase_out) plt.ylim([-3, 3]) plt.show(block = True)
def verifyConfiguration(self): """ Verify compatibility of configuration. """ logEvent = "%sverify" % self._loggingPrefix self._eventLogger.eventBegin(logEvent) Integrator.verifyConfiguration(self) self.materialObj.verifyConfiguration() if self.mesh().dimension() != self.materialObj.dimension(): raise ValueError("Mesh dimension is '%d' but material '%s' of type " \ "'%s' applies to dimension '%d'." % \ (self.mesh().dimension(), self.materialObj.label(), self.materialObj, self.materialObj.dimension())) self._verifyConfiguration() self.output.verifyConfiguration(self.mesh()) self._eventLogger.eventEnd(logEvent) return
def main(): # Ingreso de datos h_max = float(input("Altura máxima de agua: ")) h = float(input("Altura actual de agua: ")) # Comprobar condiciones de la altura ingresada if (h < 0): h = 0 # h = 0 cuando este sea menor a 0 elif (h > h_max): h = h_max # h = h_max cuando h supere el limite integrator = Integrator(0, h) #Clase integradora V = integrator.integrate() #Se integra la funcion pi * x^2 u = integrator.bisection( -1 * h, h, 1e-6 ) #Algoritmo root-finding | Metodo de Bisección con tolerancia de 1e-6 V_u = V + u #Volumen total de la presa # FUNCION PARA DIBUJAR LA GRAFICA x = np.linspace(-5, 5, 100) plt.plot(x, integrator.function_value(x)) plt.grid() # Valor del volumen cuando la altura es la máxima integrator_max = Integrator(0, h_max) v_max = integrator_max.integrate() # Comprobar si V(u) supera a V(h_max) entonces se vuelve # a realizar el calculo con u = h_max ó u = 0 if (V_u > v_max): V_u = V + h_max if (V_u < 0): V_u = V # RESULTADOS print(f"V(u): {round(V_u, 5)}, V_max(h_max): {round(v_max,5)}") plt.show()
order_id= uuid.uuid1() comment1=" " comment2="" chromecast_unit_price = 150 chromecast_quantity = 2 chromecast_subtotal = chromecast_unit_price*chromecast_quantity organza_unit_price = 50 organza_quantity = 2 organza_subtotal = organza_unit_price* organza_quantity client = Integrator(namespace, wsdl, apiVersion, merchantEmail, merchantKey, serviceType, integrationMode) chromecast = client.buildOrderItem("001", "chromecast", chromecast_unit_price, chromecast_quantity, chromecast_subtotal) organza = client.buildOrderItem("002", "organza", organza_unit_price, organza_quantity,organza_subtotal) order_items = client.buildAPIObject('ArrayOfOrderItem') order_items.OrderItem.append(chromecast) order_items.OrderItem.append(organza) # print order_items # sub_total=chromecast_subtotal+ organza_subtotal shipping_cost=30 tax_amount=0 total= sub_total + shipping_cost+ tax_amount