In geospatial_analysis.py, the starting with line 601.
Suggest replacing hru_mask with hru_mask_temp
Otherwise the code: hru_int_ma = np.ma.masked_array(hru_int,hru_mask==0) will use a hru_mask that only considers the mask from the last loop.
# concatenate element-wise two arrays to generate HRU
if iraster == 0:
hru_str_fmt = raster_str_fmt
hru_mask = (raster_mask!=0)
else:
hru_str_fmt = np.char.add(hru_str_fmt, raster_str_fmt)
hru_mask = (hru_mask & raster_mask)
# assign the unique integer to unique HRU (HRU_str_fmt)
# note: the defined numpy array dtype needs to be consistent with the available rasterio dytpes (e.g., int32,float32,float64).
# note: rasterio dytpes doesn't have int64.
hru_int = np.zeros(np.shape(hru_str_fmt), dtype=np.int32)
unique_hrus_str = np.unique(hru_str_fmt[hru_mask!=0])
for ihru, hru in enumerate(unique_hrus_str):
hru_mask_temp = hru_str_fmt == hru
hru_int[hru_mask_temp] = int(ihru)+1
hru_int_ma = np.ma.masked_array(hru_int,hru_mask==0)
To be resolved with later pull request
In geospatial_analysis.py, the starting with line 601.
Suggest replacing hru_mask with hru_mask_temp Otherwise the code: hru_int_ma = np.ma.masked_array(hru_int,hru_mask==0) will use a hru_mask that only considers the mask from the last loop.