Sample files¶
Sample .xyz files contain spatial input point data for a D-Flow FM model, and are used in various other input files.
A sample data file is described by the classes below.
Model¶
XYZModel
¶
Bases: ParsableFileModel
Sample or forcing file.
Attributes:
Source code in hydrolib/core/dflowfm/xyz/models.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
|
XYZPoint
¶
Bases: BaseModel
Single sample or forcing point.
Attributes:
Name | Type | Description |
---|---|---|
x |
float
|
x or λ coordinate |
y |
float
|
y or φ coordinate |
z |
float
|
sample value or group number (forcing) |
comment |
Optional[str]
|
keyword for grouping (forcing) |
Source code in hydrolib/core/dflowfm/xyz/models.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
|
Parser¶
XYZParser
¶
A parser for .xyz files which are like this:
number number number number number number # comment
Note that the whitespace can vary and the comment left out.
Source code in hydrolib/core/dflowfm/xyz/parser.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
|
parse(filepath)
staticmethod
¶
Parse an .xyz file into a Dict with the list of points read.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filepath
|
Path
|
.xyz file to be read. |
required |
Returns:
Name | Type | Description |
---|---|---|
Dict |
Dict
|
dictionary with "points" value set to a list of points each of which is a dict itself, with keys 'x', 'y', 'z' and 'c' for an optional comment. |
Raises:
Type | Description |
---|---|
ValueError
|
if a line in the file contains no values that could be parsed. |
Source code in hydrolib/core/dflowfm/xyz/parser.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
|
Serializer¶
XYZSerializer
¶
Source code in hydrolib/core/dflowfm/xyz/serializer.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
|
serialize(path, data, config, save_settings)
staticmethod
¶
Serializes the XYZ data to the file at the specified path.
Attributes:
Name | Type | Description |
---|---|---|
path |
Path
|
The path to the destination file. |
data |
Dict
|
The data to be serialized. |
config |
SerializerConfig
|
The serialization configuration. |
save_settings |
ModelSaveSettings
|
The model save settings. |
Source code in hydrolib/core/dflowfm/xyz/serializer.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
|