fig, ax = plt.subplots() x = np.linspace(file_num, file_num+month, month+1) nino34_from_data = index_calculation.get_nino34_from_data(file_num, month) line0 = plt.plot(x, nino34_from_data, 'b', linewidth=0, linestyle='-') line1, = plt.plot(x, nino34_from_data, 'black', linewidth=1.5) plt.tick_params(labelsize=15) labels = ax.get_xticklabels() + ax.get_yticklabels() [label.set_fontname('Times New Roman') for label in labels] f = h5py.File(file_path1+'nino34.h5', 'r') X = f['X'] Y = f['Y'] # plt.legend(['prediction', 'ZCdata'], loc='upper right') line2, = plt.plot(X, Y, 'b', linewidth=1.5, linestyle='-') print(model_name1) print(math_tool.pearson_distance(Y[:month-directly_month*prediction_month], nino34_from_data[directly_month*prediction_month:])) f.close() f = h5py.File(file_path2+'nino34.h5', 'r') X = f['X'] Y = f['Y'] line3, = plt.plot(X, Y, 'r', linewidth=1.5, linestyle='-') print(model_name2) print(math_tool.pearson_distance(Y[:month-directly_month*prediction_month], nino34_from_data[directly_month*prediction_month:])) f.close() f = h5py.File(file_path3+'nino34.h5', 'r') X = f['X'] Y = f['Y'] line4, = plt.plot(X, Y, 'y', linewidth=1.5, linestyle='-')
fig, ax = plt.subplots() x = np.linspace(file_num, file_num + month, month + 1) nino34_from_data = index_calculation.get_nino34_from_data(file_num, month) line1, = plt.plot(x, nino34_from_data, 'black', linewidth=1.5) plt.tick_params(labelsize=15) labels = ax.get_xticklabels() + ax.get_yticklabels() [label.set_fontname('Times New Roman') for label in labels] f = h5py.File(file_path1 + 'nino34.h5', 'r') X = f['X'] Y = f['Y'] # plt.legend(['prediction', 'ZCdata'], loc='upper right') line2, = plt.plot(X, Y, 'b', linewidth=1.5, linestyle='-') print( math_tool.pearson_distance(Y[:month - 3 * prediction_month], nino34_from_data[3 * prediction_month:])) f.close() f = h5py.File(file_path2 + 'nino34.h5', 'r') X = f['X'] Y = f['Y'] line3, = plt.plot(X, Y, 'r', linewidth=1.5, linestyle='-') print( math_tool.pearson_distance(Y[:month - 6 * prediction_month], nino34_from_data[6 * prediction_month:])) f.close() f = h5py.File(file_path3 + 'nino34.h5', 'r') X = f['X'] Y = f['Y'] line4, = plt.plot(X, Y, 'y', linewidth=1.5, linestyle='-') print(
if data_preprocess_method == 'preprocess_01': data_y = data_preprocess.preprocess_01(data_y, 1) # data preprocess no month mean if data_preprocess_method == 'nomonthmean': data_y = data_preprocess.no_month_mean(data_y, 1) # calculate nino 3.4 index nino34_temp1 = index_calculation.get_nino34(data_y[0]) nino34.append(nino34_temp1) # file_helper_unformatted.write_data(file_num+month, data_temp[1]) # x = np.linspace(file_num, start_month + prediction_month, prediction_month + 1) x = np.linspace(file_num, file_num + month, month + 1) plt.plot(x, nino34, 'b') nino34_from_data = index_calculation.get_nino34_from_data(file_num, month) plt.plot(x, nino34_from_data, 'r', linewidth=1) print(math_tool.pearson_distance(nino34, nino34_from_data)) # plt.legend(['prediction', 'ZCdata'], loc='upper right') plt.show() # file_helper_unformatted.write_data(file_num, model.predict(data_x)[0]) # for convolutional model only ssta # predict_data = np.empty([1, 540]) # predict_data[0] = file_helper.read_data(file_num) # predict_result = model.predict(np.reshape(predict_data[0], (1, 20, 27, 1))) # file_helper.write_data_conv2d(file_num, predict_result[0]) # for convolutional model ssta and ha # predict_data = np.empty([1, 20, 27, 2]) # predict_data[0] = file_helper.read_data_sstaha(file_num) # predict_result = model.predict(predict_data)
prediction_month = 12 directly_month = predict_369_data.directly_month data_preprocess_method = name_list.data_preprocess_method # make directory file_path = "D:\msy\projects\zc\zcdata\data_predict_" + str(prediction_month) file_hisotircal = 'D:\msy\projects\zc\zcdata\data_historical' rmse_all = [] nino34 = [] nino34_historical = [] for start_month in range(file_num + prediction_month, file_num + month + prediction_month + 1, interval): data_x = file_helper_unformatted.read_data_best(file_path, start_month + 192) data_from_data = file_helper_unformatted.read_data_historical( file_hisotircal, start_month) nino34_temp = index_calculation.get_nino34(data_x) nino34.append(nino34_temp) nino34_temp = index_calculation.get_nino34(data_from_data) nino34_historical.append(nino34_temp) rmse_all.append( math_tool.calculate_rmse(data_x[:, :, 0], data_from_data[:, :, 0])) print(math_tool.pearson_distance(nino34, nino34_historical)) plt.plot(nino34, 'r', linewidth=1) plt.plot(nino34_historical, 'y', linewidth=1) print(rmse_all) print(sum(rmse_all) / rmse_all.__len__()) plt.show()