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

Simplify and align dimensions and coordinates with netcdf Common Data Model #107

Merged
merged 4 commits into from
Dec 31, 2024

Conversation

sjdaines
Copy link
Member

@sjdaines sjdaines commented Dec 29, 2024

Simplify and align with Common Data Model

See corresponding PALEOboxes PR PALEOtoolkit/PALEOboxes.jl#151 (PALEOboxes v0.22).
Closes #48

Changes:

  • Add FixedCoord, removed from PALEOboxes
    • generalized to handle 'bounds' ie Array size(2, ncells) as a simpler way of specifying cell edges (cf CF conventions)
  • OutputMemory now based on FieldRecord, not DataFrame
    • save / load to jld2 removed
    • updates to netcdf output format
  • Simpler and more generic get_array(fr::FieldRecord) -> FieldArray
    • replaces old approach using get_region

These changes should be non-breaking, except for models using 2D or 3D Cartesian grids.

Simplify and align with Common Data Model

See corresponding PALEOboxes PR PALEOtoolkit/PALEOboxes.jl#151

TODO: this commit still includes old and now unused code

Changes:

- Add FixedCoord from PALEOboxes
  - generalized to handle 'bounds' ie Array size(2, ncells)
    as a simpler way of specifying cell edges (cf CF conventions)
- OutputMemory now based on FieldRecord, not DataFrame
  - save / load to jld2 removed
  - updates to netcdf output format
- Simpler and more generic get_array -> FieldArray from FieldRecord
  - replaces old approach using get_region
- remove old unused code
- fix doc build
sjdaines added a commit to PALEOtoolkit/PALEOsediment.jl that referenced this pull request Dec 30, 2024
…s updates

See PRs:
    PALEOtoolkit/PALEOboxes.jl#151
    PALEOtoolkit/PALEOmodel.jl#107

Example of change needed from ReactionSedimentGridn1D do_sediment_setup_grid:

    # attach coordinates to grid for output visualisation etc
    if isdefined(PB, :set_coordinates!) # PALEOboxes >= 0.22
        PB.set_coordinates!(rj.domain.grid, "cells", ["zmid", "zlower", "zupper"])
    else
        empty!(rj.domain.grid.z_coords)
        push!(rj.domain.grid.z_coords, PB.FixedCoord("zmid", grid_vars.zmid, PB.get_variable(m, "zmid").attributes))
        push!(rj.domain.grid.z_coords, PB.FixedCoord("zlower", grid_vars.zlower, PB.get_variable(m, "zlower").attributes))
        push!(rj.domain.grid.z_coords, PB.FixedCoord("zupper", grid_vars.zupper, PB.get_variable(m, "zupper").attributes))
    end
@sjdaines sjdaines changed the title Work-in-progress updating dimensions and coordinates Simplify and align dimensions and coordinates with netcdf Common Data Model Dec 31, 2024
@sjdaines sjdaines marked this pull request as ready for review December 31, 2024 12:19
@sjdaines sjdaines merged commit b4c01d2 into main Dec 31, 2024
3 checks passed
sjdaines referenced this pull request Dec 31, 2024
Simplify and tidy up FieldRecord and netcdf output
@sjdaines sjdaines deleted the dims_coords branch December 31, 2024 18:55
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.

Align FieldArray with Python xarray and netCDF data model
1 participant