Skip to content
Snippets Groups Projects
Commit e5bef64a authored by Valentin Simon Lüdke's avatar Valentin Simon Lüdke
Browse files

Small fix of cutting out by coordinate slice

parent 6a1549c5
No related branches found
No related tags found
2 merge requests!16Generate classical mhm setups from classical setup,!8Draft: Resolve "Pre-Proc: incorporate tools for creating global setups"
Pipeline #274502 failed with stages
in 3 minutes and 20 seconds
......@@ -698,17 +698,22 @@ def create_catchment(
temp_file2.unlink()
elif coordinate_slices is not None:
logger.info(f"Creating basin id file for {coordinate_slices}")
if l1_resolution is not None:
lat_max = coordinate_slices['lat'].start + 2 * l1_resolution
lat_min = coordinate_slices['lat'].stop - 2 * l1_resolution
lon_min = coordinate_slices['lon'].start - 2 * l1_resolution
lon_max = coordinate_slices['lon'].stop + 2 * l1_resolution
else:
res = round(input_ds.lon[1]-input_ds.lon[0], 6)
lat_max = coordinate_slices['lat'].start + (frame + 1) * res
lat_min = coordinate_slices['lat'].stop - (frame + 1) * res
lon_min = coordinate_slices['lon'].start - (frame + 1) * res
lon_max = coordinate_slices['lon'].stop + (frame + 1) * res
# res = round(input_ds.lon[1]-input_ds.lon[0], 6)
# if l1_resolution is not None:
# factor = get_upscaling_factor(input_ds, l1_resolution)
# lat_max = coordinate_slices['lat'].start + 2 * l1_resolution
# lat_min = coordinate_slices['lat'].stop - 2 * l1_resolution
# lon_min = coordinate_slices['lon'].start - 2 * l1_resolution
# lon_max = coordinate_slices['lon'].stop + 2 * l1_resolution
# else:
# lat_max = coordinate_slices['lat'].start + (frame + 1) * res
# lat_min = coordinate_slices['lat'].stop - (frame + 1) * res
# lon_min = coordinate_slices['lon'].start - (frame + 1) * res
# lon_max = coordinate_slices['lon'].stop + (frame + 1) * res
lat_max = coordinate_slices['lat'].start
lat_min = coordinate_slices['lat'].stop
lon_min = coordinate_slices['lon'].start
lon_max = coordinate_slices['lon'].stop
input_ds = input_ds.sel(lat=slice(lat_max, lat_min), lon=slice(lon_min, lon_max))
c = Catchment(
ds=input_ds,
......
......@@ -350,6 +350,7 @@ class MPRRunner:
p = Popen(command, shell=True, stdout=PIPE, stderr=PIPE)
try:
data, error_data = p.communicate()
logger.debug(data)
if error_data:
grid.restart_file = None
msg = f"MPR failed with STDERR {error_data} for {grid.name} and command {command}"
......@@ -749,7 +750,9 @@ class MHMRestartFile:
)
# 3. iterate over all subgrids and merge them into the whole grid
for restart_file_path in restart_file_paths:
for counter, restart_file_path in enumerate(restart_file_paths):
logger.info(f'Merging {counter}/{len(restart_file_paths)} files')
logger.debug(f'Restart path of the subdomain restart file: {restart_file_path}')
ints = re.findall(r"\d+", str(restart_file_path))
isel_start = int(ints[-2])
jsel_start = int(ints[-1])
......
......@@ -281,8 +281,9 @@ class CreateSubdomainMasks:
# Second condition: Replace all values where land_mask is 0 with NaN unless they are sink values (0)
data_var_values[land_mask_values == 0 & (data_var_values != sink_value)] = (
-9999.0
sink_value
)
#-9999.0
ds_sub_ref_file["flwdir"].values = data_var_values
for data_var in ds_sub_ref_file.data_vars:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment