Skip to content

Commit

Permalink
fix interpolation errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Datseris committed May 6, 2024
1 parent b703161 commit 754e13d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ GeoMakie = "db073c08-6b98-4ee5-b6a4-5efafb3259c6"
ClimateBaseVisualizations = "GeoMakie"

[compat]
DimensionalData = "0.24, 0.25, 0.26, 0.27"
DimensionalData = "0.27"
GeoMakie = "0.6"
Interpolations = "0.13.2, 0.14, 0.15"
NCDatasets = "0.11, 0.12"
Expand Down
6 changes: 0 additions & 6 deletions src/core/coredefs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,6 @@ DimensionalData.rebuild(
data=gnv(A), dims=dims(A), refdims=refdims(A), name=name(A), metadata=metadata(A)
) = ClimArray(data, format(dims, data), refdims, name, metadata)


# The following basic methods allow indexing with tuples, (Time(5), Lon(3))
Base.getindex(A::ClimArray, i::Tuple) = A[i...]
Base.setindex!(A::ClimArray, x, i::Tuple) = setindex!(A, x, i...)
Base.view(A::ClimArray, i::Tuple) = view(A, i...)

# Convenience
Base.ones(A::AbDimArray) = basetypeof(A)(ones(eltype(A), size(A)), dims(A))
Base.zeros(A::AbDimArray) = basetypeof(A)(zeros(eltype(A), size(A)), dims(A))
14 changes: 7 additions & 7 deletions src/interpolations/height_interpolation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,16 @@ function interpolation2pressure(A::ClimArray, pressure::ClimArray, pressure_leve
# construct output Array:
pre = Pre(pressure_levels; metadata = Dict())
dims_no_height = otherdims(A, vertical_dim)
out_dims = (dims_no_height...,pre)
out_dims = (dims_no_height..., pre)
dimension_lengths = length.(out_dims)

B = ClimArray(
zeros(eltype(A), Tuple(dimension_lengths)), out_dims;
name = A.name, attrib = A.attrib
)
for i in otheridxs(A, vertical_dim)
itp = LinearInterpolation(pressure[i],A[i],extrapolation_bc=extrapolation_bc)
B[i] = itp(pressure_levels)
itp = LinearInterpolation(pressure[i], A[i...]; extrapolation_bc)
B[i...] = itp(pressure_levels)
end
return B
end
Expand Down Expand Up @@ -105,8 +105,8 @@ function interpolate_height2pressure(A::ClimArray,pressure_levels::Vector; extra
int_array = ClimArray(zeros(eltype(A), Tuple(dimension_lengths)), out_dims; name = A.name, attrib = A.attrib)

for i in otheridxs(A, Hei())
itp = LinearInterpolation(pressure,A[i],extrapolation_bc=extrapolation_bc)
int_array[i] = itp(pressure_levels)
itp = LinearInterpolation(pressure, A[i...]; extrapolation_bc)
int_array[i...] = itp(pressure_levels)
end
return int_array
end
Expand Down Expand Up @@ -136,8 +136,8 @@ function interpolate_pressure2height(A::ClimArray,heights::Vector; extrapolation

for i in otheridxs(A, Pre())

itp = LinearInterpolation(height,A[i],extrapolation_bc=extrapolation_bc)
int_array[i] = itp(heights)
itp = LinearInterpolation(height,A[i...]; extrapolation_bc)
int_array[i...] = itp(heights)

end
return int_array
Expand Down

0 comments on commit 754e13d

Please sign in to comment.