예제 #1
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])
예제 #2
0
    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.*)')
예제 #3
0
                                     tmp.shape[1]),
                         indexing='xy',
                         copy=False)
    # xyLocations = np.array([[0]*X0.shape[0]*X0.shape[1], X0.ravel(), Y0.ravel()]).T
    print(X0.ravel())
    xyLocations = np.array([[0] * X0.shape[0] * X0.shape[1],
                            X0.ravel(),
                            Y0.ravel(), [p0.z] * X0.shape[0] * X0.shape[1]]).T

    return t, p0, p, b, xyLocations, v0, tmp.shape, tStart, tEnd


#########################################################################

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])
예제 #4
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'])
atmShape.y = len(atm.dimensions[2]['data'])
atmShape.x = len(atm.dimensions[3]['data'])

print("Shape : (", atmShape.t, atmShape.z, atmShape.x, atmShape.y, ")")

# data0 = MesonhVariable(atm, var0, interpolation='nearest')
# data1 = MesonhVariable(atm, var1, interpolation='nearest')
data0 = MesonhVariable(atm, var0, interpolation='linear')
data1 = MesonhVariable(atm, var1, interpolation='linear')

# z0 = 1100.0
z0 = 1280.0
y0 = 4500.0
xySlice = slice(0.0, 12000.0, None)
# zSlice = slice(None, None, None)
zSlice = slice(0.0, 12000.0, None)
# xySlice = slice(0.0, 3000.0, None)
# # zSlice = slice(None, None, None)
# zSlice = slice(0.0, 12000.0, None)
# tStart = time.time()
tStart = 0

xyBounds = data0[0.0, xySlice, xySlice, z0].bounds
예제 #5
0
                         copy=False)
    # xyLocations = np.array([[0]*X0.shape[0]*X0.shape[1], X0.ravel(), Y0.ravel()]).T
    print(X0.ravel())
    xyLocations = np.array([[0] * X0.shape[0] * X0.shape[1],
                            X0.ravel(),
                            Y0.ravel(), [p0.z] * X0.shape[0] * X0.shape[1]]).T

    return t, p0, p, b, xyLocations, v0, tmp.shape, tStart, tEnd


#########################################################################

mesonhPath = '/local/fseguin/nephelae_data/REFHR.1.ARMCu.4D.nc'
dataset = MesonhDataset(mesonhPath)

rct = MesonhVariable(dataset, 'RCT')
ut = MesonhVariable(dataset, 'UT')
vt = MesonhVariable(dataset, '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])
예제 #6
0
        if Y is X:
            return self.stddev * np.exp(-0.5 * distMat) + np.diag(
                [self.noiseStddev] * X.shape[0])
        else:
            return self.stddev * np.exp(-0.5 * distMat)

    def diag(self, X):
        return np.array([self.stddev + self.noiseStddev] * X.shape[0])

    def is_stationary(self):
        return True


mesonhPath = '/home/pnarvor/work/nephelae/data/MesoNH-2019-02/REFHR.1.ARMCu.4D.nc'
rct = MesonhVariable(MFDataset(mesonhPath), 'RCT')

# Estimating advective wind
ut = MesonhVariable(MFDataset(mesonhPath), 'UT')[50.0, :, :,
                                                 1100.0].data.mean()
vt = MesonhVariable(MFDataset(mesonhPath), 'VT')[50.0, :, :,
                                                 1100.0].data.mean()
print("Advective wind :", [ut, vt])

rctSlice = rct[240, :, :, 1100].data
print("Variance : ", (rctSlice**2).mean())

t = np.linspace(0, 300.0, 300)
# a0 = 400.0
a0 = 250.0
f0 = -1 / 120.0