# 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
predict_data = np.empty([1, 20, 27, 2])
data_y = np.empty([1, 20, 27, 2])
if is_seasonal_circle:
    data_sc = np.empty([1, 1], dtype='int32')
if model_type == 'conv':
    data_x = np.empty([1, 20, 27, 2])
elif model_type == 'dense':
    data_x = np.empty([1, 1080])

for start_month in range(file_num, file_num + month - interval, interval):
    predict_data[0] = file_helper_unformatted.read_data_sstaha(start_month)
    nino34 = [index_calculation.get_nino34(predict_data[0])]

    # data preprocess z-zero
    if data_preprocess_method == 'preprocess_Z':
        predict_data = data_preprocess.preprocess_Z(predict_data, 0)
    # data preprocess dimensionless
    if data_preprocess_method == 'dimensionless':
        redict_data = data_preprocess.dimensionless(predict_data, 0)
    # data preprocess 0-1
    if data_preprocess_method == 'preprocess_01':
        predict_data = data_preprocess.preprocess_01(predict_data, 0)
    # data preprocess no month mean
    if data_preprocess_method == 'nomonthmean':
        predict_data = data_preprocess.no_month_mean(predict_data, 0)

    if model_type == 'conv':
Ejemplo n.º 2
0
file_hisotircal = 'D:\msy\projects\zc\zcdata\data_historical'

data_x = np.empty([1, 20, 27, 2])

fig, ax = plt.subplots()
x = np.linspace(file_num, file_num+month+12, month+1+12)
nino34_from_data = index_calculation.get_nino34_from_data(file_num, month+12)
line1, = plt.plot(x, nino34_from_data, 'black', linewidth=2.5)
plt.tick_params(labelsize=15)
labels = ax.get_xticklabels() + ax.get_yticklabels()
[label.set_fontname('Times New Roman') for label in labels]

nino34 = []
for start_month in range(file_num+0, file_num+month+0+1, interval):
    data_x = file_helper_unformatted.read_data_best(file_path0, start_month+192)
    nino34_temp = index_calculation.get_nino34(data_x)
    nino34.append(nino34_temp)
    X = np.linspace(file_num+0, file_num+month+0, month+1)
# plt.legend(['prediction', 'ZCdata'], loc='upper right')
line2, = plt.plot(X, nino34, 'b', linewidth=1.5, linestyle='-')

nino34 = []
for start_month in range(file_num+3, file_num+month+3+1, interval):
    data_x = file_helper_unformatted.read_data_best(file_path1, start_month+192)
    nino34_temp = index_calculation.get_nino34(data_x)
    nino34.append(nino34_temp)
    X = np.linspace(file_num+3, file_num+month+3, month+1)
line3, = plt.plot(X, nino34, 'r', linewidth=1.5, linestyle='-')

nino34 = []
for start_month in range(file_num+6, file_num+month+6+1, interval):
    # data preprocess z-zero
    if data_preprocess_method == 'preprocess_Z':
        data_y = data_preprocess.preprocess_Z(data_y, 1)
    # data preprocess dimensionless
    if data_preprocess_method == 'dimensionless':
        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(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])
Ejemplo n.º 4
0
# 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
for last in range(last_month):
    predict_data = np.empty([1, 20, 27, 2])
    data_y = 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])
    predict_data[0] = file_helper_unformatted.read_data_sstaha(file_num + last)
    if is_retrain:
        predict_data = file_helper_unformatted.exchange_rows(predict_data)

    nino34 = [index_calculation.get_nino34(predict_data[0])]

    # data preprocess z-zero
    if data_preprocess_method == 'preprocess_Z':
        predict_data = data_preprocess.preprocess_Z(predict_data, 0)
    # data preprocess dimensionless
    if data_preprocess_method == 'dimensionless':
        redict_data = data_preprocess.dimensionless(predict_data, 0)
    # data preprocess 0-1
    if data_preprocess_method == 'preprocess_01':
        predict_data = data_preprocess.preprocess_01(predict_data, 0)
    # data preprocess no month mean
    if data_preprocess_method == 'nomonthmean':
        predict_data = data_preprocess.no_month_mean(predict_data, 0)

    if model_type == 'conv':