if opth not in sys.path:
    sys.path.append(opth)
import Ofun_nc
import Ofun
from importlib import reload
reload(Ofun_nc)
reload(Ofun)

start_time = datetime.now()
in_dir = Ldir['roms'] + 'output/cas3_v0_lo6m/f' + Ldir['date_string']
nc_dir = Ldir['LOogf_f']

# get grid and S info
G = zrfun.get_basic_info(Ldir['grid'] + 'grid.nc', only_G=True)
S_info_dict = Lfun.csv_to_dict(Ldir['grid'] + 'S_COORDINATE_INFO.csv')
S = zrfun.get_S(S_info_dict)
# get list of files to work on
h_list_full = os.listdir(in_dir)
h_list = [item for item in h_list_full if 'ocean_his' in item]
h_list.sort()

# debugging
testing = False
if testing:
    h_list = h_list[:2]

# get list of times
t_list = []
for h in h_list:
    T = zrfun.get_basic_info(in_dir + '/' + h, only_T=True)
    t_list.append(T['ocean_time'][0])
if opth not in sys.path:
    sys.path.append(opth)
import Ofun_nc
import Ofun
from importlib import reload
reload(Ofun_nc)
reload(Ofun)

start_time = datetime.now()
in_dir = Ldir['roms'] + 'output/cas6_v3_lo8b/f' + Ldir['date_string']
nc_dir = Ldir['LOogf_f']

# get grid and S info
G = zrfun.get_basic_info(Ldir['grid'] + 'grid.nc', only_G=True)
S_info_dict = Lfun.csv_to_dict(Ldir['grid'] + 'S_COORDINATE_INFO.csv')
S = zrfun.get_S(S_info_dict)
# get list of files to work on
h_list_full = os.listdir(in_dir)
h_list = [item for item in h_list_full if 'ocean_his' in item]
h_list.sort()

if Ldir['run_type'] == 'backfill':
    print('Using backfill list')
    h_list = h_list[:25]

# debugging
if Ldir['lo_env'] == 'pm_mac':
    testing = True
else:
    testing = False