Skip to content

Add preprocessor t_test#3133

Draft
FranziskaWinterstein wants to merge 23 commits into
mainfrom
add_ttest
Draft

Add preprocessor t_test#3133
FranziskaWinterstein wants to merge 23 commits into
mainfrom
add_ttest

Conversation

@FranziskaWinterstein

@FranziskaWinterstein FranziskaWinterstein commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Description

This new preprocessor function calculates a t-test and adds the resulted p-value as an Ancillary Variable to the model cubes. This p-value can later be used for hatching non-significant values when plotting the bias of model and reference. It is planned to add such in monitor/multi_datasets.py.

Link to documentation:

Closes #3132


Checklist

It is the responsibility of the author to make sure the pull request is ready to review. The icons indicate whether the item will be subject to the 🛠 Technical or 🧪 Scientific review.


@CLAassistant

CLAassistant commented Jun 24, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@FranziskaWinterstein FranziskaWinterstein marked this pull request as draft June 24, 2026 09:44
@FranziskaWinterstein

FranziskaWinterstein commented Jun 24, 2026

Copy link
Copy Markdown
Contributor Author

Currently the processing fails with

  File "/work/bd1132/b309109/conda_envs/envs/esmvaltool/lib/python3.13/site-packages/numpy/_core/fromnumeric.py", line 86, in _wrapreduction
    return ufunc.reduce(obj, axis, dtype, out, **passkwargs)
      ^^^^^^^^^^^^^^^^^
numpy.exceptions.AxisError: <exception str() failed>

see also attached main_log_debug.txt

@codecov

codecov Bot commented Jun 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.24%. Comparing base (87ba05a) to head (04006d7).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3133      +/-   ##
==========================================
+ Coverage   96.22%   96.24%   +0.01%     
==========================================
  Files         273      273              
  Lines       16150    16202      +52     
==========================================
+ Hits        15541    15593      +52     
  Misses        609      609              

☔ View full report in Codecov by Harness.
📢 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@schlunma schlunma changed the title Add ttest Add preprocessor t_test Jul 1, 2026
@schlunma schlunma added this to the v2.16.0 milestone Jul 1, 2026
@schlunma schlunma added the preprocessor Related to the preprocessor label Jul 1, 2026
@schlunma

schlunma commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Currently the processing fails with

  File "/work/bd1132/b309109/conda_envs/envs/esmvaltool/lib/python3.13/site-packages/numpy/_core/fromnumeric.py", line 86, in _wrapreduction
    return ufunc.reduce(obj, axis, dtype, out, **passkwargs)
      ^^^^^^^^^^^^^^^^^
numpy.exceptions.AxisError: <exception str() failed>

see also attached main_log_debug.txt

This should be fixed now.

I also updated the code so it properly works with lazy/non-lazy and masked/non-masked data, and added corresponding tests.

Would be great if you can check if it still works as you would expect!

Note that I renamed the preprocessor to t_test to avoid 100s of errors from codespell. This is probably also more readable.

Still missing:

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

Labels

preprocessor Related to the preprocessor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Adding ttest as a preprocessor function

3 participants