Add the ability to use NetCDF#125
Conversation
There was a problem hiding this comment.
Pull request overview
Adds optional NetCDF (NCDatasets-backed) output support to ClimaSeaIce by wiring in a Julia package extension, plus coverage in CI via a new NetCDF-focused test group.
Changes:
- Add
ClimaSeaIceNCDatasetsExtextension to provide NetCDF output attributes forSeaIceModel. - Add a
NetCDFWriterintegration test and hook it intoruntests.jlunder a newTEST_GROUP. - Register
NCDatasetsas a weak dependency/extension trigger, bump package version, and add a dedicated CI job for the new test group.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
ext/ClimaSeaIceNCDatasetsExt.jl |
New extension module defining default NetCDF output attributes for sea-ice fields (and velocities). |
test/test_netcdf_writer.jl |
New test that runs a short simulation and validates NetCDF output contents. |
test/runtests.jl |
Adds a netcdf test group include. |
Project.toml |
Bumps version; adds NCDatasets weakdep/extension and adds it to test target. |
.github/workflows/ci.yml |
Adds a CI job to run only the netcdf test group. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| function OCNE.default_output_attributes(model::SeaIceModel) | ||
| velocity_attrs = default_horizontal_velocity_attributes(model.grid) | ||
| tracer_attrs = default_sea_ice_attributes() | ||
| return merge(velocity_attrs, tracer_attrs) |
There was a problem hiding this comment.
Base.get_extension(Oceananigans, :OceananigansNCDatasetsExt) can return nothing. Defining function OCNE.default_output_attributes(...) will then error at extension load time (Nothing has no field default_output_attributes). Please either (a) extend a binding defined in the parent Oceananigans module (preferred), or (b) guard against isnothing(OCNE) before defining the method / provide a fallback.
| function OCNE.default_output_attributes(model::SeaIceModel) | |
| velocity_attrs = default_horizontal_velocity_attributes(model.grid) | |
| tracer_attrs = default_sea_ice_attributes() | |
| return merge(velocity_attrs, tracer_attrs) | |
| if !isnothing(OCNE) | |
| function OCNE.default_output_attributes(model::SeaIceModel) | |
| velocity_attrs = default_horizontal_velocity_attributes(model.grid) | |
| tracer_attrs = default_sea_ice_attributes() | |
| return merge(velocity_attrs, tracer_attrs) | |
| end |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
|
||
| default_horizontal_velocity_attributes(::OrthogonalSphericalShellGrid) = Dict( | ||
| "u" => Dict("long_name" => "Velocity in the i-direction (+ = increasing i).", "units" => "m/s"), | ||
| "v" => Dict("long_name" => "Velocity in the j-direction (+ = increasing j).", "units" => "m/s")) |
No description provided.