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

Refactor fix_pressure_levels function #187

Open
atteggiani opened this issue Feb 11, 2025 · 0 comments
Open

Refactor fix_pressure_levels function #187

atteggiani opened this issue Feb 11, 2025 · 0 comments

Comments

@atteggiani
Copy link
Collaborator

atteggiani commented Feb 11, 2025

Overview

In the current implementation, the fix_pressure_levels function doesn't return anything (i.e. returns None) when there is no pressure coordinate:

try:
pressure = cube.coord("pressure")
except iris.exceptions.CoordinateNotFoundError:
return

and within the process_cubes function the fix_pressure_levels function is used as it follows:

c = fix_pressure_levels(c) or c # NB: use new cube if pressure points are modified

Improvement

If the pressure coordinate is not found, the fix_pressure_levels should return the cube as it is, so in the process_cubes we can simplify the call within process_cubes.

A suggestion for the changes of the fix_pressure_levels and of the process function is shown below:

fix_pressure_levels function

try: 
     pressure = cube.coord("pressure") 
 except iris.exceptions.CoordinateNotFoundError: 
-     return 
+     return cube

process function

- c = fix_pressure_levels(c) or c 
+ c = fix_pressure_levels(c)
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

No branches or pull requests

1 participant