Configure update option
Closed this issue · 4 comments
This is a control on model building to exclude features such as update dem, meteo, etc. It's not fully integrated.
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?
The if dem.exists()
line in oceamesh implies that dem
is expected to be a pathlib.Path
object on which they call the .exists()
method.
Instead of a pathlib.Path
object you pass an xarray.Dataset
object. That's why the exception gets thrown.
If I remember well, self.dem
is an instance of the Dem
class which has an attribute named Dataset
which is an instance of xarray Dataset. Check the other attributes and you may find a path to the DEM file. If there is such an attribute, pass that one to oceamesh. If the DEM has been downloaded from the internet then you may need to save it in a temporary file
If I remember well,
self.dem
is an instance of theDem
class which has an attribute namedDataset
which is an instance of xarray Dataset. Check the other attributes and you may find a path to the DEM file. If there is such an attribute, pass that one to oceamesh. If the DEM has been downloaded from the internet then you may need to save it in a temporary file
that's why I am asking if it is really necessary.
If self.dem
is an xarray, why should self.dem_source
(originary a path) be replaced by self.dem
?
Having both as xarray is redundant