fastscape-lem / fastscape

A fast, versatile and user-friendly landscape evolution model
https://fastscape.readthedocs.io
BSD 3-Clause "New" or "Revised" License
53 stars 12 forks source link

Error in demo enviroment #12

Closed milesbodmer closed 4 years ago

milesbodmer commented 4 years ago

Hello,

I am receiving an error when trying to run the tutorial for the basic model. I have loaded the demo environment as per the instructions in the readme.md file and have not modified any of the code.

`out_ds = in_ds.xsimlab.run(model=basic_model)

out_ds


ValueError Traceback (most recent call last)

in ----> 1 out_ds = in_ds.xsimlab.run(model=basic_model) 2 3 out_ds ~/.conda/envs/fastscape-demo/lib/python3.7/site-packages/xsimlab/xr_accessor.py in run(self, model, safe_mode) 484 driver = XarraySimulationDriver(self._ds, model, store, output_store) 485 --> 486 return driver.run_model() 487 488 def run_multi(self): ~/.conda/envs/fastscape-demo/lib/python3.7/site-packages/xsimlab/drivers.py in run_model(self) 297 298 """ --> 299 ds_init, ds_gby_steps = self._get_runtime_datasets() 300 301 runtime_context = RuntimeContext( ~/.conda/envs/fastscape-demo/lib/python3.7/site-packages/xsimlab/drivers.py in _get_runtime_datasets(self) 279 280 ds_all_steps = (self.dataset.drop(ds_init.data_vars.keys(), --> 281 errors='ignore') 282 .isel({mclock_dim: slice(0, -1)}) 283 .assign(step_data_vars)) ~/.conda/envs/fastscape-demo/lib/python3.7/site-packages/xarray/core/dataset.py in drop(self, labels, dim, errors, **labels_kwargs) 3641 stacklevel=2, 3642 ) -> 3643 return self.drop_sel(labels, errors=errors) 3644 3645 def drop_sel(self, labels=None, *, errors="raise", **labels_kwargs): ~/.conda/envs/fastscape-demo/lib/python3.7/site-packages/xarray/core/dataset.py in drop_sel(self, labels, errors, **labels_kwargs) 3687 raise ValueError('errors must be either "raise" or "ignore"') 3688 -> 3689 labels = either_dict_or_kwargs(labels, labels_kwargs, "drop") 3690 3691 ds = self ~/.conda/envs/fastscape-demo/lib/python3.7/site-packages/xarray/core/utils.py in either_dict_or_kwargs(pos_kwargs, kw_kwargs, func_name) 255 if not is_dict_like(pos_kwargs): 256 raise ValueError( --> 257 "the first argument to .%s must be a dictionary" % func_name 258 ) 259 if kw_kwargs: ValueError: the first argument to .drop must be a dictionary`
milesbodmer commented 4 years ago

I am encountering a similar issue when trying to run the demo codes using binder.

benbovy commented 4 years ago

I'm pretty sure it's caused by a compatibility issue between xarray-simlab and xarray 0.14.1. It has been fixed in https://github.com/benbovy/xarray-simlab/pull/69, but I'm gonna pin xarray for the fastscape demo environment until xarray-simlab 0.4 is released.

benbovy commented 4 years ago

It should work if you downgrade xarray to 0.14.0 in your environment.

benbovy commented 4 years ago

Temporarily fixed in https://github.com/fastscape-lem/fastscape-demo/commit/61dd54d51f006a4b7cee81fc11dd5ee31bac8953

milesbodmer commented 4 years ago

Hi Benoit,

Thank you for your quick reply. I tested things out and they seem to be working for me correctly now.

Thanks!

On Tue, Jan 28, 2020 at 12:50 AM Benoit Bovy notifications@github.com wrote:

Closed #12 https://github.com/fastscape-lem/fastscape/issues/12.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/fastscape-lem/fastscape/issues/12?email_source=notifications&email_token=AIROWN3YLVIQNZ7FBIVAXHLQ77WUDA5CNFSM4KLZZ2D2YY3PNVWWK3TUL52HS4DFWZEXG43VMVCXMZLOORHG65DJMZUWGYLUNFXW5KTDN5WW2ZLOORPWSZGOWHTYYUI#event-2984741969, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIROWNZQ4AFIC4QWFSQCDODQ77WUDANCNFSM4KLZZ2DQ .

milesbodmer commented 4 years ago

Hi Benoit,

A related question. When running scripts using Binder or the environment (with the compatible xarray), routines using hvplot appear to fail. The code and error are below from the margin script.

Thank you.

import hvplot.xarrayimport holoviews as hvfrom xshade import hillshadess_ratio_plot = out_ds.mariness_ratio_sea.hvplot.image( x='x', y='y', clim=(0, 1), width=550, height=350, cmap=plt.cm.viridis_r, groupby='out')hillshade_plot = hillshade(out_ds, 'out').hvplot.image( x='x', y='y', cmap=plt.cm.gray, alpha=0.7, colorbar=False, hover=False, groupby='out')ysections = out_ds.topographyelevation.sel(y=[2.5e4, 5e4, 7.5e4])sections_plot = ysections.hvplot.line( by='y', groupby='out', ylim=(-1e3, 1e3), width=550, height=200, legend='top_left',)hv.Layout((ss_ratio_plot hillshade_plot) + sections_plot).cols(1)*

---------------------------------------------------------------------------AttributeError Traceback (most recent call last) in 10 ) 11 ---> 12 hillshade_plot = hillshade(out_ds, 'out').hvplot.image( 13 x='x', y='y', cmap=plt.cm.gray, alpha=0.7, 14 colorbar=False, hover=False, groupby='out' ~/examples/xshade.py in hillshade(ds, groupby, elev_var, kwargs) 7 if groupby is not None: 8 hshade = elev.groupby(groupby).apply(dgeo.hillshade, shortcut=True,----> 9 kwargs) 10 else: 11 hshade = dgeo.hillshade(elev, shortcut=True, kwargs) /srv/conda/envs/notebook/lib/python3.7/site-packages/xarray/core/groupby.py in apply(self, func, shortcut, args, kwargs) 680 grouped = self._iter_grouped() 681 applied = (maybe_wrap_array(arr, func(arr, *args, *kwargs)) for arr in grouped)--> 682 return self._combine(applied, shortcut=shortcut) 683 684 def _combine(self, applied, restore_coord_dims=False, shortcut=False): /srv/conda/envs/notebook/lib/python3.7/site-packages/xarray/core/groupby.py in _combine(self, applied, restore_coord_dims, shortcut) 684 def _combine(self, applied, restore_coord_dims=False, shortcut=False): 685 """Recombine the applied objects like the original."""--> 686 applied_example, applied = peek_at(applied) 687 coord, dim, positions = self._infer_concat_args(applied_example) 688 if shortcut: /srv/conda/envs/notebook/lib/python3.7/site-packages/xarray/core/utils.py in peek_at(iterable) 178 """ 179 gen = iter(iterable)--> 180 peek = next(gen) 181 return peek, itertools.chain([peek], gen) 182 /srv/conda/envs/notebook/lib/python3.7/site-packages/xarray/core/groupby.py in (.0) 679 else: 680 grouped = self._iter_grouped()--> 681 applied = (maybe_wrap_array(arr, func(arr, args, *kwargs)) for arr in grouped) 682 return self._combine(applied, shortcut=shortcut) 683 /srv/conda/envs/notebook/lib/python3.7/site-packages/datashader/geo.py in hillshade(agg, azimuth, angle_altitude) 60 shaded = np.sin(altituderad) np.sin(slope) + np.cos(altituderad) np.cos(slope)np.cos((azimuthrad - np.pi/2.) - aspect) 61 data = (shaded + 1) / 2---> 62 return DataArray(data, name='hillshade', dims=agg.dims, coords=agg.coords, attrs=agg.attrs) 63 64 AttributeError: 'Variable' object has no attribute 'coords'

On Wed, Jan 29, 2020 at 12:39 PM miles bodmer milesbodmer@gmail.com wrote:

Hi Benoit,

Thank you for your quick reply. I tested things out and they seem to be working for me correctly now.

Thanks!

On Tue, Jan 28, 2020 at 12:50 AM Benoit Bovy notifications@github.com wrote:

Closed #12 https://github.com/fastscape-lem/fastscape/issues/12.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/fastscape-lem/fastscape/issues/12?email_source=notifications&email_token=AIROWN3YLVIQNZ7FBIVAXHLQ77WUDA5CNFSM4KLZZ2D2YY3PNVWWK3TUL52HS4DFWZEXG43VMVCXMZLOORHG65DJMZUWGYLUNFXW5KTDN5WW2ZLOORPWSZGOWHTYYUI#event-2984741969, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIROWNZQ4AFIC4QWFSQCDODQ77WUDANCNFSM4KLZZ2DQ .

benbovy commented 4 years ago

I see, it's because of a recent change in datashader. I'll fix this.

benbovy commented 4 years ago

Fixed in https://github.com/fastscape-lem/fastscape-demo/commit/105c8507faf6eb304929171dd56bc0d392b329c9

milesbodmer commented 4 years ago

Hello Benoit,

Sorry to bother you again and thanks for all the help so far. I have 2 colleagues attempting to use FastScape on PCs. They are both encountering the same error when trying to install the required dependencies. They are trying to load the demo environment using the updated .yml file. Attached below is a screenshot of the error message. Any help with this would be greatly appreciated.

Thanks.

[image: Error.PNG]

On Thu, Jan 30, 2020 at 1:39 AM Benoit Bovy notifications@github.com wrote:

Fixed in fastscape-lem/fastscape-demo@105c850 https://github.com/fastscape-lem/fastscape-demo/commit/105c8507faf6eb304929171dd56bc0d392b329c9

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/fastscape-lem/fastscape/issues/12?email_source=notifications&email_token=AIROWN2AXJAC5FN72WCEIK3RAKN4DA5CNFSM4KLZZ2D2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEKKKUJA#issuecomment-580168228, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIROWN6RXJ5PMNQP2W2Q3WLRAKN4DANCNFSM4KLZZ2DQ .

benbovy commented 4 years ago

I can't see the attached screenshot, but I guess the error message says something like "fastscapelib-f2py not found". fastscapelib-f2py is a dependency of fastscape, but it has is no conda package yet on Windows (hopefully soon when the next release of scikit-build will be available).