Skip to content

Allow longitudes "bounding boxes" of 360 degrees #353

Open
simone-silvestri wants to merge 4 commits into
mainfrom
ss/bounding-box-error
Open

Allow longitudes "bounding boxes" of 360 degrees #353
simone-silvestri wants to merge 4 commits into
mainfrom
ss/bounding-box-error

Conversation

@simone-silvestri

Copy link
Copy Markdown
Member

On main, if we use bbox = BoundingBox(longitude = (0, 360)) the native_grid construction will fail with

ERROR: ArgumentError: Longitudinal extent cannot be greater than 360 degrees.
Stacktrace:
 [1] validate_lat_lon_grid_args(topology::Tuple{…}, size::Tuple{…}, halo::Tuple{…}, FT::Type{…}, latitude::Tuple{…}, longitude::Tuple{…}, z::Vector{…}, precompute_metrics::Bool)
   @ Oceananigans.Grids ~/.julia/packages/Oceananigans/eN7TM/src/Grids/latitude_longitude_grid.jl:295
 [2] LatitudeLongitudeGrid(architecture::CPU, FT::DataType; size::Tuple{…}, longitude::Tuple{…}, latitude::Tuple{…}, z::Vector{…}, radius::Float64, topology::Tuple{…}, precompute_metrics::Bool, halo::Tuple{…})
   @ Oceananigans.Grids ~/.julia/packages/Oceananigans/eN7TM/src/Grids/latitude_longitude_grid.jl:208
 [3] construct_native_grid(metadata::Metadata{…}, bbox::BoundingBox{…}, arch::CPU; halo::Tuple{…})
   @ NumericalEarth.DataWrangling ~/development/NumericalEarth.jl/src/DataWrangling/metadata_field.jl:0
 [4] construct_native_grid
   @ ~/development/NumericalEarth.jl/src/DataWrangling/metadata_field.jl:114 [inlined]
 [5] native_grid
   @ ~/development/NumericalEarth.jl/src/DataWrangling/metadata_field.jl:93 [inlined]
 [6] FieldTimeSeries(metadata::Metadata{…}, arch::CPU; kw::@Kwargs{})
   @ NumericalEarth.DataWrangling ~/development/NumericalEarth.jl/src/DataWrangling/metadata_field_time_series.jl:34
 [7] top-level scope
   @ REPL[12]:1
Some type information was truncated. Use `show(err)` to see complete types.

In theory, a longitude restriction of longitude = (0, 360) should be equal to passing longitude = nothing aka taking the whole grid.

This PR implements this fix

@codecov

codecov Bot commented Jun 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant