Commit 23a1eb15 authored by POLCHER Jan's avatar POLCHER Jan 🚴🏾
Browse files

Test that the atmospheric domain is within the HydroFile domain.

parent b858c0a0
......@@ -20,6 +20,21 @@ INFO, DEBUG, ERROR = log_master.info, log_master.debug, log_world.error
INFO_ALL, DEBUG_ALL = log_world.info, log_world.debug
#
def getbox(ncdf, corners) :
#
# Check that the domain fits in the data available.
lonrange=[getattrcontaining(ncdf, "nav_lon", "min"), getattrcontaining(ncdf, "nav_lon", "max")]
latrange=[getattrcontaining(ncdf, "nav_lat", "min"), getattrcontaining(ncdf, "nav_lat", "max")]
if len(lonrange[0]) <= 0 :
lonrange=[np.min(ncdf.variables["nav_lon"][:,:]),np.max(ncdf.variables["nav_lon"][:,:])]
if len(latrange[0]) <= 0 :
latrange=[np.min(ncdf.variables["nav_lat"][:,:]),np.max(ncdf.variables["nav_lat"][:,:])]
if np.min(corners[0][:]) < np.min(lonrange) or \
np.max(corners[0][:]) > np.max(lonrange) or \
np.min(corners[1][:]) < np.min(latrange) or \
np.max(corners[1][:]) > np.max(latrange) :
print("The atmospheric domain does not fit inside the area covered by HydroFile. Please check the file.")
sys.exit()
#
# Add a few points to tbe box to make sure to cover everything
halo_pts=2
ii=[np.argmin(abs(ncdf.variables["nav_lon"][0,:]-np.min(corners[0][:]))),
......
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