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

assign 'dem_source': string to xr.Dataset in shism.py #172

Open
tomsail opened this issue Dec 13, 2023 · 2 comments
Open

assign 'dem_source': string to xr.Dataset in shism.py #172

tomsail opened this issue Dec 13, 2023 · 2 comments

Comments

@tomsail
Copy link
Collaborator

tomsail commented Dec 13, 2023

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
Copy link
Collaborator

brey commented Jan 21, 2024

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
Copy link
Collaborator

pmav99 commented Jan 21, 2024

That might work, but hasattr(dem, "Dataset") is probably a little bit cleaner.

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

3 participants