From d4c96eed6e320e6d3127647dd0211cb96dcde565 Mon Sep 17 00:00:00 2001 From: Martin Lange <martin.lange@ufz.de> Date: Sat, 5 Mar 2022 13:51:45 +0100 Subject: [PATCH] dirty fix for output grid orientation and daily time step --- examples/simple_viewer.py | 1 + src/finam_mhm_module/mhm.py | 13 +++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/examples/simple_viewer.py b/examples/simple_viewer.py index b6b17f5..d7634c2 100644 --- a/examples/simple_viewer.py +++ b/examples/simple_viewer.py @@ -11,6 +11,7 @@ from finam.modules.visual import time_series from finam_mhm_module import Mhm from matplotlib import pyplot as plt + def grid_select(grid): col, row = 3, 5 return grid[col + row * 5] diff --git a/src/finam_mhm_module/mhm.py b/src/finam_mhm_module/mhm.py index 0308ab5..f3aa1b5 100644 --- a/src/finam_mhm_module/mhm.py +++ b/src/finam_mhm_module/mhm.py @@ -2,10 +2,11 @@ FINAM mHM module. """ from datetime import datetime -import mhm_pybind as mp -from finam.core.sdk import ATimeComponent, Output +import mhm_pybind as mp +import numpy as np from finam.core.interfaces import ComponentStatus +from finam.core.sdk import ATimeComponent, Output from finam.data.grid import Grid, GridSpec @@ -35,14 +36,14 @@ class Mhm(ATimeComponent): # set time year, month, day, hour = mp.run.current_time() print("time", year, month, day, hour) - if hour == -1: + if hour < 0: hour = 0 self._time = datetime(year=year, month=month, day=day, hour=hour) # get grid info ncols, nrows, ncells, xll, yll, cell_size, no_data = mp.get.l1_domain_info() self.no_data = no_data self.gridspec = GridSpec( - ncols=ncols, nrows=nrows, cell_size=cell_size, xll=xll, yll=yll + ncols=nrows, nrows=ncols, cell_size=cell_size, xll=xll, yll=yll ) self.outputs["runoff"] = Output() self._status = ComponentStatus.INITIALIZED @@ -54,7 +55,7 @@ class Mhm(ATimeComponent): data=Grid( spec=self.gridspec, no_data=self.no_data, - data=runoff.filled().reshape(-1), + data=np.fliplr(runoff.filled()).reshape(-1, order="F"), ), time=self.time, ) @@ -82,7 +83,7 @@ class Mhm(ATimeComponent): data=Grid( spec=self.gridspec, no_data=self.no_data, - data=runoff.filled().reshape(-1), + data=np.fliplr(runoff.filled()).reshape(-1, order="F"), ), time=self.time, ) -- GitLab