Best Python code snippet using fMBT_python
retro-display.py
Source:retro-display.py
...44 #pl.figure(1)45 #pl.plot(ra[:,0],ra[:,1],'go') 46 #pl.show()47 return ra[:,0],ra[:,1]48def dumpIni(event):49 global origin, topo50 if event["origin"] != origin:51 # Update the topography handle if required52 latitude, longitude = origin = event["origin"]53 print "Topography around (lat,long)=",latitude, longitude54 topo = Topography(latitude=latitude, longitude=longitude, path="share/topography", stack_size=121)55 # Format info for txt file to be analyzed in ciompareConeIniNew.m56 _, e, (x0, y0, z0), u, (la, lo, h), (t, p) = event["tau_at_decay"]57 print "Decay pos (m) = ",x0, y0, z058 zg = topo.ground_altitude(x0, y0)59 print "Ground altitude @ decay point (GRANDref, m)=",zg 60 print "Shower vec dir =",u61 62 # Compute the shower energy63 shower_energy = 0.64 for (pid_, momentum) in event["decay"]:65 aid = abs(pid_)66 if aid in (12, 13, 14, 16):67 continue68 shower_energy += sum(m**2 for m in momentum)**0.569 print "shower energy (GeV) =",shower_energy70 ra = np.array(event["antennas"])[:, :3]71 nants = np.shape(ra)[0]72 print "Nants in cone = ", nants73 x = np.array([shower_energy,u[0],u[1],u[2],x0,y0,z0,zg,nants])74 np.savetxt(f,x.reshape(1, x.shape[0]),fmt="%3.4f") 75 76if __name__ == "__main__":77 i = 078 global origin, topo79 origin, topo = None, None80 #xall = np.zeros(shape=(0,0))81 #yall = np.zeros(shape=(0,0))82 path = sys.argv[1]83 f = open('compIniGRAND.txt','ab')84 #np.savetxt(f,"#E (GeV), u(GRANDconv), x_decay(GRANDconv)",delimiter=" ",fmt="%s")85 for name in os.listdir(path):86 if not name.endswith("json"):87 continue88 filename = os.path.join(path, name)89 print "o Processing", filename90 for event in EventIterator(filename):91 i += 192 #xa,ya = ants(event)93 #xall = np.append(xall,xa)94 #yall = np.append(yall,ya)95 #display(event)96 display(42.1,86.3)97 #fresnel(event)98 #dumpIni(event)99 100 #if i >1000:101 # break102 103 f.close()104 #pl.figure()105 #pl.subplot(211)106 #pl.hist(xall,100)107 #pl.xlabel('Antenna X pos (km)')108 #pl.subplot(212)109 #pl.hist(yall,100)110 #pl.xlabel('Antenna Y pos (km)')...
test_example.py
Source:test_example.py
...7#-----------------------------------------------------------8# # 示ä¾ï¼ inié
置表9# parser = ini.MyParserIni()10# parser.read("../config.ini")11# parser.dumpIni()12# parser.dumpJson()13# # 示ä¾ï¼ xmlé
置表14# parser = xml.MyParserXml()15# parser.setExportMode(MODE_SINGLE)16# parser.parseSettingXml("./../example/xmls/setting.xml")17# parser.exportFiles('./../example/xmls', "./../.out/xmls", TYPE_JSON)18# # 示ä¾ï¼ excelé
置表19# parser = excel.MyParserExcel()20# parser.parseSettingXml("./../example/excels/setting.xml")21# parser.exportFiles('./../example/excels', "./../.out/excels", TYPE_JSON)22# # 示ä¾ï¼ 移é¤åç¼æ件23# removeWithSuffix("./../.out/excels", "json")24# # 示ä¾ï¼ å符串æ¿æ¢25# str_ret = replaceStr("abcdefg", "", "x", "[adf]")...
config.py
Source:config.py
1# Useful functions to read and write to config files.2import json3import configparser4from util import logger5# Reads and returns .ini file6def readINI(filename: str):7 config = configparser.ConfigParser()8 config.read(filename)9 return config10# Writes to .ini file11def dumpINI(filename: str, write):12 config = configparser.ConfigParser()13 config.write(write)14# Reads and returns .json file15def readJSON(filename: str):16 with open(filename, 'r') as jsondata:17 data = json.load(jsondata)18 return data19# Writes to .json file20def dumpJSON(filename: str, data):21 with open(filename, 'w') as jsondata:...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!