openearth / glofrim

Globally Applicable Framework for Integrated Hydrological-Hydrodynamic Modelling (GLOFRIM)
GNU General Public License v3.0
48 stars 28 forks source link

grid_2_grid treatment of missing values #107

Closed hcwinsemius closed 4 years ago

hcwinsemius commented 4 years ago

missing values should be masked in the set_value method of resp models, not in grid_2_grid.

hcwinsemius commented 4 years ago

@DirkEilander can you review my modifications for this issue? Also, I propose to add a line for ensuring that nans that lie within a model domain are set to zero for each model. You can see that I did this for Lisflood on the third line of the snippet below.

    def set_value(self, long_var_name, src, fill_value=0., **kwargs):
        # set nans that lie within to_mod model domain to zeros to prevent model crashes
        src[self.grid.mask & np.isnan(src)] = 0.
        # set remaining nans to missing value
        src = np.where(np.isnan(src), fill_value, src).astype(self.get_var_type(long_var_name))
        # LFP does not have a set_var function, but used the get_var function with an extra argument
        self._bmi.get_var(long_var_name)[:] = src
DirkEilander commented 4 years ago

@hcwinsemius The method looks good to me! I'll try to run our test cases soon to ensure all run smoothly and the results make sense.