def setup_map_generator(database, aircrafts, lengthScales, variance, noiseVariance, wind): # Object which is in charge of giving the wind to the gpr kernel. windServer = WindMapConstant('WindServer', wind) # Kernel to use in the gpr params = {} params['lengthScales'] = lengthScales params['variance'] = variance params['noiseVariance'] = noiseVariance shallowParams = {} # this is because of sklean clone function shallowParams['windMap'] = windServer params['shallowParameters'] = DeepcopyGuard(**shallowParams) kernel = WindKernel(**params) # Objects in charge of fetch cloud sensor data and voltage data from the # database and giving to the gpr calibrated sensor data. cloudViews = [] for aircraft, params in aircrafts.items(): cloudViews.append( CloudSensorProcessing("Cloud data " + aircraft, database, [aircraft, "cloud_channel_0"], [aircraft, "energy"], params['alpha'], params['beta'], params['scaling'])) # Aggregating the output of these view to a single one for the gpr cloudView = DataView("Cloud data", parents=cloudViews) # The object in charge of all gpr calculations. gpr = GprPredictor("Cloud Map estimator", cloudView, kernel) gpr.computeStd = True return gpr
######################################################################### mesonhPath = '/home/pnarvor/work/nephelae/data/MesoNH-2019-02/REFHR.1.ARMCu.4D.nc' rct = MesonhVariable(MFDataset(mesonhPath), 'RCT') ut = MesonhVariable(MFDataset(mesonhPath), 'UT') vt = MesonhVariable(MFDataset(mesonhPath), 'VT') t, p0, p, b, xyLocations, v0, mapShape, tStart, tEnd = parameters(rct) # Kernel processVariance = 1.0e-8 noiseStddev = 0.1 * np.sqrt(processVariance) # kernel0 = WindKernel(lengthScales, processVariance, noiseStddev**2, v0) # lengthScales = [70.0, 60.0, 60.0, 60.0] lengthScales = [70.0, 80.0, 80.0, 60.0] kernel0 = WindKernel(lengthScales, processVariance, noiseStddev**2, WindMapConstant('Wind', v0)) noise = noiseStddev * np.random.randn(p.shape[0]) dtfile = 'output/wind_data03.neph' print("Getting mesonh values... ", end='') # dtbase = NephelaeDataServer() # sys.stdout.flush() # for pos,n in zip(p,noise): # dtbase.add_gps(Gps("100", Position(pos[0],pos[1],pos[2],pos[3]))) # dtbase.add_sample(SensorSample('RCT', '100', pos[0], # Position(pos[0],pos[1],pos[2],pos[3]), # [rct[pos[0],pos[1],pos[2],pos[3] + n]])) # dtbase.add_sample(SensorSample('Wind', '100', pos[0], # Position(pos[0],pos[1],pos[2],pos[3]), # [ut[pos[0],pos[1],pos[2],pos[3]], vt[pos[0],pos[1],pos[2],pos[3]]])) # dtbase.save(dtfile, force=True)
database = NephelaeDataServer.load(databasePath) mesonhDataset = MesonhDataset(mesonhPath) rct = MesonhMap('Liquid water', mesonhDataset, 'RCT', interpolation='linear') # Have to define wind by hand for now. wind = np.array([8.5, 0.9]) windMap = WindMapConstant('Wind', wind) # Kernel for liquid water content processVariance = 1.0e-8 noiseStddev = 0.1 * np.sqrt(processVariance) lengthScales = [70.0, 80.0, 80.0, 60.0] rctKernel0 = WindKernel(lengthScales, processVariance, noiseStddev**2, windMap) rctGpr = GprPredictor('RCT', database, ['RCT'], rctKernel0) # coordinates of the map you want to generate/extract t = 160.0 x = [12.5, 6387.5] y = [1837.5, 2712.5] z = 1100.0 # getting some mesonh data mesonhSlice = rct[t, x[0]:x[1], y[0]:y[1], z].data # predicting with gpr gprSlice = rctGpr[t, x[0]:x[1], y[0]:y[1], z][0].data[:, :, 0] # the GPR prediction resolution depends on the kernel length scale so it is not # necessarily the same as the mesonh. Although they represent the same region