# ----------------------------------------------------------------- # # --- Run VIC with assinged states --- # # ----------------------------------------------------------------- # print('Post-process - run VIC with updated states...') # --- If take mean updated states --- # if cfg['POSTPROCESS']['if_ens_states'] == False: # !!! This part hasn't been implemented correctly !!! pass list_history_files = run_vic_assigned_states( start_time=start_time, end_time=end_time, vic_exe=vic_exe, init_state_nc=init_state_mean_nc, dict_assigned_state_nc=dict_assigned_state_nc, global_template=os.path.join(cfg['CONTROL']['root_dir'], cfg['VIC']['vic_global_template']), vic_forcing_basepath=os.path.join(dirs['forcings'], 'forc.post_prec.'), vic_model_steps_per_day=cfg['VIC']['model_steps_per_day'], output_global_root_dir=dirs['global'], output_vic_history_root_dir=dirs['history'], output_vic_log_root_dir=dirs['logs'], mpi_proc=mpi_proc, mpi_exe=cfg['VIC']['mpi_exe']) # --- Else if keep the ensemble of updated states --- # else: if cfg['POSTPROCESS']['if_ens_prec'] == True: # !!!!!!!!! Haven't implemented ensemble precip forcing yet !!!!! pass # Else if use one precip data for all ensemble members else:
dirs['logs'], mkdirs=[subdir_name])\ [subdir_name] # other variables global_template = os.path.join( cfg['CONTROL']['root_dir'], cfg['VIC']['vic_global_template']) # --- run VIC with assigned states --- # list_history_files = run_vic_assigned_states( start_time=start_time, end_time=end_time, vic_exe=vic_exe, init_state_nc=init_state_nc, dict_assigned_state_nc=dict_assigned_state_nc, global_template=global_template, vic_forcing_basepath=vic_forcing_basepath, vic_model_steps_per_day=cfg['VIC']['model_steps_per_day'], output_global_root_dir=global_subdir, output_vic_history_root_dir=hist_subdir, output_vic_log_root_dir=log_subdir, mpi_proc=mpi_proc, mpi_exe=cfg['VIC']['mpi_exe'], delete_log=False) # --- Concat all years and clean up --- # list_ds_hist = [xr.open_dataset(f) for f in list_history_files] ds_concat = xr.concat(list_ds_hist, dim='time') to_netcdf_forcing_file_compress( ds_concat, out_nc=os.path.join( hist_subdir, 'history.concat.{}_{}.nc'.format(start_year, end_year)))
init_state_nc = os.path.join(cfg['CONTROL']['root_dir'], cfg['VIC']['vic_initial_state']) # other variables global_template = os.path.join(cfg['CONTROL']['root_dir'], cfg['VIC']['vic_global_template']) vic_forcing_basepath = os.path.join(cfg['CONTROL']['root_dir'], cfg['VIC']['orig_forcing_nc_basepath']) # --- run VIC with assigned states --- # print('Run VIC with "truth" sm2 states and orig. forcing...') list_history_files = run_vic_assigned_states( start_time=start_time, end_time=end_time, vic_exe=vic_exe, init_state_nc=init_state_nc, dict_assigned_state_nc=dict_assigned_state_nc, global_template=global_template, vic_forcing_basepath=vic_forcing_basepath, vic_model_steps_per_day=cfg['VIC']['model_steps_per_day'], output_global_root_dir=dirs['global'], output_vic_history_root_dir=dirs['history'], output_vic_log_root_dir=dirs['logs'], mpi_proc=mpi_proc, mpi_exe=cfg['VIC']['mpi_exe']) # --- Concat by-year history files --- # print('Concatenating by-year history files...') subprocess.call("cdo copy {} {}".format( os.path.join(dirs['history'], '*'), os.path.join( dirs['history'], 'history.concat.{}_{}.nc'.format(start_time.strftime('%Y%m%d'), end_time.strftime('%Y%m%d')))),
cfg['VIC']['vic_initial_state']) # other variables global_template = os.path.join( cfg['CONTROL']['root_dir'], cfg['VIC']['vic_global_template']) vic_forcing_basepath = os.path.join( cfg['CONTROL']['root_dir'], cfg['VIC']['truth_forcing_nc_basepath']) # --- run VIC with assigned states --- # run_vic_assigned_states( start_time=start_time, end_time=end_time, vic_exe=vic_exe, init_state_nc=init_state_nc, dict_assigned_state_nc=dict_rescaled_state_nc, global_template=global_template, vic_forcing_basepath=vic_forcing_basepath, vic_model_steps_per_day=cfg['VIC']['model_steps_per_day'], output_global_root_dir=truth_rescaled_subdirs['global'], output_vic_history_root_dir=truth_rescaled_subdirs['history'], output_vic_log_root_dir=truth_rescaled_subdirs['logs'], mpi_proc=mpi_proc, mpi_exe=cfg['VIC']['mpi_exe']) # --- Concatenate all history files --- # hist_concat_nc = os.path.join(truth_rescaled_subdirs['history'], 'history.concat.rescaled_v1.{}_{:05d}-{}_{:05d}.nc'.format( start_time.strftime('%Y%m%d'), start_time.hour*3600+start_time.second, end_time.strftime('%Y%m%d'), end_time.hour*3600+end_time.second)) list_history_files = []