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

Adapt 2d boundary #29

Open
10 of 13 tasks
xldeltares opened this issue Jul 6, 2023 · 2 comments · May be fixed by #93
Open
10 of 13 tasks

Adapt 2d boundary #29

xldeltares opened this issue Jul 6, 2023 · 2 comments · May be fixed by #93
Assignees
Labels
enhancement New feature or request

Comments

@xldeltares
Copy link
Collaborator

xldeltares commented Jul 6, 2023

Kind of request

Changing existing functionality

Enhancement Description

In order to be consistent with 2D/3D requirements and in line with the effort in moving reading/writing into hydrolib-core Deltares/HYDROLIB-core#553, The use of 2d boundary needs to be adapted.

This involves mainly the writing of 2D boundary. For now in hydromt-delft3dfm, during setup, we set a hydromt forcing object (xarray.DataArray) with all data fields required by the hydrolin-core.ForcingModel as attributes. We need an extra step to convert that into a new xarray.DataArray with attributes that conforms the dflowfm convention. Then one could easily write the 2D boundary into .nc instead of .bc.

What needs to be adapted?

What followups needed?

How does the hydromt forcing object for 2D boundary looks like?

data
A 3D array holding the values of the DataArray. It is created from the 2D da data ("index", "time"), but expanded to a 3D shape to store support points on lines "numcoordinates". 

dims:
These are the names of the three dimensions:
index: Refers to the individual linestring geometry.
time: Represents the time steps from the original da DataArray.
numcoordinates: Refers to the individual coordinates within each linestring.

coords:
These are the actual coordinates that label the data along each dimension.
index: The original index from the GeoDataFrame.
time: The standardized time steps processed by _standardize_forcing_timeindexes.
numcoordinates: Represents the position of each coordinate within a linestring.
x: The x-coordinates of each linestring, structured to match the index and numcoordinates dimensions.
y: Similarly, the y-coordinates of each linestring.

attrs:
This dictionary holds metadata or attributes that provide additional context to the DataArray.
function: Indicates the data represents a time series.
timeInterpolation: Specifies the interpolation method used with the time data.
quantity: Represents the type of forcing, either 'dischargebnd' or 'waterlevelbnd'.
units: Specifies the unit for the forcing data, either 'm3/s' or 'm'.
time_unit: A string denoting the time unit, structured to indicate a starting point (like "hours since YYYY-MM-DD HH:MM:SS").

How does the 'Delft3D FM' netcdf convention looks like?

netcdf timeseries {
dimensions:
        strlen = 7 ;
        node = 3 ;
        time = UNLIMITED ; // (18 currently)
variables:
        double time(time) ;
                time:units = "hours since 2000-01-01 00:00:00" ;
        char location(node, strlen) ;
                location:cf_role = "timeseries_id" ;
        double x(node) ;
                x:axis = "x" ;
                x:units = "km" ;
                x:long_name = "x coordinate of projection" ;
                x:standard_name = "projection_x_coordinate" ;
        double y(node) ;
                y:axis = "y" ;
                y:units = "km" ;
                y:long_name = "y coordinate of projection" ;
                y:standard_name = "projection_y_coordinate" ;
        double rainfall(time, node) ;
                rainfall:long_name = "Rainfall" ;
                rainfall:standard_name = "precipitation" ;
                rainfall:units = "mm" ;
                  rainfall:_FillValue = "-999.9f" ;

Steps for hydromt_delft3dfm.utils._write_ncdicts

  • make sure a bndid is used for .pli, .nc and .ext.
  • For each bndid, write all support points into {bndid}.pli file.
  • For each bndid, write one timeseries for the first support point into {bndid}.nc file.
  • Use a xarray.Dataset internally for {bndid}.nc
  • Use quantity (e.g. "waterlevelbnd") in the xarray.Dataset as data variable to store the timeseries.
  • Use location (e.g. "polylin_0001") in the xarray.Dataset as data variable; because location label and quantity name uniquely identify the timeseries.
  • Use "strlen", "node" and "time" as dimensions, e.g. location(node, strlen); waterlevelbnd(time, node)

Additional Context

Use line geometry in geodataset is done in this issue below:
(#6)
Discussion of whether 2D boundary in 1D2D and 2D3D shares enough similarities yields the renaming of setup_2dboundary to setup_2dboundary_from_lines. So that it is clearer to the user that they are applying 2D boundary as lines, and each line accepts one timeseries - more common for 1D2D models.

Question

The fileformat required by 1D2D seems different from 2D3D as reported in Deltares/dfm_tools#527.

@xldeltares xldeltares self-assigned this Jul 6, 2023
@xldeltares xldeltares added bug Something isn't working enhancement New feature or request and removed bug Something isn't working labels Jul 6, 2023
@xldeltares
Copy link
Collaborator Author

Linked to issue: Deltares/dfm_tools#527
There is an example of the netcdf to conform to.

@xldeltares
Copy link
Collaborator Author

Something to discuss: for 1D2D urban type of models, it is rarely seen that the 2D boundary is as complex as 2D3D coastal models. If we enforce the 2D3D model, that might leads to large model files.

Why for 1D2D the 2D boundary is less complex? that is because in 1D2D urban applications, the 2D is mainly used for model overland flow. The water on the surface either come from overflow of underground sewer network, or overtopping from the river. for the former, we do not need to use 2D boundary while for the latter, often 1D2D links are used to simulate that. Besides that, one scenario is that we use 2D boundary to simulate the water flowing out of the domain instead of being bounded in the 2D mesh. Therefore, the initial condition and the boundary is often dry, or far less complex.

@xldeltares xldeltares linked a pull request Oct 10, 2023 that will close this issue
5 tasks
@xldeltares xldeltares linked a pull request Oct 24, 2023 that will close this issue
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant