File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change 1
1
"""obsarray.concat - module with extension to xarray.concat for obs_vars and unc_vars"""
2
2
3
+ import numpy as np
3
4
import xarray as xr
4
5
from typing import Union , Any
5
6
from xarray .core .types import T_Dataset , T_DataArray , T_Variable
@@ -20,8 +21,6 @@ def obs_concat(
20
21
** kwargs
21
22
):
22
23
"""
23
- **NB: THIS FUNCTION IS NOT CURRENTLY IMPLEMENTED AND JUST ACTS AS A WRAPPER FOR XR.CONCAT**
24
-
25
24
Concatenate xarray *obs_vars* along a new or existing dimension, safely handling also
26
25
concatenating associated *unc_vars*. Extension to :py:func:`xarray.concat`.
27
26
@@ -44,7 +43,19 @@ def obs_concat(
44
43
"""
45
44
46
45
concat_obs_vars = xr .concat (objs , dim , * args , ** kwargs )
47
- concat_unc_vars = None
46
+ concat_unc_vars = xr .Dataset
47
+
48
+ n_uc = np .array ([len (obj .attrs ["unc_comps" ]) for obj in objs ])
49
+
50
+ if np .all (n_uc != n_uc [0 ]):
51
+ raise ValueError ()
52
+ else :
53
+ n_uc = n_uc [0 ]
54
+
55
+ for i_uc in range (n_uc ):
56
+ unc_i = [unc [obj .attrs ["unc_comps" ][i_uc ]] for obj in objs ]
57
+
58
+
48
59
return concat_obs_vars , concat_unc_vars
49
60
50
61
You can’t perform that action at this time.
0 commit comments