Skip to content

Extend WebAPI to derive time series and statistics for datasets with multiple non-spatial dimensions #1213

Merged
clarasb merged 10 commits into
mainfrom
clarasb-xxx-239-add_additional_dimension
May 15, 2026
Merged

Extend WebAPI to derive time series and statistics for datasets with multiple non-spatial dimensions #1213
clarasb merged 10 commits into
mainfrom
clarasb-xxx-239-add_additional_dimension

Conversation

@clarasb
Copy link
Copy Markdown
Collaborator

@clarasb clarasb commented Apr 30, 2026

This PR extends webapi to support deriving statistics and time series for variables that have more dimensions than just time, lat, and lon.

  • xcube Server now accepts and processes additional non-spatial dimensions (e.g. depth) when computing statistics and time series. Example request:
  GET /statistics/kattegat/chl?time=2025-07-15T12:00:00Z&depth=0.5016462206840515
  • Removed special-cased handling of the time label. Now all non_spatial_dimensions are handled in the same way. If no explicit value is provided for a dimension, a value is selected automatically via get_non_spatial_labels()-
  • xcube.core.tile.get_non_spatial_labels changed to a public function to support the default-value selection logic

Checklist:

  • Add unit tests and/or doctests in docstrings
  • Add docstrings and API docs for any new/modified user-facing classes and functions
  • New/modified features documented in docs/source/*
  • Changes documented in CHANGES.md
  • GitHub CI passes
  • AppVeyor CI passes
  • Test coverage remains or increases (target 100%)

@codecov
Copy link
Copy Markdown

codecov Bot commented May 11, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.58%. Comparing base (d94ebe7) to head (d2ea5a1).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1213      +/-   ##
==========================================
+ Coverage   89.53%   89.58%   +0.05%     
==========================================
  Files         280      280              
  Lines       21655    21686      +31     
==========================================
+ Hits        19389    19428      +39     
+ Misses       2266     2258       -8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@clarasb clarasb marked this pull request as ready for review May 12, 2026 14:25
@clarasb clarasb requested a review from forman May 12, 2026 14:25
Copy link
Copy Markdown
Member

@forman forman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! But see my comments!

Comment thread xcube/webapi/timeseries/routes.py Outdated
Comment on lines +87 to +92
non_spatial_dimensions = get_non_spatial_dimensions(
self.ctx, self.request, datasetId, varName
)
non_spatial_dimensions = {
k: v for k, v in non_spatial_dimensions.items() if k != "time"
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could also enhance get_non_spatial_dimensions() by an opt. keyword argument excluded_dims: Iterable[str] | None = None to `. So the lines above would read:

Suggested change
non_spatial_dimensions = get_non_spatial_dimensions(
self.ctx, self.request, datasetId, varName
)
non_spatial_dimensions = {
k: v for k, v in non_spatial_dimensions.items() if k != "time"
}
non_spatial_dimensions = get_non_spatial_dimensions(
self.ctx, self.request, datasetId, varName, excluded_dims=["time"],
)

Comment thread xcube/webapi/timeseries/routes.py Outdated
if value is not None:
dimensions[str(dim)] = value

labels = get_non_spatial_labels(ds, variable, labels=dimensions, logger=_logger, ignore=["time"])
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, but it seems "time" is already excluded here!

@clarasb clarasb merged commit 60fdc90 into main May 15, 2026
6 checks passed
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.

2 participants