from __future__ import print_function
import numpy as np


def variable_list_to_save_in_header(flag_output="flux"):
    header_param_list_flux = [\
    "instrument","resolution_mode","spectra_type","CRVAL1","CDELT1",\
    "N_pixel_obs","lambda_scale"]

    header_param_list_tau = [\
    "z_em","sim_name","L_box","N_Grid","spec_id","HI_trans_list","flag_tau",\
    "flag_tau_each_trans","flag_absorber","z_DLA","log_N_HI_DLA","b_DLA",\
    "flag_metal_method","metal_trans_list","log_Z_val_const","uvb_model_metal",\
    ]

    header_param_list = header_param_list_tau # By default only initialize Header with basic parameters

    if flag_output == "flux":
        header_param_list.extend(header_param_list_flux)

    return header_param_list


def generate_standard_fits_file_compact_header():
    std_fit_header_dict = {\
    "m_source"        :["OBJMAG","Source magnitude"],\
    "wave_band_source":["OBJWBAND","Wavelength filter of source magnitude"],\
    "source_type":["OBJTYPE","Type of source (Point or Extended)"],\
    "instrument":["INSTR","Instrument Name"],\
    "resolution_mode":["RESMODE","Resolution mode for WEAVE survey"],\
    "spectra_type":["SPECTYPE","Type of Spectra"],\
    "dia_telescope":["DIATEL","Diameter of telescope in meters"],\
    "ccd_pix_size_micron":["PIXSIZE","Size of CCD pixel in microns"],\
    "dia_fibre_arcsec":["FIBREDIA","Diameter of fibre in arcsec"],\
    "CRVAL1":["CRVAL1","Start of wavelength array in angstroms"],\
    "CDELT1":["CDELT1","Wavelength spacing in angstroms"],\
    "N_pixel_obs":["NPIXEL","Number of pixels in wavelength/flux array"],\
    "lambda_scale":["WSCALE","Wavelength spacing scale (LIN or LOG)"],\
    "flag_cont_method":["CONTINUM","Continuum generation method"],\
    "lsf_type":["LSFTYPE","Functional form of Line Spread Function"],\
    "flag_noise":["NOISTYPE","Type of noise added to spectra"],\
    "m_sky":["SKYMAG","Sky magnitude"],\
    "wave_band_sky":["SKYWBAND","Wavelength Filter of sky magnitude"],\
    "t_exp":["EXPTIME","Exposure time in seconds"],\
    "fwhm_seeing":["SEEING","Atmospheric Seeing"],\
    "beamsize":["BEAMSIZE","Beam size"],\
    "dark_current":["DARKCURR","Amount of Dark current"],\
    "seeing_profile":["SEEPRFLE","Functional form of Seeing Profile"],\
    "r_offset":["ROFFSET","Offset of source from center of fibre in arcsec"],\
    "read_noise":["READNOIS","Amount of read noise "],\
    "airmass":["AIRMASS","Atmospheric airmass"],\
    "beta_moffat":["BETAMOFT","Power law index of MOFFAT Seeing profile"],\
    "fcol":["FCOL",""],\
    "fFP":["FFP",""],\
    "fcam":["FCAM",""],\
    "PRI_fwhm":["PRIFWHM",""],\
    "throughput_type":["THRTYPE","Type of throughput"],\
    "flux_norm_(erg/s/cm^2/A)":["FLUXNORM","Normalization factor for flux"],\
    "z_em":["ZEM","Emission redshift of QSO"],\
    "sim_name":["SIMNAME","Name of the simulation"],\
    "L_box":["BOXSIZE","Size of simulation box in cMpc / h"],\
    "N_Grid":["NGRIDSIM","Number of grids in simulation sightline"],\
    "spec_id":["SPECID","Spectrum Identification number or String"],\
    "HI_trans_list":["HILIST","HI transition list to calculate OD and Flux"],\
    "flag_tau":["TAUFIELD","Optical Depth to be calculated for specie"],\
    "flag_tau_each_trans":["TAUSCALE","If y, scaling relations are used to calculate OD"],\
    "flag_absorber":["ABSTYPE","Flux to be calculated for specie"],\
    "z_DLA":["ZDLA","Redshift list of DLA"],\
    "log_N_HI_DLA":["LNHIDLA","Column Denstion (Log N_HI) list of DLA"],\
    "b_DLA":["BDLA","Line width parameter (b) list of DLA"],\
    "flag_metal_method":["METLTYPE","Method of adding method to spectrum"],\
    "metal_trans_list":["METLLIST","Metal transition list for OD and flux calculation"],\
    "log_Z_val_const":["LZMETAL","Factor if metallicity is constant expressed in log Z_sun"],\
    "uvb_model_metal":["METALUVB","UVB used to calculate metal specie abundances"]
    }
    return std_fit_header_dict


def backup_generate_standard_fits_file_compact_header():
    std_fit_header_dict = {\
    "m_source":"OBJMAG",\
    "wave_band_source":"OBJWBAND",\
    "source_type":"OBJTYPE",\
    "instrument":"INSTR",\
    "resolution_mode":"RESMODE",\
    "spectra_type":"SPECTYPE",\
    "dia_telescope":"DIATEL",\
    "ccd_pix_size_micron":"PIXSIZE",\
    "dia_fibre_arcsec":"FIBREDIA",\
    "CRVAL1":"CRVAL1",\
    "CDELT1":"CDELT1",\
    "N_pixel_obs":"NPIXEL",\
    "lambda_scale":"WSCALE",\
    "flag_cont_method":"CONTINUM",\
    "lsf_type":"LSFTYPE",\
    "flag_noise":"NOISTYPE",\
    "m_sky":"SKYMAG",\
    "wave_band_sky":"SKYWBAND",\
    "t_exp":"EXPTIME",\
    "fwhm_seeing":"SEEING",\
    "beamsize":"BEAMSIZE",\
    "dark_current":"DARKCURR",\
    "seeing_profile":"SEEPRFLE",\
    "r_offset":"ROFFSET",\
    "read_noise":"READNOIS",\
    "airmass":"AIRMASS",\
    "beta_moffat":"BETAMOFT",\
    "fcol":"FCOL",\
    "fFP":"FFP",\
    "fcam":"FCAM",\
    "PRI_fwhm":"PRIFWHM",\
    "throughput_type":"THRTYPE",\
    "flux_norm_(erg/s/cm^2/A)":"FLUXNORM",\
    "z_em":"ZEM",\
    "sim_name":"SIMNAME",\
    "L_box":"BOXSIZE",\
    "N_Grid":"NGRIDSIM",\
    "spec_id":"SPECID",\
    "HI_trans_list":"HILIST",\
    "flag_tau":"TAUFIELD",\
    "flag_tau_each_trans":"TAUSCALE",\
    "flag_absorber":"ABSTYPE",\
    "z_DLA":"ZDLA",\
    "log_N_HI_DLA":"LNHIDLA",\
    "b_DLA":"BDLA",\
    "flag_metal_method":"METLTYPE",\
    "metal_trans_list":"METLLIST",\
    "log_Z_val_const":"LZMETAL",\
    "uvb_model_metal":"METALUVB"
    }
    return std_fit_header_dict
