Add warning for remapping with wrong domain
- Dominant language
- Julia
- Stars
- 117
- Forks
- 19
- Avg merge
- 3d 4h
- Merged PRs (30d)
- 41
Description
When using Remapping.interpolate_array and incorrect arguments are given for the domain (like 300,000 m instead of 1,000 m), instead of producing a warning or error, Remapping.interpolate_array generates data with unphysical values.
The solution would be for interpolate_array to produce some type of error or warning when the dimensions given in the arguments to the function do not match the dimensions of the data that is also being passed into the function
Code that demonstrates the problem:
```
using LinearAlgebra
import ClimaCore
using ClimaCore:
Fields,
level,
Geometry,
Remapping,
Operators,
InputOutput
import ClimaCore.Utilities: half
using ClimaCorePlots, Plots
# BOMEX example was run with t_end = 600secs and dt_save_to_disk = 100secs
file = "/central/scratch/llubecke_scratch/bomex_examples/bomex_600sec/day0.200.hdf5"
reader = InputOutput.HDF5Reader(file)
diagnostic = InputOutput.read_field(reader, "diagnostics")
Y = InputOutput.read_field(reader, "Y")
FT = eltype(Y)
# The data from the BOMEX examples has dimensions x_max = 10,000 m, y_max = 10,000 m, z_max = 3,000 m
# But the dimensions given to the interpolate_array function are x_max = 300,000 m, y_max = 300,000 m, z_max = 30,000 m
xpts = range(Geometry.XPoint(FT(0.0)), Geometry.XPoint(FT(300000.0)), length = 21)
ypts = range(Geometry.YPoint(FT(0.0)), Geometry.YPoint(FT(300000.0)), length = 21)
zpts = range(Geometry.ZPoint(FT(0.0)), Geometry.ZPoint(FT(30000.0)), length = 21)
x_correct = range(Geometry.XPoint(minimum(Fields.coordinate_field(Y.c).x)), Geometry.XPoint(maximum(Fields.coordinate_field(Y.c).x)), length = 21)
y_correct = range(Geometry.YPoint(minimum(Fields.coordinate_field(Y.c).y)), Geometry.YPoint(maximum(Fields.coordinate_field(Y.c).y)), length = 21)
z_correct = range(Geometry.ZPoint(minimum(Fields.coordinate_field(Y.c).z)), Geometry.ZPoint(maximum(Fields.coordinate_field(Y.c).z)), length = 21)
interp_tmp_wrongdim = Remapping.interpolate_array(diagnostic.w_velocity.components.data.:1, xpts, ypts, zpts)
interp_tmp_correctdim = Remapping.interpolate_array(diagnostic.w_velocity.components.data.:1, x_correct, y_correct, z_correct)
display("Raw w_velocity extrema: ")
display(extrema(diagnostic.w_velocity.components.data.:1))
display("Wrong dim Remap w_velocity extrema: ")
display(extrema(interp_tmp_wrongdim))
display("Correct dim Remap w_velocity extrema: ")
display(extrema(interp_tmp_correctdim))
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start at the Remapping.interpolate_array entry point and reproduce the issue using the provided BOMEX example, comparing the wrong-dimension and correct-dimension calls. Determine how the supplied point ranges relate to the data dimensions, then verify that mismatched dimensions produce a warning or error rather than unphysical output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- backend-api-design
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100