From 97bd405f6a99fdf0dab5dcde8b9a027465dff38c Mon Sep 17 00:00:00 2001 From: Felix Kleinert <f.kleinert@fz-juelich.de> Date: Fri, 26 Mar 2021 13:36:16 +0100 Subject: [PATCH] reset attributes to ull and vll after rotation --- mlair/helpers/geofunctions.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/mlair/helpers/geofunctions.py b/mlair/helpers/geofunctions.py index 3082b563..17923cd2 100644 --- a/mlair/helpers/geofunctions.py +++ b/mlair/helpers/geofunctions.py @@ -8,6 +8,7 @@ import xarray as xr from mlair.helpers.helpers import convert2xrda from typing import Union, Tuple +import logging xr_int_float = Union[xr.DataArray, xr.Dataset, np.ndarray, int, float] tuple_of_2xr_int_float = Tuple[xr_int_float, xr_int_float] @@ -416,7 +417,12 @@ class VectorRotateLambertConformal2latlon(VectorRotate): :return: :rtype: """ - return vgrd * da.sin(self._alpha) + ugrd * da.cos(self._alpha) + ull = vgrd * da.sin(self._alpha) + ugrd * da.cos(self._alpha) + try: + ull.attrs = ugrd.attrs + except Exception as e: + logging.debug(f"Can not set attrs for ull due to: {e}") + return ull def vgrd2vll(self, ugrd, vgrd): """ @@ -429,12 +435,12 @@ class VectorRotateLambertConformal2latlon(VectorRotate): :return: :rtype: """ - return vgrd * da.cos(self._alpha) - ugrd * da.sin(self._alpha) - - - - - + vll = vgrd * da.cos(self._alpha) - ugrd * da.sin(self._alpha) + try: + vll.attrs = vgrd.attrs + except Exception as e: + logging.debug(f"Can not set attrs for vll due to: {e}") + return vll if __name__ == '__main__': -- GitLab