File tree Expand file tree Collapse file tree 3 files changed +24
-6
lines changed Expand file tree Collapse file tree 3 files changed +24
-6
lines changed Original file line number Diff line number Diff line change @@ -58,6 +58,8 @@ function Regridders.InterpolationsRegridder(
58
58
)
59
59
coordinates = ClimaCore. Fields. coordinate_field (target_space)
60
60
61
+ num_dimensions = length (propertynames (coordinates))
62
+
61
63
if isnothing (extrapolation_bc)
62
64
extrapolation_bc = ()
63
65
if eltype (coordinates) <: ClimaCore.Geometry.LatLongPoint
@@ -69,7 +71,15 @@ function Regridders.InterpolationsRegridder(
69
71
end
70
72
end
71
73
72
- return InterpolationsRegridder (target_space, coordinates, extrapolation_bc)
74
+ num_dimensions == length (extrapolation_bc) || error (
75
+ " Number of boundary conditions does not match the number of dimensions" ,
76
+ )
77
+
78
+ return InterpolationsRegridder (
79
+ target_space,
80
+ coordinates,
81
+ extrapolation_bc
82
+ )
73
83
end
74
84
75
85
"""
Original file line number Diff line number Diff line change @@ -87,13 +87,10 @@ ClimaComms.init(context)
87
87
target_space;
88
88
regridder_type = :InterpolationsRegridder ,
89
89
file_reader_kwargs = (; preprocess_func = (data) -> 0.0 * data),
90
- regridder_kwargs = (;
91
- extrapolation_bc = (Intp. Flat (), Intp. Flat (), Intp. Flat ())
92
- ),
90
+ regridder_kwargs = (; extrapolation_bc = (Intp. Flat (), Intp. Flat ())),
93
91
)
94
92
95
- @test data_handler. regridder. extrapolation_bc ==
96
- (Intp. Flat (), Intp. Flat (), Intp. Flat ())
93
+ @test data_handler. regridder. extrapolation_bc == (Intp. Flat (), Intp. Flat ())
97
94
field = DataHandling. regridded_snapshot (data_handler)
98
95
@test extrema (field) == (0.0 , 0.0 )
99
96
end
Original file line number Diff line number Diff line change 97
97
extrapolation_bc,
98
98
)
99
99
100
+ # Test num_dimensions != length(extrapolation_bc)
101
+ @test_throws ErrorException Regridders. InterpolationsRegridder (
102
+ hv_center_space;
103
+ extrapolation_bc = (
104
+ Interpolations. Periodic (),
105
+ Interpolations. Flat (),
106
+ Interpolations. Flat (),
107
+ Interpolations. Flat (),
108
+ ),
109
+ )
110
+
100
111
regridded_lat = Regridders. regrid (reg_hv, data_lat3D, dimensions3D)
101
112
regridded_lon = Regridders. regrid (reg_hv, data_lon3D, dimensions3D)
102
113
regridded_z = Regridders. regrid (reg_hv, data_z3D, dimensions3D)
You can’t perform that action at this time.
0 commit comments