def process(self, tides): #print datetime.datetime.now(), "\t>>> update called", df = None if id(tides) != self._tides_id or tides is None: logger.debug('clearing genCurveNodeCtrlWidget_v2 (Tide Components Section) on_process()') #print 'setting tides components' self._tides_id = id(tides) if hasattr(self, '_ctrlWidget'): self._ctrlWidget.clearTideComponents() if tides is None: #print '\t > returning None' return {'sig': None} self._ctrlWidget.on_tides_received(tides) kwargs = self._ctrlWidget.prepareInputArguments() # now prepare the amplitudes kwargs['tides'] = {} for i in xrange(len(tides)): if not np.isnan(tides.iloc[i][kwargs['df_A']]) and np.isnan(tides.iloc[i][kwargs['df_omega']]): continue #skipping 0-frequency amplitude kwargs['tides'][str(i)] = {} kwargs['tides'][str(i)]['A'] = tides.iloc[i][kwargs['df_A']] kwargs['tides'][str(i)]['omega'] = tides.iloc[i][kwargs['df_omega']] kwargs['tides'][str(i)]['phi'] = tides.iloc[i][kwargs['df_phi']] # finally do the calculations with BusyCursor(): #print '\t > doing the calculations' if kwargs['eq'] == 'tide': df = generate_tide(kwargs['t0'], kwargs['dt'], kwargs['tend'], components=kwargs['tides'], W=kwargs['W'], F=kwargs['F'], label=kwargs['label'], equation=kwargs['eq']) elif kwargs['eq'] == 'ferris': df = generate_tide(kwargs['t0'], kwargs['dt'], kwargs['tend'], components=kwargs['tides'], W=kwargs['W'], F=kwargs['F'], label=kwargs['label'], equation=kwargs['eq'], D=kwargs['ferris']['D'], x=kwargs['x']) elif kwargs['eq'] == 'xia': df = generate_tide(kwargs['t0'], kwargs['dt'], kwargs['tend'], components=kwargs['tides'], W=kwargs['W'], F=kwargs['F'], label=kwargs['label'], equation=kwargs['eq'], x=kwargs['x'], alpha=kwargs['xia']['alpha'], beta=kwargs['xia']['beta'], theta=kwargs['xia']['theta'], L=kwargs['xia']['L'], K1=kwargs['xia']['K1'], b1=kwargs['xia']['b1'], K=kwargs['xia']['K'], b=kwargs['xia']['b'], K_cap=kwargs['xia']['K_cap'], b_cap=kwargs['xia']['b_cap']) elif kwargs['eq'] == 'song': df = generate_tide(kwargs['t0'], kwargs['dt'], kwargs['tend'], components=kwargs['tides'], W=kwargs['W'], F=kwargs['F'], label=kwargs['label'], equation=kwargs['eq'], x=kwargs['x'], order=kwargs['song']['order'], b=kwargs['song']['b'], n_e=kwargs['song']['n_e'], kf=kwargs['song']['K'], b2msl=kwargs['song']['b2msl']) else: df = None return {'sig': df}
def process(self, tides): if tides is None: return if self._df_id != id(tides): #print 'df new' self._df_id = id(tides) self.CW().param('tides_grp', 'n_sig').setValue(len(tides)-1) self.CW().disconnect_valueChanged2upd(self.CW().param('tides_grp', 'A')) self.CW().disconnect_valueChanged2upd(self.CW().param('tides_grp', 'omega')) self.CW().disconnect_valueChanged2upd(self.CW().param('tides_grp', 'phi')) colname = [col for col in tides.columns if isNumpyNumeric(tides[col].dtype)] self.CW().param('tides_grp', 'A').setLimits(colname) self.CW().param('tides_grp', 'omega').setLimits(colname) self.CW().param('tides_grp', 'phi').setLimits(colname) self.CW().param('tides_grp', 'A').setValue(colname[0]) self.CW().param('tides_grp', 'omega').setValue(colname[1]) self.CW().param('tides_grp', 'phi').setValue(colname[2]) self.CW().connect_valueChanged2upd(self.CW().param('tides_grp', 'A')) self.CW().connect_valueChanged2upd(self.CW().param('tides_grp', 'omega')) self.CW().connect_valueChanged2upd(self.CW().param('tides_grp', 'phi')) self.CW().disconnect_valueChanged2upd(self.CW().param('W')) W = tides[self.CW().p['tides_grp', 'A']][0] # 1st value from column `A` self.CW().param('W').setValue(W) self.CW().param('W').setDefault(W) self.CW().connect_valueChanged2upd(self.CW().param('W')) kwargs = self.CW().prepareInputArguments() kwargs['tides'] = {} for i in xrange(len(tides)): if not np.isnan(tides.iloc[i][kwargs['df_A']]) and np.isnan(tides.iloc[i][kwargs['df_omega']]): continue #skipping 0-frequency amplitude kwargs['tides'][str(i)] = {} kwargs['tides'][str(i)]['A'] = tides.iloc[i][kwargs['df_A']] kwargs['tides'][str(i)]['omega'] = tides.iloc[i][kwargs['df_omega']] kwargs['tides'][str(i)]['phi'] = tides.iloc[i][kwargs['df_phi']] #print i, ': a={0}, omega={1}, phi={2}'.format(kwargs['tides'][str(i)]['A'], kwargs['tides'][str(i)]['omega'], kwargs['tides'][str(i)]['phi'] ) with BusyCursor(): if kwargs['eq'] == 'tide': df = generate_tide(kwargs['t0'], kwargs['dt'], kwargs['tend'], components=kwargs['tides'], W=kwargs['W'], F=kwargs['F'], label=kwargs['label'], equation=kwargs['eq']) elif kwargs['eq'] == 'ferris': df = generate_tide(kwargs['t0'], kwargs['dt'], kwargs['tend'], components=kwargs['tides'], W=kwargs['W'], F=kwargs['F'], label=kwargs['label'], equation=kwargs['eq'], D=kwargs['ferris']['D'], x=kwargs['ferris']['x']) elif kwargs['eq'] == 'xia': df = generate_tide(kwargs['t0'], kwargs['dt'], kwargs['tend'], components=kwargs['tides'], W=kwargs['W'], F=kwargs['F'], label=kwargs['label'], equation=kwargs['eq'], x=kwargs['xia']['x'], alpha=kwargs['xia']['alpha'], beta=kwargs['xia']['beta'], theta=kwargs['xia']['theta'], L=kwargs['xia']['L'], K1=kwargs['xia']['K1'], b1=kwargs['xia']['b1'], K=kwargs['xia']['K'], b=kwargs['xia']['b'], K_cap=kwargs['xia']['K_cap'], b_cap=kwargs['xia']['b_cap']) else: df = None return {'sig': df}
def process(self, tides): if tides is None: return if self._df_id != id(tides): # print 'df new' self._df_id = id(tides) self.CW().param("tides_grp", "n_sig").setValue(len(tides) - 1) self.CW().disconnect_valueChanged2upd(self.CW().param("tides_grp", "A")) self.CW().disconnect_valueChanged2upd(self.CW().param("tides_grp", "omega")) self.CW().disconnect_valueChanged2upd(self.CW().param("tides_grp", "phi")) colname = [col for col in tides.columns if isNumpyNumeric(tides[col].dtype)] self.CW().param("tides_grp", "A").setLimits(colname) self.CW().param("tides_grp", "omega").setLimits(colname) self.CW().param("tides_grp", "phi").setLimits(colname) self.CW().param("tides_grp", "A").setValue(colname[0]) self.CW().param("tides_grp", "omega").setValue(colname[1]) self.CW().param("tides_grp", "phi").setValue(colname[2]) self.CW().connect_valueChanged2upd(self.CW().param("tides_grp", "A")) self.CW().connect_valueChanged2upd(self.CW().param("tides_grp", "omega")) self.CW().connect_valueChanged2upd(self.CW().param("tides_grp", "phi")) self.CW().disconnect_valueChanged2upd(self.CW().param("W")) W = tides[self.CW().p["tides_grp", "A"]][0] # 1st value from column `A` self.CW().param("W").setValue(W) self.CW().param("W").setDefault(W) self.CW().connect_valueChanged2upd(self.CW().param("W")) kwargs = self.CW().prepareInputArguments() kwargs["tides"] = {} for i in xrange(len(tides)): if not np.isnan(tides.iloc[i][kwargs["df_A"]]) and np.isnan(tides.iloc[i][kwargs["df_omega"]]): continue # skipping 0-frequency amplitude kwargs["tides"][str(i)] = {} kwargs["tides"][str(i)]["A"] = tides.iloc[i][kwargs["df_A"]] kwargs["tides"][str(i)]["omega"] = tides.iloc[i][kwargs["df_omega"]] kwargs["tides"][str(i)]["phi"] = tides.iloc[i][kwargs["df_phi"]] # print i, ': a={0}, omega={1}, phi={2}'.format(kwargs['tides'][str(i)]['A'], kwargs['tides'][str(i)]['omega'], kwargs['tides'][str(i)]['phi'] ) with BusyCursor(): if kwargs["eq"] == "tide": df = generate_tide( kwargs["t0"], kwargs["dt"], kwargs["tend"], components=kwargs["tides"], W=kwargs["W"], F=kwargs["F"], label=kwargs["label"], equation=kwargs["eq"], ) elif kwargs["eq"] == "ferris": df = generate_tide( kwargs["t0"], kwargs["dt"], kwargs["tend"], components=kwargs["tides"], W=kwargs["W"], F=kwargs["F"], label=kwargs["label"], equation=kwargs["eq"], D=kwargs["ferris"]["D"], x=kwargs["ferris"]["x"], ) elif kwargs["eq"] == "xia": df = generate_tide( kwargs["t0"], kwargs["dt"], kwargs["tend"], components=kwargs["tides"], W=kwargs["W"], F=kwargs["F"], label=kwargs["label"], equation=kwargs["eq"], x=kwargs["xia"]["x"], alpha=kwargs["xia"]["alpha"], beta=kwargs["xia"]["beta"], theta=kwargs["xia"]["theta"], L=kwargs["xia"]["L"], K1=kwargs["xia"]["K1"], b1=kwargs["xia"]["b1"], K=kwargs["xia"]["K"], b=kwargs["xia"]["b"], K_cap=kwargs["xia"]["K_cap"], b_cap=kwargs["xia"]["b_cap"], ) else: df = None return {"sig": df}
def process(self, tides): #print datetime.datetime.now(), "\t>>> update called", df = None if id(tides) != self._tides_id or tides is None: logger.debug( 'clearing genCurveNodeCtrlWidget_v2 (Tide Components Section) on_process()' ) #print 'setting tides components' self._tides_id = id(tides) if hasattr(self, '_ctrlWidget'): self._ctrlWidget.clearTideComponents() if tides is None: #print '\t > returning None' return {'sig': None} self._ctrlWidget.on_tides_received(tides) kwargs = self._ctrlWidget.prepareInputArguments() # now prepare the amplitudes kwargs['tides'] = {} for i in xrange(len(tides)): if not np.isnan(tides.iloc[i][kwargs['df_A']]) and np.isnan( tides.iloc[i][kwargs['df_omega']]): continue #skipping 0-frequency amplitude kwargs['tides'][str(i)] = {} kwargs['tides'][str(i)]['A'] = tides.iloc[i][kwargs['df_A']] kwargs['tides'][str(i)]['omega'] = tides.iloc[i][ kwargs['df_omega']] kwargs['tides'][str(i)]['phi'] = tides.iloc[i][kwargs['df_phi']] # finally do the calculations with BusyCursor(): #print '\t > doing the calculations' if kwargs['eq'] == 'tide': df = generate_tide(kwargs['t0'], kwargs['dt'], kwargs['tend'], components=kwargs['tides'], W=kwargs['W'], F=kwargs['F'], label=kwargs['label'], equation=kwargs['eq']) elif kwargs['eq'] == 'ferris': df = generate_tide(kwargs['t0'], kwargs['dt'], kwargs['tend'], components=kwargs['tides'], W=kwargs['W'], F=kwargs['F'], label=kwargs['label'], equation=kwargs['eq'], D=kwargs['ferris']['D'], x=kwargs['x']) elif kwargs['eq'] == 'xia': df = generate_tide(kwargs['t0'], kwargs['dt'], kwargs['tend'], components=kwargs['tides'], W=kwargs['W'], F=kwargs['F'], label=kwargs['label'], equation=kwargs['eq'], x=kwargs['x'], alpha=kwargs['xia']['alpha'], beta=kwargs['xia']['beta'], theta=kwargs['xia']['theta'], L=kwargs['xia']['L'], K1=kwargs['xia']['K1'], b1=kwargs['xia']['b1'], K=kwargs['xia']['K'], b=kwargs['xia']['b'], K_cap=kwargs['xia']['K_cap'], b_cap=kwargs['xia']['b_cap']) elif kwargs['eq'] == 'song': df = generate_tide(kwargs['t0'], kwargs['dt'], kwargs['tend'], components=kwargs['tides'], W=kwargs['W'], F=kwargs['F'], label=kwargs['label'], equation=kwargs['eq'], x=kwargs['x'], order=kwargs['song']['order'], b=kwargs['song']['b'], n_e=kwargs['song']['n_e'], kf=kwargs['song']['K'], b2msl=kwargs['song']['b2msl']) else: df = None return {'sig': df}