UU-Hydro / PCR-GLOBWB_model

PCR-GLOBWB (PCRaster Global Water Balance) is a large-scale hydrological model intended for global to regional studies and developed at the Department of Physical Geography, Utrecht University (Netherlands). Contact: Edwin Sutanudjaja (E.H.Sutanudjaja@uu.nl).
GNU General Public License v3.0
116 stars 79 forks source link

Bugfix for regridding where coarse and fine resolution bounds do not match #31

Open BramDr opened 6 months ago

BramDr commented 6 months ago

When regridding a course resolution (netCDF) array, a factor is applied and the array is uniformly downscaled based on this factor. However, for cases where the fine resolution bounds to not match up with the coarse resolution bounds, this will not work. Rather the regridded coarse resolution array will be too large.

This branch fixes this issue by, if necessary, cropping the regridded data to the fine resolution bounds. Note that this fix is only applied to the default netcdf loading functions 'singleTryNetcdf2PCRobjCloneWithoutTime' and 'singleTryNetcdf2PCRobjClone'. In the future it would be better to reorganize the code so that this is done in a single function.

BramDr commented 6 months ago

After discussion with @edwinkost it was decided not to implement these changes as they are still untested. Rather, the model should exit and provide an error when unaligned regridding is detected.

BramDr commented 6 months ago

Error messages added