print(cmd) subprocess.call(cmd, shell=True) # train date range # datetime info N_days = 365 + 366 + 365 + 365 + 365 # 2015-2020 (period ending) date_list = [ datetime(2015, 1, 1, 0) + timedelta(days=x) for x in range(N_days) ] # N_train = 365 + 366 + 365 train_list = [ datetime(2015, 1, 1, 0) + timedelta(days=x) for x in range(N_train) ] pick_train = du.dt_match(date_list, train_list) IND_train = du.season_ind_sep(train_list, key_format='{}_train') # split by seasons # N_valid = 365 valid_list = [ datetime(2018, 1, 1, 0) + timedelta(days=x) for x in range(N_valid) ] pick_valid = du.dt_match(date_list, valid_list) IND_valid = du.season_ind_sep(valid_list, key_format='{}_valid') # split by seasons # etopo fields input_2d = {} keys_2d = ['etopo_4km', 'etopo_regrid'] # etopo from an example with h5py.File(PRISM_dir + 'PRISM_TMEAN_features_2015_2020.hdf', 'r') as hdf_io:
lon_4km = hdf_io['lon_4km'][...] lat_4km = hdf_io['lat_4km'][...] hdf_io.close() grid_shape = land_mask.shape # defining prediction range # dt list for all N_all = 365 + 366 + 365 + 365 + 365 all_list = [datetime(2015, 1, 1, 0) + timedelta(days=x) for x in range(N_all)] # dt list for pred, 2018-2020 N_pred = 15 pred_list = [datetime(2019, 1, 1, 0) + timedelta(days=x) for x in range(N_pred)] # indices ind_pred = du.dt_match(all_list, pred_list) ind_pred_sea = du.season_ind_sep(pred_list, key_format='{}') # macros # ind_trans = 504 # now in the namelist model_import_dir = temp_dir # overlapped tile prediction settings param = {} param['gap'] = 8 param['edge'] = 32 param['size'] = 128 # loop over variables and seasons VARS = ['TMAX', 'TMIN', 'TMEAN'] seasons = ['djf', 'mam', 'jja', 'son']
# dt list for train and valid (test) N_train = 365 + 366 + 365 # 2015-2018 (period ending) N_valid = 365 # 2018-2019 (period ending) train_list = [ datetime(2015, 1, 1, 0) + timedelta(days=x) for x in range(N_train) ] valid_list = [ datetime(2018, 1, 1, 0) + timedelta(days=x) for x in range(N_valid) ] # pick ind ind_train = du.dt_match(all_list, train_list) ind_valid = du.dt_match(all_list, valid_list) # inds ind_train_sea = du.season_ind_sep(train_list, key_format='{}') ind_valid_sea = du.season_ind_sep(valid_list, key_format='{}') # shape grid_shape = land_mask.shape N_no_clim = 3 # total number of features in the "no clim" case N_with_clim = 4 # total number of features in the "with clim" case # loop over variables VARS = ['TMAX', 'TMIN'] for var in VARS: print('===== {} ====='.format(var)) C_no_clim = np.zeros(grid_shape + (4 * N_no_clim, )) I_no_clim = np.zeros(grid_shape + (4 * 1, )) OUT_no_clim = np.zeros((N_valid, ) + grid_shape) if clim: