%%bash
# Make a new directory for our baseline simulation
mkdir -p ~/wrf-hydro-training/output/free_lesson_states/run_template
# Copy our model files to the simulation directory
cp ~/wrf-hydro-training/wrf_hydro_nwm_public/trunk/NDHMS/Run/*.TBL \
~/wrf-hydro-training/output/free_lesson_states/run_template
cp ~/wrf-hydro-training/wrf_hydro_nwm_public/trunk/NDHMS/Run/wrf_hydro.exe \
~/wrf-hydro-training/output/free_lesson_states/run_template
# Create symbolic links to forcing files
cp -as $HOME/wrf-hydro-training/example_case/FORCING \
~/wrf-hydro-training/output/free_lesson_states/run_template
# Copy the domain/parameter files so we can modify them
cp -r $HOME/wrf-hydro-training/example_case/Gridded_no_lakes/DOMAIN \
~/wrf-hydro-training/output/free_lesson_states/run_template
cp -r $HOME/wrf-hydro-training/example_case/Gridded_no_lakes/RESTART \
~/wrf-hydro-training/output/free_lesson_states/run_template
# Copy namelist files
cp ~/wrf-hydro-training/example_case/Gridded_no_lakes/namelist.hrldas \
~/wrf-hydro-training/output/free_lesson_states/run_template
cp ~/wrf-hydro-training/example_case/Gridded_no_lakes/hydro.namelist \
~/wrf-hydro-training/output/free_lesson_states/run_template
Examine the soil types:
%%bash
cd ~/wrf-hydro-training/output/free_lesson_states/run_template/DOMAIN
ncdump -v SCT_DOM geo_em.d01.nc | tail -n 20
Examine the porosity values:
%%bash
cd ~/wrf-hydro-training/output/free_lesson_states/run_template/DOMAIN
ncdump -v smcmax soil_properties.nc | tail -n 20
Examine the field capacity values:
%%bash
cd ~/wrf-hydro-training/output/free_lesson_states/run_template/DOMAIN
ncdump -v smcref soil_properties.nc | tail -n 20
Examine the wilting point values:
%%bash
cd ~/wrf-hydro-training/output/free_lesson_states/run_template/DOMAIN
ncdump -v smcwlt soil_properties.nc | tail -n 20
Examine the SOILPARM TBL file:
%%bash
cd ~/wrf-hydro-training/output/free_lesson_states/run_template
cat SOILPARM.TBL | head -n 22
Examine the current TOTAL soil moisture states (top layer):
%%bash
cd ~/wrf-hydro-training/output/free_lesson_states/run_template/RESTART
ncdump -v smc1 HYDRO_RST.2011-08-26_00\:00_DOMAIN1 | tail -n 20
Examine the current LIQUID soil moisture states (top layer):
%%bash
cd ~/wrf-hydro-training/output/free_lesson_states/run_template/RESTART
ncdump -v sh2ox1 HYDRO_RST.2011-08-26_00\:00_DOMAIN1 | tail -n 20
Decide what values you want to use for high, medium, and low soil moisture initial conditions.
Copy the template directory:
%%bash
cp -r ~/wrf-hydro-training/output/free_lesson_states/run_template \
~/wrf-hydro-training/output/free_lesson_states/run_saturated
Modify the top layer total soil moisture content in the HYDRO restart file:
%%bash
cd ~/wrf-hydro-training/output/free_lesson_states/run_saturated/RESTART
ncap2 -O -s "smc1=smc1*0.0+0.434" HYDRO_RST.2011-08-26_00\:00_DOMAIN1 HYDRO_RST.2011-08-26_00\:00_DOMAIN1
ncdump -v smc1 HYDRO_RST.2011-08-26_00\:00_DOMAIN1 | tail -n 10
Repeat for the other 3 soil layers:
%%bash
cd ~/wrf-hydro-training/output/free_lesson_states/run_saturated/RESTART
ncap2 -O -s "smc2=smc2*0.0+0.434" HYDRO_RST.2011-08-26_00\:00_DOMAIN1 HYDRO_RST.2011-08-26_00\:00_DOMAIN1
ncap2 -O -s "smc3=smc3*0.0+0.434" HYDRO_RST.2011-08-26_00\:00_DOMAIN1 HYDRO_RST.2011-08-26_00\:00_DOMAIN1
ncap2 -O -s "smc4=smc4*0.0+0.434" HYDRO_RST.2011-08-26_00\:00_DOMAIN1 HYDRO_RST.2011-08-26_00\:00_DOMAIN1
ncdump -v smc4 HYDRO_RST.2011-08-26_00\:00_DOMAIN1 | tail -n 10
Modify the liquid soil moisture content for all layers in the HYDRO restart file:
%%bash
cd ~/wrf-hydro-training/output/free_lesson_states/run_saturated/RESTART
ncap2 -O -s "sh2ox1=sh2ox1*0.0+0.434" HYDRO_RST.2011-08-26_00\:00_DOMAIN1 HYDRO_RST.2011-08-26_00\:00_DOMAIN1
ncap2 -O -s "sh2ox2=sh2ox2*0.0+0.434" HYDRO_RST.2011-08-26_00\:00_DOMAIN1 HYDRO_RST.2011-08-26_00\:00_DOMAIN1
ncap2 -O -s "sh2ox3=sh2ox3*0.0+0.434" HYDRO_RST.2011-08-26_00\:00_DOMAIN1 HYDRO_RST.2011-08-26_00\:00_DOMAIN1
ncap2 -O -s "sh2ox4=sh2ox4*0.0+0.434" HYDRO_RST.2011-08-26_00\:00_DOMAIN1 HYDRO_RST.2011-08-26_00\:00_DOMAIN1
ncdump -v sh2ox4 HYDRO_RST.2011-08-26_00\:00_DOMAIN1 | tail -n 10
Run the model:
%%bash
cd ~/wrf-hydro-training/output/free_lesson_states/run_saturated
mpirun -np 2 ./wrf_hydro.exe >> run.log 2>&1
Copy the template directory:
%%bash
cp -r ~/wrf-hydro-training/output/free_lesson_states/run_template \
~/wrf-hydro-training/output/free_lesson_states/run_fieldcap
Modify the total soil moisture content for all layers in the HYDRO restart file:
%%bash
cd ~/wrf-hydro-training/output/free_lesson_states/run_fieldcap/RESTART
ncap2 -O -s "smc1=smc1*0.0+0.312" HYDRO_RST.2011-08-26_00\:00_DOMAIN1 HYDRO_RST.2011-08-26_00\:00_DOMAIN1
ncap2 -O -s "smc2=smc2*0.0+0.312" HYDRO_RST.2011-08-26_00\:00_DOMAIN1 HYDRO_RST.2011-08-26_00\:00_DOMAIN1
ncap2 -O -s "smc3=smc3*0.0+0.312" HYDRO_RST.2011-08-26_00\:00_DOMAIN1 HYDRO_RST.2011-08-26_00\:00_DOMAIN1
ncap2 -O -s "smc4=smc4*0.0+0.312" HYDRO_RST.2011-08-26_00\:00_DOMAIN1 HYDRO_RST.2011-08-26_00\:00_DOMAIN1
ncdump -v smc4 HYDRO_RST.2011-08-26_00\:00_DOMAIN1 | tail -n 10
Modify the liquid soil moisture content for all layers in the HYDRO restart file:
%%bash
cd ~/wrf-hydro-training/output/free_lesson_states/run_fieldcap/RESTART
ncap2 -O -s "sh2ox1=sh2ox1*0.0+0.312" HYDRO_RST.2011-08-26_00\:00_DOMAIN1 HYDRO_RST.2011-08-26_00\:00_DOMAIN1
ncap2 -O -s "sh2ox2=sh2ox2*0.0+0.312" HYDRO_RST.2011-08-26_00\:00_DOMAIN1 HYDRO_RST.2011-08-26_00\:00_DOMAIN1
ncap2 -O -s "sh2ox3=sh2ox3*0.0+0.312" HYDRO_RST.2011-08-26_00\:00_DOMAIN1 HYDRO_RST.2011-08-26_00\:00_DOMAIN1
ncap2 -O -s "sh2ox4=sh2ox4*0.0+0.312" HYDRO_RST.2011-08-26_00\:00_DOMAIN1 HYDRO_RST.2011-08-26_00\:00_DOMAIN1
ncdump -v sh2ox4 HYDRO_RST.2011-08-26_00\:00_DOMAIN1 | tail -n 10
Run the model:
%%bash
cd ~/wrf-hydro-training/output/free_lesson_states/run_fieldcap
mpirun -np 2 ./wrf_hydro.exe >> run.log 2>&1
Copy the template directory:
%%bash
cp -r ~/wrf-hydro-training/output/free_lesson_states/run_template \
~/wrf-hydro-training/output/free_lesson_states/run_wiltpoint
Modify the total soil moisture content for all layers in the HYDRO restart file:
%%bash
cd ~/wrf-hydro-training/output/free_lesson_states/run_wiltpoint/RESTART
ncap2 -O -s "smc1=smc1*0.0+0.047" HYDRO_RST.2011-08-26_00\:00_DOMAIN1 HYDRO_RST.2011-08-26_00\:00_DOMAIN1
ncap2 -O -s "smc2=smc2*0.0+0.047" HYDRO_RST.2011-08-26_00\:00_DOMAIN1 HYDRO_RST.2011-08-26_00\:00_DOMAIN1
ncap2 -O -s "smc3=smc3*0.0+0.047" HYDRO_RST.2011-08-26_00\:00_DOMAIN1 HYDRO_RST.2011-08-26_00\:00_DOMAIN1
ncap2 -O -s "smc4=smc4*0.0+0.047" HYDRO_RST.2011-08-26_00\:00_DOMAIN1 HYDRO_RST.2011-08-26_00\:00_DOMAIN1
ncdump -v smc4 HYDRO_RST.2011-08-26_00\:00_DOMAIN1 | tail -n 10
Modify the liquid soil moisture content for all layers in the HYDRO restart file:
%%bash
cd ~/wrf-hydro-training/output/free_lesson_states/run_wiltpoint/RESTART
ncap2 -O -s "sh2ox1=sh2ox1*0.0+0.047" HYDRO_RST.2011-08-26_00\:00_DOMAIN1 HYDRO_RST.2011-08-26_00\:00_DOMAIN1
ncap2 -O -s "sh2ox2=sh2ox2*0.0+0.047" HYDRO_RST.2011-08-26_00\:00_DOMAIN1 HYDRO_RST.2011-08-26_00\:00_DOMAIN1
ncap2 -O -s "sh2ox3=sh2ox3*0.0+0.047" HYDRO_RST.2011-08-26_00\:00_DOMAIN1 HYDRO_RST.2011-08-26_00\:00_DOMAIN1
ncap2 -O -s "sh2ox4=sh2ox4*0.0+0.047" HYDRO_RST.2011-08-26_00\:00_DOMAIN1 HYDRO_RST.2011-08-26_00\:00_DOMAIN1
ncdump -v sh2ox4 HYDRO_RST.2011-08-26_00\:00_DOMAIN1 | tail -n 10
Run the model:
%%bash
cd ~/wrf-hydro-training/output/free_lesson_states/run_wiltpoint
mpirun -np 2 ./wrf_hydro.exe >> run.log 2>&1
# Load the xarray package
%matplotlib inline
import xarray as xr
import matplotlib.pyplot as plt
import pandas as pd
from pandas.plotting import register_matplotlib_converters
register_matplotlib_converters()
chanobs_baseline = xr.open_mfdataset('/home/docker/wrf-hydro-training/output/lesson5/run_gridded_baseline/*CHANOBS*',
combine='by_coords')
chanobs_sat = xr.open_mfdataset('/home/docker/wrf-hydro-training/output/free_lesson_states/run_saturated/*CHANOBS*',
combine='by_coords')
chanobs_fc = xr.open_mfdataset('/home/docker/wrf-hydro-training/output/free_lesson_states/run_fieldcap/*CHANOBS*',
combine='by_coords')
chanobs_wp = xr.open_mfdataset('/home/docker/wrf-hydro-training/output/free_lesson_states/run_wiltpoint/*CHANOBS*',
combine='by_coords')
fig, axes = plt.subplots(ncols=1,figsize=(12, 6))
plt.suptitle('Hydrographs for soil initial states',fontsize=24)
chanobs_baseline.sel(feature_id = 2).streamflow.plot(label='Baseline',
color='black',
linestyle='--')
chanobs_sat.sel(feature_id = 2).streamflow.plot(label='Saturated',
color='blue',
linestyle='-')
chanobs_fc.sel(feature_id = 2).streamflow.plot(label='Field Capacity',
color='green',
linestyle='-')
chanobs_wp.sel(feature_id = 2).streamflow.plot(label='Wilting Point',
color='red',
linestyle='-')
plt.ylim(0,70)
plt.legend()
plt.show()