示例#1
0
    def error_develope(self):
        # sample various error development
        # Initialize initial x
        init_x = self.initialize_x() + self.initialize_noise()
        model = Lorenz96(N_dim=self.N, F=self.F, init_x=init_x)
        true_value = model.Runge_Kutta_4(dt=self.dt, t_end=self.t_end)

        # set buffer
        data_num = int(self.t_end/self.dt)+1
        buffer = np.zeros([data_num])

        # Sample noise included version
        for j in range(self.noise_sample_num):
            # Initialize noise
            x = init_x + self.initialize_noise()
            model = Lorenz96(N_dim=self.N, F=self.F, init_x=x)
            # Check error development
            value = model.Runge_Kutta_4(dt=self.dt, t_end=self.t_end)

            # Evaluate how development
            dev = value - true_value

            # Append to buffer
            for i in range(data_num):
                buffer[i] = np.linalg.norm(dev[i])

        return buffer
 def __init__(self, true_path="make_data/true_value/data", noise_path="make_data/observation_data/data"):
     self.file_num = 1460
     self.N = 40   # dimention
     self.true_path = true_path
     self.noise_path = noise_path
     self.init_true, self.init_noise = self.load_data(0)
     self.init_P = np.zeros([self.N, self.N])
     self.model = Lorenz96(N_dim=self.N, F=8, init_x=self.init_true)
示例#3
0
 def __init__(self, true_path="make_data/true_value/data",
              noise_path="make_data/observation_data/data"):
     self.file_num = 1460
     self.N = 40   # dimention
     self.dt = 10e-2 # 6 hours
     self.true_path = true_path
     self.noise_path = noise_path
     self.Q = np.identity(self.N)
     self.R = np.identity(self.N)
     data, _ = self.load_data(0)
     self.model = Lorenz96(N_dim=self.N, F=8, init_x=data)
示例#4
0
    def make_contour(self, save=False):
        t_num = int(self.t_end/self.dt + self.dt)
        t = np.arange(0, t_num, self.dt)
        init_x = self.initialize_x()
        model = Lorenz96(N_dim=self.N, F=self.F, init_x=init_x)
        value = model.Runge_Kutta_4(dt=self.dt, t_end=self.t_end)

        # Make hausdorff dimension by recursion system
        # x : x[t,N]
        x_dim = np.arange(0, self.N, float(1.0/(self.N ** (self.contour_frac-1))))
        x_num = int(self.N ** self.contour_frac)
        print(value)

        # Plot
        plt.contour(value)

        if save:
            filename = "contour.png"
            plt.savefig(filename)

        plt.show()
示例#5
0
# select CUI or GUI
parser.add_argument("-s", "--Save", dest="Save",
                    action="store_true",
                    default=False,
                    help="save file")

args = parser.parse_args()


if __name__ == "__main__":
    # Set initial parameters of x
    x = F * np.ones(N_dim)
    x[N_dim-1] += 0.01

    # Constructer
    model = Lorenz96(N_dim=N_dim, F=F, init_x=x)
    truth = model.Runge_Kutta_4(dt=dt, t_end=t_end)

    # Include error
    x = F * np.ones(N_dim)
    x[N_dim-1] += 0.01 + err

    # Constructer
    model = Lorenz96(N_dim=N_dim, F=F, init_x=x)
    error_ver = model.Runge_Kutta_4(dt=dt, t_end=t_end)

    # Evaluate
    error = error_ver - truth
    t = np.arange(0, t_end+dt, dt)
    error_set = np.array([LA.norm(error[0])])
    for i in range(0, len(error)):