{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Gridded NetCDF modelresults\n", "\n", "2D modelresults stored in NetCDF or Grib can be loaded to ModelSkill\n", "using xarray. In this way, MIKE 21 modelresults in dfsu format can\n", "easily be compared to model results from third party providers often\n", "stored in NetCDF." ], "id": "90a72bde-bcfb-4181-a001-68767592f08b" }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import xarray as xr\n", "import modelskill as ms" ], "id": "a8985d75" }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Observations" ], "id": "d722ccc0-5787-45d5-b1da-5c29b9fdbce5" }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "o1 = ms.PointObservation('../data/SW/HKNA_Hm0.dfs0', item=0, x=4.2420, y=52.6887, name=\"HKNA\")\n", "o2 = ms.PointObservation(\"../data/SW/eur_Hm0.dfs0\", item=0, x=3.2760, y=51.9990, name=\"EPL\")\n", "o3 = ms.TrackObservation(\"../data/SW/Alti_c2_Dutch.dfs0\", item=3, name=\"c2\")" ], "id": "db782ac6" }, { "cell_type": "markdown", "metadata": {}, "source": [ "## MIKE ModelResult" ], "id": "13078335-2431-411d-8215-b7747013afbd" }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "mrMIKE = ms.model_result('../data/SW/HKZN_local_2017_DutchCoast.dfsu', name='MIKE21SW', item=0)" ], "id": "74868e03" }, { "cell_type": "markdown", "metadata": {}, "source": [ "## NetCDF ModelResult" ], "id": "fe25822b-524f-4a88-a811-387a8ef63a52" }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "output_type": "display_data", "metadata": {}, "data": { "text/html": [ "
<xarray.Dataset> Size: 590kB\n", "Dimensions: (longitude: 20, latitude: 11, time: 67)\n", "Coordinates:\n", " * longitude (longitude) float32 80B -1.0 -0.5 0.0 0.5 1.0 ... 7.0 7.5 8.0 8.5\n", " * latitude (latitude) float32 44B 55.0 54.5 54.0 53.5 ... 51.0 50.5 50.0\n", " * time (time) datetime64[ns] 536B 2017-10-27 ... 2017-10-29T18:00:00\n", "Data variables:\n", " mwd (time, latitude, longitude) float64 118kB ...\n", " mwp (time, latitude, longitude) float64 118kB ...\n", " mp2 (time, latitude, longitude) float64 118kB ...\n", " pp1d (time, latitude, longitude) float64 118kB ...\n", " swh (time, latitude, longitude) float64 118kB ...\n", "Attributes:\n", " Conventions: CF-1.6\n", " history: 2021-06-07 12:25:02 GMT by grib_to_netcdf-2.16.0: /opt/ecmw...
<xarray.Dataset> Size: 119kB\n", "Dimensions: (time: 67, y: 11, x: 20)\n", "Coordinates:\n", " * x (x) float32 80B -1.0 -0.5 0.0 0.5 1.0 1.5 ... 6.5 7.0 7.5 8.0 8.5\n", " * y (y) float32 44B 55.0 54.5 54.0 53.5 53.0 ... 51.5 51.0 50.5 50.0\n", " * time (time) datetime64[ns] 536B 2017-10-27 ... 2017-10-29T18:00:00\n", "Data variables:\n", " swh (time, y, x) float64 118kB ...\n", "Attributes:\n", " Conventions: CF-1.6\n", " history: 2021-06-07 12:25:02 GMT by grib_to_netcdf-2.16.0: /opt/ecmw...
<xarray.Dataset> Size: 104B\n", "Dimensions: (time: 5)\n", "Coordinates:\n", " * time (time) datetime64[ns] 40B 2017-10-27 ... 2017-10-27T04:00:00\n", " x float64 8B 4.242\n", " y float64 8B 52.69\n", " z object 8B None\n", "Data variables:\n", " ERA5 (time) float64 40B 1.22 1.347 1.466 1.612 1.793\n", "Attributes:\n", " gtype: point\n", " modelskill_version: 1.2.dev0
<xarray.Dataset> Size: 168B\n", "Dimensions: (time: 5)\n", "Coordinates:\n", " x (time) float64 40B 2.423 2.414 2.405 2.396 2.387\n", " y (time) float64 40B 51.25 51.31 51.37 51.42 51.48\n", " * time (time) datetime64[ns] 40B 2017-10-27T12:52:52.337000 ... 2017-10...\n", " z float64 8B nan\n", "Data variables:\n", " ERA5 (time) float64 40B 1.439 1.464 1.489 1.514 1.538\n", "Attributes:\n", " gtype: track\n", " modelskill_version: 1.2.dev0