示例#1
0
# Read in inverse routing output
#===============================================================#
# A dictionary; keys: 'lat_lon'; element: Series of total runoff
dict_s_total_runoff = my_functions.read_inverse_route_output(\
                                       cfg['INPUT']['inv_ro_basin_output_dir'], \
                                       smooth_window=cfg['PARAM']['smooth_window'], \
                                       n_runs=cfg['PARAM']['n_runs'], \
                                       skip_steps=cfg['PARAM']['skip_steps'], \
                                       start_date_data=start_date, \
                                       time_step=cfg['PARAM']['time_step'], \
                                       ksteps=cfg['PARAM']['ksteps'], \
                                       latlon_precision=cfg['PARAM']['latlon_precision'])

# Select full water years
start_date_WY, end_date_WY = my_functions.find_full_water_years_within_a_range(\
                                dict_s_total_runoff[dict_s_total_runoff.keys()[0]].index[0],\
                                dict_s_total_runoff[dict_s_total_runoff.keys()[0]].index[-1])

for lat_lon in dict_s_total_runoff.keys():
    s_total_runoff = dict_s_total_runoff[lat_lon]
    dict_s_total_runoff[lat_lon] = my_functions.select_time_range(\
                                        s_total_runoff, start_date_WY, end_date_WY)

##===============================================================#
## 1) Adjust negative runoff to zero;
## 2) Rescale each month so that water is balanced within the month
##===============================================================#
#for lat_lon in dict_s_total_runoff.keys():
#    print 'Adjusting negative runoff and rescaling {}...'.format(lat_lon)
#    s_total_runoff = dict_s_total_runoff[lat_lon]
#    # Original sum of water (with negative runoff)
示例#2
0
	print 'All RBM output values are missing!'
	exit()
if s_usgs.notnull().sum()==0:  # if all missing
	print 'All USGS data are missing!'
	exit()

#========================================================
# Determine plot starting and ending date (always plot full water years)
#========================================================
# determine the common range of available data of both data sets
data_avai_start_date, data_avai_end_date = my_functions.find_data_common_range(s_rbm, s_usgs)
if (data_avai_start_date-data_avai_end_date).days>=0: # if no common time range
	print "No common range data available!"
	exit()
# find the full water years with available data for both data sets
plot_start_date, plot_end_date = my_functions.find_full_water_years_within_a_range(data_avai_start_date, data_avai_end_date)
# determine time locator
if plot_end_date.year-plot_start_date.year < 5:  # if less than 5 years
	time_locator = ('year', 1)  # time locator on the plot; 'year' for year; 'month' for month. e.g., ('month', 3) for plot one tick every 3 months
else:  # if at least 5 years
	time_locator = ('year', (plot_end_date.year-plot_start_date.year)/5)  # time locator on the plot; 'year' for year; 'month' for month. e.g., ('month', 3) for plot one tick every 3 months

#========================================================
# Select data to be plotted
#========================================================
s_rbm_to_plot = my_functions.select_time_range(s_rbm, plot_start_date, plot_end_date)
s_usgs_to_plot = my_functions.select_time_range(s_usgs, plot_start_date, plot_end_date)

#========================================================
# plot
#========================================================
示例#3
0
if s_usgs.notnull().sum() == 0:  # if all missing
    print 'All USGS data are missing!'
    exit()

#========================================================
# Determine plot starting and ending date (always plot full water years)
#========================================================
# determine the common range of available data of both data sets
data_avai_start_date, data_avai_end_date = my_functions.find_data_common_range(
    s_rbm, s_usgs)
if (data_avai_start_date -
        data_avai_end_date).days >= 0:  # if no common time range
    print "No common range data available!"
    exit()
# find the full water years with available data for both data sets
plot_start_date, plot_end_date = my_functions.find_full_water_years_within_a_range(
    data_avai_start_date, data_avai_end_date)
# determine time locator
if plot_end_date.year - plot_start_date.year < 5:  # if less than 5 years
    time_locator = (
        'year', 1
    )  # time locator on the plot; 'year' for year; 'month' for month. e.g., ('month', 3) for plot one tick every 3 months
else:  # if at least 5 years
    time_locator = (
        'year', (plot_end_date.year - plot_start_date.year) / 5
    )  # time locator on the plot; 'year' for year; 'month' for month. e.g., ('month', 3) for plot one tick every 3 months

#========================================================
# Select data to be plotted
#========================================================
s_rbm_to_plot = my_functions.select_time_range(s_rbm, plot_start_date,
                                               plot_end_date)
示例#4
0
        dict_path[line_split[0]] = [line_split[1], line_split[2]]
    else:
        print 'Error: unsupported observation data format!'
        exit()
f.close()

# Read in routed streamflow from inverted runoff
dict_Lohmann_routed = {}  # {station_name: pd.Series of daily data} [unit: cfs]
for stn in dict_path:
    # Load data
    s_Lohmann_routed = my_functions.read_Lohmann_route_daily_output(
        dict_path[stn][1])
    dict_Lohmann_routed[stn] = s_Lohmann_routed
    # Select full water years
    start_date_WY, end_date_WY = my_functions.find_full_water_years_within_a_range(\
                                                dict_Lohmann_routed[stn].index[0], \
                                                dict_Lohmann_routed[stn].index[-1])
    dict_Lohmann_routed[stn] = my_functions.select_time_range(dict_Lohmann_routed[stn], \
                                                              start_date_WY, \
                                                              end_date_WY)

# Read in original station obs rmat
dict_obs = {}  # {station_name: pd.Series of daily data} [unit: cfs]
for stn in dict_path:
    # Load data
    filename = dict_path[stn][0]
    if cfg['INPUT']['obs_format'] == 'USGS':
        column = dict_path[stn][2]
        dict_obs[stn] = my_functions.read_USGS_data(filename, [column],
                                                    ['Discharge'])
    elif cfg['INPUT']['obs_format'] == 'Lohmann':