MetOffice / CSET

Toolkit for evaluation and investigation of numerical models for weather and climate applications.
https://metoffice.github.io/CSET/
Apache License 2.0
10 stars 4 forks source link

Add repetitive functions to _common.py or similar. #619

Closed jwarner8 closed 4 months ago

jwarner8 commented 4 months ago

What problem does your feature request solve?

Identifying the x/y coordinate name, and calculating the distance between two (lat,lon) tuples, is being used in quite a few operators. This is leading to increased repetition and may make code checks more burdensome as CSET grows. Some common used functions (not involving cubes) are stored in _common.py.

Describe the solution you'd like

Would it be sensible to have something similar to _common.py to hold regularly used iris operations that are not already implemented as one-liners within the iris framework itself? The RMED toolbox had a cube_utils.py script which contained all of these.

Describe alternatives you've considered

We could continue duplication of functions within each operator instead.

jfrost-mo commented 4 months ago

This is a good idea. We could probably say something like "If a function is used across more than one operator module it should be made common."

jwarner8 commented 4 months ago

I wonder if it would be good to be _common.py to file/metadata functions, and a separate _common_cubeutils.py or something similar for computational/cube processing only?

jfrost-mo commented 4 months ago

Yeah, it would be nice to give a clear indication for what is intended for operators to use, and what is not. Both are not part of the public API, so we can move things after the fact if we need to.