CliMA / CliMA/ClimaCore.jl

_coordinate not defined for `LatLong` points

Open
#1,936 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Julia
Stars
117
Forks
19
Avg merge
3d 4h
Merged PRs (30d)
41

Description

This leads to problems with Remapper.

```
MethodError: no method matching _coordinate(::ClimaCore.Geometry.LatLongPoint{Float64}, ::Val{1})

Closest candidates are:
_coordinate(::ClimaCore.Geometry.XZPoint, ::Val{1})
@ ClimaCore ~/.julia/packages/ClimaCore/ANgUC/src/Geometry/coordinates.jl:171
_coordinate(::ClimaCore.Geometry.YZPoint, ::Val{1})
@ ClimaCore ~/.julia/packages/ClimaCore/ANgUC/src/Geometry/coordinates.jl:176
_coordinate(::ClimaCore.Geometry.Abstract1DPoint, ::Val{1})
@ ClimaCore ~/.julia/packages/ClimaCore/ANgUC/src/Geometry/coordinates.jl:162
...

Stacktrace:
[1] coordinate(pt::ClimaCore.Geometry.LatLongPoint{Float64}, ax::Int64)
@ ClimaCore.Geometry ~/.julia/packages/ClimaCore/ANgUC/src/Geometry/coordinates.jl:191
[2] containing_element(mesh::ClimaCore.Meshes.RectilinearMesh{ClimaCore.Meshes.IntervalMesh{ClimaCore.Domains.IntervalDomain{ClimaCore.Geometry.LongPoint{Float64}, Tuple{Symbol, Symbol}}, LinRange{ClimaCore.Geometry.LongPoint{Float64}, Int64}}, ClimaCore.Meshes.IntervalMesh{ClimaCore.Domains.IntervalDomain{ClimaCore.Geometry.LatPoint{Float64}, Tuple{Symbol, Symbol}}, LinRange{ClimaCore.Geometry.LatPoint{Float64}, Int64}}}, coord::ClimaCore.Geometry.LatLongPoint{Float64})
```

I found that I had to define them like this:
```julia
ClimaCore.Geometry._coordinate(
pt::ClimaCore.Geometry.LatLongPoint,
::Val{1},
) = ClimaCore.Geometry.LongPoint(pt.long)
ClimaCore.Geometry._coordinate(
pt::ClimaCore.Geometry.LatLongPoint,
::Val{2},
) = ClimaCore.Geometry.LatPoint(pt.lat)
```
That is, flipping the value with respect to the order implied by the name. If I have them with the same order, the error is:
```
promotion of types ClimaCore.Geometry.LatPoint{Float64} and ClimaCore.Geometry.LongPoint{Float64} failed to change any arguments
Stacktrace:
[1] error(::String, ::String, ::String)
@ Base ./error.jl:44
[2] sametype_error(input::Tuple{ClimaCore.Geometry.LatPoint{Float64}, ClimaCore.Geometry.LongPoint{Float64}})
@ Base ./promotion.jl:417
[3] not_sametype(x::Tuple{ClimaCore.Geometry.LatPoint{Float64}, ClimaCore.Geometry.LongPoint{Float64}}, y::Tuple{ClimaCore.Geometry.LatPoint{Float64}, ClimaCore.Geometry.LongPoint{Float64}})
@ Base ./promotion.jl:411
[4] promote
@ ./promotion.jl:394 [inlined]
[5] isless(x::ClimaCore.Geometry.LatPoint{Float64}, y::ClimaCore.Geometry.LongPoint{Float64})
@ ClimaCore.Geometry ~/.julia/packages/ClimaCore/ANgUC/src/Geometry/coordinates.jl:225
[6] lt(o::Base.Order.ForwardOrdering, a::ClimaCore.Geometry.LatPoint{Float64}, b::ClimaCore.Geometry.LongPoint{Float64})
@ Base.Order ./ordering.jl:117
[7] searchsortedlast
@ ./sort.jl:196 [inlined]
[8] searchsortedlast
@ ./sort.jl:290 [inlined]
[9] searchsortedlast
@ ./sort.jl:292 [inlined]
[10] containing_element
@ ~/.julia/packages/ClimaCore/ANgUC/src/Meshes/interval.jl:66 [inlined]
[11] containing_element(mesh::ClimaCore.Meshes.RectilinearMesh{ClimaCore.Meshes.IntervalMesh{ClimaCore.Domains.IntervalDomain{ClimaCore.Geometry.LongPoint{Float64}, Tuple{Symbol, Symbol}}, LinRange{ClimaCore.Geometry.LongPoint{Float64}, Int64}}, ClimaCore.Meshes.IntervalMesh{ClimaCore.Domains.IntervalDomain{ClimaCore.Geometry.LatPoint{Float64}, Tuple{Symbol, Symbol}}, LinRange{ClimaCore.Geometry.LatPoint{Float64}, Int64}}}, coord::ClimaCore.Geometry.LatLongPoint{Float64})
@ ClimaCore.Meshes ~/.julia/packages/ClimaCore/ANgUC/src/Meshes/rectangle.jl:131
[12] containing_pid
@ ~/.julia/packages/ClimaCore/ANgUC/src/Remapping/distributed_remapping.jl:100 [inlined]
[13] #20
@ ~/.julia/packages/ClimaCore/ANgUC/src/Remapping/distributed_remapping.jl:115 [inlined]
```

This is due to the fact that we typically put longitude as first dimension.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in Geometry/coordinates.jl at the _coordinate and coordinate methods, then trace their callers in Meshes/rectangle.jl and Remapping/distributed_remapping.jl. Confirm the expected longitude-first mapping for LatLongPoint and verify that containing_element and distributed remapping no longer raise the reported method or promotion errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.