Skip to content

Add make_function method to Topography and DTopography objects#686

Merged
rjleveque merged 4 commits intoclawpack:masterfrom
rjleveque:topo_dtopo_functions
Jan 20, 2026
Merged

Add make_function method to Topography and DTopography objects#686
rjleveque merged 4 commits intoclawpack:masterfrom
rjleveque:topo_dtopo_functions

Conversation

@rjleveque
Copy link
Member

Make it easier to read in a topo or dtopo file and define an interpolating function that can be used e.g. to plot a transect of the topo or dtopo.

WIP... example to appear.

@mandli
Copy link
Member

mandli commented Jan 13, 2026

Looks good to me, and a good idea.

I wonder if it might be better just to pass a key-words dict to the RegularGridInterpolator since all the arguments to the function go to it. That way, if there are any arguments to that function that we may want to later define, they just go straight through.

@rjleveque
Copy link
Member Author

Good idea @mandli. Does this look like the best way to do it with the desired default values set for the parameters if not specified by the user?

@mandli
Copy link
Member

mandli commented Jan 14, 2026

The defaults for RegularGridInterpolator are method=linear (same), but the other 2 are not. It is worth thinking about if the other two should deviate from the default for RegularGridInterpolator or not. For instance, is it good to it set the fill_value=0 rather than file_value=nan? The parameter for bounds_error I don't know if it's as clear.

@rjleveque
Copy link
Member Author

For the topotools version I set the default to fill_value to nan, but for dtopo, my assumption was that if the user evaluates outside the region of the dtopo file then the deformation should presumably be zero (or else they need a larger dtopo extent). Maybe it would be better to return nan so they realize this, but when running GeoClaw, the deformation used will be zero where dtopo is not defined.

One application of this code is to interpolate the dtopo file to onshore locations where we want to compute the coseismic subsidence or uplift, e.g. at gauge locations or fgmax points. In this case some gauges or points may lie outside the dtopo region and 0 is the right thing to return at these points, and we don't want to throw a bounds_error. Not so clear what default behavior is best for topo.

But I should at least document this better, so thanks for the comments!

@mandli
Copy link
Member

mandli commented Jan 16, 2026

That makes sense for dtopo for sure. I think I agree that having the default be 0 for dtopo is a good idea, and just document the discrepancy.

I think when the default value is not clear that nan is a better flag for needing more logic.

@rjleveque
Copy link
Member Author

I put a simple topo example here:
http://depts.washington.edu/clawpack/samples/topo_func_demo.html
to be added to the apps repository eventually along with a dtopo example.

This seems to work fine, so I'm going to merge it.

@rjleveque rjleveque merged commit ed42dd1 into clawpack:master Jan 20, 2026
1 check failed
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