from __future__ import print_function
import numpy as np

from WEAVEify_routines.step_11_read_write_mock_spectra.\
common_header_routines  import variable_list_to_save_in_header

###########################################
##### SAVE POST-PROCESSED FLUX FIELDS #####
###########################################

def save_flux_fields_all_format(inp_dict,flag_verbose="n"):

    flag_output_format = inp_dict["flag_output_format"]

    if flag_output_format.lower() == "hdf5":

        from WEAVEify_routines.step_11_read_write_mock_spectra.\
        input_output_hdf5_format  import save_flux_fields

    elif flag_output_format.lower() == "fits":

        from WEAVEify_routines.step_11_read_write_mock_spectra.\
        input_output_fits_format  import save_flux_fields

    inp_dict = save_flux_fields(inp_dict,flag_verbose=flag_verbose)

    return inp_dict


##############################################
##### SAVE OPTICAL DEPTH DATA ALL FORMAT #####
##############################################

def save_optical_depths_all_format(inp_dict,flag_verbose="n"):

    flag_output_format = inp_dict["flag_output_format"]

    if flag_output_format.lower() == "hdf5":

        from WEAVEify_routines.step_11_read_write_mock_spectra.\
        input_output_hdf5_format  import save_optical_depths

    elif flag_output_format.lower() == "fits":

        from WEAVEify_routines.step_11_read_write_mock_spectra.\
        input_output_fits_format  import save_optical_depths

    inp_dict = save_optical_depths(inp_dict,flag_verbose=flag_verbose)

    return inp_dict

##############################################
##### READ OPTICAL DEPTH DATA ALL FORMAT #####
##############################################

def read_optical_depths_all_format(inp_dict,flag_absorber="HI",flag_verbose="n"):

    flag_output_format = inp_dict["flag_output_format"]

    if flag_output_format.lower() == "hdf5":

        from WEAVEify_routines.step_11_read_write_mock_spectra.\
        input_output_hdf5_format  import read_optical_depths

        inp_dict_tau = read_optical_depths(inp_dict,flag_absorber=flag_absorber)

    elif flag_output_format.lower() == "fits":

        from WEAVEify_routines.step_11_read_write_mock_spectra.\
        input_output_fits_format  import read_optical_depths
        #input_output_hdf5_format  import read_optical_depths

        inp_dict_tau = read_optical_depths(inp_dict,flag_absorber=flag_absorber)
    
    return inp_dict_tau

