Skip to content

Conversation

@danlooo
Copy link
Member

@danlooo danlooo commented Apr 30, 2025

This PR aims to utilize CF conventions to generate name and label of a YAXArray.
Enables to use CF meta data in heatmap plots, see rafaqz/DimensionalData.jl#989.
Implements same behavior as of python xarray.
Like named DimArrays, this will also add the name to Base.show, if the CF metadata if present:
Closing #393 would improve the axis labels.

╭───────────────────────────────────────────────────╮
│ 4×5 YAXArray{Int64,2} global mean air temperature │
├───────────────────────────────────────────────────┴────────────── dims ┐
  ↓ X     Sampled{Float64} 1.0:1.0:4.0 ForwardOrdered Regular Points,
  → YVals Sampled{Int64} [1, 2, 3, 4, 5] ForwardOrdered Irregular Points
├────────────────────────────────────────────────────────────── metadata ┤
  Dict{String, String} with 3 entries:
  "units"         => "K"
  "long_name"     => "global mean air temperature"
  "standard_name" => "air_temperature"
├────────────────────────────────────────────────────── loaded in memory ┤
  data size: 160.0 bytes
└────────────────────────────────────────────────────────────────────────┘
plot(a_cfa)

image

See testset "YAXArrays with CF conventions" for further details.

@danlooo danlooo changed the title Add CF conventions in YAXArray plot Add CF conventions in YAXArray to use in plots Apr 30, 2025
@codecov
Copy link

codecov bot commented Apr 30, 2025

Codecov Report

Attention: Patch coverage is 54.83871% with 28 lines in your changes missing coverage. Please review.

Project coverage is 73.81%. Comparing base (1069fa1) to head (dab169e).

Files with missing lines Patch % Lines
src/Cubes/Cubes.jl 54.83% 28 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #501      +/-   ##
==========================================
+ Coverage   73.67%   73.81%   +0.14%     
==========================================
  Files          12       12              
  Lines        1865     1875      +10     
==========================================
+ Hits         1374     1384      +10     
  Misses        491      491              
Files with missing lines Coverage Δ
src/Cubes/Cubes.jl 52.76% <54.83%> (+2.09%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@danlooo danlooo changed the title Add CF conventions in YAXArray to use in plots [Draft] Add CF conventions in YAXArray to use in plots Apr 30, 2025
@danlooo
Copy link
Member Author

danlooo commented Apr 30, 2025

BUG in scatter plot but not inb lines plot: No method matching project_position(,..., DiskArrays.BlockedIndices) required for Makie.plot in unidata example.nc.

@felixcremer
Copy link
Member

From the docs failures it seems as if this broke somehow the AlgebraOfGraphics functionality.
Apart from that it looks good to me.

@danlooo
Copy link
Member Author

danlooo commented Apr 30, 2025

AlgebraOfGraphics creates a DimStack using the name for its type. I changed the name function to always return a Symbol.

@danlooo
Copy link
Member Author

danlooo commented Apr 30, 2025

  • error in 1D lines plot: Makie.number_to_date(::Type{DateTime360Day}, i) not implemented
  • error in 1D scatter plot: no method matching _indices_sub(::DiskArrays.BlockedIndices{DiskArrays.GridChunks{1, Tuple{DiskArrays.RegularChunks}}}

@lazarusA
Copy link
Collaborator

lazarusA commented May 1, 2025

AoG errors might be unrelated to this PR, probably more an internal AoG change, I will take a look later.

danlooo added 2 commits May 5, 2025 13:50
…rays.jl into use_cf_conventions_in_plot

* 'use_cf_conventions_in_plot' of github.com:danlooo/YAXArrays.jl:
  Fix cf label test
  Fix error AlgebraOfGraphics use symbol
@danlooo
Copy link
Member Author

danlooo commented May 5, 2025

DimensionalData v0.29.16 + is required to show colorbar label. However, YAXArrays allows below as DD 0.27.

@lazarusA
Copy link
Collaborator

lazarusA commented May 5, 2025

mmm .. 0.29 flavours are allow.

DimensionalData = "0.27, 0.28, 0.29"

@meggart
Copy link
Member

meggart commented Oct 22, 2025

Whats is the status for this PR. Is is ready for a final review or still in draft stage?

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.

4 participants