Skip to content

Runoff spreading - #145

Open
anton-seaice wants to merge 10 commits into
mainfrom
142-part3
Open

Runoff spreading#145
anton-seaice wants to merge 10 commits into
mainfrom
142-part3

Conversation

@anton-seaice

@anton-seaice anton-seaice commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

This generates runoff spreading weights as discussed in ACCESS-NRI/access-om3-configs#396

For the 6 large rivers, runoff is spread to nearby ocean cells with exponentially decaying weights.
Everywhere else, runoff if mapped to closest ocean cell only

Contibutes to #142

@anton-seaice anton-seaice self-assigned this Jul 31, 2026
@anton-seaice
anton-seaice marked this pull request as ready for review July 31, 2026 01:58
@anton-seaice

anton-seaice commented Jul 31, 2026

Copy link
Copy Markdown
Contributor Author

Example output in /g/data/tm70/as2285/making_inputs/om3-scripts/mesh_generation/25km_remap_weights.nc

@anton-seaice

Copy link
Copy Markdown
Contributor Author

And data in /g/data/tm70/as2285/payu/om3_rofl_spread/MC_25km_jra_iaf_spread/archive

old_area = area[col]
new_area = area[row]
# Exponential weights
w = np.exp(-dist_N[spread_i] / FOLD)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@anton-seaice I think there is a units issue in the decay calculation here:

w = np.exp(-dist_N[spread_i] / FOLD)

Because the tree uses metric="haversine", dist_N is returned as an angular distance in radians. It is then divided directly by FOLD = 15, with no conversion to kilometres.

I checked this against the generated 25 km weights file as well. The 75 destination cells are roughly 125–345 km away, corresponding to about 0.020–0.054 radians. Using the current calculation gives decay factors of around 0.997–0.999, which matches the almost-flat weights in the file. The weights therefore vary by only about 0.2% and the runoff is being spread nearly uniformly rather than noticeably decaying with distance.

Could we convert the haversine distances to a physical unit before applying the decay, and make the unit of FOLD explicit?

k=SPREAD_N,
return_distance=True,
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could we guard against meshes with fewer than SPREAD_N eligible ocean cells here?

dist_N, i_N = mask_tree_spread.query(
    in_coords_rad,
    k=SPREAD_N,
    return_distance=True,
)

Perhaps use min(SPREAD_N, number_of_target_cells) and carry that effective value through the downstream array allocations and loops.

weights_ds["S"] = xr.DataArray(data=S, dims="n_s")

# Remove zero weights
weights_ds = weights_ds.where(weights_ds["S"] != 0, drop=True)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This line upcasts col and row from integers to float64, because where() temporarily inserts NaN values. The generated weights file confirms both variables are stored as floats.

Since col and row are ESMF indices, could we keep or cast them back to integer after filtering?

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