From 787a2e59c755cd5e11ea374990446ae0eb2921aa Mon Sep 17 00:00:00 2001 From: Jim Clark Date: Fri, 9 Feb 2024 11:10:38 +0000 Subject: [PATCH] Add depth axis if missing (#146) --- pylag/arakawa_a_data_reader.pyx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pylag/arakawa_a_data_reader.pyx b/pylag/arakawa_a_data_reader.pyx index d516ae3..82cd09a 100644 --- a/pylag/arakawa_a_data_reader.pyx +++ b/pylag/arakawa_a_data_reader.pyx @@ -1531,11 +1531,13 @@ cdef class ArakawaADataReader(DataReader): if self._trim_last_latitude == 1: var = var[:, :-1] + var = np.ascontiguousarray(var.reshape(np.prod(var.shape), order='C')[self._permutation]) + # Add depth axis if required if add_depth_axis: - var = var[np.newaxis, :, :] + var = var[np.newaxis, :] - return np.ascontiguousarray(var.reshape(np.prod(var.shape), order='C')[self._permutation]) + return var elif n_dimensions == 3: depth_index = dimension_indices['depth']