def init(Engine,EngineModule,objects): Engine.log("initial sleep of 20 seconds") time.sleep(20) Engine.lightsOff() #saveload.load(Engine,EngineModule,"xmlscene/test.xml",objects) saveload.load(Engine,EngineModule,"xmlscene/scene.xml",objects) objectsNumber = Engine.howManyObjects() for i in range(0,objectsNumber): o = Engine.getObject(i) if o.isGuiShape(): if not o.isFinalShape(): o.hide() global doneLoadingTime doneLoadingTime = Engine.getExactTime()
def startMenu(): sg.theme('Purple') layout = [[sg.Button('Start new game', size=(40, 7))], [sg.Button('Load save', size=(40, 7))], [sg.Button('Back', size=(40, 7))]] start_window = sg.Window('Start menu', layout, size=(600, 355)) while True: event, values = start_window.read() if event == sg.WIN_CLOSED or event == 'Back': break if event == 'Load save': #info = (class_respect, teachers, grades, year, situation) or False info = svld.load() if info == False: break info = gameplay(class_respect=info[0], teachers=info[1], grades=info[2], year=info[3], loaded_situation=info[4]) if info != None: gameplay(class_respect=info[0], teachers=info[1], grades=info[2], year=info[3], loaded_situation=info[4]) break if event == 'Start new game': info = gameplay(class_respect=0, teachers=0, grades=0, year=8, loaded_situation=1) if info != None: gameplay(class_respect=info[0], teachers=info[1], grades=info[2], year=info[3], loaded_situation=info[4]) break start_window.close()
def load(): global filename global wavlst #Still need to decide on an extension! filename = tkFileDialog.askopenfilename(defaultextension=fextension,\ filetypes=(("Wave Combiner files",fextension),\ ("All Files", "*"))) if filename=="": return data = saveload.load(filename) if data: root.title("Wave Combiner - " + filename) wavlst = data comp.set_wave_list(wavlst) windowlist.clear() update_list() comp.draw() else: print "Invalid Data!"
def main(): import saveload ary = saveload.load("test.m4a") ary = ary.reshape(len(ary)/2,2)[:,0] spectrums = get_max_spectrums(ary,256) print spectrums
print " - Regular pixels plot: 2" if __name__ == "__main__": if len(sys.argv)!=2: perror() sys.exit(1) else: if sys.argv[1] not in ['0','1','2']: perror() print "Invalid value given: %s" % sys.argv[1] sys.exit(1) try: # Upload data print 'Loading data...' data,fxlon,fxlat,time_num=sl.load('data') except Exception: print "Error: No data file in the directory. First run a case using case.py." sys.exit(1) granules=sort_dates(data) bounds=[fxlon.min(),fxlon.max(),fxlat.min(),fxlat.max()] print 'Plotting data...' # Plot pixels if sys.argv[1] is '0': m = Basemap(projection='merc',llcrnrlat=bounds[2], urcrnrlat=bounds[3], llcrnrlon=bounds[0], urcrnrlon=bounds[1]) kmld = [] for idx, g in enumerate(granules): raster_png_data,corner_coords = basemap_scatter_mercator(g[1],bounds,m) bounds = (corner_coords[0][0],corner_coords[1][0],corner_coords[0][1],corner_coords[2][1])
def main(): import saveload ary = saveload.load("test.m4a") ary = ary.reshape(len(ary) / 2, 2)[:, 0] spectrums = get_max_spectrums(ary, 256) print spectrums
def keyPressed(Engine,EngineModule,key,selection,objects): pass if key == EngineModule.Keys.K_C: print("create objects") if len(selection.get()) == 1: if selection.get()[0].isActor(): o = selection.get()[0] numShapes = o.howManyPhysicShapes() size = EngineModule.Vec3(10,10,10) size = EngineModule.Vec3(1,1,1) method="" firstShape = o.getShapeByIndex(0) if Engine.isKeyDown(EngineModule.Keys.K_1): shape = o.addBox(size) method = "addBox" if Engine.isKeyDown(EngineModule.Keys.K_2): shape = o.addCapsule(size) method = "addCapsule" if Engine.isKeyDown(EngineModule.Keys.K_3): shape = o.addSphere(size) method = "addSphere" colour = EngineModule.Vec3(1,1,1) alpha = 1 if firstShape.hasColour(): colour = firstShape.getColour() alpha = firstShape.getAlpha() shape.setColour(colour.x,colour.y,colour.z,alpha) shape.setName(str(numShapes+1)) selection.clear() selection.add(shape) text = method + "(Engine,EngineModule" text += ",bodyName='" + o.getName() + "'" text += ",shapeName='" + shape.getName() + "'" text += ",size=EngineModule.Vec3(" + str(size) + ")" text += ",r=" + str(colour.x) text += ",g=" + str(colour.y) text += ",b=" + str(colour.z) text += ",a=" + str(alpha) text += ")" helpers.storeOperation(text) else: if (Engine.isKeyDown(EngineModule.Keys.K_1) or Engine.isKeyDown(EngineModule.Keys.K_2) or Engine.isKeyDown(EngineModule.Keys.K_3) ): size = EngineModule.Vec3(10,10,10) #size = EngineModule.Vec3(15,5,1) if Engine.isKeyDown(EngineModule.Keys.K_0): o = Engine.createStaticActor() else: o = Engine.createDynamicActor() if Engine.isKeyDown(EngineModule.Keys.K_1): shape = o.addBox(size) elif Engine.isKeyDown(EngineModule.Keys.K_2): shape = o.addCapsule(size) elif Engine.isKeyDown(EngineModule.Keys.K_3): shape = o.addSphere(size) shape.setMaterialName(Engine.getDefaultShadedMaterialName()) shape.setName("1") o.setPosition(EngineModule.Vec3(0,150,0)) if Engine.isKeyDown(EngineModule.Keys.K_4): print("create spacecage") create.createSpaceCage(Engine,EngineModule,EngineModule.Vec3( 100,200,300)) # 200,200,200)) elif Engine.isKeyDown(EngineModule.Keys.K_6): print("create ragdoll") char = ragdoll.createHumanBodyParts(Engine, EngineModule,size=5, pos=EngineModule.Vec3(0,150,0), base=False) ragdoll.createHumanJoints(Engine,EngineModule,char) ragdoll.createLimits(Engine,EngineModule,char,45) ragdoll.createLimitsHuman(Engine,EngineModule,char) elif Engine.isKeyDown(EngineModule.Keys.K_8): print("set camera pos") Engine.setCameraPosition( EngineModule.Vec3( #-39.260421753,51.768470764,-253.214447021 -37.964317322,51.912330627,-246.827178955 ) ) Engine.setCameraOrientation( EngineModule.Quat( #0.061658185,0.000627403,-0.998036027,0.011049764 0.061658185,0.000627403,-0.998036027,0.011049764 ) ) Engine.setCameraFOV(50) elif Engine.isKeyDown(EngineModule.Keys.K_7): #saveload.load(Engine,EngineModule,"xmlscene/ragdoll.xml",objects) yPos = 0.0 saveload.load(Engine,EngineModule,"xmlscene/ragdoll_1050.xml",objects, loadingPosition=EngineModule.Vec3(18.637054443,yPos,-93.069076538), loadingOrientation=EngineModule.Quat().fromAngles(0,180,0) * EngineModule.Quat(0.608761549,0.000000000,0.793353617,0.000000000)) saveload.load(Engine,EngineModule,"xmlscene/ragdoll_950.xml",objects, loadingPosition=EngineModule.Vec3(0.000000000,yPos,117.283714294), loadingOrientation=EngineModule.Quat().fromAngles(0,180,0) * EngineModule.Quat(1.000000000,0.000000000,0.000000000,0.000000000)) saveload.load(Engine,EngineModule,"xmlscene/ragdoll_850.xml",objects, loadingPosition=EngineModule.Vec3(60.000000000,yPos,57.283725739), loadingOrientation=EngineModule.Quat().fromAngles(0,180,0) * EngineModule.Quat(0.866025507,0.000000000,0.500000119,0.000000000)) saveload.load(Engine,EngineModule,"xmlscene/ragdoll_950.xml",objects, loadingPosition=EngineModule.Vec3(40.076103210,yPos,-4.459388256), loadingOrientation=EngineModule.Quat().fromAngles(0,180,0) * EngineModule.Quat(0.999048233,0.000000000,-0.043619387,0.000000000)) """ saveload.load(Engine,EngineModule,"xmlscene/ragdoll_1050.xml",objects, loadingPosition=EngineModule.Vec3(-92.474678040,yPos,-33.463573456), loadingOrientation=EngineModule.Quat().fromAngles(0,180,0) * EngineModule.Quat(0.953717113,0.000000000,-0.300705880,0.000000000)) saveload.load(Engine,EngineModule,"xmlscene/ragdoll_850.xml",objects, loadingPosition=EngineModule.Vec3(100.000000000,yPos,-42.716278076), loadingOrientation=EngineModule.Quat().fromAngles(0,180,0) * EngineModule.Quat(0.866025507,0.000000000,0.500000119,0.000000000)) saveload.load(Engine,EngineModule,"xmlscene/ragdoll_950.xml",objects, loadingPosition=EngineModule.Vec3(-98.567276001,yPos,103.246383667), loadingOrientation=EngineModule.Quat().fromAngles(0,180,0) * EngineModule.Quat(0.965926170,0.000000000,-0.258819163,0.000000000)) saveload.load(Engine,EngineModule,"xmlscene/ragdoll_850.xml",objects, loadingPosition=EngineModule.Vec3(-20.000000000,yPos,17.283725739), loadingOrientation=EngineModule.Quat().fromAngles(0,180,0) * EngineModule.Quat(0.923879683,0.000000000,-0.382683575,0.000000000)) saveload.load(Engine,EngineModule,"xmlscene/ragdoll_1050.xml",objects, loadingPosition=EngineModule.Vec3(120.000000000,yPos,57.283725739), loadingOrientation=EngineModule.Quat().fromAngles(0,180,0) * EngineModule.Quat(0.953717053,0.000000000,0.300705850,0.000000000)) saveload.load(Engine,EngineModule,"xmlscene/ragdoll_950.xml",objects, loadingPosition=EngineModule.Vec3(-150.000000000,yPos,57.283725739), loadingOrientation=EngineModule.Quat().fromAngles(0,180,0) * EngineModule.Quat(-0.130526334,0.000000000,-0.991445363,0.000000000)) saveload.load(Engine,EngineModule,"xmlscene/ragdoll_1050.xml",objects, loadingPosition=EngineModule.Vec3(-80.000000000,yPos,37.283725739), loadingOrientation=EngineModule.Quat().fromAngles(0,180,0) * EngineModule.Quat(-0.608761787,0.000000000,-0.793353677,0.000000000)) saveload.load(Engine,EngineModule,"xmlscene/ragdoll_850.xml",objects, loadingPosition=EngineModule.Vec3(-4.641016006,yPos,-40.036834717), loadingOrientation=EngineModule.Quat().fromAngles(0,180,0) * EngineModule.Quat(0.500000119,0.000000000,-0.866025686,0.000000000)) """ elif Engine.isKeyDown(EngineModule.Keys.K_5): pass createFigure(Engine,EngineModule,objects,EngineModule.Vec3(0,0,0),EngineModule.Quat(),1050)
def keyPressed(Engine,EngineModule,key,selection,objects): if key == EngineModule.Keys.K_J: ambient = Engine.getAmbientLight() factor = helpers.getModifiedVector(Engine,EngineModule,0.05) ambient = ambient + factor helpers.vecclamp(ambient) Engine.setAmbientLight(ambient) print("set ambient light to: " + str(ambient)) if key == EngineModule.Keys.K_H: fov = Engine.getCameraFOV() if Engine.isKeyDown(EngineModule.Keys.K_1): fov += 2 if Engine.isKeyDown(EngineModule.Keys.K_2): fov -= 2 if fov < 0: fov = 0 if fov > 180: fov = 180 Engine.setCameraFOV(fov) print("set FieldOfView to: " + str(fov)) if key == EngineModule.Keys.K_G: gravity = Engine.getGravity() factor = helpers.getModifiedVector(Engine,EngineModule,0.5) gravity = gravity + factor Engine.setGravity(gravity) print("set gravity to: " + str(gravity)) if key == EngineModule.Keys.K_K: if Engine.isKeyDown(EngineModule.Keys.K_1): print("save scene.xml") saveload.save(Engine,EngineModule,"xmlscene/scene.xml",objects) print("done") if Engine.isKeyDown(EngineModule.Keys.K_2): print("save ragdoll.xml") saveload.save(Engine,EngineModule,"xmlscene/ragdoll.xml",objects) print("done") if Engine.isKeyDown(EngineModule.Keys.K_3): print("save test.xml") saveload.save(Engine,EngineModule,"xmlscene/test.xml",objects) print("done") if key == EngineModule.Keys.K_L: if Engine.isKeyDown(EngineModule.Keys.K_1): print("load scene.xml") saveload.load(Engine,EngineModule,"../xmlscene/scene.xml",objects) print("done") if Engine.isKeyDown(EngineModule.Keys.K_2): print("load ragdoll.xml") saveload.load(Engine,EngineModule,"xmlscene/ragdoll.xml",objects) print("done") if Engine.isKeyDown(EngineModule.Keys.K_3): print("load test.xml") saveload.load(Engine,EngineModule,"xmlscene/test.xml",objects) print("done") if key == EngineModule.Keys.K_Z: print("change material and visibilty") #if len(selection.get()) == 1: # o = selection.get()[0] if (Engine.isKeyDown(EngineModule.Keys.K_1) or Engine.isKeyDown(EngineModule.Keys.K_2) or Engine.isKeyDown(EngineModule.Keys.K_3) or Engine.isKeyDown(EngineModule.Keys.K_4)): for o in selection.get(): if o and o.isGuiContainer(): shapesNumber = o.howManyShapes() shapesList = [] for i in range(0,shapesNumber): shape = o.getShapeByIndex(i) if Engine.isKeyDown(EngineModule.Keys.K_1): shape.setCustomMaterial() elif Engine.isKeyDown(EngineModule.Keys.K_2): shape.setMaterialName(Engine.getDefaultShadedMaterialName()) elif Engine.isKeyDown(EngineModule.Keys.K_3): shape.setFinalShape() elif Engine.isKeyDown(EngineModule.Keys.K_4): shape.setNonFinalShape() elif o and o.isGuiShape(): if Engine.isKeyDown(EngineModule.Keys.K_1): o.setCustomMaterial() elif Engine.isKeyDown(EngineModule.Keys.K_2): o.setMaterialName(Engine.getDefaultShadedMaterialName()) elif Engine.isKeyDown(EngineModule.Keys.K_3): o.setFinalShape() elif Engine.isKeyDown(EngineModule.Keys.K_4): o.setNonFinalShape() if Engine.isKeyDown(EngineModule.Keys.K_5) or Engine.isKeyDown(EngineModule.Keys.K_6): if Engine.isKeyDown(EngineModule.Keys.K_5): objectsNumber = Engine.howManyObjects() for i in range(0,objectsNumber): o = Engine.getObject(i) if o.isGuiShape(): if not o.isFinalShape(): o.hide() elif Engine.isKeyDown(EngineModule.Keys.K_6): objectsNumber = Engine.howManyObjects() for i in range(0,objectsNumber): o = Engine.getObject(i) if o.isGuiShape(): o.show() if key == EngineModule.Keys.K_N: if Engine.isKeyDown(EngineModule.Keys.K_1): if Engine.isKeyDown(EngineModule.Keys.K_EQUALS): Engine.setTimingFactor(Engine.getTimingFactor() * 0.5) print("set timingfactor: " +str(Engine.getTimingFactor())) else: Engine.setTimingFactor(Engine.getTimingFactor() * 0.9) print("set timingfactor: " +str(Engine.getTimingFactor())) if Engine.isKeyDown(EngineModule.Keys.K_2): if Engine.isKeyDown(EngineModule.Keys.K_EQUALS): Engine.setTimingFactor(Engine.getTimingFactor() * 2.0) print("set timingfactor: " +str(Engine.getTimingFactor())) else: Engine.setTimingFactor(Engine.getTimingFactor() * 1.1) print("set timingfactor: " +str(Engine.getTimingFactor())) if key == EngineModule.Keys.K_I: print("fps: " + str(float(1000.0 / Engine.getTimeDifference()))) for o in selection.get(): print("object: " + str(o)) print(" name: " + str(o.getName())) print(" uuid: " + str(o.readUuid())) if o.isActor(): print(" position: " + str(o.getPosition())) print(" size: " + str(o.getSize())) print(" orientation: " + str(o.getOrientation().toAngles())) print(" mass: " + str(o.getMass())) if o.isJoint(): print(" yLimit: " + str(o.isJoint().getYLimit())) print(" zLimit: " + str(o.isJoint().getZLimit())) print(" anchor 1: " + str(o.isJoint().getAnchor1())) print(" anchor 2: " + str(o.isJoint().getAnchor2())) print(" anchor 1 orien: " + str(o.isJoint().getAnchor1Orientation().toAngles())) print(" anchor 2 orien: " + str(o.isJoint().getAnchor2Orientation().toAngles())) print(" motorOn: " + str(o.isJoint().isMotorOn())) print(" motor target: " + str(o.isJoint().getMotorTarget().toAngles())) body,joint = bodyjoint.getBodyJoint(selection.get()) if ((body and joint) and bodyjoint.isBodyJointConnected(body,joint)): pass jointPos = bodyjoint.getBodyJointAnchorSizePos(body,joint) print("body joint size pos: " + str(jointPos))
def load(self, event): saveload.load(self.manager)
import numpy as np import saveload as sl import JPSSD as J data,fxlon,fxlat=sl.load('data') U,L,T=sl.load('result') xx=fxlon yy=fxlat zz=U J.plot_3D(xx,yy,zz) zz=L J.plot_3D(xx,yy,zz) zz=T J.plot_3D(xx,yy,zz)
import matplotlib.pyplot as pl import numpy as np import pandas as pd import saveload as sl df = sl.load('../../data/OJP/OJP_NW_VWC.pkl') # Get depths: z = [] for col in df.columns: print(col) x = np.mean( [float(i) for i in col.split('_')[1].split('c')[0].split('to')]) z.append(x) z = np.array(z) # Plot pl.figure(figsize=(12, 5)) for col in df.columns: pl.plot(df[col]) pl.grid() pl.ylabel('Volumetric water content') pl.legend() pl.savefig('OJP_NW_Timeseries.png', dpi=300)
from utils import * import numpy as np import matplotlib.pyplot as plt import saveload as sl # Load data g=sl.load('example') # Size of the center of the pixels size=200 # Ground pixels lons=np.array(g.lon_nofire) lats=np.array(g.lat_nofire) color=(0,0.59765625,0) plt.scatter(lons,lats,size,marker='.',color=color) # Fire pixels lons=np.array(g.lon_fire) lats=np.array(g.lat_fire) color=(0.59765625,0,0) plt.scatter(lons,lats,size,marker='.',color=color) plt.show()
print '>> File %s already created! Skipping all satellite processing <<' % bounds_file print 'Loading from %s...' % bounds_file result = loadmat(bounds_file) # Taking necessary variables from result dictionary scale = result['time_scale_num'][0] time_num_granules = result['time_num_granules'][0] time_num_interval = result['time_num'][0] lon = np.array(result['fxlon']).astype(float) lat = np.array(result['fxlat']).astype(float) if 'ofxlon' in result.keys(): fxlon = result['ofxlon'] fxlat = result['ofxlat'] elif cloud_exists and cloud: print '>> File %s already created! Skipping all satellite processing <<' % cloud_file print 'Loading from %s...' % cloud_file lon, lat, X, y, c, time_num_interval, time_num_granules, scale, fxlon, fxlat = sl.load( cloud_file) else: if satellite_exists: print '>> File %s already created! Skipping satellite retrieval <<' % satellite_file print 'Loading from %s...' % satellite_file data, fxlon, fxlat, time_num = sl.load(satellite_file) bbox = [fxlon.min(), fxlon.max(), fxlat.min(), fxlat.max()] else: argument = sys.argv[1].split(',') if len(argument) > 1: print '>> Creating the fire mesh <<' dlon = .005 dlat = .005 bounds = map(float, argument) fxlon, fxlat = np.meshgrid(np.arange(bounds[0], bounds[1], dlon), np.arange(bounds[2], bounds[3], dlat))
time_num = [1376114400.0, 1376546400.0] scale = [1375898400.0, 1377410400.0] dst = './patch/wrfout_patch' X, y, c = process_forecast_wrfout(dst, scale, time_num, plot=plot) sl.save(dict({'X': X, 'y': y, 'c': c}), 'forecast') else: bounds = (-113.85068, -111.89413, 39.677563, 41.156837) dst = './patch/wrfout_patch' f = process_forecast_slides_wrfout(dst, bounds, plot=plot) sl.save(f, 'forecast') else: from infrared_perimeters import process_ignitions from setup import process_detections dst = 'ideal_test' plot = False ideal = sl.load(dst) kk = 4 data = process_tign_g_slices(ideal['lon'][::kk, ::kk], ideal['lat'][::kk, ::kk], ideal['tign_g'][::kk, ::kk], ideal['bounds'], ideal['ctime'], ideal['dx'], ideal['dy'], wrfout_file='ideal', dt_for=ideal['dt'], plot=plot) if 'point' in ideal.keys(): p = [[ideal['point'][0]], [ideal['point'][1]], [ideal['point'][2]]] data.update(process_ignitions(p, ideal['bounds'])) elif 'points' in ideal.keys():