assign 'dem_source': string to xr.Dataset in shism.py
Opened this issue · 2 comments
tomsail commented
I have a problem at this line when using the sizing from oceanmesh:
Traceback (most recent call last):
File "/home/tomsail/work/python/pyPoseidon/Tutorial/mesh_model_test.py", line 40, in <module>
b.create()
File "/home/tomsail/work/python/pyPoseidon/pyposeidon/schism.py", line 455, in create
self.mesh = pmesh.set(type="tri2d", **kwargs)
File "/home/tomsail/work/python/pyPoseidon/pyposeidon/mesh.py", line 36, in set
return tri2d(**kwargs)
File "/home/tomsail/work/python/pyPoseidon/pyposeidon/mesh.py", line 226, in __init__
g, bg = moceanmesh.get(self.boundary.contours, **kwargs) # create mesh with OCEANMESH
File "/home/tomsail/work/python/pyPoseidon/pyposeidon/moceanmesh.py", line 136, in get
gr = make_oceanmesh(contours, **kwargs)
File "/home/tomsail/work/python/pyPoseidon/pyposeidon/moceanmesh.py", line 411, in make_oceanmesh
dem = om.DEM(dem_source, crs=crs, bbox=extent)
File "/home/tomsail/work/python/pyPoseidon/Tutorial/.venv/lib/python3.10/site-packages/oceanmesh/geodata.py", line 777, in __init__
if dem.exists():
File "/home/tomsail/work/python/pyPoseidon/Tutorial/.venv/lib/python3.10/site-packages/xarray/core/common.py", line 278, in __getattr__
raise AttributeError(
AttributeError: 'Dataset' object has no attribute 'exists'
This is cause by the update of this line :
kwargs.update({"dem_source": self.dem.Dataset})
is that line really needed ? since we already have the variable self.dem attributed?
Problem mentioned in #114 but I am opening a new issue here.
FIY I removed that line in the telemac.py (coming soon on my fork)
brey commented
I think the problem is with the test if dem.exists()
.
dem should be an instance with dem.Dataset
as the xarray
object. On the other hand the dem_source
is an attribute of the model
class indicating the source for the dem.
If you want to check if the Dataset exists in the instance then maybe:
'Dataset' in dem.__dict__
pmav99 commented
That might work, but hasattr(dem, "Dataset")
is probably a little bit cleaner.