-
Notifications
You must be signed in to change notification settings - Fork 29
Dynamic revetment implementation #248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -125,7 +125,16 @@ def initialize(s, p): | |||||||||||||||||||||||||||||
| # initialize threshold | ||||||||||||||||||||||||||||||
| if p['threshold_file'] is not None: | ||||||||||||||||||||||||||||||
| s['uth'] = p['threshold_file'][:,:,np.newaxis].repeat(nf, axis=-1) | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| # initialize sand and cobble layers for composite beaches | ||||||||||||||||||||||||||||||
| s['zsand'][:,:] = p['zsand_file'] | ||||||||||||||||||||||||||||||
| s['dcob'][:,:] = p['dcob_file'] | ||||||||||||||||||||||||||||||
| s['dsandcover'][:,:] = p['dsandcover_file'] | ||||||||||||||||||||||||||||||
| s['doverlap'][:,:] = p['doverlap_file'] | ||||||||||||||||||||||||||||||
| if p['process_bedupdate_comp'] is True and (p['zsand_file'] is None or p['dcob_file'] is None or p['dsandcover_file'] is None or p['doverlap_file'] is None): | ||||||||||||||||||||||||||||||
| logger.log_and_raise('Process bedupdate for composite beaches is turned on but no initial sand and cobble locations are provided. Please' | ||||||||||||||||||||||||||||||
| 'provide a zsand_file, dcob_file, dsandcover_file and doverlap_file', exc=ValueError) | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| return s | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
|
@@ -342,8 +351,12 @@ def update(s, p): | |||||||||||||||||||||||||||||
| # s['dzb'] = dm[:, 0].reshape((ny + 1, nx + 1)) | ||||||||||||||||||||||||||||||
| s['dzb'] = dz.copy() | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| if p['process_bedupdate_comp']: | ||||||||||||||||||||||||||||||
| s = update_composite(s, p) | ||||||||||||||||||||||||||||||
| else: | ||||||||||||||||||||||||||||||
| s['zb'] += dz | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| # redistribute sediment from inactive zone to marine interaction zone | ||||||||||||||||||||||||||||||
| s['zb'] += dz | ||||||||||||||||||||||||||||||
| if p['process_tide']: | ||||||||||||||||||||||||||||||
| s['zs'] += dz #??? | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
|
@@ -535,5 +548,173 @@ def arrange_layers(m,dm,d,nl,ix_ero,ix_dep): | |||||||||||||||||||||||||||||
| m[ix_dep,-1,:] -= dm[ix_dep,:] * d[ix_dep,-1,:] | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| return m | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| def update_composite(s, p): | ||||||||||||||||||||||||||||||
| '''Update bed and sand level and cobble infilling for composite beaches | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| Update XX by YYY | ||||||||||||||||||||||||||||||
| layers. | ||||||||||||||||||||||||||||||
| Initial sand level, cobble thickness, overlap and sandcover are defined | ||||||||||||||||||||||||||||||
| in the model configuration file by ``zsand``, ``dcob``, ``doverlap`` and | ||||||||||||||||||||||||||||||
| ``dsandcover``. The bathymetry is updated if the sand cover increases. | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| Parameters | ||||||||||||||||||||||||||||||
| ---------- | ||||||||||||||||||||||||||||||
| s : dict | ||||||||||||||||||||||||||||||
| Spatial grids | ||||||||||||||||||||||||||||||
| p : dict | ||||||||||||||||||||||||||||||
| Model configuration parameters | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| Returns | ||||||||||||||||||||||||||||||
| ------- | ||||||||||||||||||||||||||||||
| dict | ||||||||||||||||||||||||||||||
| Spatial grids | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| ''' | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| dz = s['dzb'] | ||||||||||||||||||||||||||||||
| por = p['porosity'] # Assumes that cobble porosity is the same as sand porosity | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| # FIND LOCATIONS | ||||||||||||||||||||||||||||||
| # with deposition | ||||||||||||||||||||||||||||||
| ix_depo = dz >0 | ||||||||||||||||||||||||||||||
| # with erosion | ||||||||||||||||||||||||||||||
| ix_ero = dz < 0 | ||||||||||||||||||||||||||||||
| # with 0 bed level change | ||||||||||||||||||||||||||||||
| ix_none = dz == 0. | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| # where no cobble is present, i.e. pure sand | ||||||||||||||||||||||||||||||
| ix_nocob = s['dcob'] == 0. | ||||||||||||||||||||||||||||||
| # where open cobbles are present | ||||||||||||||||||||||||||||||
| ix_cob = s['dcob'] > 0. | ||||||||||||||||||||||||||||||
| # where sand cover is present | ||||||||||||||||||||||||||||||
| ix_sc = s['dsandcover'] > 0. | ||||||||||||||||||||||||||||||
| # where no sand cover is present | ||||||||||||||||||||||||||||||
| ix_nosc = s['dsandcover'] == 0. | ||||||||||||||||||||||||||||||
| # where elevation change is bigger than sand cover, these are locations that can accommodate erosion | ||||||||||||||||||||||||||||||
| ix_sc_accom = dz + s['dsandcover'] >= 0. | ||||||||||||||||||||||||||||||
| # where elevation change is smaller than sand cover, these are locations that cannot accommodate erosion | ||||||||||||||||||||||||||||||
| ix_sc_noaccom = dz + s['dsandcover'] < 0. | ||||||||||||||||||||||||||||||
| # where open cobbles are present at the top | ||||||||||||||||||||||||||||||
| ix_opencob = s['dcob']-s['doverlap'] > 0. | ||||||||||||||||||||||||||||||
| # where elevation change is smaller than pore space in open cobble, these are locations that can accommodate deposition | ||||||||||||||||||||||||||||||
| ix_oc_accom = (s['dcob']-s['doverlap']) - dz/(1-por) >= 0. | ||||||||||||||||||||||||||||||
| # where elevation change is bigger than pore space in open cobble, these are locations that can't accommodate deposition | ||||||||||||||||||||||||||||||
| ix_oc_noaccom = (s['dcob']-s['doverlap']) - dz/(1-por) < 0. | ||||||||||||||||||||||||||||||
| # where cobbles are fully filled with sand, so doverlap == dcob | ||||||||||||||||||||||||||||||
| ix_fullcob = s['dcob']==s['doverlap'] | ||||||||||||||||||||||||||||||
| # where filled cobbles are present at the top, dcob > 0 & doverlap == dcob & dsandcover == 0 | ||||||||||||||||||||||||||||||
| ix_fillcob = (ix_cob & ix_fullcob & ix_nosc) | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| # where no bed level change occurs and cobble is present | ||||||||||||||||||||||||||||||
| ix_step0 = ix_none & ix_cob | ||||||||||||||||||||||||||||||
| # where deposition takes place and sand cover is present | ||||||||||||||||||||||||||||||
| ix_step1 = ix_depo & ix_sc | ||||||||||||||||||||||||||||||
| # where deposition takes place and filled cobble is present | ||||||||||||||||||||||||||||||
| ix_step2 = ix_depo & ix_cob & ix_fillcob | ||||||||||||||||||||||||||||||
| # where deposition takes place and open cobble is present with enough accommodation space | ||||||||||||||||||||||||||||||
| ix_step3 = ix_depo & ix_cob & ix_opencob & ix_oc_accom | ||||||||||||||||||||||||||||||
| # where deposition takes place and open cobble is present without enough accommodation space | ||||||||||||||||||||||||||||||
| ix_step4 = ix_depo & ix_cob & ix_opencob & ix_oc_noaccom | ||||||||||||||||||||||||||||||
| # where erosion takes place and open cobble is present | ||||||||||||||||||||||||||||||
| ix_step5 = ix_ero & ix_cob & ix_opencob | ||||||||||||||||||||||||||||||
| # where erosion takes place and filled cobble is present | ||||||||||||||||||||||||||||||
| ix_step6 = ix_ero & ix_cob & ix_fillcob | ||||||||||||||||||||||||||||||
| # where erosion takes place, sand cover is present and there is enough accommodation space | ||||||||||||||||||||||||||||||
| ix_step7 = ix_ero & ix_sc & ix_sc_accom | ||||||||||||||||||||||||||||||
| # where erosion takes place, sand cover is present and there is not enough accommodation space | ||||||||||||||||||||||||||||||
| ix_step8 = ix_ero & ix_sc & ix_sc_noaccom | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| # Check if all locations are assigned to a single step | ||||||||||||||||||||||||||||||
| ix_steps = np.vstack((ix_nocob[1,:], ix_step0[1,:], ix_step1[1,:], ix_step2[1,:], ix_step3[1,:], ix_step4[1,:], ix_step5[1,:], ix_step6[1,:], ix_step7[1,:], ix_step8[1,:])) | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
| ix_steps = np.vstack((ix_nocob[1,:], ix_step0[1,:], ix_step1[1,:], ix_step2[1,:], ix_step3[1,:], ix_step4[1,:], ix_step5[1,:], ix_step6[1,:], ix_step7[1,:], ix_step8[1,:])) | |
| ix_steps_list = [ | |
| ix_nocob[1,:], | |
| ix_step0[1,:], | |
| ix_step1[1,:], | |
| ix_step2[1,:], | |
| ix_step3[1,:], | |
| ix_step4[1,:], | |
| ix_step5[1,:], | |
| ix_step6[1,:], | |
| ix_step7[1,:], | |
| ix_step8[1,:] | |
| ] | |
| ix_steps = np.vstack(ix_steps_list) |
Copilot
AI
Jul 21, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use proper logging instead of print statements. Consider using logger.debug() or logger.warning() for debugging information.
| print(check) | |
| logger.debug(check) |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -127,7 +127,11 @@ def interpolate(s, p, t): | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| tp = s['Tp'][iy][0] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| wl = s['SWL'][iy][0] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| eta, sigma_s, R = calc_runup_stockdon(hs, tp, p['beach_slope']) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if p['method_runup'] == 'stockdon': | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| eta, sigma_s, R = calc_runup_stockdon(hs, tp, p['beach_slope']) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| elif p['method_runup'] == 'ruggiero': | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| eta, sigma_s, R = calc_runup_ruggiero(hs) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| s['R'][iy][:] = R | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| s['eta'][iy][:] = eta | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| s['sigma_s'][iy][:] = sigma_s | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -156,11 +160,15 @@ def interpolate(s, p, t): | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| s['Tp'] = apply_mask(s['Tp'], s['wave_mask']) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if p['process_runup']: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ny = p['ny'] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if ('Hs' in p['external_vars']): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| eta, sigma_s, R = calc_runup_stockdon(s['Hs'], s['Tp'], p['beach_slope']) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if p['method_runup'] == 'stockdon': | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| eta, sigma_s, R = calc_runup_stockdon(s['Hs'], s['Tp'], p['beach_slope']) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if p['method_runup'] == 'ruggiero': | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| eta, sigma_s, R = calc_runup_ruggiero(s['Hs']) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| s['R'][:] = R | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if hasattr(s['runup_mask'], "__len__"): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -820,6 +828,23 @@ def calc_runup_stockdon(Ho, Tp, beta): | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| return eta, sigma_s, R | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def calc_runup_ruggiero(Ho): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Calculate runup according to /Ruggiero et al 2004. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Calculate runup according to /Ruggiero et al 2004. | |
| Calculate runup according to Ruggiero et al. (2004). | |
| This function calculates the runup for dissipative conditions based on | |
| the significant wave height (Ho). The formula is derived from the work | |
| of Ruggiero et al. (2004). | |
| Parameters | |
| ---------- | |
| Ho : float | |
| Significant wave height (in meters). | |
| Returns | |
| ------- | |
| eta : float | |
| Mean water level (set to 0 for this method). | |
| sigma_s : float | |
| Standard deviation of swash oscillations (set to 0 for this method). | |
| R : float | |
| Total runup height (in meters). | |
| References | |
| ---------- | |
| Ruggiero, P., Komar, P. D., McDougal, W. G., Marra, J. J., & Beach, R. A. (2004). | |
| Wave runup, extreme water levels and the erosion of properties backing beaches. | |
| Journal of Coastal Research, 20(3), 1018-1026. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Placeholder text 'XX by YYY' should be replaced with actual description of what the function updates.