Commit 346adcc1 authored by Modellers Operational's avatar Modellers Operational

Edits to river model component to allow for hindcast suite runs

parent 1017130e
......@@ -27,25 +27,26 @@ for this_obj in river_dict.values():
river_list.append(this_obj)
# Add the new WRF data
forecast_nc = nc.Dataset(wrf_nc_file_str, 'r')
if wrf_nc_file_str != 'hindcast':
forecast_nc = nc.Dataset(wrf_nc_file_str, 'r')
wrf_vars = ['RAINNC', 'T2', 'Times']
forecast_data = {}
for this_var in wrf_vars:
forecast_data[this_var] = forecast_nc.variables[this_var][:]
wrf_vars = ['RAINNC', 'T2', 'Times']
forecast_data = {}
for this_var in wrf_vars:
forecast_data[this_var] = forecast_nc.variables[this_var][:]
date_str_raw = [b''.join(this_date_raw) for this_date_raw in forecast_data['Times']]
forecast_data['times'] = np.asarray([dt.datetime.strptime(this_date_str.decode('utf-8'), '%Y-%m-%d_%H:%M:%S') for this_date_str in date_str_raw])
date_str_raw = [b''.join(this_date_raw) for this_date_raw in forecast_data['Times']]
forecast_data['times'] = np.asarray([dt.datetime.strptime(this_date_str.decode('utf-8'), '%Y-%m-%d_%H:%M:%S') for this_date_str in date_str_raw])
for this_river in river_list:
if hasattr(this_river, 'wrf_catchment_factors'):
this_rain = np.sum(np.sum(forecast_data['RAINNC']*this_river.wrf_catchment_factors, axis=2), axis=1)
this_river.addToSeries('catchment_precipitation', this_rain, forecast_data['times'])
this_temp = np.zeros(len(forecast_data['times']))
for i in range(0, len(forecast_data['times'])):
this_temp[i] = np.average(forecast_data['T2'][i,:,:], weights=this_river.wrf_catchment_factors)
this_river.addToSeries('catchment_temp', this_temp, forecast_data['times'], override=True)
for this_river in river_list:
if hasattr(this_river, 'wrf_catchment_factors'):
this_rain = np.sum(np.sum(forecast_data['RAINNC']*this_river.wrf_catchment_factors, axis=2), axis=1)
this_river.addToSeries('catchment_precipitation', this_rain, forecast_data['times'])
this_temp = np.zeros(len(forecast_data['times']))
for i in range(0, len(forecast_data['times'])):
this_temp[i] = np.average(forecast_data['T2'][i,:,:], weights=this_river.wrf_catchment_factors)
this_river.addToSeries('catchment_temp', this_temp, forecast_data['times'], override=True)
for this_river in river_list:
try:
......
[command]
default = cp -r ${RIVER_MODEL_PATH}/* .; python3 river_make.py ${GRID_NAME} ${ROSE_DATAC} ${START_DATE_STR} ${END_DATE_STR} ${COORDINATES} ${WRF_ARCHIVE_DIR}/today/today_wrfout.nc; mv ${GRID_NAME}_riv* /${REMOTE_TRANSFER_DIR}
default = cp -r ${RIVER_MODEL_PATH}/* .; python3 river_make.py ${GRID_NAME} ${ROSE_DATAC} ${START_DATE_STR} ${END_DATE_STR} ${COORDINATES} ${TODAY_WRF_FILE}; mv ${GRID_NAME}_riv* /${REMOTE_TRANSFER_DIR}
......@@ -9,7 +9,8 @@ import fvcom_river as fr
wrf_forecast_out_dir = sys.argv[1]
end_date = dt.datetime.strptime(sys.argv[2],'%Y-%m-%d')
wrf_forecast_out_dir_strfmt = sys.argv[2]
end_date = dt.datetime.strptime(sys.argv[3],'%Y-%m-%d')
no_miss_loops = 4
# Load the river model
......@@ -39,8 +40,8 @@ else:
else:
print(this_date)
this_date_m1 = this_date - dt.timedelta(days=int(this_missing_loop))
this_date_str = this_date_m1.strftime('%Y-%m-%d')
potential_files = gb.glob('{}/{}/wrfout_d03*'.format(wrf_forecast_out_dir, this_date_str))
this_date_str = this_date_m1.strftime(wrf_forecast_out_dir_strfmt)
potential_files = gb.glob('{}/*{}*/wrfout_d03*'.format(wrf_forecast_out_dir, this_date_str))
try:
this_wrf_nc = nc.Dataset(potential_files[-1], 'r')
......
......@@ -29,7 +29,9 @@ AIR_PRESSURE_ON='T'
## WRF suite settings if any of the above are on
WRF_RUN_SUITE='wrf'
WRF_FORECAST_FILE_DIR='/gpfs1/users/modellers/modop/Models/WRF_transfer_dir/'
WRF_ARCHIVE_DIR='/data/sthenno1/scratch/modop/Model/WRF/output'
WRF_ARCHIVE_DIR='data/sthenno1/backup/pica/models/WRF/wrf-preprocess-gfs/output'
WRF_ARCHIVE_DATEFMT='%Y%m%d'
## River setup
## Between 'NONE', 'NEURAL_NET', and 'CLIMATOLOGY'
......
......@@ -32,7 +32,7 @@
start_cycle => nest_suite_trigger<{{NEST_RUN_SUITE}}::transfer_data> => get_nest_file => write_run_namelist
{% endif %}
{% if RIVER_MODEL == 'NEURAL_NET' %}
{% if RIVER_MODEL == 'NEURAL_NET' and FORECAST %}
start_cycle => wrf_archive_trigger <wrf::cycle_finished> & update_river_model & softlink_forcing => generate_rivers
generate_rivers:failed => trigger_archive_wrf & write_empty_river_nml
......@@ -40,6 +40,9 @@
generate_rivers:succeeded | write_empty_river_nml => mv_river_files => write_river_number
write_run_namelist => write_river_number => run_fvcom
{% elif RIVER_MODEL == 'NEURAL_NET' %}
softlink_forcing => generate_rivers => mv_river_files
mv_river_files & write_run_namelist => write_river_number => run_fvcom
{% elif RIVER_MODEL == 'CLIMATOLOGY' %}
start_cycle => get_river_files => write_run_namelist => write_river_number => run_fvcom
{% endif %}
......@@ -100,6 +103,15 @@
WRF_FORECAST_FILE_DIR={{WRF_FORECAST_FILE_DIR}}
WRF_ARCHIVE_DIR={{WRF_ARCHIVE_DIR}}
COMMON_FILES_PATH={{COMMON_FILES_PATH}}
WRF_ARCHIVE_DATESTR=$(rose date --print-format={{WRF_ARCHIVE_DATEFMT}} $CYLC_TASK_CYCLE_POINT)
{% if FORECAST %}
TODAY_WRF_FILE=/{{WRF_ARCHIVE_DIR}}/today/today_wrfout.nc
{% else %}
TODAY_WRF_FILE='hindcast'
{% endif %}
{%- if BOUNDARY_FORCING == 'TIDAL' %}
ELEV_FORCE='T'
{%- else %}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment