from prep_forcing_utils import (to_netcdf_forcing_file_compress, setup_output_dirs, remap_con, add_gridlines, edges_from_centers) # ======================================================= # # Process command line argument # ======================================================= # cfg = read_configobj(sys.argv[1]) # ============================================================ # # Setup output subdirs # ============================================================ # output_dir = cfg['OUTPUT']['out_dir'] output_subdir_plots = setup_output_dirs(output_dir, mkdirs=['plots'])['plots'] output_subdir_data_remapped = setup_output_dirs( output_dir, mkdirs=['prec_only'])['prec_only'] output_subdir_tmp = setup_output_dirs(output_dir, mkdirs=['tmp'])['tmp'] # ======================================================= # # Process data for each VIC timestep # ======================================================= # # --- Loop over each VIC timestep (if > hourly, each VIC timestep --- # # --- will contain multiple hourly NLDAS-2 data) --- # vic_times = pd.date_range( cfg['TIME']['start_time'], cfg['TIME']['end_time'], freq='{}H'.format(cfg['VIC']['time_step']))
# Process command line argument # ======================================================= # cfg = read_configobj(sys.argv[1]) start_time = pd.to_datetime(sys.argv[2]) end_time = pd.to_datetime(sys.argv[3]) start_year = start_time.year end_year = end_time.year # ============================================================ # # Setup output subdirs # ============================================================ # output_dir = cfg['OUTPUT']['out_dir'] output_subdir_plots = setup_output_dirs(output_dir, mkdirs=['plots'])['plots'] output_subdir_data = setup_output_dirs( output_dir, mkdirs=['data'])['data'] output_subdir_tmp = setup_output_dirs(output_dir, mkdirs=['tmp'])['tmp'] # ======================================================= # # Generate remap weight file, if not input # ======================================================= # # --- Load the first GPM timestep --- # filename = os.path.join( cfg['GPM']['gpm_dir'], '{}'.format(start_time.year), '{:02d}'.format(start_time.month), '{:02d}'.format(start_time.day), '{}.{:02d}00.nc'.format(start_time.strftime('%Y%m%d'), start_time.hour)) da = xr.open_dataset(filename)['precipitationCal']
from tonic.io import read_config, read_configobj from prep_forcing_utils import (to_netcdf_forcing_file_compress, setup_output_dirs, remap_con, add_gridlines, edges_from_centers) # ======================================================= # # Process command line argument # ======================================================= # cfg = read_configobj(sys.argv[1]) # ============================================================ # # Setup output subdirs # ============================================================ # output_dir = cfg['OUTPUT']['out_dir'] output_subdir_plots = setup_output_dirs(output_dir, mkdirs=['plots'])['plots'] output_subdir_data_remapped = setup_output_dirs(output_dir, mkdirs=['prec_only' ])['prec_only'] output_subdir_tmp = setup_output_dirs(output_dir, mkdirs=['tmp'])['tmp'] # ======================================================= # # Process data for each VIC timestep # ======================================================= # # --- Loop over each VIC timestep (if > hourly, each VIC timestep --- # # --- will contain multiple hourly NLDAS-2 data) --- # vic_times = pd.date_range(cfg['TIME']['start_time'], cfg['TIME']['end_time'], freq='{}H'.format(cfg['VIC']['time_step'])) # Initialize a dictionary to store VIC-timestep forcing data
from tonic.io import read_config, read_configobj from prep_forcing_utils import to_netcdf_forcing_file_compress, setup_output_dirs # ======================================================= # # Process command line argument # ======================================================= # cfg = read_configobj(sys.argv[1]) # ============================================================ # # Setup output subdirs # ============================================================ # output_dir = cfg['OUTPUT']['out_dir'] output_subdir_data_prec = setup_output_dirs( output_dir, mkdirs=['prec_only'])['prec_only'] output_subdir_data_force = setup_output_dirs( output_dir, mkdirs=['force_with_NLDAS2'])['force_with_NLDAS2'] # ======================================================= # # For each year, load GPM and NLDAS-2 forcing data and put together, and save to file # ======================================================= # # Initialize a dictionary to store final forcing data start_time = pd.to_datetime(cfg['TIME']['start_time']) end_time = pd.to_datetime(cfg['TIME']['end_time']) start_year = start_time.year end_year = end_time.year dict_force_yearly = {} # This dict will save forcing data for year in range(start_year, end_year+1): # Load GPM data
cfg = read_configobj(sys.argv[1]) # Start and end time of the 12-hour timesteps # The 12-hour time intervals would be the SMPA 6AM - 6PM local time start_date = pd.to_datetime(sys.argv[2]) end_date = pd.to_datetime(sys.argv[3]) start_year = start_date.year end_year = end_date.year # ============================================================ # # Setup output subdirs # ============================================================ # output_dir = cfg['OUTPUT']['out_dir'] output_subdir_data = setup_output_dirs(output_dir, mkdirs=['data'])['data'] output_12hour = cfg['OUTPUT']['out_dir_12hour'] output_subdir_plots = setup_output_dirs(output_12hour, mkdirs=['plots'])['plots'] # ======================================================= # # Aggregating GPM 30min timestep to 12 hourly (SMAP LST 6:00 - 18:00, 18:00 - 6:00) # NOTE: different UCT times of 30-min GPM will be extracted for the 12H-intervals local time # ======================================================= # # --- Construct final timestamps --- # # LST 6am and 6pm timestamps; timestamps are time-beginnig for precipitation times_12h = pd.date_range(start_date + pd.DateOffset(hours=6), end_date + pd.DateOffset(hours=18), freq='12H')
cfg = read_configobj(sys.argv[1]) # Start and end time of the 12-hour timesteps to concatenate # The 12-hour time intervals would be the SMPA 6AM - 6PM local time start_date = pd.to_datetime(sys.argv[2]) end_date = pd.to_datetime(sys.argv[3]) start_year = start_date.year end_year = end_date.year # ============================================================ # # Setup output subdirs # ============================================================ # output_dir = cfg['OUTPUT']['out_dir'] output_subdir_data = setup_output_dirs(output_dir, mkdirs=['data'])['data'] output_12hour = cfg['OUTPUT']['out_dir_12hour'] # ======================================================= # # Concatenate 12-hourly GPM data (SMAP LST 6:00 - 18:00, 18:00 - 6:00) # ======================================================= # # --- Construct timestamps to concatenate --- # # LST 6am and 6pm timestamps; timestamps are time-beginnig for precipitation times_12h = pd.date_range(start_date + pd.DateOffset(hours=6), end_date + pd.DateOffset(hours=18), freq='12H') # --- Load all 12-hour GPM data (LST interval) --- # list_12h_alltime = [] for time_12h in times_12h: