def self_output(self, x, y): if (self.skill_type == 1): pygame.draw.rect(op.screen, [150, 0, 0], [x + 20, y, 40, 20], 0) op.write("摸鱼", x + 60, y + 1, 18, [255, 255, 255]) if (self.skill_type == 2): pygame.draw.rect(op.screen, [0, 0, 150], [x + 20, y, 40, 20], 0) op.write("肝题", x + 60, y + 1, 18, [255, 255, 255])
def ReadOTP(self, log, plantype): '''Opens and parses a file in OTP DICOM format''' global DCMplan, Technique Technique = plantype beam_count = 0 # define options for opening or saving DICOM file self.file_opt = options = {} options['defaultextension'] = '.DCM' options['filetypes'] = [('OTP DICOM', 'RP*.dcm'), ('all files', '.*')] options[ 'title'] = 'Select DICOM file from OTP' # File types to select in file open dialog #options['initialdir'] = '..\plans' options['initialdir'] = 'C:\\OTP_DATA\DICOM\ExportTemp' #options['initialfile'] = 'myfile.txt' #options['parent'] = root OTPfile = self.askopenfilename() try: # use read_file method from dicom module to import plan into DCMplan object DCMplan = dicom.read_file(OTPfile) except: tkMessageBox.showwarning("Open file", "Cannot open this file\n(%s)" % filename) # extract patient/plan identifiers self.PatientsName = DCMplan.PatientsName self.PatientID = DCMplan.PatientID self.Approval = DCMplan.ApprovalStatus self.PlanID = DCMplan.RTPlanName self.NumBeams = DCMplan.FractionGroups[0].NumberofBeams self.NumFractions = DCMplan.FractionGroups[0].NumberofFractionsPlanned # Clear previous plan info from log window log.config(state=NORMAL) log.delete(1.0, END) log.config(state=DISABLED) #message = "Patient: %s\nID: %s" % (self.PatientsName,self.PatientID) #output.write(message,"Heading",log) #message = "Plan: %s\nBeams: %i" % (self.PlanID,self.NumBeams) #output.write(message,"Heading",log) # Load Beams from DICOM file for beam in DCMplan.Beams: new_beam = DCMBeam(beam, beam_count) beam_count += 1 self.Beams.append(new_beam) output.write(beam.BeamName, "PASS", log) return (self.PatientsName, self.PatientID, self.PlanID)
def login(): output.write(request) resp = make_response( render_template("login.jinja2", hostname=conf.get("bighp", "hostname", fallback=""), ip_address=conf.get("bighp", "ip_address", fallback=""))) resp = utils.set_login_headers(resp) jsession_id = "".join('%02x' % random.randint(0, 255) for _ in range(16)).upper() resp.headers.set( "Set-Cookie", "JSESSIONID=" + jsession_id + "; Path=/tmui; Secure; HttpOnly") return resp
def self_output(self, x, y): tot = len(pl.player_in_game) for i in range(1, tot + 1): tx = (i - (i > pl.gamer_pos and pl.gamer_pos != -1)) * 1000 / ( tot + (pl.gamer_pos == -1)) ty = max(130, 0.001 * tx * tx - 1 * tx + 350) tx -= 60 ty -= 80 for item in pl.player_in_game: if (item.seat == i - 1 and item.pos != self.pos): op.write("飞雷神×" + str(0 + self.mark_pos[item.pos]), tx + 95, ty + 170, 20, [200, 200, 0]) op.write("距离-" + str(0 + max(self.mark_pos)), x + 100, y - 60, 25, [200, 150, 50])
def send_frame(self): serial_array = [] serial_array.append(self.START_CHAR) frame = self.limit_brightness() for x, colors in enumerate(frame): serial_array.append("{0:0>3}{1:0>3}{2:0>3}{3:0>3}".format(x, colors[0], colors[1], colors[2])) serial_array.append(self.END_CHAR) output.write("".join(serial_array)) self.frame_delay()
def OnLloadBtnClick(self,plantype): global Technique Technique = plantype # Clear previous info from result log window self.passLog.config(state=NORMAL) self.passLog.delete(1.0, END) self.passLog.config(state=DISABLED) self.failLog.config(state=NORMAL) self.failLog.delete(1.0, END) self.failLog.config(state=DISABLED) # Reset info label self.label.config(bg='light cyan',fg='black') self.labelVariable.set("Loading LANTIS Plan") output.write("Loading Lantis plan","INFO",self.passLog) self.LPlan = data.Plan() LResult = self.LPlan.ReadLantis(self.RTPlog,Technique) self.lpatname.set(LResult[0]) self.lpatid.set(LResult[1]) self.lplanid.set(LResult[2]) self.labelVariable.set("Lantis Plan Loaded") output.write("Lantis plan loaded","INFO",self.passLog)
def OnLloadBtnClick(self, plantype): global Technique Technique = plantype # Clear previous info from result log window self.passLog.config(state=NORMAL) self.passLog.delete(1.0, END) self.passLog.config(state=DISABLED) self.failLog.config(state=NORMAL) self.failLog.delete(1.0, END) self.failLog.config(state=DISABLED) # Reset info label self.label.config(bg='light cyan', fg='black') self.labelVariable.set("Loading LANTIS Plan") output.write("Loading Lantis plan", "INFO", self.passLog) self.LPlan = data.Plan() LResult = self.LPlan.ReadLantis(self.RTPlog, Technique) self.lpatname.set(LResult[0]) self.lpatid.set(LResult[1]) self.lplanid.set(LResult[2]) self.labelVariable.set("Lantis Plan Loaded") output.write("Lantis plan loaded", "INFO", self.passLog)
def writeIntro(self, output): '''Write game intro. @type output: Output''' output.write(self.description, False) output.write('<h1>' + self.name + '</h1>', False) #output.write('by <b>' + self.author + '</b>', False) #output.write('Version ' + self.version, False) output.write(self.intro, False) self.actor.newLocation(output) output.close()
# Everything sent. Now do the calculations # ================================== pvals, qscores, pqvals, gene_indices = cpvalcomp(slave_geno, expr, qcal, shuffle=False) pvals = comm.gather(pvals, root=0) qscores = comm.gather(qscores, root=0) pqvals = comm.gather(pqvals, root=0) gene_indices = comm.gather(gene_indices, root=0) if rank == 0: pvals = np.vstack(pvals) #np.save(out_fileprefix, pvals) qscores = np.concatenate(qscores) pqvals = np.concatenate(pqvals) gene_indices_list = list() for x in gene_indices: gene_indices_list += x output.write(out_fileprefix, snpinfo, gene_names, pvals, qscores, pqvals, gene_indices_list) print("Job completed in {:g} seconds".format(time.time() - start_time)) else: assert gene_indices is None assert qscores is None assert pvals is None assert pqvals is None #print ("Done")
def solve_problem(filename): dataset = parse(filename) solution = solve(dataset) solution_file = write(solution, SUBMISSION_FILENAME)
# Compiler for C-- # Victor Manuel Fernandez Castro # May 22, 2014 import cparser import cfg import sys import regalloc import output from time import time if __name__ == '__main__': cparser.init(open('examples/example.cmm', 'r').read()) tStart = time() try: program = cparser.program() graphs = [cfg.gFunction(f) for f in program] output.write(graphs, 'examples/output.s') tEnd = time() print('Time:', tEnd - tStart, 'sec.') except SyntaxError as e: print('Syntax error at line', cparser.token0.line, 'near <', \ cparser.token0.string, '>', e, file = sys.stderr)
def self_output(self, x, y): if (self.limit == 1): pygame.draw.rect(op.screen, [150, 0, 0], [x + 20, y, 20, 20], 0) op.write(" 限", x + 40, y + 1, 18, [255, 255, 255])
alphas = np.array([30], dtype="float64") #alphas = np.array([0.005,0.1,0.5,1.5,1.0]) snp_index, best_betas, best_alpha = mlpack_lasso_cv(geno, expr, alphas) #print(snp_index) #snp_index = list() with open("pp.txt", "w") as output: for i, j in enumerate(snp_index): if j.shape[0] == 0: outputline = gene_names[i] + "\t" + "NA" else: outputline = gene_names[i] + "\t" + ",".join( [snpinfo[x].rsid for x in j]) output.write(outputline + "\n") with open("beta.txt", "w") as output1: for i in range(best_betas.shape[0]): writeline = " ".join([str(x) for x in best_betas[i, :]]) output1.write(writeline + "\n") print("time taken was :", time.time() - start_time) """ print("best lambdas were:",best_alpha) import matplotlib.pyplot as plt plt.figure() m_log_alphas = -np.log10(alphas) #ymin, ymax = 2300, 3800 plt.plot(m_log_alphas, mse_values, 'k', linewidth=2)
def check_beams(Plan1,Plan2,passLog,failLog): plan_mismatch = False output.write('\n\nBEAM CHECK','CheckHeading',passLog) for x in range(Plan1.NumBeams): #output.write('\n********************','INFO',passLog) output.write('\nBEAM \t %s' % Plan1.Beams[x].BeamName,'BeamHeading',passLog) output.write('Parameter\t\tLANTIS\t\tOTP','TabHeading',passLog) #output.write('********************\n','Heading',passLog) # Check for mismatch in Beam dictionaries. for key in Plan1.Beams[x].__dict__: # Initialise beam mismatch flag beam_mismatch = False # Compare parameter values if Plan1.Beams[x].__dict__[key] != Plan2.Beams[x].__dict__[key]: # Segment checking if key == "Segments": for k in range(Plan1.Beams[x].NumSegments): output.write('\nSegment: %i' % (k+1),'SegHeading',passLog) output.write('Parameter\t\tLANTIS\t\tOTP','TabHeading',passLog) for segkey in Plan1.Beams[x].Segments[k].__dict__: segment_mismatch = False if Plan1.Beams[x].Segments[k].__dict__[segkey] != Plan2.Beams[x].Segments[k].__dict__[segkey]: if segkey == "MLC": #for i in range(81): for i in range(41): logstring = ("MLC Pair %i\t\t[%0.2f %0.2f]\t\t[%0.2f %0.2f]" % (i+1,Plan1.Beams[x].Segments[k].MLC[i],Plan1.Beams[x].Segments[k].MLC[i+41], Plan2.Beams[x].Segments[k].MLC[i],Plan2.Beams[x].Segments[k].MLC[i+41])) if (fabs(Plan1.Beams[x].Segments[k].MLC[i] - round(Plan2.Beams[x].Segments[k].MLC[i],2)) > 0.011) or (fabs(Plan1.Beams[x].Segments[k].MLC[i+41] - round(Plan2.Beams[x].Segments[k].MLC[i+41],2)) > 0.011) : output.write('\nBEAM \t %s' % Plan1.Beams[x].BeamName,'BeamHeading',failLog) output.write('Parameter\t\tLANTIS\t\tOTP','TabHeading',failLog) output.write(logstring,'MLCFAIL',failLog) segment_mismatch = True else: output.write(logstring,'MLCPASS',passLog) else: segment_mismatch = True if (segkey != "MLC"): logstring = ("%s\t\t%s\t\t%s") %(segkey, Plan1.Beams[x].Segments[k].__dict__[segkey], Plan2.Beams[x].Segments[k].__dict__[segkey]) if not(segment_mismatch): output.write(logstring,'PASS',passLog) else: plan_mismatch = True output.write('\nBEAM \t %s' % Plan1.Beams[x].BeamName,'BeamHeading',failLog) output.write('Segment: %i' % (k+1),'SegHeading',failLog) output.write('Parameter\t\tLANTIS\t\tOTP','TabHeading',failLog) output.write(logstring,'FAIL',failLog) # If beam names don't fully match, but do partially match, then do nothing elif(key == 'BeamName' and Plan1.Beams[x].BeamName in Plan2.Beams[x].BeamName): pass elif(key == 'MLC'): for i in range(41): logstring = ("MLC Pair %i\t\t[%0.2f %0.2f]\t\t[%0.2f %0.2f]" % (i+1,Plan1.Beams[x].MLC[i],Plan1.Beams[x].MLC[i+41], Plan2.Beams[x].MLC[i],Plan2.Beams[x].MLC[i+41])) if (fabs(Plan1.Beams[x].MLC[i] - round(Plan2.Beams[x].MLC[i],2)) > 0.011) or (fabs(Plan1.Beams[x].MLC[i+41] - round(Plan2.Beams[x].MLC[i+41],2)) > 0.011) : #logstring = ("MLC Leaf Number %i\t\t%f\t\t%f\t\t%f" % (i,Plan1.Beams[x].Segments[k].MLC[i], Plan2.Beams[x].Segments[k].MLC[i],(fabs(Plan1.Beams[x].Segments[k].MLC[i] - round(Plan2.Beams[x].Segments[k].MLC[i],2))))) output.write('\nBEAM \t %s' % Plan1.Beams[x].BeamName,'BeamHeading',failLog) output.write('Parameter\t\tLANTIS\t\tOTP','TabHeading',failLog) output.write(logstring,'MLCFAIL',failLog) else: output.write(logstring,'MLCPASS',passLog) # for i in range(0,81): # # Run through MLC positions, check for differences exceeding rounding errors # if (fabs(Plan1.Beams[x].MLC[i] - round(Plan2.Beams[x].MLC[i],2)) > 0.011): # logstring = ("MLC Leaf Number %i: %f %f %f " % (i,Plan1.Beams[x].MLC[i], Plan2.Beams[x].MLC[i],(fabs(Plan1.Beams[x].MLC[i] - round(Plan2.Beams[x].MLC[i],2))))) # output.write(logstring,'FAIL',passLog) else: # Flag a mismatch and record which parameter failed in which beam beam_mismatch = True plan_mismatch = True if not(beam_mismatch) and not(key == "MLC"): logstring = ("%s\t\t%s\t\t%s") %(key, Plan1.Beams[x].__dict__[key], Plan2.Beams[x].__dict__[key]) output.write(logstring,'PASS',passLog) elif not(key =="MLC"): output.write('\nBEAM \t %s' % Plan1.Beams[x].BeamName,'BeamHeading',failLog) output.write('Parameter\t\tLANTIS\t\tOTP','TabHeading',failLog) logstring = ("%s\t\t%s\t\t%s") %(key, Plan1.Beams[x].__dict__[key], Plan2.Beams[x].__dict__[key]) output.write(logstring,'FAIL',failLog) if(plan_mismatch): return False else: return True
def not_found(e): output.write(request) path = request.path resp = make_response(render_template("404.jinja2", path=path), 404) resp = utils.set_root_headers(resp) return resp
def check_Px(LPlan, OTPPlan, passLog, failLog): Px_mismatch = False output.write('\nPRESCRIPTION CHECK\n', 'CheckHeading', passLog) LDoseFr = 0 # Lantis total dose per fraction OTPDoseFr = 0 # OTP total dose per fraction for i in range(0, LPlan.NumBeams): #print "Beam Number %i" %i LDoseFr += LPlan.Beams[i].Dose OTPDoseFr += OTPPlan.Beams[i].Dose OTPDoseTotal = OTPDoseFr * OTPPlan.NumFractions #print "Lantis dose/fr = %i" %LDoseFr #print "OTP Total dose = %i" %OTPDoseTotal # for prescription in LPlan.Prescriptions: #if (prescription.Site == LPlan.Site): # Check Lantis beam dose/fraction = Lantis Prescription dose/fraction if LDoseFr == LPlan.Prescription.DoseFraction: output.write( "Lantis dose/beam matches Prescription: %i %i" % (LDoseFr, LPlan.Prescription.DoseFraction), 'PASS', passLog) #print "Lantis Px dose matches %i %i" %(LDoseFr,LPlan.Prescriptions[0].DoseFraction) else: output.write( "Lantis dose/beam and Prescription mismatch: %i %i" % (LDoseFr, LPlan.Prescription.DoseFraction), 'FAIL', failLog) Px_mismatch = True # Check OTP beam dose/fraction = Lantis Prescription dose/fraction if OTPDoseFr == LPlan.Prescription.DoseFraction: output.write( "OTP dose/beam matches Prescription: %i %i" % (OTPDoseFr, LPlan.Prescription.DoseFraction), 'PASS', passLog) #print "OTP Px dose matches %i %i" %(OTPDoseFr,LPlan.Prescriptions[0].DoseFraction) else: output.write( "OTP dose/beam and Prescription mismatch: %i %i" % (OTPDoseFr, LPlan.Prescription.DoseFraction), 'FAIL', failLog) #print "OTP Px dose doesn't match %i %i" %(OTPDoseFr,LPlan.Prescriptions[0].DoseFraction) Px_mismatch = True if OTPDoseTotal == LPlan.Prescription.DoseTotal: output.write( "OTP total dose matches prescription: %i %i" % (OTPDoseTotal, LPlan.Prescription.DoseTotal), 'PASS', passLog) #print "Lantis Px dose matches %i %i" %(LDoseFr,LPlan.Prescriptions[0].DoseFraction) else: output.write( "OTP total dose and prescription mismatch: %i %i" % (OTPDoseTotal, LPlan.Prescription.DoseTotal), 'FAIL', failLog) Px_mismatch = True if (Px_mismatch): return False else: return True
def check_Ports(LPlan, passLog, failLog): output.write('\nPORTAL BEAM CHECK\n', 'CheckHeading', passLog) for field in LPlan.PortFields: output.write('\nBEAM \t %s' % field.BeamName, 'BeamHeading', passLog) if (field.MU == 1): output.write('MU: %i' % field.MU, 'PASS', passLog) else: output.write('MU: %i' % field.MU, 'FAIL', failLog) if (field.Energy == 6): output.write('Energy: %i' % field.Energy, 'PASS', passLog) else: output.write('Energy: %i' % field.Energy, 'FAIL', failLog) if (field.Dose == 0): output.write('Dose: %i' % field.Dose, 'PASS', passLog) else: output.write('Dose: %i' % field.Dose, 'FAIL', failLog)
def std_output(self,x,y): if (self.pos >= len(op.player_img)): return op.write("score:"+str(pl.score[self.pos]) + "[" + str(pl.cd_score[self.pos])+"]",950,410,20) pygame.draw.rect(op.screen,pl.country_color.setdefault(self.country,(0,0,0)),[850,438,150,162],0) pygame.draw.rect(op.screen, [30, 20, 0], [874, 440, 100, 160], 0) if (self.dead == 0): op.screen.blit(op.player_img[self.pos], [874, 440]) else: tmp = op.player_img[self.pos] tmp.set_alpha(100) op.screen.blit(tmp, [874, 440]) pygame.draw.rect(op.screen, [30, 20, 0], [849, 438, 150, 162], 2) op.Stwrite(self.name, 872, 472, 20, [255, 255, 255]) if (self.max_hp > 7): op.write(str(self.max_hp), 999, 571, 25, [90, 170, 85]) op.write(" / ", 999, 551, 22, [90, 170, 85]) op.write(str(self.hp), 999, 527, 25, [90, 170, 85]) else: for i in range(self.max_hp): if (i < self.hp): op.screen.blit(op.hp1_g, [977, 574 - 22*i]) else: op.screen.blit(op.hp0_g, [977, 574 - 22*i]) pygame.draw.rect(op.screen,(255, 250, 200), [852,578,20,20],0) op.write(str(len(self.has_card)), 871, 578, 18) x,y = 854,440 op.write(" " + self.country, x + 18, y + 2, 16, [255, 255, 255]) if (self.equip[0].id != 0): tmp = self.equip[0] pygame.draw.rect(op.screen, (250, 250, 250), [x + 20, y + 95, 100, 15], 0) pygame.draw.rect(op.screen, (30, 0, 20), [x + 20, y + 95, 100, 15], 1) op.type_img[tmp.type] = pygame.transform.smoothscale(op.type_img[tmp.type], (13, 13)) op.screen.blit(op.type_img[tmp.type], [x + 21, y + 96]) op.write(cd.card_point[tmp.num], x + 45, y + 95, 13) op.write(" " + cd.card_nm[tmp.id], x + 120, y + 95, 13) if (self.equip[1].id != 0): tmp = self.equip[1] pygame.draw.rect(op.screen, (250, 250, 250), [x + 20, y + 110, 100, 15], 0) pygame.draw.rect(op.screen, (30, 0, 20), [x + 20, y + 110, 100, 15], 1) op.type_img[tmp.type] = pygame.transform.smoothscale(op.type_img[tmp.type], (13, 13)) op.screen.blit(op.type_img[tmp.type], [x + 21, y + 111]) op.write(cd.card_point[tmp.num], x + 45, y + 110, 13) op.write(" " + cd.card_nm[tmp.id], x + 120, y + 110, 13) if (self.equip[4].id != 0): tmp = self.equip[4] pygame.draw.rect(op.screen, (250, 250, 250), [x + 20, y + 125, 100, 15], 0) pygame.draw.rect(op.screen, (30, 0, 20), [x + 20, y + 125, 100, 15], 1) op.type_img[tmp.type] = pygame.transform.smoothscale(op.type_img[tmp.type], (13, 13)) op.screen.blit(op.type_img[tmp.type], [x + 21, y + 126]) op.write(cd.card_point[tmp.num], x + 45, y + 125, 13) op.write(" " + cd.card_nm[tmp.id], x + 120, y + 125, 13) if (self.equip[2].id != 0): tmp = self.equip[2] pygame.draw.rect(op.screen, (250, 250, 250), [x + 20, y + 140, 40, 20], 0) pygame.draw.rect(op.screen, (30, 0, 20), [x + 20, y + 140, 40, 20], 1) op.type_img[tmp.type] = pygame.transform.smoothscale(op.type_img[tmp.type], (13, 13)) op.screen.blit(op.type_img[tmp.type], [x + 21, y + 143]) op.write(cd.card_point[tmp.num], x + 42, y + 142, 13) op.write("+1", x + 55, y + 140, 17) if (self.equip[3].id != 0): tmp = self.equip[3] pygame.draw.rect(op.screen, (250, 250, 250), [x + 60, y + 140, 40, 20], 0) pygame.draw.rect(op.screen, (30, 0, 20), [x + 60, y + 140, 40, 20], 1) op.type_img[tmp.type] = pygame.transform.smoothscale(op.type_img[tmp.type], (13, 13)) op.screen.blit(op.type_img[tmp.type], [x + 61, y + 143]) op.write(cd.card_point[tmp.num], x + 82, y + 142, 13) op.write("-1", x + 95, y + 140, 17) for item in self.judge: if (item.id == 19): pygame.draw.rect(op.screen, [100, 0, 100], [x + 80, y + 5, 15, 15], 0) op.write(" 乐", x + 95, y + 5, 15, [255, 255, 255]) if (item.id == 20): pygame.draw.rect(op.screen, [100, 100, 0], [x + 100, y + 5, 15, 15], 0) op.write(" 兵", x + 115, y + 5, 15, [255, 255, 255]) if (item.id == 21): pygame.draw.rect(op.screen, [0, 0, 100], [x + 100, y + 25, 15, 15], 0) op.write(" 闪", x + 114, y + 26, 15, [255, 255, 255]) if (self.drink == 1): pygame.draw.rect(op.screen, [150, 50, 50], [x + 80, y + 25, 15, 15], 0) op.write(" 酒", x + 95, y + 26, 15, [255, 255, 255]) if (self.connect == 1): pygame.draw.rect(op.screen, [100, 100, 100], [x + 20, y + 135, 25, 25], 0) op.write(" 连", x + 45, y + 135, 20, [255, 255, 255]) self.self_output(x, y) dx = min(95, 550/(len(self.has_card)+1)) mpos = pygame.mouse.get_pos() for i in range(len(self.has_card)): if(i >= len(self.has_card)): continue item = self.has_card[i] self.has_card[i].alpha = 255 ny = 467 - self.chosen[i] * 30 item.std_output(100+i*dx,ny,91,130) if(self.chosen[i] == 1): pygame.draw.rect(op.screen, [255, 255, 0], [100 + i * dx, ny, 91, 130], 1) res = self.using(item) if (res[0] == 0): pygame.draw.line(op.screen, [255, 0, 0], [100 + i * dx, ny], [191 + i * dx, ny + 130], 2) for i in range(len(self.has_card)): if(i >= len(self.has_card)): continue item = self.has_card[i] self.has_card[i].alpha = 255 ny = 467 - self.chosen[i] * 30 if (mpos[0] > 100 + i * dx and mpos[0] < 100 + (i + 1) * dx and mpos[1] > 467 and mpos[1] < 597): item.std_output(100 + i * dx, ny, 91, 130) pygame.draw.rect(op.screen,[255,255,0],[100+i*dx,ny,91,130],1)
def ending(self, output): '''Write final output before the end of the game.''' output.write("You have won.")
def std_output(self, x, y, show_score=1): if (self.pos >= len(op.player_img)): return if (show_score == 1): op.write( "score:" + str(self.fire_col) + "[" + str(score[self.pos]) + "]", x + 100, y - 25, 20) pygame.draw.rect(op.screen, country_color.setdefault(self.country, (0, 0, 0)), [x - 2, y - 2, 124, 164], 0) pygame.draw.rect(op.screen, (30, 20, 0), [x + 20, y, 101, 160], 0) op.Stwrite(self.name, x + 18, y + 20, 16, [255, 255, 255]) tmp = op.player_img[self.pos] if (self.dead == 0): if (self.flip == 1): tmp = op.fliped tmp.set_alpha(255) else: tmp.set_alpha(100) op.screen.blit(tmp, [x + 21, y]) pygame.draw.rect(op.screen, (30, 20, 0), [x - 2, y - 2, 124, 163], 2) if (show_score == 1): self.self_output(x, y) pygame.draw.rect(op.screen, (255, 250, 200), [x + 100, y + 140, 20, 20], 0) pygame.draw.rect(op.screen, (30, 0, 20), [x + 100, y + 140, 21, 21], 1) op.write(str(len(self.has_card)), x + 120, y + 140, 18) if (self.max_hp > 5): op.write(str(self.max_hp), x + 18, y + 142, 18, [90, 170, 85]) op.write(" / ", x + 18, y + 126, 16, [90, 170, 85]) op.write(str(self.hp), x + 18, y + 110, 18, [90, 170, 85]) else: for i in range(self.max_hp): if (i < self.hp): op.screen.blit(op.hp1_t, [x + 3, y + 143 - i * 17]) else: op.screen.blit(op.hp0_t, [x + 3, y + 143 - i * 17]) op.write(" " + self.country, x + 18, y + 2, 16, [255, 255, 255]) if (self.equip[0].id != 0): tmp = self.equip[0] pygame.draw.rect(op.screen, (250, 250, 250), [x + 20, y + 95, 100, 15], 0) pygame.draw.rect(op.screen, (30, 0, 20), [x + 20, y + 95, 100, 15], 1) op.type_img[tmp.type] = pygame.transform.smoothscale( op.type_img[tmp.type], (13, 13)) op.screen.blit(op.type_img[tmp.type], [x + 21, y + 96]) op.write(cd.card_point[tmp.num], x + 45, y + 95, 13) op.write(" " + cd.card_nm[tmp.id], x + 120, y + 95, 13) if (self.equip[1].id != 0): tmp = self.equip[1] pygame.draw.rect(op.screen, (250, 250, 250), [x + 20, y + 110, 100, 15], 0) pygame.draw.rect(op.screen, (30, 0, 20), [x + 20, y + 110, 100, 15], 1) op.type_img[tmp.type] = pygame.transform.smoothscale( op.type_img[tmp.type], (13, 13)) op.screen.blit(op.type_img[tmp.type], [x + 21, y + 111]) op.write(cd.card_point[tmp.num], x + 45, y + 110, 13) op.write(" " + cd.card_nm[tmp.id], x + 120, y + 110, 13) if (self.equip[4].id != 0): tmp = self.equip[4] pygame.draw.rect(op.screen, (250, 250, 250), [x + 20, y + 125, 100, 15], 0) pygame.draw.rect(op.screen, (30, 0, 20), [x + 20, y + 125, 100, 15], 1) op.type_img[tmp.type] = pygame.transform.smoothscale( op.type_img[tmp.type], (13, 13)) op.screen.blit(op.type_img[tmp.type], [x + 21, y + 126]) op.write(cd.card_point[tmp.num], x + 45, y + 125, 13) op.write(" " + cd.card_nm[tmp.id], x + 120, y + 125, 13) if (self.equip[2].id != 0): tmp = self.equip[2] pygame.draw.rect(op.screen, (250, 250, 250), [x + 20, y + 140, 40, 20], 0) pygame.draw.rect(op.screen, (30, 0, 20), [x + 20, y + 140, 40, 20], 1) op.type_img[tmp.type] = pygame.transform.smoothscale( op.type_img[tmp.type], (13, 13)) op.screen.blit(op.type_img[tmp.type], [x + 21, y + 143]) op.write(cd.card_point[tmp.num], x + 42, y + 142, 13) op.write("+1", x + 55, y + 140, 17) if (self.equip[3].id != 0): tmp = self.equip[3] pygame.draw.rect(op.screen, (250, 250, 250), [x + 60, y + 140, 40, 20], 0) pygame.draw.rect(op.screen, (30, 0, 20), [x + 60, y + 140, 40, 20], 1) op.type_img[tmp.type] = pygame.transform.smoothscale( op.type_img[tmp.type], (13, 13)) op.screen.blit(op.type_img[tmp.type], [x + 61, y + 143]) op.write(cd.card_point[tmp.num], x + 82, y + 142, 13) op.write("-1", x + 95, y + 140, 17) for item in self.judge: if (item.id == 19): pygame.draw.rect(op.screen, [100, 0, 100], [x + 80, y + 5, 15, 15], 0) op.write(" 乐", x + 95, y + 5, 15, [255, 255, 255]) if (item.id == 20): pygame.draw.rect(op.screen, [100, 100, 0], [x + 100, y + 5, 15, 15], 0) op.write(" 兵", x + 115, y + 5, 15, [255, 255, 255]) if (item.id == 21): pygame.draw.rect(op.screen, [0, 0, 100], [x + 100, y + 25, 15, 15], 0) op.write(" 闪", x + 114, y + 26, 15, [255, 255, 255]) if (self.drink == 1): pygame.draw.rect(op.screen, [150, 50, 50], [x + 80, y + 25, 15, 15], 0) op.write(" 酒", x + 95, y + 26, 15, [255, 255, 255]) if (self.connect == 1): pygame.draw.rect(op.screen, [100, 100, 100], [x + 20, y + 135, 25, 25], 0) op.write(" 连", x + 45, y + 135, 20, [255, 255, 255])
def LoadBeams(): Pxselect.destroy() #pdb.set_trace() self.Site = selected.get() beam_index = -1 beam_load = False ''' Second pass through file. Load Beam, Control Point and Prescription data for selected prescription.''' with open(RTPfile, 'rb') as f: reader = csv.reader(f) # use csv module to parse file for row in reader: if ((row[0] == "FIELD_DEF") and (prescriptions.__contains__(row[1]))): # Check if beam number field is a number or string (ISO check) try: beam_num = int(row[3]) # Flag used to load next CONTROL_PT_DEF data beam_load = True beam_index += 1 beam = RTPBeam(row) # create new beam object self.Beams.append( beam) # append beam to list of beam objects output.write(str(row[2]), "PASS", log) except ValueError: if (tkMessageBox.askyesno( "ISO Check field?", "Is %s an ISO check field?" % str(row[2]))): beam = RTPPortField(row) self.PortFields.append(beam) beam_load = False else: tkMessageBox.showwarning( "Error", "Can't proces beam %s\nCheck that beam ID is a number." % str(row[2]), ) self.NumBeams = beam_index + 1 return if (beam_load and Technique == "CRT"): if ((row[0] == "CONTROL_PT_DEF") and (int( row[1]) == self.Beams[beam_index].BeamNumber)): for i in range(32, 73): self.Beams[beam_index].MLC.append( round(float(row[i]), 3)) for i in range(132, 173): self.Beams[beam_index].MLC.append( round(float(row[i]), 3)) else: pass elif (beam_load and (Technique == "IMRT")): if ((row[0] == "CONTROL_PT_DEF") and (int( row[1]) == self.Beams[beam_index].BeamNumber)): self.Beams[beam_index].NumSegments = int( row[4]) / 2 if (int(row[5]) % 2 == 0): segMLC = [] for i in range(32, 73): segMLC.append(round(float(row[i]), 3)) for i in range(132, 173): segMLC.append(round(float(row[i]), 3)) segYjaws = [float(row[23]), float(row[24])] else: # Get actual segment cumulative MUs by multiplying fractional # cumulative MU from Lantis control point data by total beam MU CumulativeMU = float( row[7]) * self.Beams[beam_index].MU NewSegment = Segment(segMLC, segYjaws, CumulativeMU) self.Beams[beam_index].Segments.append( NewSegment) NumCtrlPnts = row[4] if ((row[0] == "RX_DEF") and (prescriptions.__contains__(row[2]))): self.Prescription = RTPPrescription(row) self.NumBeams = beam_index + 1
def logmein(): output.write(request) return flask.redirect("/tmui/login.jsp?msgcode=1&")
def check_Pt(LPlan, OTPPlan, passLog): output.write('\nPATIENT DATA CHECK\n', 'CheckHeading', passLog)
def check_Pt(LPlan,OTPPlan,passLog): output.write('\nPATIENT DATA CHECK\n','CheckHeading',passLog)
def check_beams(Plan1, Plan2, passLog, failLog): plan_mismatch = False output.write('\n\nBEAM CHECK', 'CheckHeading', passLog) for x in range(Plan1.NumBeams): #output.write('\n********************','INFO',passLog) output.write('\nBEAM \t %s' % Plan1.Beams[x].BeamName, 'BeamHeading', passLog) output.write('Parameter\t\tLANTIS\t\tOTP', 'TabHeading', passLog) #output.write('********************\n','Heading',passLog) # Check for mismatch in Beam dictionaries. for key in Plan1.Beams[x].__dict__: # Initialise beam mismatch flag beam_mismatch = False # Compare parameter values if Plan1.Beams[x].__dict__[key] != Plan2.Beams[x].__dict__[key]: # Segment checking if key == "Segments": for k in range(Plan1.Beams[x].NumSegments): output.write('\nSegment: %i' % (k + 1), 'SegHeading', passLog) output.write('Parameter\t\tLANTIS\t\tOTP', 'TabHeading', passLog) for segkey in Plan1.Beams[x].Segments[k].__dict__: segment_mismatch = False if Plan1.Beams[x].Segments[k].__dict__[ segkey] != Plan2.Beams[x].Segments[ k].__dict__[segkey]: if segkey == "MLC": #for i in range(81): for i in range(41): logstring = ( "MLC Pair %i\t\t[%0.2f %0.2f]\t\t[%0.2f %0.2f]" % (i + 1, Plan1.Beams[x].Segments[k].MLC[i], Plan1.Beams[x].Segments[k].MLC[ i + 41], Plan2.Beams[x].Segments[k].MLC[i], Plan2.Beams[x].Segments[k].MLC[ i + 41])) if (fabs(Plan1.Beams[x].Segments[k]. MLC[i] - round( Plan2.Beams[x].Segments[k] .MLC[i], 2)) > 0.011 ) or (fabs( Plan1.Beams[x].Segments[k]. MLC[i + 41] - round( Plan2.Beams[x].Segments[k]. MLC[i + 41], 2)) > 0.011): output.write( '\nBEAM \t %s' % Plan1.Beams[x].BeamName, 'BeamHeading', failLog) output.write( 'Parameter\t\tLANTIS\t\tOTP', 'TabHeading', failLog) output.write( logstring, 'MLCFAIL', failLog) segment_mismatch = True else: output.write( logstring, 'MLCPASS', passLog) else: segment_mismatch = True if (segkey != "MLC"): logstring = ("%s\t\t%s\t\t%s") % ( segkey, Plan1.Beams[x].Segments[k]. __dict__[segkey], Plan2.Beams[x]. Segments[k].__dict__[segkey]) if not (segment_mismatch): output.write(logstring, 'PASS', passLog) else: plan_mismatch = True output.write( '\nBEAM \t %s' % Plan1.Beams[x].BeamName, 'BeamHeading', failLog) output.write('Segment: %i' % (k + 1), 'SegHeading', failLog) output.write('Parameter\t\tLANTIS\t\tOTP', 'TabHeading', failLog) output.write(logstring, 'FAIL', failLog) # If beam names don't fully match, but do partially match, then do nothing elif (key == 'BeamName' and Plan1.Beams[x].BeamName in Plan2.Beams[x].BeamName): pass elif (key == 'MLC'): for i in range(41): logstring = ( "MLC Pair %i\t\t[%0.2f %0.2f]\t\t[%0.2f %0.2f]" % (i + 1, Plan1.Beams[x].MLC[i], Plan1.Beams[x].MLC[i + 41], Plan2.Beams[x].MLC[i], Plan2.Beams[x].MLC[i + 41])) if (fabs(Plan1.Beams[x].MLC[i] - round(Plan2.Beams[x].MLC[i], 2)) > 0.011) or ( fabs(Plan1.Beams[x].MLC[i + 41] - round(Plan2.Beams[x].MLC[i + 41], 2)) > 0.011): #logstring = ("MLC Leaf Number %i\t\t%f\t\t%f\t\t%f" % (i,Plan1.Beams[x].Segments[k].MLC[i], Plan2.Beams[x].Segments[k].MLC[i],(fabs(Plan1.Beams[x].Segments[k].MLC[i] - round(Plan2.Beams[x].Segments[k].MLC[i],2))))) output.write( '\nBEAM \t %s' % Plan1.Beams[x].BeamName, 'BeamHeading', failLog) output.write('Parameter\t\tLANTIS\t\tOTP', 'TabHeading', failLog) output.write(logstring, 'MLCFAIL', failLog) else: output.write(logstring, 'MLCPASS', passLog) # for i in range(0,81): # # Run through MLC positions, check for differences exceeding rounding errors # if (fabs(Plan1.Beams[x].MLC[i] - round(Plan2.Beams[x].MLC[i],2)) > 0.011): # logstring = ("MLC Leaf Number %i: %f %f %f " % (i,Plan1.Beams[x].MLC[i], Plan2.Beams[x].MLC[i],(fabs(Plan1.Beams[x].MLC[i] - round(Plan2.Beams[x].MLC[i],2))))) # output.write(logstring,'FAIL',passLog) else: # Flag a mismatch and record which parameter failed in which beam beam_mismatch = True plan_mismatch = True if not (beam_mismatch) and not (key == "MLC"): logstring = ("%s\t\t%s\t\t%s") % (key, Plan1.Beams[x].__dict__[key], Plan2.Beams[x].__dict__[key]) output.write(logstring, 'PASS', passLog) elif not (key == "MLC"): output.write('\nBEAM \t %s' % Plan1.Beams[x].BeamName, 'BeamHeading', failLog) output.write('Parameter\t\tLANTIS\t\tOTP', 'TabHeading', failLog) logstring = ("%s\t\t%s\t\t%s") % (key, Plan1.Beams[x].__dict__[key], Plan2.Beams[x].__dict__[key]) output.write(logstring, 'FAIL', failLog) if (plan_mismatch): return False else: return True
def check_Ports(LPlan,passLog,failLog): output.write('\nPORTAL BEAM CHECK\n','CheckHeading',passLog) for field in LPlan.PortFields: output.write('\nBEAM \t %s' % field.BeamName,'BeamHeading',passLog) if (field.MU == 1): output.write('MU: %i' %field.MU,'PASS',passLog) else: output.write('MU: %i' %field.MU,'FAIL',failLog) if (field.Energy == 6): output.write('Energy: %i' %field.Energy,'PASS',passLog) else: output.write('Energy: %i' %field.Energy,'FAIL',failLog) if (field.Dose == 0): output.write('Dose: %i' %field.Dose,'PASS',passLog) else: output.write('Dose: %i' %field.Dose,'FAIL',failLog)
def check_Px(LPlan,OTPPlan,passLog,failLog): Px_mismatch = False output.write('\nPRESCRIPTION CHECK\n','CheckHeading',passLog) LDoseFr = 0 # Lantis total dose per fraction OTPDoseFr = 0 # OTP total dose per fraction for i in range(0,LPlan.NumBeams): #print "Beam Number %i" %i LDoseFr += LPlan.Beams[i].Dose OTPDoseFr += OTPPlan.Beams[i].Dose OTPDoseTotal = OTPDoseFr * OTPPlan.NumFractions #print "Lantis dose/fr = %i" %LDoseFr #print "OTP Total dose = %i" %OTPDoseTotal # for prescription in LPlan.Prescriptions: #if (prescription.Site == LPlan.Site): # Check Lantis beam dose/fraction = Lantis Prescription dose/fraction if LDoseFr == LPlan.Prescription.DoseFraction: output.write("Lantis dose/beam matches Prescription: %i %i" %(LDoseFr,LPlan.Prescription.DoseFraction),'PASS',passLog) #print "Lantis Px dose matches %i %i" %(LDoseFr,LPlan.Prescriptions[0].DoseFraction) else: output.write("Lantis dose/beam and Prescription mismatch: %i %i" %(LDoseFr,LPlan.Prescription.DoseFraction),'FAIL',failLog) Px_mismatch = True # Check OTP beam dose/fraction = Lantis Prescription dose/fraction if OTPDoseFr == LPlan.Prescription.DoseFraction: output.write("OTP dose/beam matches Prescription: %i %i" %(OTPDoseFr,LPlan.Prescription.DoseFraction),'PASS',passLog) #print "OTP Px dose matches %i %i" %(OTPDoseFr,LPlan.Prescriptions[0].DoseFraction) else: output.write("OTP dose/beam and Prescription mismatch: %i %i" %(OTPDoseFr,LPlan.Prescription.DoseFraction),'FAIL',failLog) #print "OTP Px dose doesn't match %i %i" %(OTPDoseFr,LPlan.Prescriptions[0].DoseFraction) Px_mismatch = True if OTPDoseTotal == LPlan.Prescription.DoseTotal: output.write("OTP total dose matches prescription: %i %i" %(OTPDoseTotal,LPlan.Prescription.DoseTotal),'PASS',passLog) #print "Lantis Px dose matches %i %i" %(LDoseFr,LPlan.Prescriptions[0].DoseFraction) else: output.write("OTP total dose and prescription mismatch: %i %i" %(OTPDoseTotal,LPlan.Prescription.DoseTotal),'FAIL',failLog) Px_mismatch = True if(Px_mismatch): return False else: return True