IMMM-SFA / mosartwmpy

Python translation of MOSART-WM: a water routing and management model
https://mosartwmpy.readthedocs.io/
Other
20 stars 7 forks source link

Error running tutorial notebook #90

Closed hkhorasani closed 2 years ago

hkhorasani commented 2 years ago

I installed the latest version from Github and ran the tutorial notebook. But after running the following line:

mosart_wm.plot_variable('surface_water_amount', log_scale=True)

I got the following error:

ValueError                                Traceback (most recent call last)
c:\mosartw\mosartwmpy\notebooks\tutorial.ipynb Cell 10 in <cell line: 1>()
----> [1](vscode-notebook-cell:/c%3A/mosartw/mosartwmpy/notebooks/tutorial.ipynb#ch0000009?line=0) mosart_wm.plot_variable('surface_water_amount', log_scale=True)

File c:\Users\Hamed Khorasani\mambaforge\envs\mosartwm\lib\site-packages\mosartwmpy\model.py:269, in Model.plot_variable(self, variable, log_scale)
    263 def plot_variable(
    264         self,
    265         variable: str,
    266         log_scale: bool = False,
    267 ):
    268     """Display a colormap of a spatial variable at the current timestep."""
--> 269     data = self.unmask(self.get_value_ptr(variable)).reshape(self.get_grid_shape())
    270     if log_scale:
    271         data = np.where(data > 0, data, np.nan)

File c:\Users\Hamed Khorasani\mambaforge\envs\mosartwm\lib\site-packages\mosartwmpy\model.py:294, in Model.unmask(self, vector)
    292 elif vector.dtype == bool:
    293     unmasked[:] = False
--> 294 unmasked[self.mask] = vector
    295 return unmasked

ValueError: NumPy boolean array indexing assignment cannot assign 103936 input values to the 80053 output values where the mask is true

I was wondering if you could kindly provide some information about what causes this error and what changes should I make.

thurber commented 2 years ago

hi @hkhorasani, thanks for pointing this out! I'll get a fix out by later this week and let you know

thurber commented 2 years ago

hi @hkhorasani, i've published a fix for this issue -- a new version of mosartwmpy v0.3.1 should be available on pypi shortly; the conda-forge version may take a couple days before it is deployed. let me know if you still have any issues and thanks for using mosartwmpy!