import numpy as np
import matplotlib.pyplot as plt
#from common_lib.miscellaneous.numpy_special_functions import 
#slice_array_between_two_limits

def gaussian_noise_routines_main(inp_dict):
    inp_dict            = generate_SNR_per_pixel_array(inp_dict)
    SNR_arr             = inp_dict["SNR_per_pixel_arr"]
    inp_dict_Flux       = inp_dict["inp_dict_Flux"]
    Flux_arr_cont_added = inp_dict_Flux["Flux_arr_cont_added"]
    Flux_arr            = Flux_arr_cont_added[:,1]
    Flux_arr_final      = np.zeros((Flux_arr.shape[0],4))
    noise_arr           = np.random.normal(1.0,1.0/SNR_arr)
    Flux_arr_with_noise = Flux_arr_cont_added[:,1] * noise_arr
    Flux_arr_final[:,0] = Flux_arr_cont_added[:,0]
    Flux_arr_final[:,1] = Flux_arr_with_noise
    Flux_arr_final[:,2] = Flux_arr_cont_added[:,1]
    Flux_arr_final[:,3] = Flux_arr_cont_added[:,2]
    inp_dict_Flux.update({"Flux_arr_final":Flux_arr_final})
    inp_dict.update({"inp_dict_Flux":inp_dict_Flux})
    return inp_dict

################
################

def generate_SNR_per_pixel_array(inp_dict):
    key_list            = inp_dict.keys()

    if "SNR_per_pixel_arr" not in key_list:
        SNR_per_pixel_val = inp_dict["SNR_per_pixel_val"]
        N_pixel           = inp_dict["inp_dict_Flux"]["Flux_arr_cont_added"].shape[0]
        SNR_per_pixel_arr = np.ones(N_pixel) * SNR_per_pixel_val
        inp_dict.update({"SNR_per_pixel_arr":SNR_per_pixel_arr})

    return inp_dict

