Skip to content

Commit

Permalink
change mat_aa to mat_a
Browse files Browse the repository at this point in the history
* mat_aa is a historic name from times of single variables instead of matrices

fix #388
  • Loading branch information
pesekon2 committed Jun 28, 2024
1 parent 418d63b commit cbbdb40
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 34 deletions.
8 changes: 4 additions & 4 deletions smoderp2d/core/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ class Globals:
# raster contains critical water level
mat_hcrit = None
# raster contains parameter of power law for surface runoff
mat_aa = None
mat_a = None
# raster contains parameter of power law for surface runoff
mat_b = None
# raster contains surface retention data
Expand Down Expand Up @@ -314,9 +314,9 @@ def get_mat_hcrit(cls):
return cls.mat_hcrit

@classmethod
def get_mat_aa(cls):
def get_mat_a(cls):
"""TODO."""
return cls.mat_aa
return cls.mat_a

@classmethod
def get_mat_b(cls):
Expand Down Expand Up @@ -448,7 +448,7 @@ def reset(cls):
# raster contains critical water level
cls.mat_hcrit = None
# raster contains parameter of power law for surface runoff
cls.mat_aa = None
cls.mat_a = None
# raster contains parameter of power law for surface runoff
cls.mat_b = None
# raster contains surface retention data
Expand Down
2 changes: 1 addition & 1 deletion smoderp2d/core/surface.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def __init__(self):
Globals.get_mat_reten(),
Globals.get_mat_inf_index(),
Globals.get_mat_hcrit(),
Globals.get_mat_aa(),
Globals.get_mat_a(),
Globals.get_mat_b()
)

Expand Down
18 changes: 9 additions & 9 deletions smoderp2d/providers/base/data_preparation.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ def _get_a(mat_nsheet, mat_y, no_data, mat_slope):
:param mat_y:
:param no_data: no data value
:param mat_slope:
:return: np ndarray for mat_aa
:return: np ndarray for mat_a
"""
mat_aa = ma.where(
mat_a = ma.where(
ma.logical_or(
mat_nsheet == no_data, mat_y == no_data, mat_slope == no_data
),
Expand All @@ -38,11 +38,11 @@ def _get_a(mat_nsheet, mat_y, no_data, mat_slope):
)
)

return mat_aa
return mat_a

@staticmethod
def _get_crit_water(mat_b, mat_tau, mat_v, r, c, mat_slope,
no_data_value, mat_aa):
no_data_value, mat_a):
cond = ma.logical_and(
mat_slope != no_data_value, mat_tau != no_data_value
)
Expand All @@ -61,7 +61,7 @@ def _get_crit_water(mat_b, mat_tau, mat_v, r, c, mat_slope,

mat_hcrit_v = ma.where(
cond,
ma.where(mat_slope == 0, 1000, ma.power(mat_v / mat_aa, exp)),
ma.where(mat_slope == 0, 1000, ma.power(mat_v / mat_a, exp)),
no_data_value
)

Expand All @@ -70,7 +70,7 @@ def _get_crit_water(mat_b, mat_tau, mat_v, r, c, mat_slope,
ma.where(
mat_slope == 0,
1000,
ma.power(flux_crit / mat_slope / g / mat_aa, 1 / mat_b)
ma.power(flux_crit / mat_slope / g / mat_a, 1 / mat_b)
),
no_data_value
)
Expand Down Expand Up @@ -265,7 +265,7 @@ def __init__(self, writer):
'surface_retention': None,
'mat_inf_index': None,
'mat_hcrit': None,
'mat_aa': None,
'mat_a': None,
'mat_b': None,
'mat_reten': None,
'mat_fd': None,
Expand Down Expand Up @@ -612,7 +612,7 @@ def run(self):
self.data['mat_dem'])

# build a/aa arrays
self.data['mat_aa'] = self._get_a(
self.data['mat_a'] = self._get_a(
self.soilveg_fields['nsheet'], self.soilveg_fields['y'],
GridGlobals.NoDataValue, self.data['mat_slope'])
Logger.progress(50)
Expand All @@ -622,7 +622,7 @@ def run(self):
self.data['mat_b'], self.soilveg_fields['tau'],
self.soilveg_fields['v'], GridGlobals.r,
GridGlobals.c, self.data['mat_slope'],
GridGlobals.NoDataValue, self.data['mat_aa'])
GridGlobals.NoDataValue, self.data['mat_a'])
self.storage.write_raster(self.data['mat_hcrit'], 'hcrit', 'control')

# load precipitation input file
Expand Down
5 changes: 2 additions & 3 deletions smoderp2d/providers/profile1d/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def _load_roff(self):
# set values to parameter matrics
data['mat_nrill'] = parsed_data['nrill'].reshape((data['r'], data['c']))
data['mat_b'] = parsed_data['b'].reshape((data['r'], data['c']))
data['mat_aa'] = self._get_a(
data['mat_a'] = self._get_a(
data['nsheet'],
data['y'],
data['NoDataValue'],
Expand All @@ -210,7 +210,7 @@ def _load_roff(self):
data['c'],
data['mat_slope'],
data['NoDataValue'],
data['mat_aa']
data['mat_a']
)

data['mat_reten'] = parsed_data['ret'].reshape((data['r'], data['c']))
Expand Down Expand Up @@ -344,7 +344,6 @@ def _alloc_matrices(data):
data['mat_inf_index'] = np.zeros((data['r'], data['c']), float)
data['mat_fd'] = np.zeros((data['r'], data['c']), float)
data['mat_hcrit'] = np.zeros((data['r'], data['c']), float)
data['mat_aa'] = np.zeros((data['r'], data['c']), float)
data['mat_reten'] = np.zeros((data['r'], data['c']), float)
data['mat_nan'] = np.zeros((data['r'], data['c']), float)
data['mat_effect_cont'] = np.zeros((data['r'], data['c']), float)
Expand Down
6 changes: 3 additions & 3 deletions smoderp2d/time_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ def do_next_h_implicit(self, surface, subsurface, rain_arr, cumulative,
h_old = np.ravel(surface.arr.h_total_pre.tolist(0))

# Preparing the matrixes of flow parameters
aa = ma.array(Globals.get_mat_aa(), mask=GridGlobals.masks)
a = ma.array(Globals.get_mat_a(), mask=GridGlobals.masks)
b = ma.array(Globals.get_mat_b(), mask=GridGlobals.masks)
# Setting the initial guess for the solver
h_0 = h_old
Expand Down Expand Up @@ -436,7 +436,7 @@ def model_args(h_new):
h_old,
list_fd,
r,c,
aa,b,
a,b,
act_rain,
surface.arr.soil_type,
pixel_area,
Expand Down Expand Up @@ -573,7 +573,7 @@ def model_args(h_new):

#calculating sheet runoff
_q_sheet, surface.arr.vol_runoff, surface.arr.vol_rest = ma.filled(
sheet_runoff(delta_t, aa, b, surface.arr.h_sheet), fill_value=0.0
sheet_runoff(delta_t, a, b, surface.arr.h_sheet), fill_value=0.0
)

# Saving the inflows
Expand Down
25 changes: 11 additions & 14 deletions utils/convert-saved-data.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,17 @@ def main(filename):
'delta_t': indata[13], 'mat_pi': indata[14],
'mat_ppl': indata[15], 'surface_retention': indata[16],
'mat_inf_index': indata[17], 'mat_hcrit': indata[18],
'mat_aa': indata[19], 'mat_b': indata[20],
'mat_reten': indata[21], 'mat_fd': indata[22],
'mat_dmt': indata[23], 'mat_effect_cont': indata[24],
'mat_slope': indata[25], 'mat_nan': indata[26],
'mat_a': indata[27], 'mat_n': indata[28],
'outdir': indata[29], 'pixel_area': indata[30],
'points': indata[31], 'poradi': indata[32],
'end_time': indata[33], 'spix': indata[34],
'state_cell': indata[35], 'temp': indata[36],
'type_of_computing': indata[37], 'vpix': indata[38],
'mfda': indata[39], 'sr': indata[40], 'itera': indata[41],
'toky': indata[42], 'cell_stream': indata[43],
'mat_tok_reach': indata[44], 'STREAM_RATIO': indata[45],
'toky_loc': indata[46]
'mat_b': indata[19], 'mat_reten': indata[20], 'mat_fd': indata[21],
'mat_dmt': indata[22], 'mat_effect_cont': indata[23],
'mat_slope': indata[24], 'mat_nan': indata[25], 'mat_a': indata[26],
'mat_n': indata[27], 'outdir': indata[28], 'pixel_area': indata[29],
'points': indata[30], 'poradi': indata[31], 'end_time': indata[32],
'spix': indata[33], 'state_cell': indata[34], 'temp': indata[35],
'type_of_computing': indata[36], 'vpix': indata[37],
'mfda': indata[38], 'sr': indata[39], 'itera': indata[40],
'toky': indata[41], 'cell_stream': indata[42],
'mat_tok_reach': indata[43], 'STREAM_RATIO': indata[44],
'toky_loc': indata[45]
}

BaseProvider.save_data(data, filename)
Expand Down

0 comments on commit cbbdb40

Please sign in to comment.