import numpy as np
import sys,os

sys.dont_write_bytecode = True

# ---------------------------------------------
# If you want to run weave_mocks.py file from another directory, replace
# "./" with "/path/to/dir/WEAVE_MOCKS_CODE" directory
sys_path = os.path.realpath("./")
sys.path.append(sys_path)
# ---------------------------------------------

from WEAVEify_routines.step_02_common_routines.WEAVEify_function_calls import \
WEAVEify_function_calls_main

# ---------------------------------------------
# Read inputs ie.e, cosmological density, velocity and temperature fields
# for WEAVE test example
# ---------------------------------------------
spec_indx      = 0
inp_path       = "./WEAVEify_routines/WEAVE_MOCKS_AUXILIARY_FILES/CODE_TEST_EXAMPLES/WEAVE/INPUT/"
out_path       = "./WEAVEify_routines/WEAVE_MOCKS_AUXILIARY_FILES/CODE_TEST_EXAMPLES/WEAVE/OUTPUT/SERIAL_SINGLE_SPECTRUM/"
inp_file       = "Flux_Fields.npy"
npy_filename   = inp_path + inp_file
data_dict      = np.load(npy_filename,allow_pickle = True,encoding = 'latin1').item()
wavelength     = data_dict["wavelength"]
flux_all       = data_dict["flux"]
flux           = flux_all[:,spec_indx]


# ---------------------------------------------
# Put for loop here to automate script for many WEAVE mocks
# One can use as many nested for loops as necessary
# ---------------------------------------------


# Note that sequence of keyword arguments is not important
# But make sure that the variable names are exactly the same as the
# variable (parameter) names listed in "default_parameters_WEAVEify.py"
# Otherwise the default value of variables will be used by the code.

WEAVEify_function_calls_main(\
flux=flux,\
wavelength=wavelength,
out_path=out_path)





