output_dict = dict.fromkeys(np.arange(0, 49), np.array([[]], dtype="int64"))

k_levels = np.arange(0, 12).reshape([12, 1])
for key in np.arange(0, 49):
    current_values = np.arange(key * 12, key * 12 + 12).reshape([12, 1])
    output_dict[key] = np.concatenate((current_values, k_levels), axis=1)

X_speed, _, _ = EnelWindSpeedTransformation().transform(X)
print("wind speed computed")

enel_transf = Enel_directionPowerCurveTransformation()
X_transf, dict_sample_turb = enel_transf.transform(X_angle, angles_coord_turb, X_speed, power_curve, Coord, Coord_turb,
                                                   threshold_dir=threshold_dir)
print("single transformation done")

X_transf, output_dict = enel_transf.transformPerTurbineLevel(dict_sample_turb, enel_dict, X, power_curve, X_transf,
                                                             output_dict)
print("transformation per turbine done")

XTrain_transf = X_transf[:XTrain.shape[0], :]
XTest_transf = X_transf[XTrain.shape[0]:, :]

##center data


values_TM = []
start_loss, _ = compute_lasso(XTrain_, YTrain_, XVal_, YVal_, score="mean_squared_error", values_TM=values_TM)
print("loss", start_loss)

n_features_transf = XTrain_.shape[1]

####generation blocks
        X_transf_no_levels = np.concatenate((X_transf,X_transf_1), axis = 1)
        XTrain_transf = X_transf_no_levels[:XTrain.shape[0],:]
        XTest_transf = X_transf_no_levels[XTrain.shape[0]:,:]

        print("loss mean turbina solo sul validation")
        XTrain_, XVal_, YTrain_, YVal_ = train_test_split(XTrain_transf, YTrain, test_size=0.33,random_state=0)
        Linear_fit().fitting(XTrain_, YTrain_, XVal_,YVal_, [])

        print("loss mean turbina solo sul test")
        Linear_fit().fitting(XTrain_transf, YTrain, XTest_transf,YTest,values_TM)

    print("-------------")

    if compute_levels:
        X_transf_2,_ = enel_transf.transformPerTurbineLevel(matrix_turbs, enel_dict, X, power_curve, np.array([[]]),output_dict)
        print("transformation per turbine done")

        if compute_single_mean:
            XTrain_transf = X_transf_2[:XTrain.shape[0],:]
            XTest_transf = X_transf_2[XTrain.shape[0]:,:]
            print("loss mean turbina levels solo sul validation")
            XTrain_, XVal_, YTrain_, YVal_ = train_test_split(XTrain_transf, YTrain, test_size=0.33,random_state=0)
            Linear_fit().fitting(XTrain_, YTrain_, XVal_,YVal_, [])

            print("loss mean turbina levels solo sul test")
            Linear_fit().fitting(XTrain_transf, YTrain, XTest_transf,YTest,values_TM)


        X_transf = np.concatenate((X_transf,X_transf_2), axis = 1)
        XTrain_transf = X_transf[:XTrain.shape[0],:]