def __initplugin__(self, mesonhFiles):

        if isinstance(mesonhFiles, MesonhDataset):
            self.atm = mesonhFiles
        else:
            self.atm = MesonhDataset(mesonhFiles)
        self.windProbes = {}
        self.windIvyBind = None
Exemple #2
0
    def load(self):

        self.config = ensure_dictionary(self.parser.parse())

        # Using current time as global mission time
        self.missionT0 = time.time()
        localFrameConfig = ensure_dictionary(self.config['local_frame'])
        ref = Position(self.missionT0, localFrameConfig['east'],
                       localFrameConfig['north'], localFrameConfig['alt'])
        self.localFrame = NavigationRef(ref, localFrameConfig['utm_zone'])
        self.flightArea = self.config['flight_area']

        self.database = self.configure_database()

        if 'data_views' in self.config.keys():
            self.dataviews = \
                DataViewManager.from_yaml_config(self.config['data_views'],
                                                  self.database)
        else:
            print("Warning : no data_views defined in config file.")

        # To be configured in config file
        # self.windMap = WindMapConstant('Horizontal Wind', [0.0, 0.0])
        # self.windMap = WindObserverMap('Horizontal Wind', sampleName=str(['UT','VT']))
        if 'wind_map' in self.config.keys():
            self.load_wind_map(self.config['wind_map'])
        else:
            raise KeyError('No wind map detected ! Wind maps types MUST be' +
                           'declared using wind_map as yaml keyword.')

        if 'mesonh_files' in self.config.keys():
            self.mesonhFiles = self.config['mesonh_files']
            self.mesonhDataset = MesonhDataset(self.mesonhFiles)

        if 'wind_feedback' in self.config.keys():
            if self.config['wind_feedback']:
                self.load_plugin(WindSimulation, self.mesonhFiles)

        if 'maps' in self.config.keys():
            self.load_maps(self.config['maps'])
        else:
            print("Warning : no maps defined in config file")

        if 'aircrafts' in self.config.keys():
            self.load_aircrafts(self.config['aircrafts'])
        else:
            print("Warning : no aircrafts defined in config file")
Exemple #3
0
    def __initplugin__(self,
                       mesonhFiles,
                       mesonhVariables=[],
                       targetCacheBounds=[[0, 20], [-500, 500], [-500, 500],
                                          [-400, 200]],
                       updateThreshold=0.25,
                       rctFeedback=True,
                       defaultRctBounds=Bounds(0.0, 1.0e-5),
                       mesonhOrigin=None):

        self.mesonhInitialized = False
        self.rctFeedback = rctFeedback
        self.windFeedback = rctFeedback
        self.add_notification_method('add_sample')

        # Check if proper variables are fetched to do the feedback
        if self.rctFeedback and 'RCT' not in mesonhVariables:
            mesonhVariables.append('RCT')

        if isinstance(mesonhFiles, MesonhDataset):
            self.atm = mesonhFiles
        else:
            self.atm = MesonhDataset(mesonhFiles)
        self.probes = {}
        for var in mesonhVariables:
            mesonhVar = MesonhVariable(self.atm,
                                       var,
                                       origin=mesonhOrigin,
                                       interpolation='linear')
            self.probes[str(var)] = MesonhCachedProbe(mesonhVar,
                                                      targetCacheBounds,
                                                      updateThreshold)
            self.probes[str(var)].start()

        b = self.probes['RCT'].var.actual_range[0]
        if b.min is None or b.max is None:
            self.rctBounds = defaultRctBounds
            print(
                "Warning. This Mesonh dataset does not seem to define " +
                "the range of its RCT variable. Using default value.",
                defaultRctBounds)
        else:
            self.rctBounds = Bounds(b[0], b[-1])
    def __init__(self, uavPid, navFrame, mesonhFiles,
                 targetCacheBounds=[[0,20],[-500,500],[-500,500],[-400,200]],
                 updateThreshold=0.25):

        self.uavPid   = uavPid
        self.navFrame = navFrame
        if isinstance(mesonhFiles, MesonhDataset):
            self.atm = mesonhFiles
        else:
            self.atm = MesonhDataset(mesonhFiles)
        self.probes = {}
        for var in ['UT','VT','WT']:
            mesonhVar = MesonhVariable(self.atm, var, interpolation='linear')
            self.probes[var] = MesonhCachedProbe(mesonhVar,
                                                 targetCacheBounds,
                                                 updateThreshold)
            self.probes[var].start()
        self.initialized = False
        self.stopping    = False
        self.stopped     = False

        self.reqBind = messageInterface.bind_raw(
                lambda sender, msg: self.wind_request_callback(msg),
                '(.*' + str(self.uavPid) + '.*WORLD_ENV_REQ.*)')
#! /usr/bin/python3

import sys
sys.path.append('../../')
import numpy as np
import matplotlib.pyplot as plt

from nephelae.types import Bounds
from nephelae.mapping import MapServer
from nephelae_mesonh import MesonhMap, MesonhDataset

mesonhFiles = "/home/pnarvor/work/nephelae/data/nephelae-remote/MesoNH02/bomex_hf.nc"

dataset = MesonhDataset(mesonhFiles)
maps = {
    'lwc': MesonhMap("Liquid Water Content", dataset, 'RCT'),
    'wt': MesonhMap("Vertical Wind", dataset, 'WT'),
    'hwind': MesonhMap("Horizontal Wind", dataset, ['UT', 'VT'])
}

mapServer0 = MapServer(mapSet=maps,
                       mapBounds=(None, Bounds(300.0, 800.0), None, None))
mapServer1 = MapServer(mapSet=maps,
                       mapBounds=(None, Bounds(300.0,
                                               800.0), Bounds(0.0,
                                                              500.0), None))

fig, axes = plt.subplots(2, 1, sharex=True)
# axes[0].imshow(mapServer0['lwc'][0.0,:,0.0:12000.0,650.0].data.T, origin='lower')
# axes[1].imshow(mapServer1['lwc'][0.0,:,0.0:12000.0,650.0].data.T, origin='lower')
axes[0].imshow(mapServer0['wt'][0.0, :, :, 650.0].data.T, origin='lower')
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)

# coordinates of the map you want to generate/extract
Exemple #7
0
# var1 = 'UT'     # WE wind
# var1 = 'VT'     # SN wind
var1 = 'WT'  # vertical wind
# var1 = 'TKET'   # Turbulent kinetic energy
# var1 = 'PABST'  # Absolute pressure
# var1 = 'RVT'    # Vapor mixing ratio
# var1 = 'RRT'    # Rain mixing ratio
# var1 = 'SVT001' # User data (?)
# var1 = 'SVT002' # User data (?)
# var1 = 'SVT003'  # User data (?)

mesonhFiles = '/home/pnarvor/work/nephelae/data/MesoNH-2019-02/REFHR.1.ARMCu.4D.nc'
# mesonhFiles = '/home/pnarvor/work/nephelae/data/nephelae-remote/Nephelae_tmp/download/L12zo.1.BOMEX.OUT.*.nc'
# mesonhFiles = '/home/pnarvor/work/nephelae/data/nephelae-remote/MesoNH02/bomex_hf.nc'

atm = MesonhDataset(mesonhFiles)

# tvar = atm.variables['time'][:]
# tvar = tvar - tvar[0]
# xvar = 1000.0*atm.variables['W_E_direction'][:]
# yvar = 1000.0*atm.variables['S_N_direction'][:]
# zvar = 1000.0*np.squeeze(atm.variables['VLEV'][:,0,0])

tvar = atm.dimensions[0]['data']
xvar = atm.dimensions[3]['data']
yvar = atm.dimensions[2]['data']
zvar = atm.dimensions[1]['data']

atmShape = type('AtmShape', (), {})()
atmShape.t = len(atm.dimensions[0]['data'])
atmShape.z = len(atm.dimensions[1]['data'])