-
Notifications
You must be signed in to change notification settings - Fork 30
Long term dune growth (by Selwyn) #286
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
b617b80
1f469f7
208d045
5db83bb
eb5d66b
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 | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -32,6 +32,7 @@ | |||||||||||||||||||||||||||
| import aeolis.gridparams | ||||||||||||||||||||||||||||
| from matplotlib import pyplot as plt | ||||||||||||||||||||||||||||
| from numba import njit | ||||||||||||||||||||||||||||
| import math | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| # package modules | ||||||||||||||||||||||||||||
| from aeolis.utils import * | ||||||||||||||||||||||||||||
|
|
@@ -125,7 +126,7 @@ def initialize(s, p): | |||||||||||||||||||||||||||
| # initialize threshold | ||||||||||||||||||||||||||||
| if p['threshold_file'] is not None: | ||||||||||||||||||||||||||||
| s['uth'] = p['threshold_file'][:,:,np.newaxis].repeat(nf, axis=-1) | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| return s | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
|
|
@@ -197,14 +198,40 @@ def mixtoplayer(s, p): | |||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| s['mass'][ix] = mass[ix] | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| return s | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| def wet_bed_reset(s, p): | ||||||||||||||||||||||||||||
| ''' Reset wet bed to initial bed level if the total water level is above the bed level. | ||||||||||||||||||||||||||||
| # def wet_bed_reset(s, p): **** Now part of def sediment_supply **** | ||||||||||||||||||||||||||||
| # ''' Reset wet bed to initial bed level if the total water level is above the bed level. | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| # Parameters | ||||||||||||||||||||||||||||
| # ---------- | ||||||||||||||||||||||||||||
| # s : dict | ||||||||||||||||||||||||||||
| # Spatial grids | ||||||||||||||||||||||||||||
| # p : dict | ||||||||||||||||||||||||||||
| # Model configuration parameters | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| # Returns | ||||||||||||||||||||||||||||
| # ------- | ||||||||||||||||||||||||||||
| # dict | ||||||||||||||||||||||||||||
| # Spatial grids | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| # ''' | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| # if p['process_wet_bed_reset']: | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| # Tbedreset = p['dt_opt'] / p['Tbedreset'] | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| # ix = s['TWL'] > (s['zb']) | ||||||||||||||||||||||||||||
| # s['zb'][ix] += (s['zb0'][ix] - s['zb'][ix]) * Tbedreset | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| # return s | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| def wet_supply(s, p): | ||||||||||||||||||||||||||||
| ''' Increase elevation of beach topography. | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| Parameters | ||||||||||||||||||||||||||||
| ---------- | ||||||||||||||||||||||||||||
|
|
@@ -219,19 +246,96 @@ def wet_bed_reset(s, p): | |||||||||||||||||||||||||||
| Spatial grids | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ''' | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| if p['process_wet_bed_reset']: | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| Tbedreset = p['dt_opt'] / p['Tbedreset'] | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ix = s['TWL'] > (s['zb']) | ||||||||||||||||||||||||||||
| s['zb'][ix] += (s['zb0'][ix] - s['zb'][ix]) * Tbedreset | ||||||||||||||||||||||||||||
| if p['process_wet_supply'] or p['process_wet_bed_reset']: | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| if p['method_wet_supply'] == 'wet_bed_reset': | ||||||||||||||||||||||||||||
| Tbedreset = p['dt_opt'] / p['Tbedreset'] | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| return s | ||||||||||||||||||||||||||||
| ix = s['TWL'] > (s['zb']) | ||||||||||||||||||||||||||||
| s['zb'][ix] += (s['zb0'][ix] - s['zb'][ix]) * Tbedreset | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| if p['process_wet_supply']: | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| if p['method_wet_supply'] == 'vertical_beach_growth': | ||||||||||||||||||||||||||||
| beach_inc = p['shoreline_change_rate']*math.cos((math.pi/2)-math.atan(p['beach_slope'])) | ||||||||||||||||||||||||||||
| vrate = (beach_inc*(1/365.25/24/3600))*p['dt'] #(m/timestep) | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
| vrate = (beach_inc*(1/365.25/24/3600))*p['dt'] #(m/timestep) | |
| vrate = (beach_inc/(365.25*24*3600))*p['dt'] # (m/timestep) |
Copilot
AI
Feb 23, 2026
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.
Division by multiple time factors appears unnecessarily complex. The expression (beach_inc/(365.25*24*3600))*p['dt'] could be simplified for clarity. Consider computing the conversion factor once and documenting the units more clearly in comments.
Copilot
AI
Feb 23, 2026
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.
Potential issue with accessing xi3[0][0] without first checking if xi3[0] is non-empty. If np.where(beach_z > p['zshoreline']) returns an empty array, accessing xi3[0][0] will raise an IndexError. Add a check to ensure the array is not empty before indexing, or handle the case where no points exceed the shoreline elevation.
| xi3 = np.where(beach_z > p['zshoreline']) | |
| xi3 = np.where(beach_z > p['zshoreline']) | |
| # Guard against empty result: if no points exceed zshoreline, skip this profile | |
| if xi3[0].size == 0: | |
| continue |
Copilot
AI
Feb 23, 2026
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.
Missing input validation for the method_wet_supply parameter. If an invalid method name is provided in the configuration, the function will silently do nothing without any error or warning. Add validation to check if the method is one of the supported values and raise an informative error if not.
Copilot
AI
Feb 23, 2026
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.
The code uses both <= (line 312) and < (line 268, 287) when comparing to p['dune_toe_elevation']. This inconsistency could lead to boundary cells being handled differently in different methods. Verify whether the dune toe elevation should be included or excluded, and use consistent comparison operators across all methods.
| xi = zb_all <= p['dune_toe_elevation'] | |
| xi = zb_all < p['dune_toe_elevation'] |
Copilot
AI
Feb 23, 2026
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.
Same indexing issue as above: accessing xi3[0][0] on line 318 without verifying the array is non-empty could raise an IndexError. This pattern appears in multiple places (lines 292, 318) and should be handled consistently with proper validation.
| xi3 = np.where(beach_z > p['zshoreline']) | |
| xi3 = xi3[0][0] | |
| beach_x = x-x[xi3] | |
| xy1 = ((np.min(x[xi3])),np.min(beach_z[xi3])) | |
| xi3 = np.where(beach_z > p['zshoreline'])[0] | |
| if xi3.size == 0: | |
| # No points satisfy beach_z > zshoreline for this transect; skip update | |
| continue | |
| xi3 = xi3[0] | |
| beach_x = x - x[xi3] | |
| xy1 = ((np.min(x[xi3])), np.min(beach_z[xi3])) |
Copilot
AI
Feb 23, 2026
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.
The variable xy1 is assigned but never used (line 321). Similarly, xy2 appears to be defined for calculating slope but the actual slope calculation on line 324 doesn't use these tuples correctly. The slope calculation uses individual array elements when the tuple structure suggests coordinate pairs were intended. Either remove these unused variables or fix the slope calculation to properly use them.
| xy1 = ((np.min(x[xi3])),np.min(beach_z[xi3])) | |
| xy2 = (np.max(x), np.max(beach_z)) | |
| new_slope = (xy2[1]-xy1[1])/(xy2[0]-(xy1[0])) | |
| # compute slope directly between (x[xi3], beach_z[xi3]) and (max(x), max(beach_z)) | |
| new_slope = (np.max(beach_z) - np.min(beach_z[xi3])) / (np.max(x) - np.min(x[xi3])) |
Copilot
AI
Feb 23, 2026
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.
The variable name b on lines 270, 293, and 325 is not descriptive. This appears to represent a y-intercept or baseline elevation value. Use a more descriptive name like baseline_elevation or y_intercept to improve code readability.
| b = np.min(beach_z[xi3]) + vrate | |
| new_temp_beach = new_slope*(beach_x) + b | |
| baseline_elevation = np.min(beach_z[xi3]) + vrate | |
| new_temp_beach = new_slope*(beach_x) + baseline_elevation |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -174,6 +174,7 @@ | |||||
| 'process_moist' : False, # Enable the process of moist | ||||||
| 'process_mixtoplayer' : False, # Enable the process of mixing | ||||||
| 'process_wet_bed_reset' : False, # Enable the process of bed-reset in the intertidal zone | ||||||
| 'process_wet_supply' : False, # Enable the process of beach sediment supply | ||||||
| 'process_meteo' : False, # Enable the process of meteo | ||||||
| 'process_salt' : False, # Enable the process of salt | ||||||
| 'process_humidity' : False, # Enable the process of humidity | ||||||
|
|
@@ -340,6 +341,10 @@ | |||||
| 'rhoveg_max' : 0.5, #maximum vegetation density, only used in duran and moore 14 formulation | ||||||
| 't_veg' : 3, #time scale of vegetation growth (days), only used in duran and moore 14 formulation | ||||||
| 'v_gam' : 1, # only used in duran and moore 14 formulation | ||||||
| 'method_wet_supply' :'wet_bed_reset', # Name of method to comput sediment supply (wet_bed_reset, vertical_beach_growth, constant_SCR_constant_tanB, constant_SCR_variable_tanB) | ||||||
|
||||||
| 'method_wet_supply' :'wet_bed_reset', # Name of method to comput sediment supply (wet_bed_reset, vertical_beach_growth, constant_SCR_constant_tanB, constant_SCR_variable_tanB) | |
| 'method_sed_supply' :'wet_bed_reset', # Name of method to comput sediment supply (wet_bed_reset, vertical_beach_growth, constant_SCR_constant_tanB, constant_SCR_variable_tanB) |
Copilot
AI
Feb 23, 2026
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.
The closing brace is missing for the dictionary in constants.py. Line 347 has a closing brace in a comment (# ... }) which suggests it was accidentally commented out. This will cause a syntax error. Uncomment or add the proper closing brace.
| 'xshoreline' : 0, # Cross-shore position where beach profile ends and shoreline change rate is applied } | |
| 'xshoreline' : 0, # Cross-shore position where beach profile ends and shoreline change rate is applied |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -69,7 +69,9 @@ vanWesten2024/parabolic | |||||
| <description> | ||||||
|
|
||||||
|
|
||||||
| longterm_dune_growth - 1D 27-year simulation from Long Beach Penninsula, Washington, USA (LBP) | ||||||
|
||||||
| longterm_dune_growth - 1D 27-year simulation from Long Beach Penninsula, Washington, USA (LBP) | |
| longterm_dune_growth - 1D 27-year simulation from Long Beach Peninsula, Washington, USA (LBP) |
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.
Large block of commented-out code (lines 204-230) should be removed rather than kept in the codebase. If this code needs to be preserved for reference, it belongs in version control history. Keeping extensive commented code reduces readability and can cause confusion about what is actually being used.