how to create a Grid1D variable
Closed this issue · 2 comments
First, I want to store my water level dataset to mikeio.DataArray, but it inform me "Geometry is required for ndim >=1" ,
and then I try to use Grid1D function to create my own Geometry, I found the parameter of "dx" is must to provided. So I checked my tide.dfs1 file created by Tide Prediction of Heights in MIKE 21 Toolbox, there exists a Grid Step that the parameter of "dx".
Now, I want to know how to confirm the value of 'dx' or Grid Step(m).
Thank you very much!
System information:
- Python version
- MIKE IO version
You can create a DataArray with a Grid1D geometry like this.
>>> import numpy as np
>>> import pandas as pd
>>> import mikeio
>>> data = np.zeros((10,2)) # example
>>> grid = mikeio.Grid1D(nx=2, dx=500) # this is how to create a Grid1D
>>> da = mikeio.DataArray(data=data, geometry=grid, time=pd.date_range("2000", freq='H', periods=10))
>>> da
<mikeio.DataArray>
name: NoName
dims: (time:10, x:2)
time: 2000-01-01 00:00:00 - 2000-01-01 09:00:00 (10 records)
geometry: Grid1D (n=2, dx=500)
>>> da.geometry.dx
500
That said, the grid spacing might not be used by model engine, since the tidal boundary is applied at the location specified in model setup, irrespective of the grid spacing in the dfs1 file, which is why we will change the default behavior to create a dummy Grid1D #494 unless specified.
So I can pick a random dx value to create my Grid1D geometry, and it has no effect on the model setup when I use a tidal file of dfs1 to setting my Boundary Conditions.
Thank you very much!