def _calculate_infiltration(self, datasets): # short keys s = self.I_SOIL l = self.I_LANDUSE o = self.O_INFILTRATION # create no_data_value = self.no_data_value[o] infiltration = make_dataset(template=datasets[s], data_type=self.data_type[o], no_data_value=no_data_value) # read and convert soil s_conv = np.array([no_data_value if x is None else x for x in self.soil_tables['max_infil']]) s_band = datasets[s].GetRasterBand(1) s_data = s_conv[s_band.ReadAsArray()] s_mask = ~s_band.GetMaskBand().ReadAsArray().astype('b1') s_data[s_mask] = no_data_value # read and convert landuse l_conv = np.array([no_data_value if x is None else x for x in self.landuse_tables['permeability']]) l_band = datasets[l].GetRasterBand(1) l_data = l_conv[l_band.ReadAsArray()] l_mask = ~l_band.GetMaskBand().ReadAsArray().astype('b1') l_data[l_mask] = no_data_value # calculate data = np.where( np.logical_and(l_data != no_data_value, s_data != no_data_value), l_data * s_data, no_data_value, ) # write infiltration.GetRasterBand(1).WriteArray(data) return infiltration
def _calculate_infiltration(self, datasets): # short keys s = self.I_SOIL c = self.I_LANDUSE o = self.O_INFILTRATION # create no_data_value = self.no_data_value[o] infiltration = make_dataset(template=datasets[s], data_type=self.data_type[o], no_data_value=no_data_value) # read and convert soil s_conv = np.array([ no_data_value if x is None else x for x in self.soil_tables['max_infil'] ]) s_band = datasets[s].GetRasterBand(1) s_data = s_conv[s_band.ReadAsArray()] s_mask = ~s_band.GetMaskBand().ReadAsArray().astype('b1') s_data[s_mask] = no_data_value # read and convert landuse l_conv = np.array([ no_data_value if x is None else x for x in self.landuse_tables['permeability'] ]) l_band = datasets[c].GetRasterBand(1) l_data = l_conv[l_band.ReadAsArray()] l_mask = ~l_band.GetMaskBand().ReadAsArray().astype('b1') l_data[l_mask] = no_data_value # calculate data = np.where( np.logical_and(l_data != no_data_value, s_data != no_data_value), l_data * s_data, no_data_value, ) # write infiltration.GetRasterBand(1).WriteArray(data) return infiltration
def __init__(self, layers, dtype, fillvalue, time, **kwargs): """ Initialize the operation. """ # self.layers = layers self.outputs = {self.name: [self.name]} self.inputs = {self.name: {'layers': layers, 'time': time}} self.data_type = {self.name: DTYPES[dtype]} if fillvalue is None: if dtype[0] == 'f': no_data_value = float(np.finfo(dtype).max) else: no_data_value = int(np.iinfo(dtype).max) else: no_data_value = np.array(fillvalue, dtype).tolist() self.no_data_value = { self.name: no_data_value, }
def __init__(self, layers, dtype, fillvalue, time, **kwargs): """ Initialize the operation. """ # self.layers = layers self.outputs = [self.name] self.inputs = {self.name: {'layers': layers, 'time': time}} self.data_type = {self.name: DTYPES[dtype]} if fillvalue is None: if dtype[0] == 'f': no_data_value = float(np.finfo(dtype).max) else: no_data_value = int(np.iinfo(dtype).max) else: no_data_value = np.array(fillvalue, dtype).tolist() self.no_data_value = { self.name: no_data_value, }
def _calculate_hydr_cond(self, datasets): # short keys i = self.I_SOIL o = self.O_HYDRAULIC_CONDUCTIVITY # create no_data_value = self.no_data_value[o] permeability = make_dataset(template=datasets[i], data_type=self.data_type[o], no_data_value=no_data_value) # read and convert conversion = np.array([no_data_value if x is None else x for x in self.soil_tables['intr_perm']]) band = datasets[i].GetRasterBand(1) data = conversion[band.ReadAsArray()] mask = ~band.GetMaskBand().ReadAsArray().astype('b1') data[mask] = no_data_value # write permeability.GetRasterBand(1).WriteArray(data) return permeability
def _calculate_interception(self, datasets): # short keys i = self.I_LANDUSE o = self.O_INTERCEPTION # create no_data_value = self.no_data_value[o] interception = make_dataset(template=datasets[i], data_type=self.data_type[o], no_data_value=no_data_value) # read and convert conversion = np.array([no_data_value if x is None else x for x in self.landuse_tables['interception']]) band = datasets[i].GetRasterBand(1) data = conversion[band.ReadAsArray()] mask = ~band.GetMaskBand().ReadAsArray().astype('b1') data[mask] = no_data_value # write interception.GetRasterBand(1).WriteArray(data) return interception
def _calculate_hydr_cond(self, datasets): # short keys i = self.I_SOIL o = self.O_HYDRAULIC_CONDUCTIVITY # create no_data_value = self.no_data_value[o] permeability = make_dataset(template=datasets[i], data_type=self.data_type[o], no_data_value=no_data_value) # read and convert conversion = np.array([ no_data_value if x is None else x for x in self.soil_tables['intr_perm'] ]) band = datasets[i].GetRasterBand(1) data = conversion[band.ReadAsArray()] mask = ~band.GetMaskBand().ReadAsArray().astype('b1') data[mask] = no_data_value # write permeability.GetRasterBand(1).WriteArray(data) return permeability
def _calculate_interception(self, datasets): # short keys i = self.I_LANDUSE o = self.O_INTERCEPTION # create no_data_value = self.no_data_value[o] interception = make_dataset(template=datasets[i], data_type=self.data_type[o], no_data_value=no_data_value) # read and convert conversion = np.array([ no_data_value if x is None else x for x in self.landuse_tables['interception'] ]) band = datasets[i].GetRasterBand(1) data = conversion[band.ReadAsArray()] mask = ~band.GetMaskBand().ReadAsArray().astype('b1') data[mask] = no_data_value # write interception.GetRasterBand(1).WriteArray(data) return interception