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) dtbase = NephelaeDataServer.load(dtfile) print("Done !") sys.stdout.flush() gprMap = GprPredictor('RCT', dtbase, ['RCT'], kernel0) profiling = False # profiling = True if not profiling: fig, axes = plt.subplots(3, 1, sharex=True, sharey=True) simTime = p0.t lastTime = time.time() simSpeed = 50.0 # interp='nearest' interp = 'bicubic'
#! /usr/bin/python3 import sys sys.path.append('../../') import os import signal import time from nephelae.database import NephelaeDataServer database = NephelaeDataServer.load('/home/pnarvor/work/nephelae/data/temp/default.neph')
parser = argparse.ArgumentParser( description='Converts a NephelaeDataServer binary file to ASCII') parser.add_argument('inputpath', type=str, help="Path to database to be converted.") parser.add_argument('-o', '--outputpath', dest='outputpath', type=str, default=None, help="File to write the output to (default is stdout)") args = parser.parse_args() # database = NephelaeDataServer.load('/home/pnarvor/work/nephelae/data/barbados/logs/flight_01_28_02/database/database01.neph') database = NephelaeDataServer.load(args.inputpath) data = [entry.data for entry in database['STATUS'][:]] data = data + [entry.data for entry in database['SAMPLE'][:]] data.sort(key=lambda x: x.position.t) if args.outputpath is None: print(database.navFrame.one_line_str()) for datum in data: print(datum.one_line_str()) else: with open(args.outputpath, 'w') as f: f.write(database.navFrame.one_line_str() + '\n') for datum in data: f.write(datum.one_line_str() + '\n') print(datum.one_line_str())
from nephelae_mesonh import MesonhDataset, MesonhMap from nephelae.types import Position from nephelae.types import Bounds from nephelae.types import Gps from nephelae.types import SensorSample from nephelae.mapping import GprPredictor from nephelae.mapping import WindKernel from nephelae.mapping import WindMapConstant from nephelae.database import NephelaeDataServer mesonhPath = '/home/pnarvor/work/nephelae/data/MesoNH-2019-02/REFHR.1.ARMCu.4D.nc' # databasePath = '/home/pnarvor/work/nephelae/data/temp/dt5_01.neph' databasePath = 'output/wind_data04.neph' 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)
import sys sys.path.append('../../') import os import signal import time from ivy.std_api import * import logging from nephelae_paparazzi import PprzMesonhUav, PprzSimulation from nephelae.database import NephelaeDataServer # mesonhFiles = '/home/pnarvor/work/nephelae/data/MesoNH-2019-02/REFHR.1.ARMCu.4D.nc' mesonhFiles = '/local/fseguin/nephelae_data/MesoNH02/bomex_hf.nc' dtbase = NephelaeDataServer() # dtbase.enable_periodic_save('output/database01.neph', timerTick=10.0) def build_uav(uavId, navRef): uav = PprzMesonhUav(uavId, navRef, mesonhFiles, ['RCT', 'WT']) uav.add_sensor_observer(dtbase) uav.add_gps_observer(dtbase) return uav interface = PprzSimulation(mesonhFiles, ['RCT', 'WT'], build_uav_callback=build_uav) interface.start() # Has to be called after interface.start() dtbase.set_navigation_frame(interface.navFrame)
#! /usr/bin/python3 import time from nephelae.database import NephelaeDataServer import numpy as np import matplotlib.pyplot as plt from scipy.signal import medfilt t0 = time.time() database = NephelaeDataServer.load( '/home/pnarvor/work/nephelae/data/barbados/logs/flight_01_28_01/database/database01.neph' ) print("Loading time : ", time.time() - t0) t0 = time.time() channel0_10 = [ entry.data for entry in database['10', 'cloud_channel_0']( sortCriteria=lambda x: x.position.t)[:] ] channel1_10 = [ entry.data for entry in database['10', 'cloud_channel_1']( sortCriteria=lambda x: x.position.t)[:] ] channel0_12 = [ entry.data for entry in database['12', 'cloud_channel_0']( sortCriteria=lambda x: x.position.t)[:] ] channel1_12 = [ entry.data for entry in database['12', 'cloud_channel_1']( sortCriteria=lambda x: x.position.t)[:]
def configure_database(self): """TODO implement the replay""" database = None try: self.warmStart = self.config['allow_warm_start'] except KeyError as e: warn("No warm start configuration specified. No warm start " + "allowed byt default. Exception feedback : " + str(e)) self.warmStart = False try: config = self.config['database'] except KeyError: # No specific options were given to the database. # Leaving default behavior. if self.warmStart: raise RuntimeError("Warm start enable but no database " + "configuration was given. Aborting.") else: database = NephelaeDataServer() database.set_navigation_frame(self.localFrame) return database try: enableSave = config['enable_save'] except KeyError: # No saving configuration enableSave = False try: filePath = config['filepath'] except KeyError: filePath = None # This is safe (in python spec, x and y returns false if x is false # without trying to evaluate y) if self.warmStart and filePath is not None and os.path.exists( filePath): database = NephelaeDataServer.load(filePath) self.missionT0 = database.navFrame.position.t self.localFrame.position.t = self.missionT0 else: database = NephelaeDataServer() database.set_navigation_frame(self.localFrame) if enableSave: if filePath is None: raise ValueError("Configuration file "+self.mainConfigPath+\ " asked for database saving but did not set a 'filepath' field.") try: timerTick = config['timer_tick'] except KeyError: # Save database every 60.0 seconds if no tick given timerTick = 60.0 try: force = config['overwrite_existing'] except KeyError: # Don;t overwrite existing database by default force = False database.enable_periodic_save(filePath, timerTick, force) return database