Note
Go to the end to download the full example code.
Weil et al example with spatially heterogeneous atmbc#
Weill, S., et al. « Coupling Water Flow and Solute Transport into a Physically-Based Surface–Subsurface Hydrological Model ». Advances in Water Resources, vol. 34, no 1, janvier 2011, p. 128‑36. DOI.org (Crossref), https://doi.org/10.1016/j.advwatres.2010.10.001.
This example shows how to use pyCATHY object to create spatially and temporally variable atmbc conditions
Estimated time to run the notebook = 5min
# !! run preprocessor change the DEM shape !
# dtm_13 does not have the same shape anymore!
import os
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import pyCATHY.meshtools as mt
from pyCATHY import cathy_tools
from pyCATHY.importers import cathy_inputs as in_CT
from pyCATHY.importers import cathy_outputs as out_CT
from pyCATHY.plotters import cathy_plots as cplt
path2prj = "../SSHydro/" # add your local path here
simu = cathy_tools.CATHY(dirName=path2prj,
prj_name="atmbc_spatially_from_weill"
)
simu.create_mesh_vtk(verbose=True)
Traceback (most recent call last):
File "/home/runner/work/pycathy_wrapper/pycathy_wrapper/examples/SSHydro/plot_3c_spatial_atmbc_from_weill.py", line 41, in <module>
simu.create_mesh_vtk(verbose=True)
File "/home/runner/work/pycathy_wrapper/pycathy_wrapper/pyCATHY/cathy_tools.py", line 3807, in create_mesh_vtk
self.run_processor(IPRT1=3, verbose=verbose)
File "/home/runner/work/pycathy_wrapper/pycathy_wrapper/pyCATHY/cathy_tools.py", line 584, in run_processor
self.update_parm(**kwargs) # to uncomment
File "/home/runner/work/pycathy_wrapper/pycathy_wrapper/pyCATHY/cathy_tools.py", line 1858, in update_parm
self.update_cathyH(
File "/home/runner/work/pycathy_wrapper/pycathy_wrapper/pyCATHY/cathy_tools.py", line 776, in update_cathyH
self.update_veg_map()
File "/home/runner/work/pycathy_wrapper/pycathy_wrapper/pyCATHY/cathy_tools.py", line 3353, in update_veg_map
indice_veg, str_hd_rootmap = in_CT.read_root_map(os.path.join(
File "/home/runner/work/pycathy_wrapper/pycathy_wrapper/pyCATHY/importers/cathy_inputs.py", line 529, in read_root_map
with open(os.path.join(rootmapfile), "r") as f: # open the file for reading
FileNotFoundError: [Errno 2] No such file or directory: '/home/runner/work/pycathy_wrapper/pycathy_wrapper/examples/SSHydro/../SSHydro/atmbc_spatially_from_weill/input/veg_map'
grid3d = simu.read_outputs('grid3d')
# np.shape(simu.DEM)
# DEM, dem_header = simu.read_inputs('dem')
t_atmbc = [0,86400]
v_atmbc = np.zeros(int(grid3d['nnod']))
v_atmbc[0:int(len(np.zeros(int(grid3d['nnod'])))/2)] = 1e-7
v_atmbc_mat = np.reshape(v_atmbc,[np.shape(simu.DEM)[0]+1,
np.shape(simu.DEM)[1]+1
])
fig, ax = plt.subplots()
ax.imshow(v_atmbc_mat)
# np.shape([v_atmbc]*len(t_atmbc))
simu.update_atmbc(
HSPATM=0,
IETO=0,
time=t_atmbc,
netValue=[v_atmbc]*len(t_atmbc)
)
simu.run_processor(IPRT1=2,
DTMIN=1e-2,
DTMAX=1e2,
DELTAT=5,
TRAFLAG=0,
verbose=False
)
# cplt.show_spatial_atmbc()
cplt.show_vtk(
unit="pressure",
timeStep=1,
notebook=False,
path=simu.workdir + simu.project_name + "/vtk/",
savefig=True,
)
cplt.show_vtk_TL(
unit="pressure",
notebook=False,
path=simu.workdir + simu.project_name + "/vtk/",
show=False,
x_units='days',
clim = [0.55,0.70],
savefig=True,
)
Total running time of the script: (0 minutes 6.117 seconds)