def __init__(self, exp_path, agents=None): """ Constructor """ self.params = parameters.Params() self.params.load(os.path.join(exp_path, '_params.json')) self.exp_path = exp_path self.agents = agents self.bd_extractor = BehaviorDescriptor(self.params) self.pca = None self.traj_to_obs = registered_envs[self.params.env_name]['traj_to_obs'] self.grid_params = registered_envs[self.params.env_name]['grid'] if not os.path.exists(os.path.join(self.exp_path, 'analyzed_data')): os.mkdir(os.path.join(self.exp_path, 'analyzed_data')) # GT_BD is the ground truth bd that is used to calculate the CVG if self.params.env_name == 'Dummy': self.gt_bd_extractor = dummy_gt_bd self.goals = 0 elif self.params.env_name == 'Walker2D': self.gt_bd_extractor = dummy_gt_bd self.goals = 0 elif self.params.env_name == 'CollectBall': self.gt_bd_extractor = collect_ball_gt_bd self.goals = 0 elif self.params.env_name == 'NDofArm': self.gt_bd_extractor = red_arm_gt_bd self.goals = 3 elif self.params.env_name == 'AntMaze': self.gt_bd_extractor = ant_maze_gt_bd self.goals = 2 elif self.params.env_name == 'HardMaze': self.gt_bd_extractor = hard_maze_gt_bd self.goals = 2 elif self.params.env_name == 'Curling': self.gt_bd_extractor = curling_gt_bd self.goals = 0 else: print("No GT BD given for: {}".format(self.params.env_name)) raise ValueError
def __init__(self, exp_path, multip=False, agents=None): """ Constructor """ self.params = parameters.Params() self.params.load(os.path.join(exp_path, '_params.json')) self.exp_path = exp_path self.agents = agents self.bd_extractor = BehaviorDescriptor(self.params) self.traj_to_obs = registered_envs[self.params.env_name]['traj_to_obs'] self.mp = multip if self.mp: global main_pool main_pool = mp.Pool(initializer=self.init_process, processes=int(os.cpu_count())) else: self.evaluator = Evaluator(self.params) if not os.path.exists(os.path.join(self.exp_path, 'analyzed_data')): os.mkdir(os.path.join(self.exp_path, 'analyzed_data'))
def setupModelSpecificPopsizes(self, inputData, agePopSizes): import model import derived import parameters # gaussianise stunting in *data* ages = self.keyList['ages'] for iAge in range(len(ages)): ageName = ages[iAge] probStunting = self.sumStuntedComponents( inputData.stuntingDistribution[ageName]) inputData.stuntingDistribution[ageName] = self.restratify( probStunting) listOfAgeCompartments = self.makeAgeCompartments( agePopSizes, inputData) pregnantWomen = self.makePregnantWomen(inputData) model = model.Model(pregnantWomen, listOfAgeCompartments, self.keyList) derived = derived.Derived(inputData, model, self.keyList) model.setDerived(derived) parameters = parameters.Params(inputData, derived, self.keyList) model.setParams(parameters) model.updateMortalityRate() return model, derived, parameters
# file.writerow(['x', 'y']) # file.writerow([1.0, 2.0]) # file.close() # out = csv.writer(open('natural_shape_points.csv', 'w'), delimiter=',', quoting=csv.QUOTE_ALL) # out.writerow(['x','y']) # out.writerow([1.0,2.0]) # out.close() # writer = csv.DictWriter(out, fieldnames=fieldnames) # writer.writeheader() # writer.writerow({'first_name': 'Baked', 'last_name': 'Beans'}) # writer.writerow({'first_name': 'Lovely', 'last_name': 'Spam'}) # writer.writerow({'first_name': 'Wonderful', 'last_name': 'Spam'}) params = parameters.Params() ''' Shape Definition ''' pointsNaturalShape = [] circle_sections = 50 for i in range(0, circle_sections): theta = (np.pi / (1.7 * circle_sections)) * i # pointsNaturalShape.append([params.r_base * (1.0 - np.cos(np.pi / 1.7 - theta)), params.r_base * np.sin(np.pi / 1.7 - theta)]) pointsNaturalShape.append( [params.r_base * (1.0 - np.cos(theta)), params.r_base * np.sin(theta)]) ## Transition region pointsNaturalShape.append([params.r_base + 1.4, params.r_base - 0.3])
.... .... linearly interpolate between times Note: this is different from Wang et al (2020), which assumes piecewise constant values for R_zero """ r_zero_array = np.zeros([6, 2]) r_zero_array[0, :] = [0.0, 3.0] # t=0 days R_zero = 3.0 r_zero_array[1, :] = [20.0, 2.6] # t = 60 days R_zero = 2.6 r_zero_array[2, :] = [70.0, 1.9] # t = 70 days R_zero = 1.9 r_zero_array[3, :] = [84.0, 1.0] # t = 84 days R_zero = 1.0 r_zero_array[4, :] = [90.0, .50] # t = 90 days R_zero = .50 r_zero_array[5, :] = [1000, .50] # t = 1000 days R_zero =.50 params = parameters.Params(c, N, sigma, gamma, r_zero_array) t_0 = 0 tspan = np.linspace(t_0, 181, 180) # time in days y_init = np.zeros(4) y_init[0] = S_0 y_init[1] = E_0 y_init[2] = I_0 y_init[3] = R_0 def seir_with_params(t, y): return seir_function(t, y, params)
Y_tout_snr, snr_diff_dec = dt.gen_signaux_snr(objet_principal, source_gal, source_halo, bruit_pose, SNR, simu) Y = Y_tout_snr[:, :, :, :, 0] Y_src = Y.mean(axis=3) empty_cube = snr_diff_dec * st.norm.rvs(loc=0, scale=1, size=(S, S, W)) # to change if the object center is not the subcube center : centre = np.array([int(S / 2), int(S / 2)]) # creating the "parameter" object : params = parameters.Params(Y, centre, pfa_bright=pfa_bright, pfa_faint=pfa_faint, taille_f=11, FWHM=FWHM) #%% # Actual detection Xe1, ve1, vem1, Xi, vi = sdp.detection_strategy(params) #%% isolating some regions for averaging spectra reg_init = ma.masked_array( Y_src, np.tile((Xi == 0)[:, :, np.newaxis], (1, 1, Y_src.shape[2]))) sp_init = ma.mean(ma.mean(reg_init, axis=0), axis=0) reg_ext = ma.masked_array( Y_src,
import threading import generator import parameters import controller import webGui import os threadLock = threading.Lock() threads = [] Parameters = parameters.Params(50, 44100, 10 * 4410, 500) controller.initialize(Parameters, threadLock) webGui.initialize(Parameters) generatorThread = generator.Generator(Parameters, threadLock) controllerThread = controller.Controller(Parameters, threadLock) generatorThread.start() controllerThread.start() webGui.run() # Add threads to thread list threads.append(generatorThread) threads.append(controllerThread) # Wait for all threads to complete for t in threads: t.join() generatorThread.stop() print('Generator and controller stoped')