file_num = 417 month = 47 interval = 1 prediction_month = 1 directly_month = 12 # make directory file_path1 = "D:\msy\projects\zc\zcdata\data_networks\\" + model_name1 + '\\' + str(directly_month) + '\\' file_path2 = "D:\msy\projects\zc\zcdata\data_networks\\" + model_name2 + '\\' + str(directly_month) + '\\' file_path3 = "D:\msy\projects\zc\zcdata\data_networks\\" + model_name3 + '\\' + str(directly_month) + '\\' data_x = np.empty([1, 20, 27, 2]) 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()
data_y = data_preprocess.dimensionless(data_y, 1) # data preprocess 0-1 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(start_month, start_month + prediction_month, prediction_month + 1) plt.plot(x, nino34, 'b') x = np.linspace(file_num, file_num + month, month + 1) plt.plot(x, index_calculation.get_nino34_from_data(file_num, month), 'r', linewidth=1) # 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)
# month = 124 interval = 1 prediction_month = name_list.prediction_month directly_months = [3, 6, 9, 12] # directly_months = [1, 2, 3, 4] data_preprocess_method = name_list.data_preprocess_method is_sequence = name_list.is_sequence time_step = name_list.time_step is_nino_output = name_list.is_nino_output # for dense_model # predict_data = np.empty([1, 540]) # predict_data[0] = file_helper.read_data(file_num) # file_helper.write_data(file_num, model.predict(predict_data)[0]) # for dense_model ssta and ha nino34_from_data = index_calculation.get_nino34_from_data( file_num + time_step, month - time_step) # print(nino34_from_data) for di, directly_month in enumerate(directly_months): if not is_sequence: predict_data = np.empty([1, 20, 27, 2]) if model_type == 'conv': data_x = np.empty([1, 20, 27, 2]) else: data_x = np.empty([1, 1080]) else: predict_data = np.empty([1, time_step, 20, 27, 2]) if is_seasonal_circle: pass else: pass data_x = np.empty([1, time_step, 20, 27, 2])