Beispiel #1
0
    def addentity(self, entity, pos):
        if self.getentities(pos) == []:
            entitydatabase = data.database(entityfolder, entity)
            entitytype = entitydatabase.get("type", entitytypes[0])
            entityclass = entityclasses[entitytype]

            self.entities.append(entityclass(self, entity, pos))
Beispiel #2
0
 def add_account(self):
     Username = self.l_edit1.text()
     Password = self.l_edit2.text()
     if Username and Password:
         d = data.database()
         d._add('Account','baidutieba',str(Username),str(Password))
         d._done()
     self.close()
Beispiel #3
0
 def set_l_list(self):
     d = data.database()
     temp = d._search('Task','taskid','baidutieba')
     self.lists = []
     for i in temp:
         self.lists.append(i[1])
     qlist = QtCore.QStringList(self.lists)
     self.l_view.insertItems(0,qlist)
Beispiel #4
0
 def add_account(self):
     Username = self.l_edit1.text()
     Password = self.l_edit2.text()
     if Username and Password:
         d = data.database()
         d._add('Account', 'baidutieba', str(Username), str(Password))
         d._done()
     self.close()
Beispiel #5
0
	def finishaddtile(self, name):
		namedatabase = data.database("", "names")
		tilenames = namedatabase.get("tiles", [])
		tilenames.append(name)
		namedatabase.set("tiles", tilenames)
		namedatabase.write()
				
		self.edittile(name)
Beispiel #6
0
	def __init__(self, dungeon, name, pos):
		self.dungeon = dungeon
		self.name = name
		self.pos = pos
		self.data = data.database(dungeonmap.entityfolder, self.name)
		self.selected = False
		self.selectionimage, rect = resources.load_image("gui", "selection.png") #@UnusedVariable
		self.refresh()
Beispiel #7
0
    def savemap(self):
        if self.mapname != None:
            mapdatabase = data.database(mapfolder, self.mapname)

            namedatabase = data.database("", "names")

            tilenames = namedatabase.get("tiles", [])

            strmap = copy.deepcopy(self.map)

            for y, row in enumerate(strmap):
                for x, tile in enumerate(row):
                    if not tile in tilenames:
                        tilenames.append(tile)
                        print "WARNING: tile did not exist"
                    strmap[y][x] = tilenames.index(tile)

            entitynames = namedatabase.get("entities")
            if entitynames == None:
                entitynames = []

            entitylist = [[entity.name, entity.pos] for entity in self.entities]

            if entitylist == None:
                entitylist = []

            for entity in entitylist:
                if not entity[0] in entitynames:
                    entitynames.append(entity[0])
                    print "WARNING: entity did not exist"
                entity[0] = entitynames.index(entity[0])

            mapdatabase.set("map", strmap)

            mapdatabase.set("entities", entitylist)

            mapdatabase.set("width", self.mapwidth)
            mapdatabase.set("height", self.mapheight)

            namedatabase.set("tiles", tilenames)
            namedatabase.set("entities", entitynames)

            namedatabase.write()
            mapdatabase.write()
Beispiel #8
0
 def add_task(self):
     url = self.l_edit.text()
     temp = re.search('kw=.+?&fr', url)
     if temp:
         key_word = temp.group()[3:-3]
         key_word = urllib.unquote(str(key_word))
         key_word = key_word.decode('gb2312')
         d = data.database()
         d._add('Task', 'baidutieba', key_word)
         d._done()
     self.close()
Beispiel #9
0
	def finishcopyentity(self, oldentity, newentity):
		shutil.copytree(resources.fullname(dungeonmap.entityimgfolder, oldentity), resources.fullname(dungeonmap.entityimgfolder, newentity))
		shutil.copy(data.fullname(dungeonmap.entityfolder, oldentity), data.fullname(dungeonmap.entityfolder, newentity))
		
		namedatabase = data.database("", "names")
		entitynames = namedatabase.get("entities", [])
		entitynames.append(newentity)
		namedatabase.set("entities", entitynames)
		namedatabase.write()
		
		self.refreshlist()
Beispiel #10
0
 def exe_all_func(self):
     d = data.database()
     account = d._search('Account','sitename','baidutieba')[0]
     bd = baidu.Baidu(account[1],account[2])
     self.exe_all.setText('Proccessing....')
     if bd.login():
         for name in self.lists:
             self.exe_all.setText('....')
             bd.sign_in(name)
             self.l_view2.insertItem(0,QtCore.QString(name))
     self.exe_all.setText('All Done!')
Beispiel #11
0
	def finishcopytile(self, oldtile, newtile):
		shutil.copy(resources.fullname(dungeonmap.tileimgfolder, oldtile+".png"), resources.fullname(dungeonmap.tileimgfolder, newtile+".png"))
		shutil.copy(data.fullname(dungeonmap.tilefolder, oldtile), data.fullname(dungeonmap.tilefolder, newtile))

		namedatabase = data.database("", "names")
		tilenames = namedatabase.get("tiles", [])
		tilenames.append(newtile)
		namedatabase.set("tiles", tilenames)
		namedatabase.write()
		
		self.refreshlist()
Beispiel #12
0
 def add_task(self):
     url = self.l_edit.text()
     temp = re.search('kw=.+?&fr',url)
     if temp:
         key_word = temp.group()[3:-3]
         key_word = urllib.unquote(str(key_word))
         key_word = key_word.decode('gb2312')
         d = data.database()
         d._add('Task','baidutieba',key_word)
         d._done()
     self.close()
Beispiel #13
0
	def newname(self, oldname, newname):
		shutil.move(resources.fullname(dungeonmap.tileimgfolder, oldname+".png"), resources.fullname(dungeonmap.tileimgfolder, newname+".png"))
		shutil.move(data.fullname(dungeonmap.tilefolder, oldname), data.fullname(dungeonmap.tilefolder, newname))
		objlists.dungeonmap.renametile(oldname, newname)

		namedatabase = data.database("", "names")
		tilenames = namedatabase.get("tiles", [])
		tilenames[tilenames.index(oldname)] = newname
		namedatabase.set("tiles", tilenames)
		namedatabase.write()
		
		self.refreshlist()
Beispiel #14
0
def kernel_TimeDepScan(run_desc, environment):
    xstep = 0
    comment = "Time Dependence Scan. Measuring %s and %s for %.2g secs every %.2g secs. Impulse provided by %s, which was set at %.2g for %.2g, at %.2g for %.2g and then set at %.2g for duration of measurment."%(run_desc['y1label'], run_desc['y2label'], run_desc['meastime'], run_desc['interval'], run_desc['impulselabel'], run_desc['hysttop'], run_desc['hysttopwait'], run_desc['hystbot'], run_desc['hystbotwait'], run_desc['measureat'])

    mydatabase = data.database(run_desc['filename'], run_desc['dirname'], 1, 3, comment)
    environment['purgatory'](environment['plot'].set_labels,
                             run_desc['xlabel'], run_desc['y1label'], run_desc['y2label'])
    if (run_desc['f_Y2read']):
        environment['purgatory'](environment['plot'].set_mode, pyextfigure.DUALTWODPLOT)
    else:
        environment['purgatory'](environment['plot'].set_mode, pyextfigure.TWODPLOT)

    try:
        if run_desc['f_Xset']:
            run_desc['f_Xset'](run_desc['hysttop'])
            time.sleep(run_desc['hysttopwait'])
            run_desc['f_Xset'](run_desc['hystbot'])
            time.sleep(run_desc['hystbotwait'])
            run_desc['f_Xset'](run_desc['measureat'])
        
        STARTTIME = time.time()
        if (run_desc['pause'] > 0): time.sleep(run_desc['pause'])

        while ((time.time() - STARTTIME < run_desc['meastime']) and not STOP_FLAG):
            readval1 = run_desc['f_Y1read']()*run_desc['y1scale']
            if (run_desc['f_Y2read']):
                readval2 = run_desc['f_Y2read']()*run_desc['y2scale']
            else:
                readval2 = 0.0
            
            timenow = time.time() - STARTTIME
            mydatabase.add_data_point([timenow, readval1, readval2], xstep) 
            xstep = xstep + 1
            time.sleep(run_desc['interval'])
            
            environment['purgatory'](environment['plot'].add_point, timenow, readval1, readval2)
            environment['purgatory'](environment['plot'].repaint)
            
            environment['purgatory'](environment['progressbar'].set_fraction, \
                                         min(1.0, (1.0 * timenow)/run_desc['meastime']))
            
            while PAUSE_FLAG:
                time.sleep(0.1)
     
    finally:
        if (run_desc['f_Xset']):
            if ((run_desc['finishat'] <= max(run_desc['Xstart'], run_desc['Xend'])) and
                (run_desc['finishat'] >= min(run_desc['Xstart'], run_desc['Xend']))):
                run_desc['f_Xset'](run_desc['finishat'])
            else:
                print "SAFETY CHECK: Finish at out of bounds. Ignoring"

    return mydatabase
Beispiel #15
0
def kernel_MultiTimeDepScan(run_desc, environment):
    xstep = 0
    comment = "Time Dependence Scan of Multiple Variables. Measuring for %.2g secs every %.2g secs.\n" % (
        run_desc['meastime'], run_desc['interval'])
    comment += "Hello World Filler."

    y_variables = len(run_desc['reads'])

    mydatabase = data.database(run_desc['filename'], run_desc['dirname'], 1,
                               1 + y_variables, comment)
    #environment['purgatory'](environment['plot'].set_labels,
    #                         run_desc['xlabel'], run_desc['y1label'], run_desc['y2label'])
    #if (run_desc['f_Y2read']):
    #    environment['purgatory'](environment['plot'].set_mode, pyextfigure.DUALTWODPLOT)
    #else:
    #    environment['purgatory'](environment['plot'].set_mode, pyextfigure.TWODPLOT)

    try:
        STARTTIME = time.time()
        if (run_desc['pause'] > 0):
            time.sleep(run_desc['pause'])

        while ((time.time() - STARTTIME < run_desc['meastime'])
               and not STOP_FLAG):
            #readval1 = run_desc['f_Y1read']()*run_desc['y1scale']
            #if (run_desc['f_Y2read']):
            #    readval2 = run_desc['f_Y2read']()*run_desc['y2scale']
            #else:
            #    readval2 = 0.0

            y_values = []
            for read_function in run_desc['reads'].itervalues():
                y_values.append(read_function())

            timenow = time.time() - STARTTIME
            y_values.insert(0, timenow)
            mydatabase.add_data_point(y_values, xstep)
            xstep = xstep + 1
            time.sleep(run_desc['interval'])

            #environment['purgatory'](environment['plot'].add_point, timenow, readval1, readval2)
            #environment['purgatory'](environment['plot'].repaint)

            environment['purgatory'](environment['progressbar'].set_fraction, \
                                         min(1.0, (1.0 * timenow)/run_desc['meastime']))

            while PAUSE_FLAG:
                time.sleep(0.1)

    finally:
        pass

    return mydatabase
Beispiel #16
0
	def finishaddentity(self, name):
		os.makedirs(resources.fullname(dungeonmap.entityimgfolder, name))
		
		namedatabase = data.database("", "names")
		entitynames = namedatabase.get("entities", [])
		entitynames.append(name)
		namedatabase.set("entities", entitynames)
		namedatabase.write()

		self.editentity(name)
		
		self.refreshlist()
Beispiel #17
0
    def openmap(self, name):
        self.mapname = name

        mapdatabase = data.database(mapfolder, self.mapname)

        self.mapwidth = int(mapdatabase.get("width", self.mapwidth))
        self.mapheight = int(mapdatabase.get("height", self.mapheight))

        self.newmap()

        mapdata = mapdatabase.get(
            "map", [[0] * self.mapwidth] * self.mapheight
        )  # data.get_data(mapfolder, self.mapname)

        namedatabase = data.database("", "names")
        tilenames = namedatabase.get("tiles", [])

        if mapdata != "":
            for y, line in enumerate(mapdata):
                for x, tile in enumerate(line):
                    try:
                        tile = tilenames[tile]
                    except:
                        tile = tilenames[0]
                    self.map[y][x] = self.tilesprite(tile)

        entitynames = namedatabase.get("entities", [])

        mapentities = mapdatabase.get("entities", [])

        for entity in mapentities:
            entityposition = entity[1]
            try:
                entityname = entitynames[int(entity[0])]
            except:
                entityname = None
            if entityname != None:
                self.addentity(entityname, entityposition)

        namedatabase.write()
Beispiel #18
0
	def deletetile(self, tile):
		os.remove(resources.fullname(dungeonmap.tileimgfolder, tile+".png"))
		os.remove(data.fullname(dungeonmap.tilefolder, tile))
		if objlists.dungeonmap.selectedtile == tile:
			objlists.dungeonmap.selectedtile = None
		
		namedatabase = data.database("", "names")
		tilenames = namedatabase.get("tiles", [])
		tilenames.remove(tile)
		namedatabase.set("tiles", tilenames)
		namedatabase.write()

		self.refreshlist()
Beispiel #19
0
	def deleteentity(self, entity):
		shutil.rmtree(resources.fullname(dungeonmap.entityimgfolder, entity))
		os.remove(data.fullname(dungeonmap.entityfolder, entity))
		if objlists.dungeonmap.selectedentity == entity:
			objlists.dungeonmap.selectedentity = None

		namedatabase = data.database("", "names")
		entitynames = namedatabase.get("entities", [])
		entitynames.remove(entity)
		namedatabase.set("entities", entitynames)
		namedatabase.write()
		
		self.refreshlist()
Beispiel #20
0
	def newname(self, oldentity, newentity):
		shutil.copytree(resources.fullname(dungeonmap.entityimgfolder, oldentity), resources.fullname(dungeonmap.entityimgfolder, newentity))
		shutil.rmtree(resources.fullname(dungeonmap.entityimgfolder, oldentity))
		shutil.move(data.fullname(dungeonmap.entityfolder, oldentity), data.fullname(dungeonmap.entityfolder, newentity))
		objlists.dungeonmap.renameentity(oldentity, newentity)
		
		namedatabase = data.database("", "names")
		entitynames = namedatabase.get("entities", [])
		entitynames[entitynames.index(oldentity)] = newentity
		namedatabase.set("entities", entitynames)
		namedatabase.write()
		
		self.refreshlist()
Beispiel #21
0
def kernel_MultiTimeDepScan(run_desc, environment):
    xstep = 0
    comment = "Time Dependence Scan of Multiple Variables. Measuring for %.2g secs every %.2g secs.\n"%(run_desc['meastime'], run_desc['interval'])
    comment += "Hello World Filler."

    y_variables = len(run_desc['reads'])
    
    mydatabase = data.database(run_desc['filename'], run_desc['dirname'], 1, 1 + y_variables, comment)
    #environment['purgatory'](environment['plot'].set_labels,
    #                         run_desc['xlabel'], run_desc['y1label'], run_desc['y2label'])
    #if (run_desc['f_Y2read']):
    #    environment['purgatory'](environment['plot'].set_mode, pyextfigure.DUALTWODPLOT)
    #else:
    #    environment['purgatory'](environment['plot'].set_mode, pyextfigure.TWODPLOT)

    try:            
        STARTTIME = time.time()
        if (run_desc['pause'] > 0):
            time.sleep(run_desc['pause'])
        
        while ((time.time() - STARTTIME < run_desc['meastime']) and not STOP_FLAG):
            #readval1 = run_desc['f_Y1read']()*run_desc['y1scale']
            #if (run_desc['f_Y2read']):
            #    readval2 = run_desc['f_Y2read']()*run_desc['y2scale']
            #else:
            #    readval2 = 0.0
            
            y_values = []
            for read_function in run_desc['reads'].itervalues():
                y_values.append(read_function())
            
            timenow = time.time() - STARTTIME
            y_values.insert(0, timenow)
            mydatabase.add_data_point(y_values, xstep) 
            xstep = xstep + 1
            time.sleep(run_desc['interval'])
            
            #environment['purgatory'](environment['plot'].add_point, timenow, readval1, readval2)
            #environment['purgatory'](environment['plot'].repaint)
            
            environment['purgatory'](environment['progressbar'].set_fraction, \
                                         min(1.0, (1.0 * timenow)/run_desc['meastime']))     
            
            while PAUSE_FLAG:
                time.sleep(0.1)
                
    finally:
        pass

    return mydatabase
Beispiel #22
0
def kernel_PIDlock(run_desc, environment):
    xstep = 0
    comment = "PID Lock. Measuring %s, adjusting %s." % (run_desc['y1label'],
                                                         run_desc['y2label'])

    mydatabase = data.database(run_desc['filename'], run_desc['dirname'], 1, 3,
                               comment)
    environment['purgatory'](environment['plot'].set_labels,
                             run_desc['xlabel'], run_desc['y1label'],
                             run_desc['y2label'])
    environment['purgatory'](environment['plot'].set_mode,
                             pyextfigure.DUALTWODPLOT)

    try:
        STARTTIME = time.time()

        Pvalue = 0
        Ivalue = run_desc['xstart']
        step = 0
        while (not STOP_FLAG):
            readval = run_desc['read_func']() * run_desc['scale']
            timenow = time.time() - STARTTIME
            if (run_desc['pause'] > 0): time.sleep(run_desc['pause'])

            if ((readval > run_desc['setpoint'] / 2)
                    and (readval < 2 * run_desc['setpoint'])):
                Pvalue = (run_desc['setpoint'] - readval) * run_desc['pgain']
                Ivalue = Ivalue + Pvalue * run_desc['igain']
            setval = min(run_desc['ubound'],
                         max(run_desc['lbound'], Pvalue + Ivalue))

            mydatabase.add_data_point([timenow, readval, setval], step)
            step = step + 1

            run_desc['set_func'](setval)

            environment['purgatory'](environment['plot'].add_point, timenow,
                                     readval, setval)
            environment['purgatory'](environment['plot'].repaint)
    finally:
        pass

    return mydatabase
Beispiel #23
0
	def __init__(self, tilename, tilewindow, scrollbar=True):
		Window.__init__(self, tilename)
		
		self.name = tilename
		self.originalname = copy.copy(self.name)
		
		self.tilewindow = tilewindow

		self.database = data.database(dungeonmap.tilefolder, self.name)
		
#		self.namelabel = label(self, "Name: " + self.name)
#		self.pack(self.namelabel)
				
		self.imagebox = picturebox(self, dungeonmap.tileimgfolder, self.name+".png", size=[50,50])
		self.pack(self.imagebox)
		
		self.testcheck = checkbox(self, "test value")
		self.testcheck.checked = self.database.get("test", True)
		self.pack(self.testcheck)
Beispiel #24
0
def kernel_PIDlock(run_desc, environment):
    xstep = 0
    comment = "PID Lock. Measuring %s, adjusting %s."%(run_desc['y1label'], run_desc['y2label'])

    mydatabase = data.database(run_desc['filename'], run_desc['dirname'], 1, 3, comment)
    environment['purgatory'](environment['plot'].set_labels,
                             run_desc['xlabel'], run_desc['y1label'], run_desc['y2label'])
    environment['purgatory'](environment['plot'].set_mode, pyextfigure.DUALTWODPLOT)

    try:
        STARTTIME = time.time()

        Pvalue = 0
        Ivalue = run_desc['xstart']
        step = 0
        while (not STOP_FLAG):
            readval = run_desc['read_func']()*run_desc['scale']
            timenow = time.time() - STARTTIME
            if (run_desc['pause'] > 0): time.sleep(run_desc['pause'])

            if ((readval > run_desc['setpoint']/2) and (readval < 2*run_desc['setpoint'])):
                Pvalue = (run_desc['setpoint'] - readval)*run_desc['pgain']
                Ivalue = Ivalue + Pvalue * run_desc['igain']
            setval = min(run_desc['ubound'], max(run_desc['lbound'], Pvalue + Ivalue))
            
            mydatabase.add_data_point([timenow, readval, setval], step) 
            step = step + 1

	    run_desc['set_func'](setval)
            
            environment['purgatory'](environment['plot'].add_point, timenow, readval, setval)
            environment['purgatory'](environment['plot'].repaint)
    finally:
        pass

    return mydatabase
Beispiel #25
0
def kernel_Stab1DScan(run_desc, environment):
    step = 0
    datastep = 0
    MAX_STEPS = run_desc['steps']
    increment = 1

    comment = "Stab 1D Scan of %s against %s. Stabilizing %s. X starts at %.2g and ends at %.2g, with %d steps."%(run_desc['ylabel'], run_desc['xlabel'], run_desc['slabel'], run_desc['Xstart'], run_desc['Xend'], run_desc['steps'])  

    mydatabase = data.database(run_desc['filename'], run_desc['dirname'], 1, 3, comment)
    environment['purgatory'](environment['plot'].set_labels,
                             run_desc['xlabel'], run_desc['ylabel'], run_desc['slabel'])
    
    environment['purgatory'](environment['plot'].set_mode, pyextfigure.DUALTWODPLOT)

    try:
        run_desc['f_Xset'](run_desc['Xstart'])
        run_desc['f_Sset'](run_desc['Sstart'])
        time.sleep(2*run_desc['pause'] + 1)

        Ssetval = run_desc['Sstart']

        while (((step <= MAX_STEPS) or run_desc['cycle?'] > 0.) and not STOP_FLAG):
            Xsetval = (run_desc['Xend'] - run_desc['Xstart']) * (1.0*step)/MAX_STEPS + run_desc['Xstart']
            run_desc['f_Xset'](Xsetval)
            run_desc['f_Sset'](Ssetval)
            if (run_desc['pause'] > 0): time.sleep(run_desc['pause'])
                
            if (run_desc['f_Xread']):
                Xreadval = run_desc['f_Xread']()
            else:
                Xreadval = Xsetval
                
            Yreadval = run_desc['f_Yread']() * run_desc['yscale']
            Sreadval = run_desc['f_Sread']()

            if ((Sreadval > run_desc['Ssetpoint']/2) and (Sreadval < 2*run_desc['Ssetpoint'])):
                Ssetval = Ssetval + run_desc['igain']*(run_desc['Ssetpoint'] - Sreadval)

            mydatabase.add_data_point([Xreadval, Yreadval, Sreadval], datastep)
            datastep = datastep + 1

            environment['purgatory'](environment['plot'].add_point, Xreadval, Yreadval, Sreadval)
            environment['purgatory'](environment['plot'].repaint)

            if (step % (MAX_STEPS/100 + 1) == 0):
                environment['purgatory'](environment['progressbar'].set_fraction, (1.0*step)/MAX_STEPS)

            step = step + increment
            if (((step == MAX_STEPS) or (step == 0)) and (run_desc['cycle?'] > 0.)):
                increment = -increment
            
            while PAUSE_FLAG:
                time.sleep(0.1)
                
    finally:
        if ((run_desc['finishat'] <= max(run_desc['Xstart'], run_desc['Xend'])) and
            (run_desc['finishat'] >= min(run_desc['Xstart'], run_desc['Xend']))):
            run_desc['f_Xset'](run_desc['finishat'])
        else:
            print "SAFETY CHECK: Finish at out of bounds. Ignoring"

    return mydatabase
Beispiel #26
0
def kernel_2DScan(run_desc, environment):
    xstep = 0
    ystep = 0
    MAX_XSTEPS = run_desc['xsteps']
    xstep_size = (run_desc['Xend'] - run_desc['Xstart'])/MAX_XSTEPS
    MAX_YSTEPS = run_desc['ysteps']
    ystep_size = (run_desc['Yend'] - run_desc['Ystart'])/MAX_YSTEPS

    comment = "2D Scan of %s against %s and %s. X starts at %.2g and ends at %.2g, with %d steps. Y starts at %.2g and ends at %.2g with %d steps"%(run_desc['zlabel'], run_desc['xlabel'], run_desc['ylabel'], run_desc['Xstart'], run_desc['Xend'], run_desc['xsteps'], run_desc['Ystart'], run_desc['Yend'], run_desc['ysteps'])  
    mydatabase = data.database(run_desc['filename'], run_desc['dirname'], 2, 3, comment)

    environment['purgatory'](environment['plot'].set_labels,
                             run_desc['xlabel'], run_desc['ylabel'], run_desc['zlabel'])
    environment['purgatory'](environment['plot'].set_mode, pyextfigure.THREEDPLOT)
    environment['purgatory'](environment['plot'].set_spot_shape, abs(xstep_size), abs(ystep_size))

    try:
        Xsetval = run_desc['Xstart']
        Ysetval = run_desc['Ystart']
        run_desc['f_Xset'](Xsetval)
        time.sleep(2*run_desc['xpause'] + 1)
        run_desc['f_Yset'](Ysetval)
        time.sleep(2*run_desc['ypause'] + 1)

        while (not STOP_FLAG):
            Ysetval = ystep * ystep_size + run_desc['Ystart']
            run_desc['f_Yset'](Ysetval)
            if (run_desc['ypause'] > 0): time.sleep(run_desc['ypause'])
            
            if (run_desc['f_Xread']):
                Xreadval = run_desc['f_Xread']()
            else:
                Xreadval = Xsetval
            if (run_desc['f_Yread']):
                Yreadval = run_desc['f_Yread']()
            else:
                Yreadval = Ysetval

            Zreadval = run_desc['f_Zread']() * run_desc['zscale']
                
            mydatabase.add_data_point([Xreadval, Yreadval, Zreadval], xstep, ystep) 

            environment['purgatory'](environment['plot'].add_point, Xsetval, Ysetval, Zreadval)
            environment['purgatory'](environment['plot'].repaint)

            ystep = int((ystep + 1)%(MAX_YSTEPS + 1))
            if (ystep == 0):
                xstep = int(xstep + 1)
                if (xstep > MAX_XSTEPS): break
                Xsetval = xstep*xstep_size + run_desc['Xstart']
                run_desc['f_Xset'](Xsetval)
                run_desc['f_Yset'](run_desc['Ystart'])
                if (run_desc['xpause'] > 0): time.sleep(run_desc['xpause'])
                
                environment['purgatory'](environment['progressbar'].set_fraction, (1.0*xstep)/MAX_XSTEPS)
                
            while PAUSE_FLAG:
                time.sleep(0.1)
                
    finally:
        if ((run_desc['finishxat'] <= max(run_desc['Xstart'], run_desc['Xend'])) and
            (run_desc['finishxat'] >= min(run_desc['Xstart'], run_desc['Xend']))):
            run_desc['f_Xset'](run_desc['finishxat'])
        else:
            print "SAFETY CHECK: Finish X at out of bounds. Ignoring"

        if ((run_desc['finishyat'] <= max(run_desc['Ystart'], run_desc['Yend'])) and
            (run_desc['finishyat'] >= min(run_desc['Ystart'], run_desc['Yend']))):
            run_desc['f_Yset'](run_desc['finishyat'])
        else:
            print "SAFETY CHECK: Finish Y at out of bounds. Ignoring"

    return mydatabase
Beispiel #27
0
def kernel_WireBreak2(run_desc, environment):
    # Define two helpers
    def measure_background(run_desc):
        Izero = run_desc['I offset']
        data = []
        for i in range(50):
            if STOP_FLAG:
                break
            V = i * run_desc['Vsafe'] / 50.0
            run_desc['f_set'](V)
            time.sleep(run_desc['pause'])
            I = run_desc['f_read']() * run_desc['iscale'] - Izero
            data.append([I, V])
            run_desc['mydatabase'].add_data_point([V, I], run_desc['step'])
            run_desc['step'] = run_desc['step'] + 1

        fit = linear_fit(numarray.array(data))
        return (fit[0], fit[1], fit[2], fit[3])

    def get_wire_res(run_desc, V, Rzero, Vzero):
        Inow = run_desc['f_read']() * run_desc['iscale'] - run_desc['I offset']
        run_desc['mydatabase'].add_data_point([V, Inow], run_desc['step'])
        run_desc['step'] = run_desc['step'] + 1

        if (Inow < 1e-9):
            print "Current too low (%g A at %g V), quitting!" % (Inow, V)
            return (-1, 1e12, 1e12)

        if ((V - Vzero) / Inow < 1.0 + Rzero):
            Rzero = (V - Vzero) / Inow - 1.0
            print "Readjusting resistance of leads to %g" % (Rzero)

        Rnow = (V - Vzero) / Inow - Rzero

        if (Rzero < 0 or Rnow < 1):
            print "Negative resistance (imprecise offset correction?), quitting!"
            return (-1, 1, 0)
        else:
            return (0, Rnow, Rzero)

    # ACTUAL CODE STARTS HERE

    comment = "Wirebreak2 data. Setting %s, reading %s. The break rate is set to %.2g, small and large step to %.2g and %.2g. Safe value is %.2g, max value is %.2g" % (
        run_desc['xlabel'], run_desc['ylabel'], run_desc['rate'],
        run_desc['smallstep'], run_desc['bigstep'], run_desc['Vsafe'],
        run_desc['Vmax'])

    run_desc.update({
        'step':
        0,
        'mydatabase':
        data.database(run_desc['filename'], run_desc['dirname'], 1, 2, comment)
    })
    environment['purgatory'](environment['plot'].set_labels,
                             run_desc['xlabel'], run_desc['ylabel'], '')
    environment['purgatory'](environment['plot'].set_mode,
                             pyextfigure.TWODPLOT)
    tempsafeV = run_desc['Vsafe']

    try:
        [Vzero, Rzero, sigmaVzero, sigmaRzero] = measure_background(run_desc)
        print "Voltage offset is %g (+- %g)" % (Vzero, sigmaVzero)
        print "Leads resistance is %g (+- %g)" % (Rzero, sigmaRzero)

        Rzero = Rzero - 1.0  # Wire has less than an ohm, assume an ohm
        if run_desc['Rzero'] > .1:
            Rzero = run_desc['Rzero']
            print "Overriding leads resistance to %f" % (Rzero)
        Vnow = run_desc['Vsafe']  # start at safe V
        updateV = 1
        lastdata = []
        START_TIME = time.time()

        print "BREAK STARTED"
        while (not STOP_FLAG):
            # set new voltage
            if (updateV == 1):
                run_desc['f_set'](Vnow)
                updateV = 0
                time.sleep(run_desc['pause'])

        # Measure wire resistance, taking care of offsetts
            [status, Rnow, Rzero] = get_wire_res(run_desc, Vnow, Rzero, Vzero)
            if (status == -1): break

            environment['purgatory'](environment['plot'].add_point, Vnow,
                                     math.log10(Rnow), 1.0)
            environment['purgatory'](environment['plot'].repaint)

            # Are we done?
            if (Rnow + Rzero > run_desc['target']):
                print "Exceeded target (Wire %g Ohm, Leads %g), quitting!" % (
                    Rnow, Rzero)
                break

        # If something crazy happened, reset data, and ramp back quite a bit
            if ((len(lastdata) > 1) and
                (abs(math.log10(Rnow) - lastdata[len(lastdata) - 1][1]) > .3)):
                print "Jump in data, restarting fit"
                Vnow = tempsafeV
                tempsafeV = (tempsafeV + run_desc['Vsafe']) / 2
                lastdata = []
                updateV = 1
                continue

        # Add data point, shifting old data out if needed
            lastdata.append([time.time() - START_TIME, math.log10(Rnow)])
            if ((lastdata[len(lastdata) - 1][0] - lastdata[0][0]) < .2):
                continue
            while ((lastdata[len(lastdata) - 1][0] - lastdata[0][0]) > .5):
                lastdata = lastdata[1:]

        # Find out the rate of change
            [a, rate, sigma_a,
             sigma_rate] = linear_fit(numarray.array(lastdata))

            # Are we good?
            if ((rate > .1 * run_desc['rate']) and (rate < run_desc['rate'])):
                continue

        # Nope, what should we do?
            if ((rate < .01 * run_desc['rate']) and (Vnow < run_desc['Vmax'])):
                tempsafeV = (.9 * Vnow + 3.0 * tempsafeV) / 4.0
                Vnow = Vnow + run_desc['bigstep']
            elif ((rate < .1 * run_desc['rate'])
                  and (Vnow < run_desc['Vmax'])):
                Vnow = Vnow + run_desc['smallstep']
            elif (rate > run_desc['rate'] + 3.0 * sigma_rate):
                Vnow = tempsafeV + (Vnow - tempsafeV) * (10.0 / (
                    (rate / run_desc['rate'])**2 + 10.0))
                tempsafeV = (tempsafeV + run_desc['Vsafe']) / 2

        # voltage change, reset data
            updateV = 1
            lastdata = []

    finally:
        run_desc['f_set'](0.0)

    return run_desc['mydatabase']
Beispiel #28
0
def kernel_2DScan(run_desc, environment):
    xstep = 0
    ystep = 0
    MAX_XSTEPS = run_desc['xsteps']
    xstep_size = (run_desc['Xend'] - run_desc['Xstart']) / MAX_XSTEPS
    MAX_YSTEPS = run_desc['ysteps']
    ystep_size = (run_desc['Yend'] - run_desc['Ystart']) / MAX_YSTEPS

    comment = "2D Scan of %s against %s and %s. X starts at %.2g and ends at %.2g, with %d steps. Y starts at %.2g and ends at %.2g with %d steps" % (
        run_desc['zlabel'], run_desc['xlabel'], run_desc['ylabel'],
        run_desc['Xstart'], run_desc['Xend'], run_desc['xsteps'],
        run_desc['Ystart'], run_desc['Yend'], run_desc['ysteps'])
    mydatabase = data.database(run_desc['filename'], run_desc['dirname'], 2, 3,
                               comment)

    environment['purgatory'](environment['plot'].set_labels,
                             run_desc['xlabel'], run_desc['ylabel'],
                             run_desc['zlabel'])
    environment['purgatory'](environment['plot'].set_mode,
                             pyextfigure.THREEDPLOT)
    environment['purgatory'](environment['plot'].set_spot_shape,
                             abs(xstep_size), abs(ystep_size))

    try:
        Xsetval = run_desc['Xstart']
        Ysetval = run_desc['Ystart']
        run_desc['f_Xset'](Xsetval)
        time.sleep(2 * run_desc['xpause'] + 1)
        run_desc['f_Yset'](Ysetval)
        time.sleep(2 * run_desc['ypause'] + 1)

        while (not STOP_FLAG):
            Ysetval = ystep * ystep_size + run_desc['Ystart']
            run_desc['f_Yset'](Ysetval)
            if (run_desc['ypause'] > 0): time.sleep(run_desc['ypause'])

            if (run_desc['f_Xread']):
                Xreadval = run_desc['f_Xread']()
            else:
                Xreadval = Xsetval
            if (run_desc['f_Yread']):
                Yreadval = run_desc['f_Yread']()
            else:
                Yreadval = Ysetval

            Zreadval = run_desc['f_Zread']() * run_desc['zscale']

            mydatabase.add_data_point([Xreadval, Yreadval, Zreadval], xstep,
                                      ystep)

            environment['purgatory'](environment['plot'].add_point, Xsetval,
                                     Ysetval, Zreadval)
            environment['purgatory'](environment['plot'].repaint)

            ystep = int((ystep + 1) % (MAX_YSTEPS + 1))
            if (ystep == 0):
                xstep = int(xstep + 1)
                if (xstep > MAX_XSTEPS): break
                Xsetval = xstep * xstep_size + run_desc['Xstart']
                run_desc['f_Xset'](Xsetval)
                run_desc['f_Yset'](run_desc['Ystart'])
                if (run_desc['xpause'] > 0): time.sleep(run_desc['xpause'])

                environment['purgatory'](
                    environment['progressbar'].set_fraction,
                    (1.0 * xstep) / MAX_XSTEPS)

            while PAUSE_FLAG:
                time.sleep(0.1)

    finally:
        if ((run_desc['finishxat'] <= max(run_desc['Xstart'],
                                          run_desc['Xend']))
                and (run_desc['finishxat'] >= min(run_desc['Xstart'],
                                                  run_desc['Xend']))):
            run_desc['f_Xset'](run_desc['finishxat'])
        else:
            print "SAFETY CHECK: Finish X at out of bounds. Ignoring"

        if ((run_desc['finishyat'] <= max(run_desc['Ystart'],
                                          run_desc['Yend']))
                and (run_desc['finishyat'] >= min(run_desc['Ystart'],
                                                  run_desc['Yend']))):
            run_desc['f_Yset'](run_desc['finishyat'])
        else:
            print "SAFETY CHECK: Finish Y at out of bounds. Ignoring"

    return mydatabase
Beispiel #29
0
def kernel_Stab1DScan(run_desc, environment):
    step = 0
    datastep = 0
    MAX_STEPS = run_desc['steps']
    increment = 1

    comment = "Stab 1D Scan of %s against %s. Stabilizing %s. X starts at %.2g and ends at %.2g, with %d steps." % (
        run_desc['ylabel'], run_desc['xlabel'], run_desc['slabel'],
        run_desc['Xstart'], run_desc['Xend'], run_desc['steps'])

    mydatabase = data.database(run_desc['filename'], run_desc['dirname'], 1, 3,
                               comment)
    environment['purgatory'](environment['plot'].set_labels,
                             run_desc['xlabel'], run_desc['ylabel'],
                             run_desc['slabel'])

    environment['purgatory'](environment['plot'].set_mode,
                             pyextfigure.DUALTWODPLOT)

    try:
        run_desc['f_Xset'](run_desc['Xstart'])
        run_desc['f_Sset'](run_desc['Sstart'])
        time.sleep(2 * run_desc['pause'] + 1)

        Ssetval = run_desc['Sstart']

        while (((step <= MAX_STEPS) or run_desc['cycle?'] > 0.)
               and not STOP_FLAG):
            Xsetval = (run_desc['Xend'] - run_desc['Xstart']) * (
                1.0 * step) / MAX_STEPS + run_desc['Xstart']
            run_desc['f_Xset'](Xsetval)
            run_desc['f_Sset'](Ssetval)
            if (run_desc['pause'] > 0): time.sleep(run_desc['pause'])

            if (run_desc['f_Xread']):
                Xreadval = run_desc['f_Xread']()
            else:
                Xreadval = Xsetval

            Yreadval = run_desc['f_Yread']() * run_desc['yscale']
            Sreadval = run_desc['f_Sread']()

            if ((Sreadval > run_desc['Ssetpoint'] / 2)
                    and (Sreadval < 2 * run_desc['Ssetpoint'])):
                Ssetval = Ssetval + run_desc['igain'] * (
                    run_desc['Ssetpoint'] - Sreadval)

            mydatabase.add_data_point([Xreadval, Yreadval, Sreadval], datastep)
            datastep = datastep + 1

            environment['purgatory'](environment['plot'].add_point, Xreadval,
                                     Yreadval, Sreadval)
            environment['purgatory'](environment['plot'].repaint)

            if (step % (MAX_STEPS / 100 + 1) == 0):
                environment['purgatory'](
                    environment['progressbar'].set_fraction,
                    (1.0 * step) / MAX_STEPS)

            step = step + increment
            if (((step == MAX_STEPS) or (step == 0))
                    and (run_desc['cycle?'] > 0.)):
                increment = -increment

            while PAUSE_FLAG:
                time.sleep(0.1)

    finally:
        if ((run_desc['finishat'] <= max(run_desc['Xstart'], run_desc['Xend']))
                and (run_desc['finishat'] >= min(run_desc['Xstart'],
                                                 run_desc['Xend']))):
            run_desc['f_Xset'](run_desc['finishat'])
        else:
            print "SAFETY CHECK: Finish at out of bounds. Ignoring"

    return mydatabase
Beispiel #30
0
	def editentity(self, name):
		database = data.database(dungeonmap.entityfolder, name)
		entityeditor.editors[database.get("type", dungeonmap.entitytypes[0])](name, self)
Beispiel #31
0
def kernel_WireBreak2(run_desc, environment):
    # Define two helpers
    def measure_background(run_desc):
        Izero = run_desc['I offset']
        data = []
        for i in range(50):
            if STOP_FLAG:
                break
            V = i * run_desc['Vsafe']/50.0
            run_desc['f_set'](V)
            time.sleep(run_desc['pause'])
            I = run_desc['f_read']() * run_desc['iscale'] - Izero
            data.append([I, V])
            run_desc['mydatabase'].add_data_point([V, I], run_desc['step'])
            run_desc['step'] = run_desc['step'] + 1
            
        fit = linear_fit(numarray.array(data))
        return (fit[0], fit[1], fit[2], fit[3])

    def get_wire_res(run_desc, V, Rzero, Vzero):
        Inow = run_desc['f_read']() * run_desc['iscale'] - run_desc['I offset']
        run_desc['mydatabase'].add_data_point([V, Inow], run_desc['step'])
        run_desc['step'] = run_desc['step'] + 1
        
        if (Inow < 1e-9):
            print "Current too low (%g A at %g V), quitting!"%(Inow, V)
            return (-1, 1e12, 1e12)

        if ((V - Vzero)/Inow < 1.0 + Rzero):
            Rzero = (V - Vzero)/Inow - 1.0
            print "Readjusting resistance of leads to %g"%(Rzero)
        
        Rnow = (V - Vzero)/Inow - Rzero

        if (Rzero < 0 or Rnow < 1):
            print "Negative resistance (imprecise offset correction?), quitting!"
            return (-1, 1, 0)
        else:
            return (0, Rnow, Rzero)

    # ACTUAL CODE STARTS HERE

    comment = "Wirebreak2 data. Setting %s, reading %s. The break rate is set to %.2g, small and large step to %.2g and %.2g. Safe value is %.2g, max value is %.2g"%(run_desc['xlabel'], run_desc['ylabel'], run_desc['rate'], run_desc['smallstep'], run_desc['bigstep'], run_desc['Vsafe'], run_desc['Vmax'])

    run_desc.update({'step' : 0, 'mydatabase' : data.database(run_desc['filename'], run_desc['dirname'], 1, 2, comment)})
    environment['purgatory'](environment['plot'].set_labels,
                             run_desc['xlabel'], run_desc['ylabel'], '')
    environment['purgatory'](environment['plot'].set_mode, pyextfigure.TWODPLOT)
    tempsafeV = run_desc['Vsafe']

    try:
        [Vzero, Rzero, sigmaVzero, sigmaRzero] = measure_background(run_desc)
        print "Voltage offset is %g (+- %g)"%(Vzero, sigmaVzero)
        print "Leads resistance is %g (+- %g)"%(Rzero, sigmaRzero)

        Rzero = Rzero - 1.0 # Wire has less than an ohm, assume an ohm
        if run_desc['Rzero'] > .1:
            Rzero = run_desc['Rzero']
            print "Overriding leads resistance to %f"%(Rzero)
        Vnow = run_desc['Vsafe'] # start at safe V
	updateV = 1
        lastdata = []
    	START_TIME = time.time()
            
        print "BREAK STARTED"
        while (not STOP_FLAG):
            # set new voltage 
	    if (updateV == 1):
            	run_desc['f_set'](Vnow)
		updateV = 0
            	time.sleep(run_desc['pause'])

            # Measure wire resistance, taking care of offsetts
            [status, Rnow, Rzero] = get_wire_res(run_desc, Vnow, Rzero, Vzero)
            if (status == -1): break
                    
            environment['purgatory'](environment['plot'].add_point, Vnow, math.log10(Rnow), 1.0)
            environment['purgatory'](environment['plot'].repaint)
                
            # Are we done?
            if (Rnow + Rzero > run_desc['target']):
                print "Exceeded target (Wire %g Ohm, Leads %g), quitting!"%(Rnow, Rzero)
                break

            # If something crazy happened, reset data, and ramp back quite a bit
            if ((len(lastdata) > 1) and (abs(math.log10(Rnow) - lastdata[len(lastdata) - 1][1]) > .3)):
                print "Jump in data, restarting fit"
                Vnow = tempsafeV
                tempsafeV = (tempsafeV + run_desc['Vsafe'])/2
                lastdata = []
		updateV = 1
                continue

            # Add data point, shifting old data out if needed
            lastdata.append([time.time() - START_TIME, math.log10(Rnow)])
            if ((lastdata[len(lastdata) - 1][0] - lastdata[0][0]) < .2): 
		continue
            while ((lastdata[len(lastdata) - 1][0] - lastdata[0][0]) > .5): 
		lastdata = lastdata[1:]

            # Find out the rate of change
            [a, rate, sigma_a, sigma_rate]  = linear_fit(numarray.array(lastdata))
            
            # Are we good?
            if ((rate > .1 * run_desc['rate']) and (rate < run_desc['rate'])):
                continue

            # Nope, what should we do?
            if ((rate < .01 * run_desc['rate']) and (Vnow < run_desc['Vmax'])):
                tempsafeV = (.9 * Vnow + 3.0*tempsafeV)/4.0
                Vnow = Vnow + run_desc['bigstep']
            elif ((rate < .1 * run_desc['rate']) and (Vnow < run_desc['Vmax'])):
                Vnow = Vnow + run_desc['smallstep']
            elif (rate > run_desc['rate'] + 3.0 * sigma_rate):
                Vnow = tempsafeV + (Vnow - tempsafeV) * (10.0/((rate/run_desc['rate'])**2 + 10.0))
                tempsafeV = (tempsafeV + run_desc['Vsafe'])/2

            # voltage change, reset data
	    updateV = 1
            lastdata = []
                
    finally:
        run_desc['f_set'](0.0)

    return run_desc['mydatabase']
Beispiel #32
0
	def __init__(self, entity, entitieswindow):
		editor.__init__(self, entity, width=500, height=500, scrollbar=True)
		
		self.entity = entity
		self.entitieswindow = entitieswindow
		
		self.database = data.database("entities", self.entity)
		
		largefontsize = 20
		numboxwidth = 20
		
		abilitywidth = 30

		# Images
		
		self.imgdrawer = drawer(self, "Images")
		
		self.imgdrawer.pack(label(self, "icon"))
		
		icon = picturebox(self, os.path.join(dungeonmap.entityimgfolder, entity), "icon.png", size=dungeonmap.actualentitysize)
		self.imgdrawer.pack(icon)
		
		self.imgdrawer.pack(label(self, "view from front"))
		
		front = picturebox(self, os.path.join(dungeonmap.entityimgfolder, entity), "front.png", size=dungeonmap.actualentitysize)
		self.imgdrawer.pack(front)
		
		self.imgdrawer.pack(label(self, "view from back"))
		
		back = picturebox(self, os.path.join(dungeonmap.entityimgfolder, entity), "back.png", size=dungeonmap.actualentitysize)
		self.imgdrawer.pack(back)
		
		self.imgdrawer.pack(label(self, "view from left"))
		
		left = picturebox(self, os.path.join(dungeonmap.entityimgfolder, entity), "left.png", size=dungeonmap.actualentitysize)
		self.imgdrawer.pack(left)
		
		self.imgdrawer.pack(label(self, "view from right"))
		
		right = picturebox(self, os.path.join(dungeonmap.entityimgfolder, entity), "right.png", size=dungeonmap.actualentitysize)
		self.imgdrawer.pack(right)
		
		self.pack(self.imgdrawer)
		
		# Details
		
		self.detailsdrawer = drawer(self, "Details")
		
		l = label(self, "full name: ")
		self.detailsdrawer.pack(l)

		name = entry(self, 100)
		self.detailsdrawer.pack(name)
		self.link(name, "fullname", entity)
		
		l = label(self, "class: ")
		self.detailsdrawer.pack(l)
		
		classentry = entry(self, 100)
		self.detailsdrawer.pack(classentry)
		self.link(classentry, "class", "")
		
		l = label(self, "level: ")
		self.detailsdrawer.pack(l)
		
		lvl = entry(self, 50, numbers=True)
		self.detailsdrawer.pack(lvl)
		self.link(lvl, "level", "0")
		
		l = label(self, "race: ")
		self.detailsdrawer.pack(l)
		
		race = entry(self, 100)
		self.detailsdrawer.pack(race)
		self.link(race, "race", "")
		
		l = label(self, "alignment: ")
		self.detailsdrawer.pack(l)
		
		alignment = entry(self, 100)
		self.detailsdrawer.pack(alignment)
		self.link(alignment, "alignment", "")

		self.pack(self.detailsdrawer)
		
		# Hit Points
		
		self.hpdrawer = drawer(self, "Hit Points")
		
		l = label(self, "total hp: ")
		l.width = 50
		self.hpdrawer.pack(l)
		
		hp = entry(self, numboxwidth, numbers=True)
		self.hpdrawer.pack(hp, "right")
		self.link(hp, "hit points", "0")
		
		self.pack(self.hpdrawer)
		
		# Abilities
		
		self.abilitydrawer = drawer(self, "Ability Scores")
		
		l = label(self, "")
		l.width = 20
		self.abilitydrawer.pack(l)
		
		l = label(self, "score")
		l.width = abilitywidth
		self.abilitydrawer.pack(l, "right")
		
		l = label(self, "base")
		l.width = abilitywidth
		self.abilitydrawer.pack(l, "right")
		
		l = label(self, "race")
		l.width = abilitywidth
		self.abilitydrawer.pack(l, "right")
		
		l = label(self, "magic")
		l.width = abilitywidth
		self.abilitydrawer.pack(l, "right")
		
		l = label(self, "misc")
		l.width = abilitywidth
		self.abilitydrawer.pack(l, "right")
		
		l = label(self, "misc")
		l.width = abilitywidth
		self.abilitydrawer.pack(l, "right")
		
		l = label(self, "modifier")
		l.width = abilitywidth
		self.abilitydrawer.pack(l, "right")
		
		saveabilities = {}
		self.abilitymodifiers = {}
		
		for ability in ["str","dex","con","int","wis","cha"]:
			abilitylabel = label(self, ability)
			abilitylabel.width = 20
			self.abilitydrawer.pack(abilitylabel)
			
			total = entry(self, numboxwidth, numbers=True)
			self.abilitydrawer.pack(total, "right")
			self.link(total, ability+" total", 10)
			
			self.abilitydrawer.pack(label(self, "="), "right")
			
			base = entry(self, numboxwidth, numbers=True)
			self.abilitydrawer.pack(base, "right")
			self.link(base, ability+" base", 10)
			
			self.abilitydrawer.pack(label(self, "+"), "right")
			
			race = entry(self, numboxwidth, numbers=True)
			self.abilitydrawer.pack(race, "right")
			self.link(race, ability+" race", 0)
			
			self.abilitydrawer.pack(label(self, "+"), "right")
			
			enhancement = entry(self, numboxwidth, numbers=True)
			self.abilitydrawer.pack(enhancement, "right")
			self.link(enhancement, ability+" enhancement", 0)
			
			self.abilitydrawer.pack(label(self, "+"), "right")
			
			miscplus = entry(self, numboxwidth, numbers=True)
			self.abilitydrawer.pack(miscplus, "right")
			self.link(miscplus, ability+" misc plus", 0)
			
			self.abilitydrawer.pack(label(self, "-"), "right")
			
			miscminus = entry(self, numboxwidth, numbers=True)
			self.abilitydrawer.pack(miscminus, "right")
			self.link(miscminus, ability+" misc minus", 0)
			
			self.abilitydrawer.pack(label(self, "|"), "right")
			
			modifier = entry(self, numboxwidth, numbers=True)
			self.abilitydrawer.pack(modifier, "right")
			self.link(modifier, ability+" modifier", 0)
			
			self.function(self.abilityscore, [base, race, enhancement, miscplus, miscminus], total)
			self.function(self.abilitymodifier, [total], modifier)
			
			self.abilitymodifiers[ability] = modifier
			if ability == "con":
				saveabilities["fort"] = modifier
			elif ability == "dex":
				saveabilities["ref"] = modifier
			elif ability == "wis":
				saveabilities["will"] = modifier
				
		self.pack(self.abilitydrawer)
		
		# Combat Options
		
		self.weaponsdrawer = drawer(self, "Combat Options")
		
		l = label(self, "base attack bonus: ")
		self.weaponsdrawer.pack(l)
		
		bab = entry(self, numboxwidth, numbers=True)
		self.weaponsdrawer.pack(bab, "right")
		self.link(bab, "base attack bonus", "0")

		l = label(self, "weapon")
		l.width = 100
		self.weaponsdrawer.pack(l)
		
		l = label(self, "attack")
		l.width = 40
		self.weaponsdrawer.pack(l, "right")
		
		l = label(self, "damage")
		l.width = 50
		self.weaponsdrawer.pack(l, "right")
		
		l = label(self, "crit")
		l.width = 50
		self.weaponsdrawer.pack(l, "right")
				
		for weapon in range(4):
			weaponname = entry(self, 100)
			self.weaponsdrawer.pack(weaponname)
			self.link(weaponname, "weapon "+str(weapon), "")
			
			attack = entry(self, 40, numbers=True)
			self.weaponsdrawer.pack(attack, "right")
			self.link(attack, "weapon attack "+str(weapon), 0)
			
			dmg = entry(self, 50)
			self.weaponsdrawer.pack(dmg, "right")
			self.link(dmg, "weapon damage "+str(weapon), "")
			
			crit = entry(self, 50)
			self.weaponsdrawer.pack(crit, "right")
			self.link(crit, "weapon crit "+str(weapon), "")
		
		self.pack(self.weaponsdrawer)
		
		# Speed
		
		self.speeddrawer = drawer(self, "Speed")
		
		l = label(self, "speed: ")
		l.width = 50
		self.speeddrawer.pack(l)
		
		speed = entry(self, 50, numbers=True)
		self.speeddrawer.pack(speed, "right")
		self.link(speed, "speed", "0")
		
		l = label(self, "initiative: ")
		l.width = 50
		self.speeddrawer.pack(l)
		
		init = entry(self, 50, numbers=True)
		self.speeddrawer.pack(init, "right")
		self.link(init, "initiative", "0")
		
		self.pack(self.speeddrawer)
		
		# Grapple
		
		self.grappledrawer = drawer(self, "Grapple")
		
		l = label(self, "grapple: ")
		l.width = 50
		self.grappledrawer.pack(l)
		
		grapple = entry(self, 50, numbers=True)
		self.grappledrawer.pack(grapple, "right")
		self.link(grapple, "grapple", "0")
		
		self.pack(self.grappledrawer)
		
		# Saving Throws
		
		self.savedrawer = drawer(self, "Saving Throws")
		
		l = label(self, "")
		l.width = 20
		self.savedrawer.pack(l)
		
		l = label(self, "total")
		l.width = abilitywidth
		self.savedrawer.pack(l, "right")
		
		l = label(self, "base")
		l.width = abilitywidth
		self.savedrawer.pack(l, "right")
		
		l = label(self, "ability")
		l.width = abilitywidth
		self.savedrawer.pack(l, "right")
		
		l = label(self, "magic")
		l.width = abilitywidth
		self.savedrawer.pack(l, "right")
		
		l = label(self, "misc")
		l.width = abilitywidth
		self.savedrawer.pack(l, "right")
		
		l = label(self, "misc")
		l.width = abilitywidth
		self.savedrawer.pack(l, "right")

		for save in ["fort", "ref", "will"]:
			abilitylabel = label(self, save)
			abilitylabel.width = 20
			self.savedrawer.pack(abilitylabel)
			
			total = entry(self, numboxwidth, numbers=True)
			self.savedrawer.pack(total, "right")
			self.link(total, save+" total", 0)
			
			self.savedrawer.pack(label(self, "="), "right")
			
			base = entry(self, numboxwidth, numbers=True)
			self.savedrawer.pack(base, "right")
			self.link(base, save+" base", 0)
			
			self.savedrawer.pack(label(self, "+"), "right")
			
			ability = entry(self, numboxwidth, numbers=True)
			self.savedrawer.pack(ability, "right")
			self.link(ability, save+" ability", 0)
					
			self.savedrawer.pack(label(self, "+"), "right")
			
			magic = entry(self, numboxwidth, numbers=True)
			self.savedrawer.pack(magic, "right")
			self.link(magic, save+" magic", 0)
			
			self.savedrawer.pack(label(self, "+"), "right")
			
			miscplus = entry(self, numboxwidth, numbers=True)
			self.savedrawer.pack(miscplus, "right")
			self.link(miscplus, save+" misc plus", 0)
					
			self.savedrawer.pack(label(self, "-"), "right")
			
			miscminus = entry(self, numboxwidth, numbers=True)
			self.savedrawer.pack(miscminus, "right")
			self.link(miscminus, save+" misc minus", 0)
			
			self.function(self.savescore, [base, ability, magic, miscplus, miscminus], total)
			self.function(self.same, [saveabilities[save]], ability)
			
		self.pack(self.savedrawer)
		
		# Armor
		
		self.armordrawer = drawer(self, "Armor")
		
		l = label(self, "total")
		l.width = abilitywidth
		self.armordrawer.pack(l)
		
		l = label(self, "")
		l.width = abilitywidth
		self.armordrawer.pack(l, "right")
		
		l = label(self, "armor")
		l.width = abilitywidth
		self.armordrawer.pack(l, "right")
		
		l = label(self, "shield")
		l.width = abilitywidth
		self.armordrawer.pack(l, "right")
		
		l = label(self, "dex")
		l.width = abilitywidth
		self.armordrawer.pack(l, "right")
		
		l = label(self, "size")
		l.width = abilitywidth
		self.armordrawer.pack(l, "right")
		
		l = label(self, "natrl")
		l.width = abilitywidth
		self.armordrawer.pack(l, "right")
		
		l = label(self, "deflect")
		l.width = abilitywidth
		self.armordrawer.pack(l, "right")
		
		l = label(self, "misc")
		l.width = abilitywidth
		self.armordrawer.pack(l, "right")
		
		l = label(self, "misc")
		l.width = abilitywidth
		self.armordrawer.pack(l, "right")
		
		total = entry(self, numboxwidth, numbers=True)
		self.armordrawer.pack(total)
		self.link(total, "AC total", 10)
		
		self.armordrawer.pack(label(self, "="), "right")
		
		l = label(self, "10")
		l.width = numboxwidth
		self.armordrawer.pack(l, "right")

		self.armordrawer.pack(label(self, "+"), "right")
		
		armor = entry(self, numboxwidth, numbers=True)
		self.armordrawer.pack(armor, "right")
		self.link(armor, "AC armor", 0)
		
		self.armordrawer.pack(label(self, "+"), "right")
				
		shield = entry(self, numboxwidth, numbers=True)
		self.armordrawer.pack(shield, "right")
		self.link(shield, "AC shield", 0)
		
		self.armordrawer.pack(label(self, "+"), "right")
				
		dex = entry(self, numboxwidth, numbers=True)
		self.armordrawer.pack(dex, "right")
		self.link(dex, "AC dex", 0)
		self.function(self.same, [self.abilitymodifiers["dex"]], dex)
		
		self.armordrawer.pack(label(self, "+"), "right")
				
		size = entry(self, numboxwidth, numbers=True)
		self.armordrawer.pack(size, "right")
		self.link(size, "AC size", 0)
		
		self.armordrawer.pack(label(self, "+"), "right")
				
		natural = entry(self, numboxwidth, numbers=True)
		self.armordrawer.pack(natural, "right")
		self.link(natural, "AC natural", 0)
		
		self.armordrawer.pack(label(self, "+"), "right")
				
		deflection = entry(self, numboxwidth, numbers=True)
		self.armordrawer.pack(deflection, "right")
		self.link(deflection, "AC deflection", 0)
		
		self.armordrawer.pack(label(self, "+"), "right")
		
		miscplus = entry(self, numboxwidth, numbers=True)
		self.armordrawer.pack(miscplus, "right")
		self.link(miscplus, "AC misc plus", 0)
		
		self.armordrawer.pack(label(self, "-"), "right")
				
		miscminus = entry(self, numboxwidth, numbers=True)
		self.armordrawer.pack(miscminus, "right")
		self.link(miscminus, "AC misc minus", 0)
		
		self.function(self.armorclass, [armor, shield, dex, size, natural, deflection, miscplus, miscminus], total)

		l = label(self, "touch: ")
		l.width = 50
		self.armordrawer.pack(l)
		
		touch = entry(self, 100, numbers=True)
		self.armordrawer.pack(touch, "right")
		self.link(touch, "AC touch", 10)
		
		self.function(self.toucharmorclass, [armor, shield, dex, size, natural, deflection, miscplus, miscminus], touch)
		
		l = label(self, "flat-footed: ")
		l.width = 50
		self.armordrawer.pack(l)
		
		flat = entry(self, 100, numbers=True)
		self.armordrawer.pack(flat, "right")
		self.link(flat, "AC flatfooted", 10)
		
		self.function(self.flatarmorclass, [armor, shield, dex, size, natural, deflection, miscplus, miscminus], flat)
		
		l = label(self, "")
		l.width = 50
		self.armordrawer.pack(l)
				
		l = label(self, "type")
		l.width = 100
		self.armordrawer.pack(l, "right")
		
		l = label(self, "max dex")
		l.width = 50
		self.armordrawer.pack(l, "right")
				
		l = label(self, "armor check")
		l.width = 70
		self.armordrawer.pack(l, "right")
				
		l = label(self, "weight")
		l.width = 50
		self.armordrawer.pack(l, "right")
		
		for armortype in ["armor", "shield"]:
			l = label(self, armortype)
			l.width = 50
			self.armordrawer.pack(l)
			
			nametype = entry(self, 100)
			self.armordrawer.pack(nametype, "right")
			self.link(nametype, armortype + " type", "")
			
			maxdex = entry(self, 50, numbers=True)
			self.armordrawer.pack(maxdex, "right")
			self.link(maxdex, armortype + " max dex", 0)
			
			acpenalty = entry(self, 70, numbers=True)
			self.armordrawer.pack(acpenalty, "right")
			self.link(acpenalty, armortype + " armor check penalty", 0)
			
			weight = entry(self, 50, numbers=True)
			self.armordrawer.pack(weight, "right")
			self.link(weight, armortype + " weight", 0)
		
		self.pack(self.armordrawer)
		
		# XP / Money
		
		self.moneydrawer = drawer(self, "XP / Money")
		
		l = label(self, "XP: ")
		l.width = 50
		self.moneydrawer.pack(l)
		
		xp = entry(self, 100, numbers=True)
		self.moneydrawer.pack(xp, "right")
		self.link(xp, "xp", 0)
		
		l = label(self, "Gold: ")
		l.width = 50
		self.moneydrawer.pack(l)
		
		gold = entry(self, 100, numbers=True)
		self.moneydrawer.pack(gold, "right")
		self.link(gold, "gp", 0)
		
		l = label(self, "gp")
		self.moneydrawer.pack(l, "right")
		
		self.pack(self.moneydrawer)
		
		# Skills
		
		self.skillsdrawer = drawer(self, "Skills")
		
		self.skillsdrawer.pack(label(self, "Skills", fontsize=largefontsize))
				
		l = label(self, "skill name")
		l.width = 150
		self.skillsdrawer.pack(l)
		
		l = label(self, "abil")
		l.width = 30
		self.skillsdrawer.pack(l, "right")
		
		l = label(self, "modif")
		l.width = abilitywidth
		self.skillsdrawer.pack(l, "right")
		
		l = label(self, "ranks")
		l.width = abilitywidth
		self.skillsdrawer.pack(l, "right")
		
		l = label(self, "abil")
		l.width = abilitywidth
		self.skillsdrawer.pack(l, "right")
		
		l = label(self, "misc")
		l.width = abilitywidth
		self.skillsdrawer.pack(l, "right")
		
		l = label(self, "misc")
		l.width = abilitywidth
		self.skillsdrawer.pack(l, "right")
		
		for skill, ability in skills:
			l = label(self, skill)
			l.width = 150
			self.skillsdrawer.pack(l)
			
			l = label(self, ability)
			l.width = 30
			self.skillsdrawer.pack(l, "right")
			
			total = entry(self, numboxwidth, numbers=True)
			self.skillsdrawer.pack(total, "right")
			self.link(total, skill + " total", 0)
			
			self.skillsdrawer.pack(label(self, "="), "right")
			
			ranks = entry(self, numboxwidth, numbers=True)
			self.skillsdrawer.pack(ranks, "right")
			self.link(ranks, skill + " ranks", 0)
			
			self.skillsdrawer.pack(label(self, "+"), "right")
			
			abil = entry(self, numboxwidth, numbers=True)
			self.skillsdrawer.pack(abil, "right")
			self.link(abil, skill + " ability", 0)
			
			self.skillsdrawer.pack(label(self, "+"), "right")
			
			miscplus = entry(self, numboxwidth, numbers=True)
			self.skillsdrawer.pack(miscplus, "right")
			self.link(miscplus, skill + " misc plus", 0)
			
			self.skillsdrawer.pack(label(self, "-"), "right")

			miscminus = entry(self, numboxwidth, numbers=True)
			self.skillsdrawer.pack(miscminus, "right")
			self.link(miscminus, skill + " misc minus", 0)
			
			self.function(self.same, [self.abilitymodifiers[ability]], abil)
			self.function(self.skill, [ranks, abil, miscplus, miscminus], total)
		
		self.pack(self.skillsdrawer)
		
		# Special Abilities
		
		self.specialdrawer = drawer(self, "Special Abilities")
		
		features = listbox(self, "racial traits/class features", [])
		self.specialdrawer.pack(features)
		self.link(features, "racial traits class features", [])
		
		self.pack(self.specialdrawer)
		
		# Possessions
		
		self.possessionsdrawer = drawer(self, "Possessions")

		onperson = listbox(self, "Possessions on person", [])
		self.possessionsdrawer.pack(onperson)
		self.link(onperson, "possessions on person", [])
		
		offperson = listbox(self, "Possessions off person", [])
		self.possessionsdrawer.pack(offperson)
		self.link(offperson, "possessions off person", [])
				
		self.pack(self.possessionsdrawer)
		
		# Magic
		
		self.magicdrawer = drawer(self, "Magic")
		
		self.magicdrawer.pack(label(self, "In order to use magic you must first unlock the achievement"))
		
		self.pack(self.magicdrawer)
Beispiel #33
0
def kernel_TimeDepScan(run_desc, environment):
    xstep = 0
    comment = "Time Dependence Scan. Measuring %s and %s for %.2g secs every %.2g secs. Impulse provided by %s, which was set at %.2g for %.2g, at %.2g for %.2g and then set at %.2g for duration of measurment." % (
        run_desc['y1label'], run_desc['y2label'], run_desc['meastime'],
        run_desc['interval'], run_desc['impulselabel'], run_desc['hysttop'],
        run_desc['hysttopwait'], run_desc['hystbot'], run_desc['hystbotwait'],
        run_desc['measureat'])

    mydatabase = data.database(run_desc['filename'], run_desc['dirname'], 1, 3,
                               comment)
    environment['purgatory'](environment['plot'].set_labels,
                             run_desc['xlabel'], run_desc['y1label'],
                             run_desc['y2label'])
    if (run_desc['f_Y2read']):
        environment['purgatory'](environment['plot'].set_mode,
                                 pyextfigure.DUALTWODPLOT)
    else:
        environment['purgatory'](environment['plot'].set_mode,
                                 pyextfigure.TWODPLOT)

    try:
        if run_desc['f_Xset']:
            run_desc['f_Xset'](run_desc['hysttop'])
            time.sleep(run_desc['hysttopwait'])
            run_desc['f_Xset'](run_desc['hystbot'])
            time.sleep(run_desc['hystbotwait'])
            run_desc['f_Xset'](run_desc['measureat'])

        STARTTIME = time.time()
        if (run_desc['pause'] > 0): time.sleep(run_desc['pause'])

        while ((time.time() - STARTTIME < run_desc['meastime'])
               and not STOP_FLAG):
            readval1 = run_desc['f_Y1read']() * run_desc['y1scale']
            if (run_desc['f_Y2read']):
                readval2 = run_desc['f_Y2read']() * run_desc['y2scale']
            else:
                readval2 = 0.0

            timenow = time.time() - STARTTIME
            mydatabase.add_data_point([timenow, readval1, readval2], xstep)
            xstep = xstep + 1
            time.sleep(run_desc['interval'])

            environment['purgatory'](environment['plot'].add_point, timenow,
                                     readval1, readval2)
            environment['purgatory'](environment['plot'].repaint)

            environment['purgatory'](environment['progressbar'].set_fraction, \
                                         min(1.0, (1.0 * timenow)/run_desc['meastime']))

            while PAUSE_FLAG:
                time.sleep(0.1)

    finally:
        if (run_desc['f_Xset']):
            if ((run_desc['finishat'] <= max(run_desc['Xstart'],
                                             run_desc['Xend']))
                    and (run_desc['finishat'] >= min(run_desc['Xstart'],
                                                     run_desc['Xend']))):
                run_desc['f_Xset'](run_desc['finishat'])
            else:
                print "SAFETY CHECK: Finish at out of bounds. Ignoring"

    return mydatabase
Beispiel #34
0
import nvidia
import data
import matplotlib.pyplot as plt
import seaborn as sns
from preprocess import preprocess
import cv2
import numpy as np

model = nvidia.model_x()
model.summary()
model.load_weights('model.h5')
plot_model(model, show_shapes=True, show_layer_names=True, to_file='report/model.png')


# data distribution
db = data.database()
d_plot = sns.distplot(db['angle'])
d_plot.get_figure().savefig('report/data_dist.png')

print(len(db))

test_image = 'images/run4/IMG/center_2017_03_19_22_39_31_990.jpg'
img = cv2.imread(test_image)
p_img = preprocess(img)
mp_img = cv2.flip(p_img, 1)

cv2.imwrite('report/original_sample.jpg', img)
cv2.imwrite('report/preprocessed_sample.jpg', np.uint8(p_img * 255))
cv2.imwrite('report/mirrored_sample.jpg', np.uint8(mp_img * 255))
cv2.imwrite('report/inv_preprocessed_sample.jpg', np.uint8((1 - p_img) * 255))
cv2.imwrite('report/inv_mirrored_sample.jpg', np.uint8((1 - mp_img) * 255))
Beispiel #35
0
	def finishchangetype(self, entity, entitytype):
		database = data.database(dungeonmap.entityfolder, entity)
		database.set("type", entitytype)
		database.write()