Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyaerocom/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from cf_units import Unit
from collections import Counter
from datetime import MINYEAR, datetime, date
import iris
import iris, iris.analysis, iris.cube, iris.coords
import math as ma
import numpy as np
import pandas as pd
Expand Down
24 changes: 11 additions & 13 deletions pyaerocom/io/iris_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import cf_units
from datetime import datetime
import iris
import iris, iris.coords, iris.util
try:
# as of iris version 3
from iris.util import equalise_attributes
Expand Down Expand Up @@ -546,11 +546,7 @@ def _check_correct_dtypes_timedim_cube_list(cubes):
def concatenate_iris_cubes(cubes, error_on_mismatch=True):
"""Concatenate list of :class:`iris.Cube` instances cubes into single Cube

Helper method for concatenating list of cubes and that helps
with handling the fact that the corresponding iris method is not well
defined in the sense of what it returns (i.e. instance of
:class:`Cube` or :class:`CubeList`, depending on whether all cubes
could be concatenated or not...)
Helper method for concatenating list of cubes

This method is not supposed to be called directly but rather
:func:`concatenate_cubes` (which ALWAYS returns instance of
Expand All @@ -559,15 +555,15 @@ def concatenate_iris_cubes(cubes, error_on_mismatch=True):

Parameters
----------
cubes : CubeList
cubes : CubeList or list(Cubes)
list of individual cubes
error_on_mismatch
boolean specifying whether an Exception is supposed to be raised
or not

Returns
-------
:obj:`Cube` or :obj:`CubeList`
:obj:`Cube`
result of concatenation

Raises
Expand All @@ -577,6 +573,7 @@ def concatenate_iris_cubes(cubes, error_on_mismatch=True):
into a single instance of :class:`iris.Cube` class.

"""
cubes = iris.cube.CubeList(cubes)
var_name = cubes[0].var_name
if const.GRID_IO.EQUALISE_METADATA:
meta_init = cubes[0].metadata
Expand All @@ -595,14 +592,15 @@ def concatenate_iris_cubes(cubes, error_on_mismatch=True):
#unify time units
iris.util.unify_time_units(cubes)
#now concatenate the cube list to one cube

try:
cubes_concat = iris._concatenate.concatenate(cubes, error_on_mismatch)
except Exception as e: #
cubes_concat = iris.cube.CubeList.concatenate_cube(cubes, error_on_mismatch)
except Exception as e:
if _check_correct_dtypes_timedim_cube_list(cubes):
cubes_concat = iris._concatenate.concatenate(cubes,
error_on_mismatch)
cubes_concat = iris.cube.CubeList.concatenate_cube(cubes,
error_on_mismatch)
else:
raise

return cubes_concat[0]
return cubes_concat

2 changes: 1 addition & 1 deletion pyaerocom_env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
channels:
- conda-forge
dependencies:
- iris >=3.0.1,<3.1.0
- iris >=3.1.0
- xarray >=0.16.0
- cartopy >=0.16.0
- matplotlib >=3.0.1
Expand Down
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@

python_requires = '>=3.7,<4',
install_requires = [
'scitools-iris>=3.0.1,<3.1.0',
'scitools-pyke>=1.1.1',
'scitools-iris>=3.1.0',
'xarray>=0.16.0',
'cartopy>=0.16.0',
'matplotlib>=3.0.1',
Expand Down