Skip to content
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

Mask-aware interpolation needs in ClimaLand.jl #987

Open
juliasloan25 opened this issue Jan 17, 2025 · 0 comments
Open

Mask-aware interpolation needs in ClimaLand.jl #987

juliasloan25 opened this issue Jan 17, 2025 · 0 comments
Labels
enhancement New feature or request

Comments

@juliasloan25
Copy link
Member

It's becoming increasingly apparent that mask-aware interpolations will be helpful to land model development in multiple ways, including the following.

Related to #488, but doesn't solve that issue

Interpolating parameters/inputs to model grid

Parameter values are not guaranteed to be physical over the ocean, and may even be NaN. We need to make sure we don't include those values when interpolating parameters/inputs to our model grid.

Using parameter/input maps with different resolutions

Similar to the previous point - Different resolutions will lead to mismatch at the coastlines. We need a general solution that allows us to handle input maps with a variety of land/ocean masks.

Plotting

Right now, our global plots use regular interpolation everywhere, even at the coastlines. This produces chunks of NaN along all coasts, which inhibits our ability to visually inspect our outputs and determine regions of stability, and also lowers the quality of our output plots. See this build for examples.

Proposed solution

We want to have a function interpolate with an interface like this:

interpolate(target_x::FT, target_y::FT, data::Arr{Nx, Ny}, source_xs::Nx, source_ys::Ny, mask::Array{Nx', Ny'}, mask_xs::FT{Nx'}, mask_ys::FT{Ny'})

The first 2 argument specify a point P on our simulation grid that we want to interpolate to.
The next 3 arguments provide information about the data to be regridded (e.g. a parameter map), and its grid
The next 3 arguments provide information about the land/ocean mask to be used in the interpolation, and its grid

Algorithm outline

  • For each of the 4 closest source data points to P, determine if ocean or land
    • Find 4 closest mask points, check if they're ocean or land
    • If >= 2 are land, label source data point as land; otherwise ocean
  • If all 4 points land -> bilinear interpolation
  • If 3 points land -> ?
  • If 2 points land -> linear interpolation between these two points (simplification, loses second dimension)
  • If 1 point land -> use this value

Alternative solution

Temporarily enlarge the land areas of the mask, use this larger mask to interpolate inputs/parameters to the model grid. Then, use the normal mask again to only select input values within the real land.

  • Q: what if input values are 0 over ocean and this just becomes enlarged land area? Not sure I understand this approach
@juliasloan25 juliasloan25 added the enhancement New feature or request label Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant