Skip to content

Commit

Permalink
make sure also -180 - 180 works always
Browse files Browse the repository at this point in the history
  • Loading branch information
simone-silvestri authored Jan 31, 2025
1 parent 9d76a46 commit 82e591e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Fields/interpolate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ end
end

@inline convert_to_0_360(x) = ((x % 360) + 360) % 360
@inline convert_to_minus_180_180(x) = ifelse(x > 180, x - 360, x)
@inline function convert_to_minus_180_180(x) =
x = convert_to_0_360(x)
return ifelse(x > 180, x - 360, x)
end

# When interpolating longitude values, we convert all longitudes to the 0-360 range
# if the parent grid starts with a positive number (λ₀ > 0), and to a -180-180 range
Expand Down

0 comments on commit 82e591e

Please sign in to comment.