def __init__(self): #***** Private variables ***** self.__GHz = 1.e9 self.__ph = ph.Physics() #***** Public variables ***** #Dust constants, taken from Planck self.dustTemp = 19.7 #[K] self.dustSpecIndex = 1.5 self.dustFact = 2.e-3 self.dustFrequency = 353*self.__GHz #[Hz] #Dust angular power spectrum constants, taken from Dunkley self.dustAngFact = 8.e-12 self.dustEll0 = 10.0 self.dustNu0 = 90.0*self.__GHz #[Hz] self.dustM = -0.5 #Synchrotron constants self.syncSpecIndex = -3.0 self.syncFact = 6.e3 #Synchrotron angular power spectrum constants, taken from Dunkley self.syncAngFact = 4e-12 self.syncEll0 = 10.0 self.syncNu0 = 90.0*self.__GHz #[Hz] self.syncM = -0.6
def __init__(self, renderer, things, prev_score): self.timer = pygame.time.Clock() self.fps = 50.0 self.brain = ai.AI(self.timer) self.events = ui.Events() self.engine = physics.Physics(1 / self.fps) self.renderer = renderer human = entities.make_human() self.queue = [] self.things = [human, entities.make_steel()] floor = int(math.sqrt(prev_score / 100)) + 3 for i in xrange(floor): if random.random() < 0.2 and i != 0: self.queue.append(entities.make_rock()) else: self.queue.append(entities.make_enemy()) self.brain.initialize(self.things) self.events.initialize(self.things) self.engine.initialize(self.things) self.renderer.initialize(self.things) self.brain.initialize(self.queue) self.events.initialize(self.queue) self.engine.initialize(self.queue) self.renderer.initialize(self.queue) self.max_score = prev_score + sum( [e.max_health for e in self.queue if entities.Enemy in e])
def __init__(self, atmFile=None, inclForegrounds=False): #***** Private Variables ***** self.__GHz = 1.e9 self.__atmFile = atmFile self.__inclF = inclForegrounds self.__fg = fg.Foregrounds() self.__ph = ph.Physics() #***** Public Variables ***** #CMB parameters self.Ncmb = 'CMB' self.Tcmb = 2.725 #K self.Acmb = 1.0 self.Ecmb = 1.0 if self.__inclF: #Synchrotron parameters self.Nsyn = 'SYNC' self.Asyn = 1.0 self.Esyn = 1.0 #Dust parameters self.Ndst = 'DUST' self.Adst = 1.0 self.Edst = 1.0 if self.__atmFile: #Atmosphere parameters self.Natm = 'ATM' self.Aatm = 1. self.freq, self.atmTemp, self.atmTx = np.loadtxt(self.__atmFile, dtype=np.str, unpack=True, usecols=[0, 2, 3])
def __init__(self, log, exp, corr=True): #Store passed parameters self.exp = exp self.corr = corr #Generate classes for calculating self.ph = ph.Physics() self.nse = ns.Noise()
def __init__(self): #***** Private variables ***** self.__ph = phy.Physics() self.__pb2 = exp.PB2() #Efficiency of the cosmos self.__skyEff = 1. #Bunching factor self.__bf = 1.
def create_level4(self): self.minus_life = False level = level4.Level4(self.screen, self.col_life) self.phys_list = [] self.object_list = level.get_level() self.phys = physics.Physics(self.object_list[-1], self.fps) self.phys_list.append(self.phys) for i in self.object_list: if i.get_string() == 'shadow block': self.phys_list.append( shadow_flat_phys.ShadowFlatPhys(i, self.fps)) self.unit = self.object_list[-1]
def __init__(self, exp): #***** Private Variables ***** self.__mmToM = 1.e-03 self.__mToMm = 1.e+03 self.__GHz = 1.e-09 self.__uK2 = 1.e-12 self.__exp = exp self.__clc = calc.Calculate(self.__exp) self.__ph = ph.Physics() #Set plotting parameters plt.rc('font', size=32) plt.rc('font', family='serif') self.__lw = 3
def __init__(self): self.__ph = ph.Physics() #Efficiency of the galaxy self.__skyEff = 1.0 #Correlation files dir = '/'.join(__file__.split('/')[:-1])+'/detCorrFiles/PKL/' self.p_c_apert, self.c_apert = pk.load(open(dir+'coherentApertCorr.pkl', 'rb')) self.p_c_stop, self.c_stop = pk.load(open(dir+'coherentStopCorr.pkl', 'rb')) self.p_i_apert, self.i_apert = pk.load(open(dir+'incoherentApertCorr.pkl', 'rb')) self.p_i_stop, self.i_stop = pk.load(open(dir+'incoherentStopCorr.pkl', 'rb')) #Detector pitch array self.DetP = self.p_c_apert #Geometric pitch factor self.corrFact = 6 #Hex packing
def __init__(self, fgndDict=None, nrealize=1): self.__ph = ph.Physics() #Sample the foreground parameters if fgndDict: def samp(param, pos=False, norm=False): if nrealize == 1: return param.getAvg() else: return param.sample(nsample=1, pos=pos, norm=norm) self.dustTemp = samp(pr.Parameter(fgndDict['Dust Temperature']), pos=True) self.dustSpecIndex = samp(pr.Parameter( fgndDict['Dust Spec Index'])) self.dustAmp = samp(pr.Parameter(fgndDict['Dust Amplitude']), pos=True) self.dustFrequency = samp(pr.Parameter( fgndDict['Dust Scale Frequency']), pos=True) self.syncSpecIndex = samp( pr.Parameter(fgndDict['Synchrotron Spec Index'])) self.syncAmp = samp(pr.Parameter( fgndDict['Synchrotron Amplitude']), pos=True) else: #Dust constants, taken from Planck self.dustTemp = 19.7 #[K] self.dustSpecIndex = 1.5 self.dustAmp = 2.e-3 self.dustFrequency = 353 * un.GHzToHz #[Hz] #Synchrotron constants self.syncSpecIndex = -3.0 self.syncAmp = 6.e3 #Dust angular power spectrum constants, taken from Dunkley self.dustAngAmp = 8.e-12 self.dustEll0 = 10.0 self.dustNu0 = 90.0 * un.GHzToHz #[Hz] self.dustM = -0.5 #Synchrotron angular power spectrum constants, taken from Dunkley self.syncAngAmp = 4e-12 self.syncEll0 = 10.0 self.syncNu0 = 90.0 * un.GHzToHz #[Hz] self.syncM = -0.6
def __init__(self, exp, corr=False): #***** Private variables ***** self.__ph = phy.Physics() self.__nse = nse.Noise() self.__exp = exp self.__corr = corr #Unit conversions self.__GHz = 1.e-09 self.__mm = 1.e+03 self.__pct = 1.e+02 self.__pW = 1.e+12 self.__aWrtHz = 1.e+18 self.__uK = 1.e+06 self.__uK2 = 1.e-12 #Directory for writing result tables self.__dir = self.__exp.dir+'/TXT/'
def __init__(self): #***** Private variables ***** self.__ph = phy.Physics() #Efficiency of the cosmos self.__skyEff = 1. #Bunching factor self.__bf = 1. #Correlation files dir = '/'.join(__file__.split('/')[:-1])+'/detCorrFiles/PKL/' self.p_c_apert, self.c_apert = pkl.load(open(dir+'coherentApertCorr.pkl', 'rb')) self.p_c_stop, self.c_stop = pkl.load(open(dir+'coherentStopCorr.pkl', 'rb')) self.p_i_apert, self.i_apert = pkl.load(open(dir+'incoherentApertCorr.pkl', 'rb')) self.p_i_stop, self.i_stop = pkl.load(open(dir+'incoherentStopCorr.pkl', 'rb')) self.DetP = self.p_c_apert #Correlation factor for hex packing #self.corrFact = 3 self.corrFact = 6
def __init__(self, exp, corr=False): #***** Private variables***** self.__ph = ph.Physics() self.__exp = exp self.__clc = clc.Calculate(self.__exp, corr) self.__freq = [] self.__fbw = [] self.__numDet = [] self.__netArr = [] self.__sens = [] self.__ms = [] #Unit conversions self.__GHz = 1.e-09 self.__mm = 1.e+03 self.__pct = 1.e+02 self.__pW = 1.e+12 self.__aWrtHz = 1.e+18 self.__uK = 1.e+06 self.__uK2 = 1.e-12
def __init__(self, log, dict, nrealize=1, bandFile=None): self.__ph = ph.Physics() self.log = log self.bandFile = bandFile self.nrealize = nrealize #Store optic parameters self.element = dict['Element'] self.temper = pr.Parameter(dict['Temperature']) self.absorb = pr.Parameter(dict['Absorption']) self.refl = pr.Parameter(dict['Reflection']) self.thick = pr.Parameter(dict['Thickness'], un.mmToM) self.index = pr.Parameter(dict['Index']) self.lossTan = pr.Parameter(dict['Loss Tangent'], 1.e-04) self.conductivity = pr.Parameter(dict['Conductivity'], 1.e+06) self.surfaceRough = pr.Parameter(dict['Surface Rough'], un.umToM) self.spill = pr.Parameter(dict['Spillover']) self.spillTemp = pr.Parameter(dict['Spillover Temp']) self.scattFrac = pr.Parameter(dict['Scatter Frac']) self.scattTemp = pr.Parameter(dict['Scatter Temp'])
def __init__(self): #Efficiency of the galaxy self.__skyEff = 1.0 #Instantiate physics object for calculations self.ph = ph.Physics() #Correlation files #dir = '/'.join(__file__.split('/')[:-1])+'/detCorrFiles/PKL/' dir = os.path.join(os.path.split(__file__)[0], 'detCorrFiles', 'PKL') self.p_c_apert, self.c_apert = pk.load( open(os.path.join(dir, 'coherentApertCorr.pkl'), 'rb')) self.p_c_stop, self.c_stop = pk.load( open(os.path.join(dir, 'coherentStopCorr.pkl'), 'rb')) self.p_i_apert, self.i_apert = pk.load( open(os.path.join(dir, 'incoherentApertCorr.pkl'), 'rb')) self.p_i_stop, self.i_stop = pk.load( open(os.path.join(dir, 'incoherentStopCorr.pkl'), 'rb')) #Detector pitch array self.DetP = self.p_c_apert #Geometric pitch factor self.corrFact = 6 #Hex packing
def __init__(self, log, ch, band=None): self.log = log self.ch = ch self.__ph = ph.Physics() #Store detector parameters self.bandCenter = self.__paramSamp(ch.params['Band Center'], ch.bandID) self.fbw = self.__paramSamp(ch.params['Fractional BW'], ch.bandID) self.detEff = self.__paramSamp(ch.params['Det Eff'], ch.bandID) self.psat = self.__paramSamp(ch.params['Psat'], ch.bandID) self.psatFact = self.__paramSamp(ch.params['Psat Factor'], ch.bandID) self.n = self.__paramSamp(ch.params['Carrier Index'], ch.bandID) self.Tc = self.__paramSamp(ch.params['Tc'], ch.bandID) self.TcFrac = self.__paramSamp(ch.params['Tc Fraction'], ch.bandID) self.nei = self.__paramSamp(ch.params['SQUID NEI'], ch.bandID) self.boloR = self.__paramSamp(ch.params['Bolo Resistance'], ch.bandID) self.readN = self.__paramSamp(ch.params['Read Noise Frac'], ch.bandID) self.flo, self.fhi = self.__ph.bandEdges(self.bandCenter, self.fbw) self.Tb = ch.Tb if 'NA' in str(self.Tc): self.Tc = self.Tb * self.TcFrac #Load band if band is not None: eff = band if eff is not None: eff = np.array([e if e > 0 else 0. for e in eff]) eff = np.array([e if e < 1 else 1. for e in eff]) else: #Default to top hat band eff = [ self.detEff if f > self.flo and f < self.fhi else 0. for f in ch.freqs ] #Store detector optical parameters self.elem = ["Detector"] self.emiss = [[0.000 for f in ch.freqs]] self.effic = [eff] self.temp = [[self.Tb for f in ch.freqs]]
def __init__(self, log, calcs): self.log = log self.__calcs = calcs self.__ph = ph.Physics() self.exp = self.__calcs[0].exp snsmeans = [calc.snsmeans for calc in calcs] snsstds = [calc.snsstds for calc in calcs] optmeans = [calc.optmeans for calc in calcs] optstds = [calc.optstds for calc in calcs] self.snsmeans = [[[(np.mean([snsmeans[m][i][j][k] for m in range(len(snsmeans))], axis=0) ).tolist() for k in range(len(snsmeans[0][i][j]))] for j in range(len(snsmeans[0][i]))] for i in range(len(snsmeans[0]))] self.snsstds = [[[(np.mean([snsstds[m][i][j][k] for m in range(len(snsstds))], axis=0) + np.std([snsmeans[m][i][j][k] for m in range(len(snsmeans))], axis=0)).tolist() for k in range(len(snsstds[0][i][j]))] for j in range(len(snsstds[0][i]))] for i in range(len(snsstds[0] ))] self.optmeans = [[[(np.mean([optmeans[m][i][j][k] for m in range(len(optmeans))], axis=0) ).tolist() for k in range(len(optmeans[0][i][j]))] for j in range(len(optmeans[0][i]))] for i in range(len(optmeans[0]))] self.optstds = [[[(np.mean([optstds[m][i][j][k] for m in range(len(optstds))], axis=0) + np.std([optmeans[m][i][j][k] for m in range(len(optmeans))], axis=0)).tolist() for k in range(len(optstds[0][i][j]))] for j in range(len(optstds[0][i]))] for i in range(len(optstds[0] ))] self.name = [] self.freq = []; self.freqStd = [] self.fbw = []; self.fbwStd = [] self.numDet = [] self.netArr = []; self.netArrStd = [] self.sens = []; self.sensStd = [] self.ms = []; self.msStd = [] #Table column titles for camera files self.titleStrC = str("%-5s | %-15s | %-15s | %-7s | %-15s | %-15s | %-15s | %-15s | %-15s | %-15s | %-17s | %-15s | %-17s | %-15s\n" % ("Chan", "Frequency", "Frac Bandwidth", "Num Det", "Lyot Efficiency", "Optical Power", "Photon NEP", "Bolometer NEP", "Readout NEP", "Detector NEP", "Detector NET", "Array NET", "Mapping Speed", "Map Depth")) self.unitStrC = str("%-5s | %-15s | %-15s | %-7s | %-15s | %-15s | %-15s | %-15s | %-15s | %-15s | %-17s | %-15s | %-17s | %-15s\n" % ("", "[GHz]", "", "", "[%]", "[pW]", "[aW/rtHz]", "[aW/rtHz]", "[aW/rtHz]", "[aW/rtHz]", "[uK-rtSec]", "[uK-rtSec]", "[(uK^2 s)^-1]", "[uK-arcmin]")) self.breakStrC = "-"*240+"\n" #Table column titles for telescope and experiment files self.titleStrTE = str("%-5s | %-15s | %-15s | %-7s | %-15s | %-17s | %-15s\n" % ("Chan", "Frequency", "Frac Bandwidth", "Num Det", "Array NET", "Mapping Speed", "Map Depth")) self.unitStrTE = str("%-5s | %-15s | %-15s | %-7s | %-15s | %-17s | %-15s\n" % ("", "[GHz]", "", "", "[uK-rtSec]", "[(uK^2 s)^-1]", "[uK-arcmin]")) self.breakStrTE = "-"*110+"\n"
# algorithm variables error_sum, last_error, prev_time = 0, 0, 0 output_lon, output_lat = 0, 0 # sprites all_sprites = pygame.sprite.Group() balloon = Balloon(altitude, latitude, longitude, home_lat, home_lon) home = Home(home_lat, home_lon) all_sprites.add(balloon) all_sprites.add(home) theta = balloon.compute_theta() phy = physics.Physics(cd, mass, area, temp, glide_angle) # Serial port - from Arduino """while not ser: try: ser = serial.Serial(port, 9600) # name/path needs to be changed except: print("Not connected")""" #Gui.TitleScreen() # Display the title screen #pygame.time.delay(2000) # wait 2 seconds then change screens # Main loop while (finish != 'quit'): #print balloon.Vx,balloon.Vy # recieve data
# algorithm variables error_Sum, last_error, prev_time = 0, 0, 0 output_lon, output_lat = 0, 0 # sprites all_sprites = pygame.sprite.Group() balloon = Balloon(altitude, latitude, longitude, home_lat, home_lon) home = Home(home_lat, home_lon) all_sprites.add(balloon) all_sprites.add(home) theta = balloon.compute_theta() phy = physics.Physics() # Serial port - from Arduino """while not ser: try: ser = serial.Serial(port, 9600) # name/path needs to be changed except: print("Not connected")""" #Gui.TitleScreen() # Display the title screen #pygame.time.delay(2000) # wait 2 seconds then change screens # Main loop while (finish != 'quit'): # recieve data """while (not ser): # Serial disconnected
def __init__(self, log, ch, band=None): self.log = log self.ch = ch self.__ph = ph.Physics() #Sample detector parameters def samp(param, bandID=ch.bandID, pos=False, norm=False, min=None, max=None): if ch.clcDet == 1: return param.getAvg(bandID) else: return param.sample(bandID=bandID, nsample=1, pos=pos, norm=norm, min=min, max=max) self.bandCenter = samp(pr.Parameter(ch.dict['Band Center'], un.GHzToHz), pos=True) self.fbw = samp(pr.Parameter(ch.dict['Fractional BW']), pos=True, norm=True) self.flo, self.fhi = self.__ph.bandEdges(self.bandCenter, self.fbw) self.detEff = samp(pr.Parameter(ch.dict['Det Eff']), pos=True, norm=True) * ch.optCouple self.psat = samp(pr.Parameter(ch.dict['Psat'], un.pWtoW), pos=True) self.psatFact = samp(pr.Parameter(ch.dict['Psat Factor']), pos=True) self.n = samp(pr.Parameter(ch.dict['Carrier Index']), pos=True) self.Tb = ch.Tb self.Tc = samp(pr.Parameter(ch.dict['Tc']), min=self.Tb + 0.001) self.TcFrac = samp(pr.Parameter(ch.dict['Tc Fraction']), min=1.01) if 'NA' in str(self.Tc): self.Tc = self.Tb * self.TcFrac self.nei = samp(pr.Parameter(ch.dict['SQUID NEI'], un.pArtHzToArtHz), pos=True) self.boloR = samp(pr.Parameter(ch.dict['Bolo Resistance']), pos=True) self.readN = samp(pr.Parameter(ch.dict['Read Noise Frac']), pos=True) #Load band if band is not None: eff = band if eff is not None: eff = np.array([e if e > 0 else 0. for e in eff]) eff = np.array([e if e < 1 else 1. for e in eff]) else: #Default to top hat band eff = [ self.detEff if f > self.flo and f < self.fhi else 0. for f in ch.freqs ] #Store detector optical parameters self.elem = ["Detector"] self.emiss = [[0.000 for f in ch.freqs]] self.effic = [eff] self.temp = [[self.Tb for f in ch.freqs]]
def __init__(self, log, dict, nrealize=1, bandFile=None): self.__ph = ph.Physics() self.log = log self.bandFile = bandFile self.nrealize = nrealize #Store optic parameters self.params = { 'Element': dict['Element'], 'Temperature': pr.Parameter(self.log, 'Temperature', dict['Temperature'], min=0.0, max=np.inf), 'Absorption': pr.Parameter(self.log, 'Absorption', dict['Absorption'], min=0.0, max=1.0), 'Reflection': pr.Parameter(self.log, 'Reflection', dict['Reflection'], min=0.0, max=1.0), 'Thickness': pr.Parameter(self.log, 'Thickness', dict['Thickness'], un.mmToM, min=0.0, max=np.inf), 'Index': pr.Parameter(self.log, 'Index', dict['Index'], min=0.0, max=np.inf), 'Loss Tangent': pr.Parameter(self.log, 'Loss Tangent', dict['Loss Tangent'], 1.e-04, min=0.0, max=np.inf), 'Conductivity': pr.Parameter(self.log, 'Conductivity', dict['Conductivity'], 1.e+06, min=0.0, max=np.inf), 'Surface Rough': pr.Parameter(self.log, 'Surface Rough', dict['Surface Rough'], un.umToM, min=0.0, max=np.inf), 'Spillover': pr.Parameter(self.log, 'Spillover', dict['Spillover'], min=0.0, max=1.0), 'Spillover Temp': pr.Parameter(self.log, 'Spillover Temp', dict['Spillover Temp'], min=0.0, max=np.inf), 'Scatter Frac': pr.Parameter(self.log, 'Scatter Frac', dict['Scatter Frac'], min=0.0, max=1.0), 'Scatter Temp': pr.Parameter(self.log, 'Scatter Temp', dict['Scatter Temp'], min=0.0, max=np.inf) }
def run(self): """ The game loop. This performs initialisation including setting up pygame, and shows a loading screen while certain resources are preloaded. Then, we enter the game loop wherein we remain until the game is over. """ # Initialise the pygame display. pygame.init() pygame.mixer.init() self.renderer.initialise() # Create the game systems. self.entity_manager.register_component_system(physics.Physics()) self.entity_manager.register_component_system(systems.FollowsTrackedSystem()) self.entity_manager.register_component_system(systems.TrackingSystem()) self.entity_manager.register_component_system(systems.LaunchesFightersSystem()) self.entity_manager.register_component_system(systems.KillOnTimerSystem()) self.entity_manager.register_component_system(systems.PowerSystem()) self.entity_manager.register_component_system(systems.ShieldSystem()) self.entity_manager.register_component_system(systems.TextSystem()) self.entity_manager.register_component_system(systems.AnimSystem()) self.entity_manager.register_component_system(systems.ThrusterSystem()) self.entity_manager.register_component_system(systems.ThrustersSystem()) self.entity_manager.register_component_system(systems.WaveSpawnerSystem()) self.entity_manager.register_component_system(systems.CameraSystem()) self.entity_manager.register_component_system(systems.TurretSystem()) self.entity_manager.register_component_system(systems.TurretsSystem()) self.entity_manager.register_component_system(systems.WeaponSystem()) # Preload certain images. self.resource_loader.preload() # Make the camera. camera = self.entity_manager.create_entity_with(components.Camera, components.Body, components.Tracking, components.FollowsTracked) camera.get_component(components.FollowsTracked).follow_type = "instant" # Draw debug info if requested. self.game_services.debug_level = self.config.get_or_default("debug", 0) # Make the player player = self.entity_manager.create_entity("player.txt") camera.get_component(components.Tracking).tracked.entity = player # Create a view to pass to the input handling - this lets it map between # world and screen coordinates. view = drawing.CameraView(self.renderer, camera) # Make the input handling system. self.input_handling = input_handling.InputHandling(view, self.game_services) # Create the wave spawner. if not self.config.get_or_default("peaceful_mode", False): self.entity_manager.register_component_system(systems.WaveSpawnerSystem()) # Make it so that bullets can damage things. self.entity_manager.get_system(physics.Physics).add_collision_handler( DamageCollisionHandler() ) # Set the scrolling background. self.drawing.set_background("res/images/857-tileable-classic-nebula-space-patterns/6.jpg") # Run the game loop. self.running = True fps = 60 clock = pygame.time.Clock() tick_time = 1.0/fps while self.running: # Has a load been requested? if self.want_load: self.entity_manager.load(open("space_game.save", "r")) self.want_load = False ## Create any queued objects self.entity_manager.create_queued_objects() # If a pause has been scheduled then pause the game. if self.want_pause: self.want_pause = False self.entity_manager.pause() # If an unpause has been scheduled then unpause the game. if self.want_resume: self.want_resume = False self.entity_manager.unpause() # If a step has been scheduled then advance a frame and schedule a # pause. if self.want_step: self.entity_manager.unpause() self.want_pause = True self.want_step = False # Input for e in pygame.event.get(): response = self.input_handling.handle_input(e) if response.quit_requested: self.running = False # Update the systems. self.entity_manager.update(tick_time) # Draw self.renderer.pre_render(view) self.drawing.draw(view) self.renderer.post_render() self.renderer.flip_buffers() # Maintain frame rate. clock.tick(fps) # Remember how long the frame took. limited_fps = 1.0/(clock.get_time() / 1000.0) raw_fps = 1.0/(clock.get_rawtime() / 1000.0) time_ratio = (1.0/fps) / (clock.get_time()/1000.0) self.game_services.info.update_framerate(limited_fps, raw_fps, time_ratio) # Finalise pygame.quit()
def __init__(self, log, exp, corr=True): self.__ph = ph.Physics() self.__nse = ns.Noise() self.__exp = exp self.__corr = corr
def __init__(self, channelDict, camera, opticalChainFile, atmFile=None): #***** Private variables ***** self.__mm = 1.e-03 #m from mm self.__GHz = 1.e+09 #GHz from Hz self.__aWrtHz = 1.e-18 #aW/rtHz from W/rtHz self.__pArtHz = 1.e-12 #pA/rtHz from A/rtHz self.__Hz = 1.e-09 #Hz from GHz self.__pW = 1.e-12 #pW from W self.__camera = camera self.__opticalChainFile = opticalChainFile self.__ph = ph.Physics() self.__sky = sky.Sky(atmFile) #***** Camera Parameters ***** #Optical coupling to Focal Plane self.optCouple = self.__camera.opticalCouplingToFP #Detector F-number self.Fnumber = self.__camera.fnumber #Bath temperature self.Tb = self.__camera.Tb #***** Channel Parameters ***** #Band ID self.bandID = self.__float(channelDict['BandID']) #Pixel ID self.pixelID = self.__float(channelDict['PixelID']) #Band Center self.bandCenter = self.__float(channelDict['BandCenter'], self.__GHz) #Fractional Bandwidth self.fbw = self.__float(channelDict['FBW']) #Pixel Size self.pixSize = self.__float(channelDict['PixSize'], self.__mm) #Number of detectors self.numDet = self.__float(channelDict['NumDet']) #Number of pixels self.numPix = self.numDet / 2. #Waist factor self.wf = self.__float(channelDict['WaistFact']) #Detector efficiency self.detEff = self.__float(channelDict['DetEff']) #Psat self.psat = self.__float(channelDict['Psat'], self.__pW) #Psat Factor self.psatFact = self.__float(channelDict['PsatFact']) #Thermal Carrier Index self.n = self.__float(channelDict['CarrierIndex']) #Transition temperature self.Tc = self.__float(channelDict['TransTemp']) if self.Tc == 'NA': self.TcFrac = self.__float(channelDict['TcFrac']) self.Tc = self.Tb * self.TcFrac #Photon bunching factor self.bunchFact = self.__float(channelDict['BunchFactor']) #Detector yield self.detYield = self.__float(channelDict['Yield']) #Noise equivalent current self.nei = self.__float(channelDict['NEI'], self.__pArtHz) #Number of modes self.nModes = self.__float(channelDict['nModes']) #Bolometer resistance self.boloR = self.__float(channelDict['boloR']) #***** Optical Chain ***** self.opticalChain = oc.OpticalChain(self.__opticalChainFile, self.bandID) #Generate optical arrays self.genOptics()
from bird import Bird from levels import Level import pymunk as pm import math import physics from pig import Pig import cannon # Init pygame.init() window = pygame.display.set_mode((contants.WIDTH, contants.HEIGHT)) clock = pygame.time.Clock() Background = background.Background("images\\background.png") SlingShot = slingShot.SlingShot() Physics = physics.Physics() Cannon = cannon.Cannon() Running = True ParabolaList = [] birds = [] pigs = [] redbird = pygame.image.load("images\\red-bird3.png").convert_alpha() pigImage = pygame.image.load("images\\rsz_pig_failed.png").convert_alpha() space = pm.Space() space.gravity = (0.0, -982) physics.Polygon.create_ground(space)
# time _time = 0 time_step = 0.001 # can be calculated by how many iterations per second # change time step to speed up the simulation # sprites all_sprites = pygame.sprite.Group() balloon = Balloon(altitude,latitude,longitude,home_lat,home_lon,yaw) home = Home(home_lat,home_lon) all_sprites.add(balloon) all_sprites.add(home) theta = balloon.compute_theta() phy = physics.Physics(cd, mass, area, temp, glide_angle) # initialise the Physics file # Serial port - from Arduino """while not ser: try: ser = serial.Serial(port, 9600) # try to connect to the serial port except: print("Not connected") # warn the user that the serial port is not connected""" #Gui.TitleScreen() # Display the title screen #pygame.time.delay(1500) # wait 2 seconds then change screens pygame.time.set_timer(pygame.USEREVENT, random.randrange(5000,15000)) # Main loop while (finish != 'quit'): _time += time_step # simulate time
def __init__(self, log, fgndDict=None, nrealize=1): #Store passed parameters self.log = log self.fgndDict = fgndDict self.nrealize = nrealize #Create physics object for calculations self.ph = ph.Physics() #Store foreground parameters if self.fgndDict: self.params = { 'Dust Temperature': self.__paramSamp( pr.Parameter(self.log, 'Dust Temperature', self.fgndDict['Dust Temperature'], min=0.0, max=np.inf)), 'Dust Spec Index': self.__paramSamp( pr.Parameter(self.log, 'Dust Spec Index', self.fgndDict['Dust Spec Index'], min=-np.inf, max=np.inf)), 'Dust Amplitude': self.__paramSamp( pr.Parameter(self.log, 'Dust Amplitude', self.fgndDict['Dust Amplitude'], min=0.0, max=np.inf)), 'Dust Scale Frequency': self.__paramSamp( pr.Parameter(self.log, 'Dust Scale Frequency', self.fgndDict['Dust Scale Frequency'], min=0.0, max=np.inf)), 'Synchrotron Spec Index': self.__paramSamp( pr.Parameter(self.log, 'Synchrotron Spec Index', self.fgndDict['Synchrotron Spec Index'], min=-np.inf, max=np.inf)), 'Synchrotron Amplitude': self.__paramSamp( pr.Parameter(self.log, 'Synchrotron Amplitude', self.fgndDict['Synchrotron Amplitude'], min=0.0, max=np.inf)) } else: #Default parameters from Planck self.params = { 'Dust Temperature': 19.7, 'Dust Spec Index': 1.5, 'Dust Amplitude': 2.e-3, 'Dust Scale Frequency': 353. * un.GHzToHz, 'Synchrotron Spec Index': -3.0, 'Synchrotron Amplitude': 6.e3 } #Dust angular power spectrum constants, taken from Dunkley self.dustAngAmp = 8.e-12 self.dustEll0 = 10.0 self.dustNu0 = 90.0 * un.GHzToHz #[Hz] self.dustM = -0.5 #Synchrotron angular power spectrum constants, taken from Dunkley self.syncAngAmp = 4e-12 self.syncEll0 = 10.0 self.syncNu0 = 90.0 * un.GHzToHz #[Hz] self.syncM = -0.6