#added feature for including ocean WQ boundary as well as for increasing

river inflow temp and ocean temp by a user defined delta for near and
far future
#fully working.
Development
tinoheimhuber 6 years ago
parent ddf60b7cb0
commit 399318dcf3

@ -11,11 +11,6 @@ import pyrma.pyrma
path = "C:/Users/z5025317/OneDrive - UNSW/Hunter_CC_Modeling/07_Modelling/01_Input/BCGeneration/"
###Input parameters for Climate change runs
pres_start_date = datetime(int(1995), int('1'), int('1'))
pres_end_date = datetime(int(2005), int('12'), int('31'))
River_temp_increase = 0.5
# Load project settings
# Establish the settings and run parameters (see the description of
# settings that are in header of this code)
@ -92,6 +87,11 @@ start_date = datetime(int(S['start_year']), int(S['start_month']), int(S['start_
end_date = datetime(int(S['end_year']), int(S['end_month']), int(S['end_day']))
inflow_timeseries = pd.DataFrame(index=pd.date_range(start_date, end_date))
#presend day period start and end day
pres_start_date = datetime(int(S['PD_start_year']), int(S['PD_start_month']), int(S['PD_start_day']))
pres_end_date = datetime(int(S['PD_end_year']), int(S['PD_end_month']), int(S['PD_end_day']))
# Generate empty dictionary (to be filled with dataframes) for water quality
wq_timeseries = {}
@ -144,7 +144,38 @@ if S['include_boundary_flows'].lower() == 'yes':
inflow_timeseries = pd.concat([inflow_timeseries, df[[key]]], axis=1)
# Add to water quality timeseries
wq_timeseries[key] = df.drop(['Q[ML/d]', key], axis = 1)
df = df.drop(['Q[ML/d]', key], axis = 1)
#increase river temperature by Delta
if S['Increase_riv_temp'] == 'yes':
df['Temperature'] = df['Temperature'] + S['Riv_temp_increase']
wq_timeseries[key] = df
CC_data = {}
for key, val in S.items():
if re.match('CC_\d', key):
CC_data[val[0]] = dict(cc=int(val[1]))
dir_name = S['CC_WQ_directory']
for key, val in CC_data.items():
file_name = [x for x in os.listdir(dir_name) if x.startswith(key)][0]
CC_data[key]['path'] = os.path.join(dir_name, file_name)
CC_timeseries = {}
if S['include_CC_wq'].lower() == 'yes':
print('Reading WQ at CC line')
for key in CC_data.keys():
df = pd.read_csv(
CC_data[key]['path'],
index_col=0,
parse_dates=[0],
dayfirst=True)
#Shift the water quality time series data frame by
df.index = df.index + (start_date - pres_start_date)
#increase temperature by Delta
if S['Increase_SST_temp'] == 'yes':
df['Temperature'] = df['Temperature'] + S['SST_increase']
CC_timeseries[key] = df.copy()
# Read WWTP data from setup file
wwtp_data = {}
@ -561,11 +592,9 @@ if S['include_WQ'].lower() == 'yes':
wq = wq.reset_index()
wq.index = np.tile(i, wq.shape[0])
wq_df = wq_df.append(wq)
#Shift the water quality time series data frame by
wq_df.index = wq_df.index + (start_date - pres_start_date)
# Write element inflows for RMA
# Consolidate inflow elements in RMA mesh (only include those with inflows)
inflow_elements = mesh.loc[[len(n) > 0
@ -680,6 +709,18 @@ for current_year in range(start_date.year, end_date.year + 1):
fq.close()
if S['include_WQ'].lower() == 'yes':
if S['include_CC_wq'].lower() == 'yes':
for key, value in CC_timeseries.items():
fwq.write('TI {}\n'.format(key))
fwq.write('{:<8}{:>8}{:>8}{:>8}\n'.format('QT', CC_data['Entrance']['cc'], 1,
current_year))
for index, row in value[value.index.year ==
current_year].iterrows():
fwq.write('{:<5}{:>3}{:>8}'.format(
'QD', index.dayofyear, index.hour) + ''.join(
'{:>8.2E}'.format(x) for x in row))
fwq.write('\n')
print('a')
fwq.write('ENDDATA\n\n')
fwq.write(env_str)
fwq.close()

Loading…
Cancel
Save