Skip to content

Commit

Permalink
Added a cheat sheet
Browse files Browse the repository at this point in the history
  • Loading branch information
priscavdsluis committed Nov 13, 2023
1 parent b5a3461 commit ed54dce
Showing 1 changed file with 43 additions and 1 deletion.
44 changes: 43 additions & 1 deletion docs/tutorials/dsd_2023/instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
- [Requirements](#requirements)
- [Installation](#installation)
- [Run the demo notebook](#run-the-demo-notebook)
- [Cheat sheet](#cheat-sheet)
- [Kernel files vs HYDROLIB-core FileModels](#kernel-files-vs-hydrolib-core-filemodels)
- [Commonly used functions of a FileModel](#commonly-used-functions-of-a-filemodel)


## Introduction
This document contains instructions about the installation and usage of HYDROLIB-core during the Delft Software Days 2023.
Expand Down Expand Up @@ -67,4 +71,42 @@ conda activate dsd_env
```
jupyter notebook
```
4. Open the *demo.ipynb* inside the *demo* folder
4. Open the *demo.ipynb* inside the *demo* folder

## Cheat sheet

In HYDROLIB-core, there is a class called FileModel, which is used to represent an individual kernel file. This class has multiple derived implementations, with each one corresponding to a specific kernel file. Every FileModel, except for the root model, is referenced within another FileModel, following the same hierarchy as the kernel files themselves.

The table below contains the models relevant for today's exercises.

### Kernel files vs HYDROLIB-core FileModels
| **Kernel file** | **FileModel (Python class in HYDROLIB-core)** | **File reference** |
|--------------------------------------------- |------------------ |------------------------------------------------------------ |
| Model definition file (*.mdu) | FMModel | - |
| Network file (*_net.nc) | NetworkModel | Model definition file > geometry > netFile |
| Cross-section location file (crosloc.ini) | CrossLocModel | Model definition file > geometry > crossLocFile |
| Cross-section definition file (crosdef.ini) | CrossDefModel | Model definition file > geometry > crossDefFile |
| Roughness file (roughness-*.ini) | FrictionModel | Model definition file > geometry > frictFile |
| New external forcing file (*_bnd.ext) | ExtModel | Model definition file > external forcing > extForceFileNew |
| Boundary conditions file (*.bc) | ForcingModel | New external forcing file > boundary > forcingFile |
| 1D initial conditions field file (*.ini) | OneDFieldModel | Initial field file > initial > dataFile |
| Initial field file (*.ini) | IniFieldModel | Model definition file > geometry > iniFieldFile |
| Structures file (structures.ini) | StructureModel | Model definition file > geometry > structureFile |

### Commonly used functions of a FileModel
Each FileModel offers a set of commonly used functions.

**__init__(): Initialize a new file model instance**
Parameters (all optional):
* `filepath (Path)`: The file path from which the file model should be loaded. Default to None.
* `resolve_casing (bool)`: Whether or not to resolve the file name references so that they match the case with what is on disk. Defaults to False.
* `recurse (bool)`: Whether or not to recursively load the model. Defaults to True.
* `path_style (str)`: Which path style is used in the loaded files. Options: 'unix', 'windows'. Defaults to the path style that matches the current operating system.

**save(): Export the file model data to a file**
Parameters (all optional):
* `filepath (Path)`: The file path at which this model is saved. If None is specified it defaults to the filepath currently stored in the filemodel. Defaults to None.
* `recurse (bool)`: Whether or not to recursively save all children of this file model, or only save this model. Defaults to False.
* `path_style (str)`: With which file path style to save the model. File references will be written with the specified path style. Options: 'unix', 'windows'. Defaults to the path style used by the current operating system.

**show_tree(): Print the file model tree**

0 comments on commit ed54dce

Please sign in to comment.