Skip to content

Eloisa's block-averaged topography and some minor fixes#25

Merged
domingom merged 6 commits intodomingom:feature/icbcs_fe2fefrom
raluy:feature/icbcs_fe2fe
Apr 15, 2026
Merged

Eloisa's block-averaged topography and some minor fixes#25
domingom merged 6 commits intodomingom:feature/icbcs_fe2fefrom
raluy:feature/icbcs_fe2fe

Conversation

@raluy
Copy link
Copy Markdown

@raluy raluy commented Apr 15, 2026

This PR introduces a new option for block-averaged topography and fixes some small issues related to interpolation in SimGrid.py.

Main changes

1. Fix for interpolation domain when interp_flag = 1

The computation of x_e and y_e has been corrected for non-integer resolution ratios (d_xi/dx_inter). Previously, the selected source subdomain could be too small when interpolation was used, leading to insufficient spatial coverage and edge artifacts in the interpolated fields.

2. Fix in building mask interpolation

When interp_flag == 1, the interpolator was using an undefined variable (data_bmask). This has been corrected to use the appropriate source field (bdg_heights).

3. New option: block-averaged topography

This new option has been added via simgrid.json ("topo_average_opt": 1, with "topo_average_opt": 0 by default). When enabled, topography is computed using an area-weighted block average instead of decimation or interpolation. This helps mitigate potential aliasing in terrain data. For interp_flag == 0, uses block_reduce with mean. For interp_flag == 1, uses the function block_average_topo (introduced in couplingUtils.py) based on cell overlap.

Testing

The changes have been tested with the four possible combinations:

  • Integer and non-integer resolution ratios (interp_flag = 0 and interp_flag = 1).
  • Both interpolation and averaging options (topo_average_opt = 0 and topo_average_opt = 1).

if (topo_average_opt==0):
data_topo0 = topo[y_s:y_e:npy_inc,x_s:x_e:npx_inc]
else:
data_topo0 = block_reduce(topo[y_s:y_e,x_s:x_e], block_size=(int(d_eta/dy_inter),int(d_xi/dx_inter)), func=np.mean)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change 'func=np.mean' by 'func=np.median'

@domingom domingom merged commit ee9fd2f into domingom:feature/icbcs_fe2fe Apr 15, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants