def __init__(self, parent=None): super(Pd_info, self).__init__(parent) label = QLabel(self) label.setGeometry(QRect(550, 10, 90, 90)) pixmap = QPixmap('img40.jpg') pixmap = pixmap.scaledToWidth(90) label.setPixmap(pixmap) self.ui = Pd.Ui_Form() self.ui.setupUi(self)
def Teff(Ta, hs, hi, freq): #compute the effective temperature i.e the physical temperature at penetration depth #the temperature profile Gs, Gi = Tgr.Tgr(Ta, hs, hi) #C-shaped salinity profile? hold on, wait a bit #set up profile layer_number_snow = int(math.ceil(hs * 100.0)) if hs == 0.0: layer_number_snow = 0 layer_number_ice = int(math.ceil(hi * 100.0)) if hi == 0.0: layer_number_ice = 0 layer_number_all = layer_number_snow + layer_number_ice num = range(layer_number_all + 2) si = np.zeros(layer_number_all + 2) salinity = np.zeros(layer_number_all + 2) density = np.zeros(layer_number_all + 2) temperature = np.zeros(layer_number_all + 2) scatter = 0.07 * np.ones(layer_number_all + 2) scatter[0] = 0.0 rms = np.zeros(layer_number_all + 2) d = 0.01 * np.ones(layer_number_all + 2) wc = np.zeros(layer_number_all + 2) Tb = np.zeros(90) emissivity = np.zeros(90) Tb_ = np.zeros(90) emis_ = np.zeros(90) Tv = np.zeros(90) Th = np.zeros(90) si[0:layer_number_snow] = 0 si[layer_number_snow:layer_number_all] = 1 salinity[0:layer_number_snow] = 0.0 density[1:layer_number_snow] = 300.0 density[layer_number_snow:layer_number_all] = 920.0 for s in range(layer_number_snow): temperature[s] = Ta + Gs * 0.01 * s for i in range(layer_number_snow, layer_number_all): temperature[i] = Ta + Gs * 0.01 * layer_number_snow + Gi * 0.01 * ( i - layer_number_snow + 1) for i in range(layer_number_snow, layer_number_all): salinity[i] = 16.0 / (i - layer_number_snow + 1)**2 + 6.0 frequency = np.array( [1.4, 6, 10, 18, 23, 36, 50, 89, 118, 150, 183, 243, 325, 448, 664]) for i in range(0, 90): #ryd op i returparametre Tb[i], emissivity[i], Tb_[i], emis_[i], Tv[i], Th[i] = Pd.emod( num, temperature, rms, density, d, scatter, salinity, wc, si, i, freq) print i, Th, Tv, Tb, emissivity, Tb_, emis_ plt.plot(Tv, 'x', Th, 'o', Tb, 'x', Tb_, 'o') plt.show() return Tv, Th
# date: 26/04/2010 ########################################################## ########################################################## #imports Pyata library from Pd import * #mains method if __name__ == '__main__': #creates an instance of Pd pd = Pd() #initializes Pyata pd.init() #creates a bang bang = Message(300, 100, "bang") #creates a random object rand = Object(300, 200, "random 100") #creates a number n = Number(300, 300) #connects the bang to the random connect(bang, 0, rand, 0) #connects the outlet from radom to a number connect(rand, 0, n, 0)
theObject = Object(x, y, msg, len(memory_box)) allObjects.append(theObject) return theObject def pdMessage(x, y, msg): global allObjects theObject = Message(x, y, msg, len(memory_box)) allObjects.append(theObject) return theObject if __name__ == "__main__": global pd #global allObjects #allObjects = [] logging.info("Starting Pyata...") pd = Pd() pd.init(usePdThread=True) # TODO: may want to be able to keep the content of the patch between restarts? pd.clear() logging.info("Making send~ objects") lsend = pdObject(300, 400, "send~ left") rsend = pdObject(400, 400, "send~ right") logging.info("Starting web.py server") #application = web.application(urls, globals()).wsgifunc() app = web.application(urls, globals()) app.internalerror = web.debugerror app.run()
def move(self, angle): angle = math.radians(angle) x = self.radius * math.cos(angle) y = self.radius * math.sin(angle) x += self.c_x y += self.c_y x = int(x) y = int(y) self.box.move(x, y) #mains method if __name__ == '__main__': #creates an instance of Pd pd = Pd() #initializes Pyata pd.init() #creates some numbers n1 = Number(100, 300) n2 = Number(500, 300) n3 = Number(300, 100) n4 = Number(300, 500) #creates an object dac~ in 10, 10 on the patch dac = Object(10, 10, "dac~") #creates a planet to rotate boxes p1 = Planet(100, 300, 300, dac)
class VideoEngine(): """ Through this class the gui communicates with puredata-vanilla by using pyata """ def __init__(self): #creates an instance of Pd self.pd = Pd() #initializes Pyata self.pd.init() self.pd.clear() def quit(self): self.pd.quit() def initbang(self,name): command = "init "+name+" loadbang;" self.sendCommand(command) def createOutput(self): self.outputWin = Object(50, 40, "qwin 320 240") createMsg = Message(50, 20, "create, 1") connect(createMsg,0, self.outputWin,0) self.initbang("qwin") createMsg.click() createMsg.delete() def createLayer(self, layer_num): obj1 = "qvideoplayer p"+str(layer_num) videoplayer = Object((100*layer_num), 130,obj1) obj = "qscreen p"+str(layer_num) screen = Object((100*layer_num), 400, obj) connect(videoplayer, 0, screen, 0) self.initbang("p"+str(layer_num)) self.getOutDim() msg = "set /q/screen/p"+str(layer_num)+"/fullscreen 1;" self.sendCommand(msg) self.setAlpha(layer_num, 0) def resizeOutput(self, width, height): msg = "destroy, dimen "+width+" "+height+",create" createMsg = Message(50, 20, msg) createMsg.click() createMsg.delete() def removeLayer(self, channel): # I can't understand what happen here: I have to reproduce same procedure for each object in layer....loop is not enough for i in memory_box: if hasattr(i, "label"): if channel in i.label: i.delete() for i in memory_box: if hasattr(i, "label"): if channel in i.label: i.delete() def openVideo(self, channel, path): msg = "video /q/videoplayer/p"+str(channel)+"/video "+path+";" self.sendCommand(msg) def setSpeed(self, channel, val): msg = "set /q/videoplayer/p"+str(channel)+"/speed "+ str(val) +";" self.sendCommand(msg) def setScratch(self, channel, val): msg = "set /q/videoplayer/p"+str(channel)+"/scratch "+ str(val) +";" self.sendCommand(msg) def setLoopin(self, channel, val): msg = "set /q/videoplayer/p"+str(channel)+"/loopin "+ str(val) +";" self.sendCommand(msg) def setLoopout(self, channel, val): msg = "set /q/videoplayer/p"+str(channel)+"/loopout "+ str(val) +";" self.sendCommand(msg) def setAlpha(self, channel, val): msg = "set /q/screen/p"+str(channel)+"/alpha "+ str(val) +";" self.sendCommand(msg) def setPlay(self, channel, val): msg = "set /q/videoplayer/p"+str(channel)+"/play "+ str(val) +";" self.sendCommand(msg) def setStop(self, channel, val): msg = "set /q/videoplayer/p"+str(channel)+"/stop "+ str(val) +";" self.sendCommand(msg) def setRewind(self, channel, val): msg = "set /q/videoplayer/p"+str(channel)+"/begin "+ str(val) +";" self.sendCommand(msg) def setSize(self, channel, val): msg = "set /q/screen/p"+str(channel)+"/size "+ str(val) +";" self.sendCommand(msg) def setFullscreen(self, channel): msg = "set /q/screen/p"+str(channel)+"/fullscreen ;" self.sendCommand(msg) def setRotateX(self, channel, val): msg = "set /q/screen/p"+str(channel)+"/rotate/x "+ str(val) +";" self.sendCommand(msg) def setRotateY(self, channel, val): msg = "set /q/screen/p"+str(channel)+"/rotate/y "+ str(val) +";" self.sendCommand(msg) def setPositionX(self, channel, val): msg = "set /q/screen/p"+str(channel)+"/translate/x "+ str(val) +";" self.sendCommand(msg) def setPositionY(self, channel, val): msg = "set /q/screen/p"+str(channel)+"/translate/y "+ str(val) +";" self.sendCommand(msg) def setColorR(self, channel, val): msg = "set /q/screen/p"+str(channel)+"/color/r "+ str(val) +";" self.sendCommand(msg) def setColorG(self, channel, val): msg = "set /q/screen/p"+str(channel)+"/color/g "+ str(val) +";" self.sendCommand(msg) def setColorB(self, channel, val): msg = "set /q/screen/p"+str(channel)+"/color/b "+ str(val) +";" self.sendCommand(msg) def sendCommand(self, command): self.pd.c.send_pd(command) def getOutDim(self): command = "set Qwin.getdim 1;" self.sendCommand(command) def setOutputFullscreen(self, w,h): createMsg = Message(50, 20, "destroy") connect(createMsg,0, self.outputWin,0) createMsg.click() createMsg.delete() dimen = "dimen "+str(w)+" "+str(h) createMsg = Message(50, 20, dimen) connect(createMsg,0, self.outputWin,0) createMsg.click() self.getOutDim() def createPreview(self): self.preview = Object(50, 90, "v4l2loopback preview") self.getOutDim() self.initbang("preview")
def __init__(self): #creates an instance of Pd self.pd = Pd() #initializes Pyata self.pd.init() self.pd.clear()
def pdObject(x, y, msg): global allObjects theObject = Object(x, y, msg, len(memory_box)) allObjects.append(theObject) return theObject def pdMessage(x, y, msg): global allObjects theObject = Message(x, y, msg, len(memory_box)) allObjects.append(theObject) return theObject if __name__ == "__main__": global pd #global allObjects #allObjects = [] logging.info("Starting Pyata...") pd = Pd() pd.init(usePdThread=True) # TODO: may want to be able to keep the content of the patch between restarts? pd.clear() logging.info("Making send~ objects") lsend = pdObject(300, 400, "send~ left") rsend = pdObject(400, 400, "send~ right") logging.info("Starting web.py server") #application = web.application(urls, globals()).wsgifunc() app = web.application(urls, globals()) app.internalerror = web.debugerror app.run()