From d7793b19f46baf73b644d8a2299a875aff989f32 Mon Sep 17 00:00:00 2001 From: ecomodeller Date: Thu, 29 Feb 2024 07:50:50 +0000 Subject: [PATCH] deploy: 31cf6bf3985dc1daecfa17c62782f8bb577de95f --- examples/Dfs2-Bathymetry.html | 44 +++++++++++------------ examples/Generic.html | 66 +++++++++++++++++------------------ examples/index.html | 8 ++--- index.html | 2 +- 4 files changed, 60 insertions(+), 60 deletions(-) diff --git a/examples/Dfs2-Bathymetry.html b/examples/Dfs2-Bathymetry.html index 813e28ebf..51550e88e 100644 --- a/examples/Dfs2-Bathymetry.html +++ b/examples/Dfs2-Bathymetry.html @@ -346,11 +346,11 @@

Dfs2 - Bathymetric data

GEBCO Compilation Group (2020) GEBCO 2020 Grid (doi:10.5285/a29c5465-b138-234d-e053-6c86abc040b9)

-
+
import xarray
 import mikeio
-
+
ds = xarray.open_dataset("../data/gebco_2020_n56.3_s55.2_w12.2_e13.1.nc")
 ds
@@ -732,7 +732,7 @@

Dfs2 - Bathymetric data

history: Information on the development of the data set and the sour... references: DOI: 10.5285/a29c5465-b138-234d-e053-6c86abc040b9 comment: The data in the GEBCO_2020 Grid should not be used for navi... - node_offset: 1.0
  • Conventions :
    CF-1.6
    title :
    The GEBCO_2020 Grid - a continuous terrain model for oceans and land at 15 arc-second intervals
    institution :
    On behalf of the General Bathymetric Chart of the Oceans (GEBCO), the data are held at the British Oceanographic Data Centre (BODC).
    source :
    The GEBCO_2020 Grid is the latest global bathymetric product released by the General Bathymetric Chart of the Oceans (GEBCO) and has been developed through the Nippon Foundation-GEBCO Seabed 2030 Project. This is a collaborative project between the Nippon Foundation of Japan and GEBCO. The Seabed 2030 Project aims to bring together all available bathymetric data to produce the definitive map of the world ocean floor and make it available to all.
    history :
    Information on the development of the data set and the source data sets included in the grid can be found in the data set documentation available from https://www.gebco.net
    references :
    DOI: 10.5285/a29c5465-b138-234d-e053-6c86abc040b9
    comment :
    The data in the GEBCO_2020 Grid should not be used for navigation or any purpose relating to safety at sea.
    node_offset :
    1.0
  • -
    +
    ds.elevation.plot();
    @@ -763,7 +763,7 @@

    Dfs2 - Bathymetric data

    -
    +
    ds.elevation.sel(lon=12.74792, lat=55.865, method="nearest")
    @@ -1141,17 +1141,17 @@

    Dfs2 - Bathymetric data

    sdn_parameter_urn: SDN:P01::BATHHGHT sdn_parameter_name: Sea floor height (above mean sea level) {bathymetric... sdn_uom_urn: SDN:P06::ULAA - sdn_uom_name: Metres
    + sdn_uom_name: Metres

    Check ordering of dimensions, should be (y,x)

    -
    +
    ds.elevation.dims
    ('lat', 'lon')
    -
    +
    el = ds.elevation.values
     el.shape
    @@ -1159,37 +1159,37 @@

    Dfs2 - Bathymetric data

    Check that axes are increasing, S->N W->E

    -
    +
    ds.lat.values[0],ds.lat.values[-1] 
    (55.20208333333332, 56.29791666666665)
    -
    +
    ds.lat.values[0] < ds.lat.values[-1] 
    True
    -
    +
    ds.lon.values[0],ds.lon.values[-1] 
    (12.20208333333332, 13.097916666666663)
    -
    +
    el[0,0] # Bottom left
    -8
    -
    +
    el[-1,0] # Top Left
    -31
    -
    +
    geometry = mikeio.Grid2D(x=ds.lon.values, y=ds.lat.values, projection="LONG/LAT")
     geometry
    @@ -1199,7 +1199,7 @@

    Dfs2 - Bathymetric data

    projection: LONG/LAT
    -
    +
    da = mikeio.DataArray(data=el,
                    item=mikeio.ItemInfo("Elevation", mikeio.EUMType.Total_Water_Depth),
                    geometry=geometry,
    @@ -1214,7 +1214,7 @@ 

    Dfs2 - Bathymetric data

    geometry: Grid2D (ny=264, nx=216)
    -
    +
    da.plot();
    @@ -1224,7 +1224,7 @@

    Dfs2 - Bathymetric data

    -
    +
    da.plot(cmap='coolwarm', vmin=-100, vmax=100);
    @@ -1234,10 +1234,10 @@

    Dfs2 - Bathymetric data

    -
    +
    da.to_dfs("gebco.dfs2")
    -
    +
    ds = mikeio.read("gebco.dfs2")
     ds.Elevation.plot()
    @@ -1250,7 +1250,7 @@

    Dfs2 - Bathymetric data

    Clean up

    -
    +
    import os
     
     os.remove("gebco.dfs2")
    diff --git a/examples/Generic.html b/examples/Generic.html index e50d7335e..8025422c3 100644 --- a/examples/Generic.html +++ b/examples/Generic.html @@ -365,7 +365,7 @@

    Generic dfs processing

  • quantile: Create temporal quantiles of dfs file
  • -
    +
    import matplotlib.pyplot as plt
     import mikeio
     import mikeio.generic
    @@ -373,7 +373,7 @@

    Generic dfs processing

    Concatenation

    Take a look at these two files with overlapping timesteps.

    -
    +
    t1 = mikeio.read("../data/tide1.dfs1")
     t1
    @@ -385,7 +385,7 @@

    Concatenation

    0: Level <Water Level> (meter)
    -
    +
    t2 = mikeio.read("../data/tide2.dfs1")
     t2
    @@ -398,7 +398,7 @@

    Concatenation

    Plot one of the points along the line.

    -
    +
    plt.plot(t1.time,t1[0].isel(x=1).values, label="File 1")
     plt.plot(t2.time,t2[0].isel(x=1).values,'k+', label="File 2")
     plt.legend()
    @@ -410,15 +410,15 @@

    Concatenation

    -
    +
    mikeio.generic.concat(infilenames=["../data/tide1.dfs1",
                                        "../data/tide2.dfs1"],
                          outfilename="concat.dfs1")
    -
      0%|          | 0/2 [00:00<?, ?it/s]100%|██████████| 2/2 [00:00<00:00, 547.10it/s]
    +
      0%|          | 0/2 [00:00<?, ?it/s]100%|██████████| 2/2 [00:00<00:00, 625.78it/s]
    -
    +
    c = mikeio.read("concat.dfs1")
     c[0].isel(x=1).plot()
     c
    @@ -442,16 +442,16 @@

    Concatenation

    Difference between two files

    Take difference between two dfs files with same structure - e.g. to see the difference in result between two calibration runs

    -
    +
    fn1 = "../data/oresundHD_run1.dfsu"
     fn2 = "../data/oresundHD_run2.dfsu"
     fn_diff = "oresundHD_difference.dfsu"
     mikeio.generic.diff(fn1, fn2, fn_diff)
    -
      0%|          | 0/5 [00:00<?, ?it/s]100%|██████████| 5/5 [00:00<00:00, 2635.61it/s]
    +
      0%|          | 0/5 [00:00<?, ?it/s]100%|██████████| 5/5 [00:00<00:00, 2611.65it/s]
    -
    +
    _, ax = plt.subplots(1,3, sharey=True, figsize=(12,5))
     da = mikeio.read(fn1, time=-1)[0]
     da.plot(vmin=0.06, vmax=0.27, ax=ax[0], title='run 1')
    @@ -475,11 +475,11 @@ 

    Extract time s
  • time slice by specifying start and/or end
  • specific items
  • -
    +
    infile = "../data/tide1.dfs1"
     mikeio.generic.extract(infile, "extracted.dfs1", start='2019-01-02')
    -
    +
    e = mikeio.read("extracted.dfs1")
     e
    @@ -491,11 +491,11 @@

    Extract time s 0: Level <Water Level> (meter)

    -
    +
    infile = "../data/oresund_vertical_slice.dfsu"
     mikeio.generic.extract(infile, "extracted.dfsu", items='Salinity', end=-2)
    -
    +
    e = mikeio.read("extracted.dfsu")
     e
    @@ -516,7 +516,7 @@

    Extract time s

    Scaling

    Adding a constant e.g to adjust datum

    -
    +
    ds = mikeio.read("../data/gebco_sound.dfs2")
     ds.Elevation[0].plot();
    @@ -527,23 +527,23 @@

    Scaling

    -
    +
    ds['Elevation'][0,104,131].to_numpy()
    -1.0

    This is the processing step.

    -
    +
    mikeio.generic.scale("../data/gebco_sound.dfs2", 
                          "gebco_sound_local_datum.dfs2",
                          offset=-2.1
                          )
    -
      0%|          | 0/1 [00:00<?, ?it/s]100%|██████████| 1/1 [00:00<00:00, 1922.23it/s]
    +
      0%|          | 0/1 [00:00<?, ?it/s]100%|██████████| 1/1 [00:00<00:00, 1024.25it/s]
    -
    +
    ds2 = mikeio.read("gebco_sound_local_datum.dfs2")
     ds2['Elevation'][0].plot()
    @@ -554,7 +554,7 @@

    Scaling

    -
    +
    ds2['Elevation'][0,104,131].to_numpy()
    -3.1
    @@ -562,7 +562,7 @@

    Scaling

    Spatially varying correction

    -
    +
    import numpy as np
     factor = np.ones_like(ds['Elevation'][0].to_numpy())
     factor.shape
    @@ -571,7 +571,7 @@

    Spatially var

    Add some spatially varying factors, exaggerated values for educational purpose.

    -
    +
    factor[:,0:100] = 5.3
     factor[0:40,] = 0.1
     factor[150:,150:] = 10.7
    @@ -586,7 +586,7 @@ 

    Spatially var

    The 2d array must first be flipped upside down and then converted to a 1d vector using numpy.ndarray.flatten to match how data is stored in dfs files.

    -
    +
    factor_ud = np.flipud(factor)
     factor_vec  = factor_ud.flatten()
     mikeio.generic.scale("../data/gebco_sound.dfs2", 
    @@ -594,10 +594,10 @@ 

    Spatially var factor=factor_vec )

    -
      0%|          | 0/1 [00:00<?, ?it/s]100%|██████████| 1/1 [00:00<00:00, 1294.94it/s]
    +
      0%|          | 0/1 [00:00<?, ?it/s]100%|██████████| 1/1 [00:00<00:00, 1678.39it/s]
    -
    +
    ds3 = mikeio.read("gebco_sound_spatial.dfs2")
     ds3.Elevation[0].plot();
    @@ -612,15 +612,15 @@

    Spatially var

    Time average

    -
    +
    fn = "../data/NorthSea_HD_and_windspeed.dfsu"
     fn_avg = "Avg_NorthSea_HD_and_windspeed.dfsu"
     mikeio.generic.avg_time(fn, fn_avg)
    -
      0%|          | 0/66 [00:00<?, ?it/s]100%|██████████| 66/66 [00:00<00:00, 16318.32it/s]
    +
      0%|          | 0/66 [00:00<?, ?it/s]100%|██████████| 66/66 [00:00<00:00, 18074.17it/s]
    -
    +
    ds = mikeio.read(fn)
     ds.mean(axis=0).describe()   # alternative way of getting the time average
    @@ -684,7 +684,7 @@

    Time average

    -
    +
    ds_avg = mikeio.read(fn_avg)
     ds_avg.describe()
    @@ -752,12 +752,12 @@

    Time average

    Quantile

    Example that calculates the 25%, 50% and 75% percentile for all items in a dfsu file.

    -
    +
    fn = "../data/NorthSea_HD_and_windspeed.dfsu"
     fn_q = "Q_NorthSea_HD_and_windspeed.dfsu"
     mikeio.generic.quantile(fn, fn_q, q=[0.25,0.5,0.75])
    -
    +
    ds = mikeio.read(fn_q)
     ds
    @@ -774,7 +774,7 @@

    Quantile

    5: Quantile 0.75, Wind speed <Wind speed> (meter per sec)
    -
    +
    da_q75 = ds["Quantile 0.75, Wind speed"]
     da_q75.plot(title="75th percentile, wind speed", label="m/s")
    @@ -788,7 +788,7 @@

    Quantile

    Clean up

    -
    +
    import os
     os.remove("concat.dfs1")
     os.remove("oresundHD_difference.dfsu")
    diff --git a/examples/index.html b/examples/index.html
    index 3e8662c28..4e2c648fb 100644
    --- a/examples/index.html
    +++ b/examples/index.html
    @@ -391,7 +391,7 @@ 

    Examples

    - + Dfs2 - Bathymetric data @@ -399,7 +399,7 @@

    Examples

    Convert GEBCO 2020 NetCDF to dfs2 - + Dfsu - 2D interpolation @@ -407,7 +407,7 @@

    Examples

    Interpolate dfsu data to a grid, save as dfs2 and geotiff. Interpolate dfsu data to another mesh. - + Generic dfs processing @@ -415,7 +415,7 @@

    Examples

    - + Time interpolation diff --git a/index.html b/index.html index a1c1982c8..2603315c9 100644 --- a/index.html +++ b/index.html @@ -359,7 +359,7 @@

    Installation

    Getting started

    -
    +
    import mikeio
     
     ds = mikeio.read("data/FakeLake.dfsu")