예제 #1
0
    def predict(self, x, y) -> wf.WindDataFrame:
        r = np.ndarray(shape=(2, len(x.values)))
        r[0, :] = x.values
        r[1, :] = y.values

        f = np.real(self.series.eval(r))
        return tools.create_wind_data_frame(x, y, f[0, :], f[1, :])
예제 #2
0
    def predict(self, x, y) -> wf.WindDataFrame:
        ############
        frame = self.lookup_data
        frame = frame[['x', 'y', 'altitude']].drop_duplicates()
        l1 = len(frame.index)

        x_ref = np.array(frame['x']).reshape((l1, 1))
        y_ref = np.array(frame['y']).reshape((l1, 1))

        def lookup(x, y):
            # Copied code from nn_windfield
            l2 = len(x)
            x_m = np.array(x).reshape((1, l2))
            y_m = np.array(y).reshape((1, l2))

            d_x = np.repeat(x_ref, l2, axis=1) - np.repeat(x_m, l1, axis=0)
            d_y = np.repeat(y_ref, l2, axis=1) - np.repeat(y_m, l1, axis=0)

            distance = d_x**2.0 + d_y**2.0

            nearest = np.argmin(distance, axis=0)
            return frame.iloc[nearest]['altitude'].values

        self.altitude_lookup = lookup
        #############

        df = pd.DataFrame({'x': x, 'y': y})
        df['z'] = self.altitude_lookup(df.x, df.y)

        uv = self.rf.predict(X=self.pol.fit_transform(df[['x', 'y', 'z']]))

        frame = tools.create_wind_data_frame(df.x, df.y, uv[:, 0], uv[:, 1])
        frame['altitude'] = df.z
        return frame
    def predict(self, x, y) -> wf.WindDataFrame:
        df = pd.DataFrame({'x': x, 'y': y})
        df['z'] = self.altitude_lookup(df.x, df.y)

        uv = self.rf.predict(X=self.pol.fit_transform(df[['x', 'y', 'z']]))

        frame = tools.create_wind_data_frame(df.x, df.y, uv[:, 0], uv[:, 1])
        frame['altitude'] = df.z
        return frame
예제 #4
0
    def predict(self, x, y) -> wf.WindDataFrame:
        if self.elevation is True:
            h = self.altitude_lookup(x, y)
            coordinates = np.hstack((x[:, None], y[:, None], h[:, None]))
        else:
            coordinates = np.hstack((x[:, None], y[:, None]))
        predicted_wind_vectors = self.MLP.predict(
            self.scaler_data.transform(coordinates))

        u = predicted_wind_vectors[:, 0]
        v = predicted_wind_vectors[:, 1]
        return tools.create_wind_data_frame(x, y, np.real(u), np.real(v))
예제 #5
0
    def predict(self, x, y) -> wf.WindDataFrame:
        def calculate_u(x, y):
            weight = 1 / ((np.abs(self.x - x))**2 + np.abs((self.y - y))**2)
            total_weight = np.sum(weight)
            return np.sum(self.u * weight) / total_weight

        def calculate_v(x, y):
            weight = 1 / ((self.x - x)**2 + (self.y - y)**2)
            total_weight = np.sum(weight)
            return np.sum(self.v * weight) / total_weight

        u = np.array([calculate_u(a, b) for (a, b) in zip(x, y)])
        v = np.array([calculate_v(a, b) for (a, b) in zip(x, y)])
        return tools.create_wind_data_frame(x, y, u, v)
예제 #6
0
    def predict(self, x, y) -> wf.WindDataFrame:
        l2 = len(x)
        x_m = np.array(x).reshape((1, l2))
        y_m = np.array(y).reshape((1, l2))

        d_x = np.repeat(self.x, l2, axis=1) - np.repeat(x_m, self.l, axis=0)
        d_y = np.repeat(self.y, l2, axis=1) - np.repeat(y_m, self.l, axis=0)

        distance = d_x ** 2.0 + d_y ** 2.0

        nearest = np.argmin(distance, axis=0)

        u = self.u[nearest]
        v = self.v[nearest]

        return tools.create_wind_data_frame(x, y, u, v)
    def predict(self, x, y) -> wf.WindDataFrame:
        ############
        frame = self.lookup_data
        frame = frame[['x', 'y', 'altitude']].drop_duplicates()
        l1 = len(frame.index)

        x_ref = np.array(frame['x']).reshape((l1, 1))
        y_ref = np.array(frame['y']).reshape((l1, 1))

        def lookup(x, y):
            # Copied code from nn_windfield
            l2 = len(x)
            x_m = np.array(x).reshape((1, l2))
            y_m = np.array(y).reshape((1, l2))

            d_x = np.repeat(x_ref, l2, axis=1) - np.repeat(x_m, l1, axis=0)
            d_y = np.repeat(y_ref, l2, axis=1) - np.repeat(y_m, l1, axis=0)

            distance = d_x**2.0 + d_y**2.0

            nearest = np.argmin(distance, axis=0)
            return frame.iloc[nearest]['altitude'].values

        self.altitude_lookup = lookup
        #############
        if self.elevation is True:
            h = self.altitude_lookup(x, y)
            coordinates = np.hstack((x[:, None], y[:, None], h[:, None]))
        else:
            coordinates = np.hstack((x[:, None], y[:, None]))
        predicted_wind_vectors = self.MLP.predict(
            self.scaler_data.transform(coordinates))

        u = predicted_wind_vectors[:, 0]
        v = predicted_wind_vectors[:, 1]
        return tools.create_wind_data_frame(x, y, np.real(u), np.real(v))
 def predict(self, x, y) -> wf.WindDataFrame:
     wdf = tools.create_wind_data_frame(x, y, np.zeros(len(x)), np.zeros(len(x)))
     wdf[['u', 'v']] = sum([w*wf.predict(x, y)[['u','v']] for w, wf in zip(self.weights, self.windfields)])
     return wdf
예제 #9
0
 def predict(self, x, y) -> wf.WindDataFrame:
     return tools.create_wind_data_frame(x, y, np.zeros_like(x),
                                         np.zeros_like(y))
예제 #10
0
 def predict(self, x, y) -> wf.WindDataFrame:
     u, _ = self.u_kriging.execute(style='points', xpoints=x, ypoints=y)
     v, _ = self.v_kriging.execute(style='points', xpoints=x, ypoints=y)
     pred = create_wind_data_frame(x, y, u, v)
     return pred