Skip to content

Commit

Permalink
Fixup vertical grid offset
Browse files Browse the repository at this point in the history
  • Loading branch information
cbegeman committed Aug 25, 2023
1 parent c4b494f commit 4b9d8df
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions compass/ocean/vertical/grid_1d/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,21 @@ def generate_1d_grid(config):
A 1D array of positive depths for layer interfaces in meters
"""
section = config['vertical_grid']
offset = 0
if config.has_option('vertical_grid', 'inactive_top_cells'):
offset = section.getint('inactive_top_cells')
print(f'offset = {offset}')

grid_type = section.get('grid_type')
if grid_type == 'uniform':
vert_levels = section.getint('vert_levels')
interfaces = _generate_uniform(vert_levels)
interfaces = _generate_uniform(vert_levels - offset)
elif grid_type == 'tanh_dz':
vert_levels = section.getint('vert_levels')
min_layer_thickness = section.getfloat('min_layer_thickness')
max_layer_thickness = section.getfloat('max_layer_thickness')
bottom_depth = section.getfloat('bottom_depth')
interfaces = create_tanh_dz_grid(vert_levels,
interfaces = create_tanh_dz_grid(vert_levels - offset,
bottom_depth,
min_layer_thickness,
max_layer_thickness)
Expand Down Expand Up @@ -66,6 +71,9 @@ def generate_1d_grid(config):
# renormalize to the requested range
interfaces = (bottom_depth / interfaces[-1]) * interfaces

if config.has_option('vertical_grid', 'inactive_top_cells'):
interfaces = np.append(np.zeros((offset)), interfaces)

return interfaces


Expand Down

0 comments on commit 4b9d8df

Please sign in to comment.