Skip to content

Commit

Permalink
Merge pull request NCAS-CMS#738 from davidhassell/lbproc-131072
Browse files Browse the repository at this point in the history
Recognise LBPROC 131072 when reading UM files
  • Loading branch information
davidhassell authored Mar 14, 2024
2 parents a19d870 + fc5407d commit a90a26f
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
3 changes: 3 additions & 0 deletions Changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ version NEXT
* Fix misleading error message when it is not possible to create area
weights requested from `cf.Field.collapse`
(https://github.com/NCAS-CMS/cf-python/issues/731)
* Fix bug in `cf.read` when reading UM files that caused LBPROC value
131072 (Mean over an ensemble of parallel runs) to be ignored
(https://github.com/NCAS-CMS/cf-python/issues/737)

----

Expand Down
37 changes: 36 additions & 1 deletion cf/read_write/um/umread.py
Original file line number Diff line number Diff line change
Expand Up @@ -1583,16 +1583,51 @@ def create_bounds_array(self, bounds0, bounds1):
def create_cell_methods(self):
"""Create the cell methods.
**UMDP F3**
LBPROC Processing code. This indicates what processing has
been done to the basic field. It should be 0 if no processing
has been done, otherwise add together the relevant numbers
from the list below:
1 Difference from another experiment.
2 Difference from zonal (or other spatial) mean.
4 Difference from time mean.
8 X-derivative (d/dx)
16 Y-derivative (d/dy)
32 Time derivative (d/dt)
64 Zonal mean field
128 Time mean field
256 Product of two fields
512 Square root of a field
1024 Difference between fields at levels BLEV and BRLEV
2048 Mean over layer between levels BLEV and BRLEV
4096 Minimum value of field during time period
8192 Maximum value of field during time period
16384 Magnitude of a vector, not specifically wind speed
32768 Log10 of a field
65536 Variance of a field
131072 Mean over an ensemble of parallel runs
:Returns:
`list`
`list` of `str`
The cell methods.
"""
cell_methods = []

LBPROC = self.lbproc
LBTIM_IB = self.lbtim_ib
tmean_proc = 0

# ------------------------------------------------------------
# Ensemble mean cell method
# ------------------------------------------------------------
if 131072 <= LBPROC < 262144:
cell_methods.append("realization: mean")
LBPROC -= 131072

if LBTIM_IB in (2, 3) and LBPROC in (128, 192, 2176, 4224, 8320):
tmean_proc = 128
LBPROC -= 128
Expand Down

0 comments on commit a90a26f

Please sign in to comment.