import pandas as pd
import mikeio
= pd.DataFrame(dict(station=["Foo", "Bar"],include=[0,1]), index=[1,2])
df df
station | include | |
---|---|---|
1 | Foo | 0 |
2 | Bar | 1 |
Create a PfsDocument object for reading, writing and manipulating pfs files.
Name | Type | Description | Default |
---|---|---|---|
data | TextIO | PfsSection | Mapping[str | PfsSection, Any] | str | Path | Either a file name (including full path) to the pfs file to be read or dictionary-like structure. | required |
encoding | str | How is the pfs file encoded? By default cp1252 | 'cp1252' |
unique_keywords | bool | Should the keywords in a section be unique? Some tools e.g. the MIKE Plot Composer allows non-unique keywords. If True: warnings will be issued if non-unique keywords are present and the first occurence will be used by default False | False |
Name | Description |
---|---|
is_unique | Are the target (root) names unique? |
n_targets | Number of targets (root sections). |
names | Names of the targets (root sections) as a list. |
targets | List of targets (root sections). |
Name | Description |
---|---|
clear | Remove all items from the PfsSection. |
copy | Return a deep copy of the PfsDocument. |
find_replace | Update recursively all old_value with new_value. |
from_dataframe | Create a PfsSection from a DataFrame. |
from_text | Create a PfsDocument from a string. |
get | Return the value for key if key is in the PfsSection, |
items | Return a new view of the PfsDocument’s items ((key, value) pairs). |
keys | Return a list of the PfsDocument’s keys (target names). |
pop | If key is in the dictionary, remove it and return its |
search | Find recursively all keys, sections or parameters |
to_dataframe | Output enumerated subsections to a DataFrame. |
to_dict | Convert to (nested) dict (as a copy). |
update_recursive | Update recursively all matches of key with value. |
values | Return a list of the PfsDocument’s values (targets). |
write | Write object to a pfs file. |
Remove all items from the PfsSection.
Return a deep copy of the PfsDocument.
Update recursively all old_value with new_value.
Create a PfsSection from a DataFrame.
Name | Type | Description | Default |
---|---|---|---|
df | pd.DataFrame | data | required |
prefix | str | section header prefix | required |
Create a PfsDocument from a string.
Return the value for key if key is in the PfsSection, else default. If default is not given, it defaults to None, so that this method never raises a KeyError.
Return a new view of the PfsDocument’s items ((key, value) pairs).
Return a list of the PfsDocument’s keys (target names).
If key is in the dictionary, remove it and return its value, else return default. If default is not given and key is not in the dictionary, a KeyError is raised.
Find recursively all keys, sections or parameters matching a pattern.
NOTE: logical OR between multiple conditions
Name | Type | Description | Default |
---|---|---|---|
text | str | Search for text in either key, section or parameter, by default None | None |
key | str | text pattern to seach for in keywords, by default None | None |
section | str | text pattern to seach for in sections, by default None | None |
param | (str, bool, float, int) | text or value in a parameter, by default None | None |
case | bool | should the text search be case-sensitive?, by default False | False |
Name | Type | Description |
---|---|---|
PfsSection | Search result as a nested PfsSection |
Output enumerated subsections to a DataFrame.
Name | Type | Description | Default |
---|---|---|---|
prefix | str | The prefix of the enumerated sections, e.g. “OUTPUT_”, which can be supplied if it fails without this argument, by default None (will try to “guess” the prefix) | None |
Name | Type | Description |
---|---|---|
pd.DataFrame | The enumerated subsections as a DataFrame |
Touched | include | title | file_name | type | format | flood_and_dry | coordinate_type | zone | input_file_name | ... | last_time_step | time_step_frequency | number_of_points | POINT_1 | LINE | AREA | INTEGRAL_WAVE_PARAMETERS | INPUT_PARAMETERS | MODEL_PARAMETERS | SPECTRAL_PARAMETERS | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | 1 | 1 | Wave parameters in domain | Wave_parameters.dfsu | 1 | 2 | 2 | UTM-32 | 0 | || | ... | 450 | 10 | 1 | {'name': 'POINT_1', 'x': 20000.0, 'y': 20000.0} | {'npoints': 3, 'x_first': 0.0, 'y_first': 0.0,... | {'number_of_points': 4, 'POINT_1': {'x': -400.... | {'Touched': 1, 'type_of_spectrum': 1, 'minimum... | {'Touched': 1, 'Surface_elevation': 0, 'Water_... | {'Touched': 1, 'Wind_friction_speed': 0, 'Roug... | {'Touched': 1, 'separation_of_wind_sea_and_swe... |
2 | 1 | 0 | Wave parameters along line | Wave_line.dfs1 | 1 | 1 | 2 | UTM-32 | 0 | || | ... | 450 | 10 | 1 | {'name': 'POINT_1', 'x': 20000.0, 'y': 20000.0} | {'npoints': 41, 'x_first': 0.0, 'y_first': 200... | {'number_of_points': 4, 'POINT_1': {'x': -400.... | {'Touched': 1, 'type_of_spectrum': 1, 'minimum... | {'Touched': 1, 'Surface_elevation': 0, 'Water_... | {'Touched': 1, 'Wind_friction_speed': 0, 'Roug... | {'Touched': 1, 'separation_of_wind_sea_and_swe... |
3 | 1 | 1 | Wave parameters in a point | Waves_x20km_y20km.dfs0 | 1 | 0 | 2 | UTM-32 | 0 | || | ... | 450 | 1 | 1 | {'name': 'POINT_1', 'x': 38000.0, 'y': 20000.0} | {'npoints': 3, 'x_first': 0.0, 'y_first': 0.0,... | {'number_of_points': 4, 'POINT_1': {'x': -400.... | {'Touched': 1, 'type_of_spectrum': 1, 'minimum... | {'Touched': 1, 'Surface_elevation': 0, 'Water_... | {'Touched': 1, 'Wind_friction_speed': 0, 'Roug... | {'Touched': 1, 'separation_of_wind_sea_and_swe... |
4 | 1 | 1 | Spectrum in a point | spectrum_x20km_y20km.dfsu | 4 | 0 | 2 | UTM-32 | 0 | || | ... | 450 | 10 | 1 | {'name': 'POINT_1', 'x': 38000.0, 'y': 20000.0} | {'npoints': 3, 'x_first': 0.0, 'y_first': 0.0,... | {'number_of_points': 4, 'POINT_1': {'x': -400.... | {'Touched': 1, 'type_of_spectrum': 1, 'minimum... | {'Touched': 1, 'Surface_elevation': 0, 'Water_... | {'Touched': 1, 'Wind_friction_speed': 0, 'Roug... | {'Touched': 1, 'separation_of_wind_sea_and_swe... |
4 rows × 24 columns
Convert to (nested) dict (as a copy).
Update recursively all matches of key with value.
Return a list of the PfsDocument’s values (targets).
Write object to a pfs file.
Name | Type | Description | Default |
---|---|---|---|
filename | str | Full path and filename of pfs to be created. | required |
To return the content as a string, use repr()