Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_coordinate not defined for LatLong points #1936

Open
Sbozzolo opened this issue Aug 16, 2024 · 0 comments
Open

_coordinate not defined for LatLong points #1936

Sbozzolo opened this issue Aug 16, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@Sbozzolo
Copy link
Member

Sbozzolo commented Aug 16, 2024

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:

    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.

@Sbozzolo Sbozzolo added the bug Something isn't working label Aug 16, 2024
Sbozzolo added a commit to CliMA/ClimaDiagnostics.jl that referenced this issue Aug 16, 2024
This commit makes identifying coordinates for resampling more
coordinate agnostic.

This commit introduces a workaround for
CliMA/ClimaCore.jl#1936

More fundamentally, CliMA/ClimaCore.jl#1936 is
probably a reflection of the fact that boxes with longlat points are not
supported extremely well.
Sbozzolo added a commit to CliMA/ClimaDiagnostics.jl that referenced this issue Sep 8, 2024
This commit makes identifying coordinates for resampling more
coordinate agnostic.

This commit introduces a workaround for
CliMA/ClimaCore.jl#1936

More fundamentally, CliMA/ClimaCore.jl#1936 is
probably a reflection of the fact that boxes with longlat points are not
supported extremely well.

Here, we make the decision to work with LatLong boxes (instead of the
more natural LongLat ones, more natural because Long is the X axis).
LongLat boxes will fail
Sbozzolo added a commit to CliMA/ClimaDiagnostics.jl that referenced this issue Sep 8, 2024
This commit makes identifying coordinates for resampling more
coordinate agnostic.

This commit introduces a workaround for
CliMA/ClimaCore.jl#1936

More fundamentally, CliMA/ClimaCore.jl#1936 is
probably a reflection of the fact that boxes with longlat points are not
supported extremely well.

Here, we make the decision to work with LatLong boxes (instead of the
more natural LongLat ones, more natural because Long is the X axis).
LongLat boxes will fail
Sbozzolo added a commit to CliMA/ClimaDiagnostics.jl that referenced this issue Sep 8, 2024
This commit makes identifying coordinates for resampling more
coordinate agnostic.

This commit introduces a workaround for
CliMA/ClimaCore.jl#1936

More fundamentally, CliMA/ClimaCore.jl#1936 is
probably a reflection of the fact that boxes with longlat points are not
supported extremely well.

Here, we make the decision to work with LatLong boxes (instead of the
more natural LongLat ones, more natural because Long is the X axis).
LongLat boxes will fail
Sbozzolo added a commit to CliMA/ClimaDiagnostics.jl that referenced this issue Sep 8, 2024
This commit makes identifying coordinates for resampling more
coordinate agnostic.

This commit introduces a workaround for
CliMA/ClimaCore.jl#1936

More fundamentally, CliMA/ClimaCore.jl#1936 is
probably a reflection of the fact that boxes with longlat points are not
supported extremely well.

Here, we make the decision to work with LatLong boxes (instead of the
more natural LongLat ones, more natural because Long is the X axis).
LongLat boxes will fail
Sbozzolo added a commit to CliMA/ClimaDiagnostics.jl that referenced this issue Sep 8, 2024
This commit makes identifying coordinates for resampling more
coordinate agnostic.

This commit introduces a workaround for
CliMA/ClimaCore.jl#1936

More fundamentally, CliMA/ClimaCore.jl#1936 is
probably a reflection of the fact that boxes with longlat points are not
supported extremely well.

Here, we make the decision to work with LatLong boxes (instead of the
more natural LongLat ones, more natural because Long is the X axis).
LongLat boxes will fail
Sbozzolo added a commit to CliMA/ClimaDiagnostics.jl that referenced this issue Sep 8, 2024
This commit makes identifying coordinates for resampling more
coordinate agnostic.

This commit introduces a workaround for
CliMA/ClimaCore.jl#1936

More fundamentally, CliMA/ClimaCore.jl#1936 is
probably a reflection of the fact that boxes with longlat points are not
supported extremely well.

Here, we make the decision to work with LatLong boxes (instead of the
more natural LongLat ones, more natural because Long is the X axis).
LongLat boxes will fail
Sbozzolo added a commit to CliMA/ClimaDiagnostics.jl that referenced this issue Sep 8, 2024
This commit makes identifying coordinates for resampling more
coordinate agnostic.

This commit introduces a workaround for
CliMA/ClimaCore.jl#1936

More fundamentally, CliMA/ClimaCore.jl#1936 is
probably a reflection of the fact that boxes with longlat points are not
supported extremely well.

Here, we make the decision to work with LatLong boxes (instead of the
more natural LongLat ones, more natural because Long is the X axis).
LongLat boxes will fail
Sbozzolo added a commit to CliMA/ClimaDiagnostics.jl that referenced this issue Sep 8, 2024
This commit makes identifying coordinates for resampling more
coordinate agnostic.

This commit introduces a workaround for
CliMA/ClimaCore.jl#1936

More fundamentally, CliMA/ClimaCore.jl#1936 is
probably a reflection of the fact that boxes with longlat points are not
supported extremely well.

Here, we make the decision to work with LatLong boxes (instead of the
more natural LongLat ones, more natural because Long is the X axis).
LongLat boxes will fail
Sbozzolo added a commit to CliMA/ClimaDiagnostics.jl that referenced this issue Sep 8, 2024
This commit makes identifying coordinates for resampling more
coordinate agnostic.

This commit introduces a workaround for
CliMA/ClimaCore.jl#1936

More fundamentally, CliMA/ClimaCore.jl#1936 is
probably a reflection of the fact that boxes with longlat points are not
supported extremely well.

Here, we make the decision to work with LatLong boxes (instead of the
more natural LongLat ones, more natural because Long is the X axis).
LongLat boxes will fail
Sbozzolo added a commit to CliMA/ClimaDiagnostics.jl that referenced this issue Sep 9, 2024
This commit makes identifying coordinates for resampling more
coordinate agnostic.

This commit introduces a workaround for
CliMA/ClimaCore.jl#1936

More fundamentally, CliMA/ClimaCore.jl#1936 is
probably a reflection of the fact that boxes with longlat points are not
supported extremely well.

Here, we make the decision to work with LatLong boxes (instead of the
more natural LongLat ones, more natural because Long is the X axis).
LongLat boxes will fail
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant