From 59b9b3520baf7aff7b99f9beafc8e9b63ba10aac Mon Sep 17 00:00:00 2001 From: malloryprow Date: Thu, 12 Apr 2018 12:48:55 +0000 Subject: [PATCH] Added in ability for grid-to-grid use case plotting scripts to plot using initialization time --- ush/plotting_scripts/plot_grid2grid_anom_timemap.py | 6 +++++- ush/plotting_scripts/plot_grid2grid_anom_ts.py | 6 +++++- ush/plotting_scripts/plot_grid2grid_anom_ts_HGTfourier.py | 6 +++++- ush/plotting_scripts/plot_grid2grid_pres_tp.py | 6 +++++- ush/plotting_scripts/plot_grid2grid_pres_ts.py | 8 ++++++-- ush/plotting_scripts/plot_grid2grid_sfc_ts.py | 6 +++++- 6 files changed, 31 insertions(+), 7 deletions(-) diff --git a/ush/plotting_scripts/plot_grid2grid_anom_timemap.py b/ush/plotting_scripts/plot_grid2grid_anom_timemap.py index 4040c76f5e..ccb1111c34 100644 --- a/ush/plotting_scripts/plot_grid2grid_anom_timemap.py +++ b/ush/plotting_scripts/plot_grid2grid_anom_timemap.py @@ -56,6 +56,7 @@ emonth = month_name[emon-1] eday = int(edate[6:8]) cycle_int = int(os.environ['CYCLE']) +lead_int = int(os.environ['LEAD']) sd = datetime.datetime(syear, smon, sday, cycle_int) ed = datetime.datetime(eyear, emon, eday, cycle_int)+datetime.timedelta(days=1) tdelta = datetime.timedelta(days=1) @@ -174,7 +175,10 @@ model_now_stat_file_dates = data_array[:,4] dateformat = "%Y%m%d_%H%M%S" for d in range(len(model_now_stat_file_dates)): - model_date = datetime.datetime.strptime(model_now_stat_file_dates[d], dateformat) + if date_filter_method == 'Valid': + model_date = datetime.datetime.strptime(model_now_stat_file_dates[d], dateformat) + elif date_filter_method == 'Initialization': + model_date = datetime.datetime.strptime(model_now_stat_file_dates[d], dateformat) - datetime.timedelta(hours=lead_int) model_now_dates_list.append(md.date2num(model_date)) model_now_dates = np.asarray(model_now_dates_list) #account for missing data diff --git a/ush/plotting_scripts/plot_grid2grid_anom_ts.py b/ush/plotting_scripts/plot_grid2grid_anom_ts.py index 22237f091c..2a182a7da6 100644 --- a/ush/plotting_scripts/plot_grid2grid_anom_ts.py +++ b/ush/plotting_scripts/plot_grid2grid_anom_ts.py @@ -52,6 +52,7 @@ emonth = month_name[emon-1] eday = int(edate[6:8]) cycle_int = int(os.environ['CYCLE']) +lead_int = int(os.environ['LEAD']) sd = datetime.datetime(syear, smon, sday, cycle_int) ed = datetime.datetime(eyear, emon, eday, cycle_int)+datetime.timedelta(days=1) tdelta = datetime.timedelta(days=1) @@ -145,7 +146,10 @@ model_now_stat_file_dates = data_array[:,4] dateformat = "%Y%m%d_%H%M%S" for d in range(len(model_now_stat_file_dates)): - model_date = datetime.datetime.strptime(model_now_stat_file_dates[d], dateformat) + if date_filter_method == 'Valid': + model_date = datetime.datetime.strptime(model_now_stat_file_dates[d], dateformat) + elif date_filter_method == 'Initialization': + model_date = datetime.datetime.strptime(model_now_stat_file_dates[d], dateformat) - datetime.timedelta(hours=lead_int) model_now_dates_list.append(md.date2num(model_date)) model_now_dates = np.asarray(model_now_dates_list) #account for missing data diff --git a/ush/plotting_scripts/plot_grid2grid_anom_ts_HGTfourier.py b/ush/plotting_scripts/plot_grid2grid_anom_ts_HGTfourier.py index 23e459e99f..5684d1aa4c 100644 --- a/ush/plotting_scripts/plot_grid2grid_anom_ts_HGTfourier.py +++ b/ush/plotting_scripts/plot_grid2grid_anom_ts_HGTfourier.py @@ -53,6 +53,7 @@ emonth = month_name[emon-1] eday = int(edate[6:8]) cycle_int = int(os.environ['CYCLE']) +lead_int = int(os.environ['LEAD']) sd = datetime.datetime(syear, smon, sday, cycle_int) ed = datetime.datetime(eyear, emon, eday, cycle_int)+datetime.timedelta(days=1) tdelta = datetime.timedelta(days=1) @@ -159,7 +160,10 @@ model_now_stat_file_dates = data_array[:,4] dateformat = "%Y%m%d_%H%M%S" for d in range(len(model_now_stat_file_dates)): - model_date = datetime.datetime.strptime(model_now_stat_file_dates[d], dateformat) + if date_filter_method == 'Valid': + model_date = datetime.datetime.strptime(model_now_stat_file_dates[d], dateformat) + elif date_filter_method == 'Initialization': + model_date = datetime.datetime.strptime(model_now_stat_file_dates[d], dateformat) - datetime.timedelta(hours=lead_int) model_now_dates_list.append(md.date2num(model_date)) model_now_dates = np.asarray(model_now_dates_list) #account for missing data diff --git a/ush/plotting_scripts/plot_grid2grid_pres_tp.py b/ush/plotting_scripts/plot_grid2grid_pres_tp.py index 437b44fbfe..d351176ae8 100644 --- a/ush/plotting_scripts/plot_grid2grid_pres_tp.py +++ b/ush/plotting_scripts/plot_grid2grid_pres_tp.py @@ -58,6 +58,7 @@ emonth = month_name[emon-1] eday = int(edate[6:8]) cycle_int = int(os.environ['CYCLE']) +lead_int = int(os.environ['LEAD']) sd = datetime.datetime(syear, smon, sday, cycle_int) ed = datetime.datetime(eyear, emon, eday, cycle_int)+datetime.timedelta(days=1) tdelta = datetime.timedelta(days=1) @@ -225,7 +226,10 @@ model_now_stat_file_dates = data_array[:,4] dateformat = "%Y%m%d_%H%M%S" for d in range(len(model_now_stat_file_dates)): - model_date = datetime.datetime.strptime(model_now_stat_file_dates[d], dateformat) + if date_filter_method == 'Valid': + model_date = datetime.datetime.strptime(model_now_stat_file_dates[d], dateformat) + elif date_filter_method == 'Initialization': + model_date = datetime.datetime.strptime(model_now_stat_file_dates[d], dateformat) - datetime.timedelta(hours=lead_int) model_now_dates_list.append(md.date2num(model_date)) model_now_dates = np.asarray(model_now_dates_list) #account for missing data diff --git a/ush/plotting_scripts/plot_grid2grid_pres_ts.py b/ush/plotting_scripts/plot_grid2grid_pres_ts.py index cc8f8de179..7800e382c4 100644 --- a/ush/plotting_scripts/plot_grid2grid_pres_ts.py +++ b/ush/plotting_scripts/plot_grid2grid_pres_ts.py @@ -52,6 +52,7 @@ emonth = month_name[emon-1] eday = int(edate[6:8]) cycle_int = int(os.environ['CYCLE']) +lead_int = int(os.environ['LEAD']) sd = datetime.datetime(syear, smon, sday, cycle_int) ed = datetime.datetime(eyear, emon, eday, cycle_int)+datetime.timedelta(days=1) tdelta = datetime.timedelta(days=1) @@ -187,8 +188,11 @@ model_now_stat_file_dates = data_array[:,4] dateformat = "%Y%m%d_%H%M%S" for d in range(len(model_now_stat_file_dates)): - model_date = datetime.datetime.strptime(model_now_stat_file_dates[d], dateformat) - model_now_dates_list.append(md.date2num(model_date)) + if date_filter_method == 'Valid': + model_date = datetime.datetime.strptime(model_now_stat_file_dates[d], dateformat) + elif date_filter_method == 'Initialization': + model_date = datetime.datetime.strptime(model_now_stat_file_dates[d], dateformat) - datetime.timedelta(hours=lead_int) + model_now_dates_list.append(md.date2num(model_date)) model_now_dates = np.asarray(model_now_dates_list) #account for missing data model_now_stat_now_dates_vals = np.zeros_like(dates) diff --git a/ush/plotting_scripts/plot_grid2grid_sfc_ts.py b/ush/plotting_scripts/plot_grid2grid_sfc_ts.py index 4fddde1b8c..611356f940 100644 --- a/ush/plotting_scripts/plot_grid2grid_sfc_ts.py +++ b/ush/plotting_scripts/plot_grid2grid_sfc_ts.py @@ -52,6 +52,7 @@ emonth = month_name[emon-1] eday = int(edate[6:8]) cycle_int = int(os.environ['CYCLE']) +lead_int = int(os.environ['LEAD']) sd = datetime.datetime(syear, smon, sday, cycle_int) ed = datetime.datetime(eyear, emon, eday, cycle_int)+datetime.timedelta(days=1) tdelta = datetime.timedelta(days=1) @@ -145,7 +146,10 @@ model_now_stat_file_dates = data_array[:,4] dateformat = "%Y%m%d_%H%M%S" for d in range(len(model_now_stat_file_dates)): - model_date = datetime.datetime.strptime(model_now_stat_file_dates[d], dateformat) + if date_filter_method == 'Valid': + model_date = datetime.datetime.strptime(model_now_stat_file_dates[d], dateformat) + elif date_filter_method == 'Initialization': + model_date = datetime.datetime.strptime(model_now_stat_file_dates[d], dateformat) - datetime.timedelta(hours=lead_int) model_now_dates_list.append(md.date2num(model_date)) model_now_dates = np.asarray(model_now_dates_list) #account for missing data