Ejemplo n.º 1
0
for index, row in dry_water_balance_df.iterrows():
    if index > min(water_balance_daily_df.index):
        t_1 = index - timedelta(days=1)
        if t_1 < max(water_balance_daily_df.index):
            dry_water_balance_df['infiltration(cu.m)'][index.strftime(date_format)] = -1.0 * (
                delta_s[index.strftime(daily_format)] + evap[index.strftime(daily_format)])

# dry_water_balance_df[:, 'infiltration(cu.m)'] = cd.myround(dry_water_balance_df['infiltration(cu.m)'], decimals=3)
dry_water_balance_df = dry_water_balance_df[dry_water_balance_df['stage(m)'] > 0.1]
dry_water_balance_df = dry_water_balance_df[dry_water_balance_df['infiltration(cu.m)'] > 1.0]
# dry_water_balance_df = dry_water_balance_df[dry_water_balance_df['infiltration(cu.m)'] < 60]
dry_water_balance_df['infiltration_rate(m)'] = dry_water_balance_df['infiltration(cu.m)']/dry_water_balance_df['ws_area(sq.m)']
dry_water_balance_df.to_csv('/media/kiruba/New Volume/ACCUWA_Data/Checkdam_water_balance/591/dry_wb.csv')
print dry_water_balance_df.head()
print dry_water_balance_df['infiltration_rate(m)'].mean()
average_infiltration_rate = cd.myround(dry_water_balance_df['infiltration_rate(m)'].mean(), decimals=3)
print "infilt"
fig, (ax1, ax2, ax3, ax4) = plt.subplots(nrows=4, ncols=1, facecolor='white', sharex=True)
ax1.plot(dry_water_balance_df.index, dry_water_balance_df['infiltration_rate(m)'], 'ro')
ax2.plot(dry_water_balance_df.index, dry_water_balance_df['infiltration(cu.m)'], 'bo')
ax3.plot(dry_water_balance_df.index, dry_water_balance_df['Evaporation (cu.m)'], 'go')
ax4.plot(eleven_30_df.index, eleven_30_df['raw value'], 'ko')
plt.show()
# raise SystemExit(0)

"""
Fitting exponential function

dry_water_balance_df['average_stage(m)'] = 0.00

# for index in dry_water_balance_df.index:
Ejemplo n.º 2
0
Calculate infiltration
"""
dry_water_balance_df['infiltration(cu.m)'] = 0.000
delta_s = water_balance_daily_df['change_storage(cu.m)']
evap = water_balance_daily_df['Evaporation (cu.m)']
outflow = water_balance_daily_df['overflow(cu.m)']
for index, row in dry_water_balance_df.iterrows():
    if index > min(water_balance_daily_df.index):
        t_1 = index - timedelta(days=1)
        if t_1 < max(water_balance_daily_df.index):
            dry_water_balance_df.loc[index.strftime(date_format),
                                     'infiltration(cu.m)'] = -1.0 * (
                                         delta_s[index.strftime(daily_format)]
                                         + evap[index.strftime(daily_format)])

dry_water_balance_df.loc[:, 'infiltration(cu.m)'] = cd.myround(
    dry_water_balance_df['infiltration(cu.m)'], decimals=2)
dry_water_balance_df.loc[dry_water_balance_df['stage(m)'] < 0.1,
                         'infiltration(cu.m)'] = 0
# dry_water_balance_df = dry_water_balance_df.loc[dry_water_balance_df['infiltration(cu.m)'] > 1]
# dry_water_balance_df = dry_water_balance_df.loc[dry_water_balance_df['infiltration(cu.m)'] < 60]
# print dry_water_balance_df['2014-05-20':'2014-05-21']
# raise SystemExit(0)
dry_water_balance_df['infiltration_rate(m)'] = dry_water_balance_df[
    'infiltration(cu.m)'] / dry_water_balance_df['ws_area(sq.m)']
print dry_water_balance_df.head()
print dry_water_balance_df['infiltration_rate(m)'].mean()
average_infiltration_rate = cd.myround(
    dry_water_balance_df['infiltration_rate(m)'].mean(), decimals=3)
print "infilt"
dry_water_balance_df.to_csv(
    '/media/kiruba/New Volume/ACCUWA_Data/Checkdam_water_balance/ch_634/dry_wb.csv'
Ejemplo n.º 3
0
# stage_599_df.set_index(pd.to_datetime(stage_599_df['Date'],format=datetime_format),  inplace=True)
wb_599.set_index(pd.to_datetime(wb_599['Date'], format=daily_format), inplace=True)
# 634
file_634 = '/media/kiruba/New Volume/ACCUWA_Data/Checkdam_water_balance/ch_634/et_infilt_634_w_of.csv'
# stage_634_file = '/media/kiruba/New Volume/ACCUWA_Data/Checkdam_water_balance/ch_634/stage_634.csv'
wb_634 = pd.read_csv(file_634, sep=',', header=0)
# stage_634_df = pd.read_csv(stage_634_file, sep=',', header=0)
# stage_634_df.set_index(pd.to_datetime(stage_634_df['Date'],format=datetime_format),  inplace=True)
wb_634.set_index(pd.to_datetime(wb_634['Date'], format=daily_format), inplace=True)
# dry days df separation
dry_wb_591_df = wb_591.loc[wb_591['status'] == 'N']
dry_wb_599_df = wb_599.loc[wb_599['status'] == 'N']
dry_wb_634_df = wb_634.loc[wb_634['status'] == 'N']
# print dry_wb_591_df.head()
# round decimals two decimal
dry_wb_591_df.loc[:, 'stage(m)'] = cd.myround(dry_wb_591_df['stage(m)'], decimals=2)
dry_wb_599_df.loc[:, 'stage(m)'] = cd.myround(dry_wb_599_df['stage(m)'], decimals=2)
dry_wb_634_df.loc[:, 'stage(m)'] = cd.myround(dry_wb_634_df['stage(m)'], decimals=2)
dry_wb_591_df.loc[:, 'infiltration(cu.m)'] = cd.myround(dry_wb_591_df['infiltration(cu.m)'], decimals=3)
dry_wb_599_df.loc[:, 'infiltration(cu.m)'] = cd.myround(dry_wb_599_df['infiltration(cu.m)'], decimals=3)
dry_wb_634_df.loc[:, 'infiltration(cu.m)'] = cd.myround(dry_wb_634_df['infiltration(cu.m)'], decimals=3)
dry_wb_591_df = dry_wb_591_df.loc[dry_wb_591_df['stage(m)'] > 0.1]
dry_wb_599_df = dry_wb_599_df.loc[dry_wb_599_df['stage(m)'] > 0.1]
dry_wb_634_df = dry_wb_634_df.loc[dry_wb_634_df['stage(m)'] > 0.1]
dry_wb_591_df = dry_wb_591_df.loc[dry_wb_591_df['infiltration(cu.m)'] > 1]
dry_wb_599_df = dry_wb_599_df.loc[dry_wb_599_df['infiltration(cu.m)'] > 1]
dry_wb_634_df = dry_wb_634_df.loc[dry_wb_634_df['infiltration(cu.m)'] > 1]
dry_wb_591_df = dry_wb_591_df.loc[dry_wb_591_df['infiltration(cu.m)'] < 60]
# add month column
dry_wb_591_df.loc[:, 'month'] = dry_wb_591_df.index.month
dry_wb_599_df.loc[:, 'month'] = dry_wb_599_df.index.month
Ejemplo n.º 4
0
        y1 = stage_vol_df['total_vol_cu_m'][x1]
        y2 = stage_vol_df['total_vol_cu_m'][x2]
        y_diff = y2 - y1
        slope = y_diff / x_diff
        y_intercept = y2 - (slope * x2)
        water_balance_df['volume (cu.m)'][index.strftime('%Y-%m-%d %H:%M:%S')] = (slope * obs_stage) + y_intercept
"""
Overflow
"""
length_check_dam = 17.0
width_check_dam = 0.5
no_of_contractions = 0
water_balance_df['overflow(cu.m)'] = 0.000
for index, row in water_balance_df.iterrows():
    obs_stage = row['stage(m)']
    if cd.myround(a=obs_stage, decimals=2) > full_stage:
        effective_head = obs_stage - full_stage
        previous_time = index - timedelta(seconds=1800)
        if cd.myround(a=water_balance_df['stage(m)'][previous_time.strftime(date_format)], decimals=2) > full_stage:
            water_balance_df['overflow(cu.m)'][index.strftime(date_format)] = 1800 * 1.84 * width_check_dam * (
                effective_head ** 1.5)
        else:
            x1 = 0
            x2 = 1800
            y1 = cd.myround(a=water_balance_df['stage(m)'][previous_time.strftime(date_format)], decimals=2)
            y2 = cd.myround(a=obs_stage, decimals=2)
            slope = (y1 - y2) / (x1 - x2)
            intercept = y2 - (slope * x2)
            time_of_overflow = 1800 - ((full_stage - intercept) / slope)
            water_balance_df['overflow(cu.m)'][
                index.strftime(date_format)] = time_of_overflow * 1.84 * width_check_dam * (effective_head ** 1.5)
Ejemplo n.º 5
0
"""
Calculate infiltration
"""
dry_water_balance_df['infiltration(cu.m)'] = 0.000
delta_s = water_balance_daily_df['change_storage(cu.m)']
evap = water_balance_daily_df['Evaporation (cu.m)']
outflow = water_balance_daily_df['overflow(cu.m)']
for index, row in dry_water_balance_df.iterrows():
    if index > min(water_balance_daily_df.index):
        t_1 = index - timedelta(days=1)
        if t_1 < max(water_balance_daily_df.index):
            dry_water_balance_df.loc[index.strftime(date_format), 'infiltration(cu.m)'] = -1.0 * (
                delta_s[index.strftime(daily_format)] + evap[index.strftime(daily_format)])


dry_water_balance_df.loc[:, 'infiltration(cu.m)'] = cd.myround(dry_water_balance_df['infiltration(cu.m)'], decimals=2)
dry_water_balance_df.loc[dry_water_balance_df['stage(m)'] < 0.1, 'infiltration(cu.m)'] = 0
# dry_water_balance_df = dry_water_balance_df.loc[dry_water_balance_df['infiltration(cu.m)'] > 1]
# dry_water_balance_df = dry_water_balance_df.loc[dry_water_balance_df['infiltration(cu.m)'] < 60]
# print dry_water_balance_df['2014-05-20':'2014-05-21']
# raise SystemExit(0)
dry_water_balance_df['infiltration_rate(m)'] = dry_water_balance_df['infiltration(cu.m)']/dry_water_balance_df['ws_area(sq.m)']
print dry_water_balance_df.head()
print dry_water_balance_df['infiltration_rate(m)'].mean()
average_infiltration_rate = cd.myround(dry_water_balance_df['infiltration_rate(m)'].mean(), decimals=3)
print "infilt"
dry_water_balance_df.to_csv('/media/kiruba/New Volume/ACCUWA_Data/Checkdam_water_balance/ch_634/dry_wb.csv')


"""
Fitting exponential function
Ejemplo n.º 6
0
        y2 = stage_vol_df['total_vol_cu_m'][x2]
        y_diff = y2 - y1
        slope = y_diff / x_diff
        y_intercept = y2 - (slope * x2)
        water_balance_df['volume (cu.m)'][index.strftime(
            '%Y-%m-%d %H:%M:%S')] = (slope * obs_stage) + y_intercept
"""
Overflow
"""
length_check_dam = 17.0
width_check_dam = 0.5
no_of_contractions = 0
water_balance_df['overflow(cu.m)'] = 0.000
for index, row in water_balance_df.iterrows():
    obs_stage = row['stage(m)']
    if cd.myround(a=obs_stage, decimals=2) > full_stage:
        effective_head = obs_stage - full_stage
        previous_time = index - timedelta(seconds=1800)
        if cd.myround(a=water_balance_df['stage(m)'][previous_time.strftime(
                date_format)],
                      decimals=2) > full_stage:
            water_balance_df['overflow(cu.m)'][index.strftime(
                date_format)] = 1800 * 1.84 * width_check_dam * (effective_head
                                                                 **1.5)
        else:
            x1 = 0
            x2 = 1800
            y1 = cd.myround(a=water_balance_df['stage(m)'][
                previous_time.strftime(date_format)],
                            decimals=2)
            y2 = cd.myround(a=obs_stage, decimals=2)
Ejemplo n.º 7
0
                                        evap[index.strftime(daily_format)])

# dry_water_balance_df[:, 'infiltration(cu.m)'] = cd.myround(dry_water_balance_df['infiltration(cu.m)'], decimals=3)
dry_water_balance_df = dry_water_balance_df[
    dry_water_balance_df['stage(m)'] > 0.1]
dry_water_balance_df = dry_water_balance_df[
    dry_water_balance_df['infiltration(cu.m)'] > 1.0]
# dry_water_balance_df = dry_water_balance_df[dry_water_balance_df['infiltration(cu.m)'] < 60]
dry_water_balance_df['infiltration_rate(m)'] = dry_water_balance_df[
    'infiltration(cu.m)'] / dry_water_balance_df['ws_area(sq.m)']
dry_water_balance_df.to_csv(
    '/media/kiruba/New Volume/ACCUWA_Data/Checkdam_water_balance/591/dry_wb.csv'
)
print dry_water_balance_df.head()
print dry_water_balance_df['infiltration_rate(m)'].mean()
average_infiltration_rate = cd.myround(
    dry_water_balance_df['infiltration_rate(m)'].mean(), decimals=3)
print "infilt"
fig, (ax1, ax2, ax3, ax4) = plt.subplots(nrows=4,
                                         ncols=1,
                                         facecolor='white',
                                         sharex=True)
ax1.plot(dry_water_balance_df.index,
         dry_water_balance_df['infiltration_rate(m)'], 'ro')
ax2.plot(dry_water_balance_df.index,
         dry_water_balance_df['infiltration(cu.m)'], 'bo')
ax3.plot(dry_water_balance_df.index,
         dry_water_balance_df['Evaporation (cu.m)'], 'go')
ax4.plot(eleven_30_df.index, eleven_30_df['raw value'], 'ko')
plt.show()
# raise SystemExit(0)
"""
Ejemplo n.º 8
0
"""
#input parameters
base_file_591 = '/media/kiruba/New Volume/ACCUWA_Data/Checkdam_water_balance/591/created_profile_591.csv'
check_dam_no = 591
check_dam_height = 1.96    # m
df_591 = pd.read_csv(base_file_591, sep=',')
# print df_591
df_591_trans = df_591.iloc[0:, 2:]  # Transpose
### Renaming the column and dropping y values
# print df_591_trans
y_name_list = []
for y_value in df_591_trans.columns:
    y_name_list.append(('Y_%s' %y_value))

df_591_trans.columns = y_name_list
# print df_591_trans
y_value_list = df_591_trans.ix[0, 1:]
# print y_value_list

# drop the y values from data
final_data = df_591_trans.ix[1:, 0:]
# print final_data

stage_vol_df = cd.calcvolume(y_value_list=y_value_list, elevation_data=final_data, dam_height=1.96)
stage_vol_df['stage_m'] = cd.myround(stage_vol_df['stage_m'], decimals=2)
print stage_vol_df
# raise SystemExit(0)
stage_vol_df.to_csv('/media/kiruba/New Volume/ACCUWA_Data/Checkdam_water_balance/591/stage_vol_new.csv')
# fig=plt.figure()
# plt.plot(stage_vol_df.stage_m, stage_vol_df.total_vol_cu_m)
# plt.show()
Ejemplo n.º 9
0
check_dam_height = 1.96  # m
df_591 = pd.read_csv(base_file_591, sep=',')
# print df_591
df_591_trans = df_591.iloc[0:, 2:]  # Transpose
### Renaming the column and dropping y values
# print df_591_trans
y_name_list = []
for y_value in df_591_trans.columns:
    y_name_list.append(('Y_%s' % y_value))

df_591_trans.columns = y_name_list
# print df_591_trans
y_value_list = df_591_trans.ix[0, 1:]
# print y_value_list

# drop the y values from data
final_data = df_591_trans.ix[1:, 0:]
# print final_data

stage_vol_df = cd.calcvolume(y_value_list=y_value_list,
                             elevation_data=final_data,
                             dam_height=1.96)
stage_vol_df['stage_m'] = cd.myround(stage_vol_df['stage_m'], decimals=2)
print stage_vol_df
# raise SystemExit(0)
stage_vol_df.to_csv(
    '/media/kiruba/New Volume/ACCUWA_Data/Checkdam_water_balance/591/stage_vol_new.csv'
)
# fig=plt.figure()
# plt.plot(stage_vol_df.stage_m, stage_vol_df.total_vol_cu_m)
# plt.show()
water_level_10min = water_level_10min.set_index(rounded)
start_time_10 = min(water_level_10min.index)
end_time_10 = max(water_level_10min.index)
# new_index_10min = pd.date_range(start=start_time_10.strftime('%Y-%m-%d %H:%M'), end=end_time_10.strftime('%Y-%m-%d %H:%M'), freq='10min')
new_index_10 = pd.date_range(start=start_time_10, end=end_time_10, freq='10min')
water_level_10min = water_level_10min.reindex(new_index_10, method=None)
water_level_10min = water_level_10min.interpolate(method='time')
# water_level_10min = water_level_10min.set_index(new_index_10min)
water_level_10min.index.name = 'Date'

water_level = pd.concat([water_level_30min, water_level_10min], axis=0)
water_level = water_level.resample('30min', how=np.mean, label='right', closed='right')
water_level = water_level[:'2015-02-09']
print water_level.tail()
# raise SystemExit(0)
water_level.loc[:, 'stage(m)'] = cd.myround(water_level['stage(m)'], decimals=2)
water_level.to_csv('/media/kiruba/New Volume/ACCUWA_Data/Checkdam_water_balance/591/stage_591.csv')
hour = water_level.index.hour
minute = water_level.index.minute
eleven_30_df = water_level.loc[((hour == 23) & (minute == 30))]
print eleven_30_df.head()
fig = plt.figure()
plt.plot(eleven_30_df.index, eleven_30_df['raw value'], 'ro')
plt.show()
# raise SystemExit(0)
# raise SystemExit(0)
"""
Join weather and rain data
"""
weather_df = weather_df.join(rain_df, how='right')
weather_df = weather_df[min(water_level.index).strftime(daily_format): max(water_level.index).strftime(daily_format)]