Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust dem fails when also interpolating onto grid #113

Open
TPCollings opened this issue Aug 2, 2022 · 1 comment
Open

Adjust dem fails when also interpolating onto grid #113

TPCollings opened this issue Aug 2, 2022 · 1 comment

Comments

@TPCollings
Copy link

Hello again,

When using the tutorial script DEM.ipynb, I get an error when running the command to process the DEM with the mesh grid nodes, whilst also adjusting for coastlines. Example error is below.

I've found a work around, to adjust coastlines before including the interpolation onto the mesh, and then use the output from that to sample onto the mesh, with adjust_dem=False.

Cheers,

Tom

dem = pdem.Dem(**geometry, coastlines = ne_i, dem_source=dem.Dataset, grid_x = x, grid_y = y,adjust_dem=True)

INFO:pyposeidon.dem:dem done

INFO:pyposeidon.dem:.. interpolating on mesh ..

INFO:pyposeidon.dem:.. using elevation values ..

INFO:pyposeidon.dem:dem on grid done

INFO:pyposeidon.utils.fix:adjust dem

DEBUG:pyposeidon.utils.fix:compute water and land

DEBUG:pyposeidon.utils.fix:invoke pygeos

DEBUG:pyposeidon.utils.fix:find wet and dry masks

DEBUG:pyposeidon.utils.fix:fix wet points

DEBUG:pyposeidon.utils.fix:fix dry points

DEBUG:pyposeidon.utils.fix:assemble dataset

WARNING:pyposeidon.dem:Adjusting dem failed, keeping original values


ValueError Traceback (most recent call last)
Input In [77], in <cell line: 1>()
----> 1 dem = pdem.Dem(**geometry, coastlines = ne_i, dem_source=dem.Dataset, grid_x = x, grid_y = y,adjust_dem=True)

File ~/anaconda3/envs/pypos_main1/lib/python3.8/site-packages/pyposeidon/dem.py:79, in Dem.init(self, dem_source, **kwargs)
77 logger.info("Dem already adjusted\n")
78 else:
---> 79 self.adjust(coastline)

File ~/anaconda3/envs/pypos_main1/lib/python3.8/site-packages/pyposeidon/dem.py:91, in Dem.adjust(self, coastline, **kwargs)
89 if not check:
90 logger.warning("Adjusting dem failed, keeping original values\n")
---> 91 self.Dataset = self.Dataset.drop_vars("adjusted")

File ~/anaconda3/envs/pypos_main1/lib/python3.8/site-packages/xarray/core/dataset.py:4834, in Dataset.drop_vars(self, names, errors)
4832 names = set(names)
4833 if errors == "raise":
-> 4834 self._assert_all_in_dataset(names)
4836 # GH6505
4837 other_names = set()

File ~/anaconda3/envs/pypos_main1/lib/python3.8/site-packages/xarray/core/dataset.py:4801, in Dataset._assert_all_in_dataset(self, names, virtual_okay)
4799 bad_names -= self.virtual_variables
4800 if bad_names:
-> 4801 raise ValueError(
4802 "One or more of the specified variables "
4803 "cannot be found in this dataset"
4804 )

ValueError: One or more of the specified variables cannot be found in this dataset

@brey
Copy link
Collaborator

brey commented Aug 2, 2022

I am testing it on binder and it seems to work fine there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants