Skip to content

Add effective radius output#311

Draft
nathgrimmer wants to merge 4 commits into
contrailcirrus:mainfrom
nathgrimmer:feature/reff-output
Draft

Add effective radius output#311
nathgrimmer wants to merge 4 commits into
contrailcirrus:mainfrom
nathgrimmer:feature/reff-output

Conversation

@nathgrimmer
Copy link
Copy Markdown

Closes #XX

Changes

Description of changes in this PR.
Use make changelog for starter.
Should be copied and commit to CHANGELOG.md

Breaking changes

Features

Fixes

Internals

Tests

  • QC test passes locally (make test)
  • CI tests pass

Reviewer

Select @ reviewer

Copy link
Copy Markdown
Contributor

@thabbott thabbott left a comment

Choose a reason for hiding this comment

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

This looks good overall! A lot of changes have been merged into main since you opened this PR, so before you do anything else you should rebase your branch onto the contrailcirrus main branch:

git remote add upstream https://github.com/contrailcirrus/pycontrails
git fetch upstream
git rebase upstream/main

If this is successful that latest changes in CHANGELOG.md should be for v0.54.11.

After that you should make sure that tests pass locally. To do that, run

GITHUB_ACTIONS=true make test

(Setting GITHUB_ACTIONS=true disables some slow LEO datalib tests that don't matter for this PR.) If the tests fail, try re-installing your pycontrails environment to make sure your dependencies are all up to date.

Once you confirm tests pass, push the changes to update this PR (you'll have to force push after rebasing).

A few other things, in addition to those in other comments:

  • Can you add a description of your changes to CHANGELOG.md?
  • I don't think any of the pinned test results in static json files should need updating... can you try re-running tests without those changes and see if they still pass?
  • Can you add a similar set of tests for gridded CoCip?

verbose_outputs: bool = False

#: Add effective radius to contrail.
#: It is not necessary for calculation.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
#: It is not necessary for calculation.

#: :attr:`CocipGridParams.verbose_outputs_evolution`.
verbose_outputs: bool = False

#: Add effective radius to contrail.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
#: Add effective radius to contrail.
#: Add effective radius to contrail output.

radius_threshold_um: npt.NDArray[np.floating],
) -> npt.NDArray[np.floating]:
r"""
Calculate the effective radius of contrail ice particles for each waypoints.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
Calculate the effective radius of contrail ice particles for each waypoints.
Calculate the effective radius of contrail ice particles for each waypoint.

r"""
Calculate the effective radius of contrail ice particles for each waypoints.

For each waypoints, all the habits are assumed by applying a weighted harmonic mean.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you add a brief explanation of why a harmonic mean is required?

Comment thread tests/unit/test_cocip.py Outdated
assert 0 < ratio < 1


def test_effective_radius(cocip_persistent: Cocip):
Copy link
Copy Markdown
Contributor

@thabbott thabbott Jul 8, 2025

Choose a reason for hiding this comment

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

This doesn't actually test whether effective radius gets attached to CoCiP output when params["output_effective_radius"] is True. Rather than calling effective_radius directly in the test, I'd create a new fixture with effective radius output enabled and test the effective radius values in that fixture.

…roperties (to allow to have the effective radius in CoCiPGrid too) only if output_effective_radius is True
…_effective_radius = False. Verify also the reff value.
… doesn't work for the moment, even if the output_effective_radius parameter is True, the reff parameter isn't in the output when running CocipGrid.
@nathgrimmer nathgrimmer force-pushed the feature/reff-output branch from 3e42f05 to 598b0c1 Compare July 11, 2025 13:50
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