diff --git a/examples/simple_viewer.py b/examples/simple_viewer.py index b6b17f59905e6d6847143f1d53c633788ac036bf..d7634c2feb60cdd18842250d98e3c7406a27475c 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 0308ab5dd4dd84248582fd547b52df7f81eedb88..f3aa1b53b8deeacf2fe3464ef94e7a393e35dd6b 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, )