From 89e322260af25dd63ca885be240db78a0844c5fb Mon Sep 17 00:00:00 2001 From: Henrik Andersson Date: Thu, 22 Feb 2024 19:01:21 +0100 Subject: [PATCH] Design --- docs/_quarto.yml | 2 ++ docs/{user-guide => }/design.md | 0 docs/user-guide/dataarray.qmd | 2 +- docs/user-guide/dataset.qmd | 2 +- docs/user-guide/generic.md | 18 +++++++++--------- docs/user-guide/pfs.qmd | 10 +++++----- mikeio/generic.py | 6 +++--- pyproject.toml | 1 + 8 files changed, 22 insertions(+), 19 deletions(-) rename docs/{user-guide => }/design.md (100%) diff --git a/docs/_quarto.yml b/docs/_quarto.yml index fb16469a4..c7e3bb238 100644 --- a/docs/_quarto.yml +++ b/docs/_quarto.yml @@ -51,6 +51,8 @@ website: - examples/Dfsu-2D-interpolation.qmd - examples/Time-interpolation.qmd - examples/Generic.qmd + - text: Design philosophy + href: design.md - text: API Reference href: api/index.qmd diff --git a/docs/user-guide/design.md b/docs/design.md similarity index 100% rename from docs/user-guide/design.md rename to docs/design.md diff --git a/docs/user-guide/dataarray.qmd b/docs/user-guide/dataarray.qmd index a089b6384..9cde697d4 100644 --- a/docs/user-guide/dataarray.qmd +++ b/docs/user-guide/dataarray.qmd @@ -1,4 +1,4 @@ -# {{< fa database >}} DataArray +# DataArray The [DataArray](`mikeio.DataArray`) is the common MIKE IO data structure for *item* data from dfs files. diff --git a/docs/user-guide/dataset.qmd b/docs/user-guide/dataset.qmd index 187c7097f..5587497a6 100644 --- a/docs/user-guide/dataset.qmd +++ b/docs/user-guide/dataset.qmd @@ -1,4 +1,4 @@ -# {{< fa database >}} Dataset +# Dataset The [Dataset](`mikeio.Dataset`) is the MIKE IO data structure for data from dfs files. diff --git a/docs/user-guide/generic.md b/docs/user-guide/generic.md index 51632de24..69ff0bdbc 100644 --- a/docs/user-guide/generic.md +++ b/docs/user-guide/generic.md @@ -1,14 +1,14 @@ # Generic -The generic module contains functionality that works for all dfs files: - -* [`concat()`](generic.concat) - Concatenates files along the time axis -* [`extract()`](generic.extract) - Extract timesteps and/or items to a new dfs file -* [`diff()`](generic.diff) - Calculate difference between two dfs files with identical geometry -* [`sum()`](generic.sum) - Calculate the sum of two dfs files -* [`scale()`](generic.scale) - Apply scaling to any dfs file -* [`avg_time()`](generic.avg_time) - Create a temporally averaged dfs file -* [`quantile()`](generic.quantile) - Create a dfs file with temporal quantiles +The generic module contains functionality that works for all types of dfs (dfs0, dfs1, dfs2, dfs3, dfsu) files: + +* [`concat()`](`mikeio.generic.concat`) - Concatenates files along the time axis +* [`extract()`](`mikeio.generic.extract`) - Extract timesteps and/or items to a new dfs file +* [`diff()`](`mikeio.generic.diff`) - Calculate difference between two dfs files with identical geometry +* [`sum()`](`mikeio.generic.sum`) - Calculate the sum of two dfs files +* [`scale()`](`mikeio.generic.scale`) - Apply scaling to any dfs file +* [`avg_time()`](`mikeio.generic.avg_time`) - Create a temporally averaged dfs file +* [`quantile()`](`mikeio.generic.quantile`) - Create a dfs file with temporal quantiles diff --git a/docs/user-guide/pfs.qmd b/docs/user-guide/pfs.qmd index 6cfa2858a..d25bdbfd8 100644 --- a/docs/user-guide/pfs.qmd +++ b/docs/user-guide/pfs.qmd @@ -30,7 +30,7 @@ EndSect // TARGET2 When a PFS file is read with MIKE IO, a `PfsDocument` object is created. It will contain one or more `PfsSection` objects - one for each target. The PfsSections will typically contain other PfsSections together with a number of key-value pairs. -A PFS file is read using `mikeio.read_pfs()`: +A PFS file is read using [](`mikeio.read_pfs`): ```{python} import mikeio @@ -41,7 +41,7 @@ pfs ### PfsDocument -The `PfsDocument` is the MIKE IO equivalent to a PFS file. Its targets can be accessed by their name (as properties), like this: +The [](`-mikeio.PfsDocument`) is the MIKE IO equivalent to a PFS file. Its targets can be accessed by their name (as properties), like this: ```{python} pfs.txconc @@ -49,12 +49,12 @@ pfs.txconc Or by the `pfs.targets` object (which is a list of PfsSections). Each of the targets is a `PfsSection` object consisting of key-value pairs (keyword-parameter) and other PfsSections. -The `PfsDocument` object is similar to a dictionary. You can loop over its contents with `items()`, `keys()` and `values()` like a dictionary. +The [](`-mikeio.PfsDocument`) object is similar to a dictionary. You can loop over its contents with `items()`, `keys()` and `values()` like a dictionary. ### PfsSection -The `PfsSection` object is also similar to a dictionary. You can loop over its contents with `items()`, `keys()` and `values()` like a dictionary. +The [](`-mikeio.PfsSection`) object is also similar to a dictionary. You can loop over its contents with `items()`, `keys()` and `values()` like a dictionary. ```{python} pfs.txconc.keys() @@ -88,7 +88,7 @@ pfs.txconc.Setup.to_dataframe(prefix="File_") ### Unique or non-unique keywords -Depending on the engine intended for reading the PFS file it may or may not make sense to have multiple identical keywords in the same PfsSection. MIKE 21/3 and the marine tools does *not* support non-unique keywords---if non-unique keywords are present, only the first will be read and the presence is most likely a mistake made by hand-editing the file. In other tools, e.g. MIKE Plot Composer, non-unique keywords are used a lot. How MIKE IO shall deal with non-unique keywords can be specified using the `unique_keywords` argument in the `read_pfs()` method: +Depending on the engine intended for reading the PFS file it may or may not make sense to have multiple identical keywords in the same PfsSection. MIKE 21/3 and the marine tools does *not* support non-unique keywords---if non-unique keywords are present, only the first will be read and the presence is most likely a mistake made by hand-editing the file. In other tools, e.g. MIKE Plot Composer, non-unique keywords are used a lot. How MIKE IO shall deal with non-unique keywords can be specified using the `unique_keywords` argument in the [](`-mikeio.read_pfs`) function: ```python pfs = mikeio.read_pfs("myplot.plt", unique_keywords=False) diff --git a/mikeio/generic.py b/mikeio/generic.py index df3cf1945..b047a7328 100644 --- a/mikeio/generic.py +++ b/mikeio/generic.py @@ -437,11 +437,11 @@ def concat( Parameters ---------- - infilenames: List[str] + infilenames: filenames to concatenate - outfilename: str | pathlib.Path + outfilename: filename of output - keep: str | pathlib.Path + keep: either 'first' (keep older), 'last' (keep newer) or 'average' can be selected. By default 'last' diff --git a/pyproject.toml b/pyproject.toml index 12ba103b8..5f94cb3de 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -66,6 +66,7 @@ notebooks= [ "jupyter", "xarray", "netcdf4", + "rasterio", "geopandas", "scikit-learn", "matplotlib",