{ "cells": [ { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "# Met Éireann Reanalysis - dealing with missing data" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import glob\n", "import os\n", "from datetime import datetime, timezone\n", "import cartopy.crs as ccrs\n", "import matplotlib.pyplot as plt\n", "import pandas as pd\n", "import xarray as xr\n", "import climag.climag as cplt" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "# directory of processed MÉRA netCDF files\n", "DATA_DIR = os.path.join(\"/run/media/nms/MyPassport\", \"MERA\", \"netcdf_day\")" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "## Find timestamps with missing data" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "ds_grib = xr.open_dataset(\n", " \"/run/media/nms/MyPassport/MERA/grib/117_105_0_4_FC3hr/\"\n", " \"MERA_PRODYEAR_2013_05_117_105_0_4_FC3hr\",\n", " chunks=\"auto\",\n", " decode_coords=\"all\",\n", " engine=\"cfgrib\",\n", ")" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
<xarray.Dataset>\n",
"Dimensions: (time: 128, step: 3, y: 489, x: 529)\n",
"Coordinates:\n",
" * time (time) datetime64[ns] 2013-05-01 ... 2013-05-16T21:00:00\n",
" * step (step) timedelta64[ns] 01:00:00 02:00:00 03:00:00\n",
" heightAboveGround float64 ...\n",
" latitude (y, x) float64 dask.array<chunksize=(489, 529), meta=np.ndarray>\n",
" longitude (y, x) float64 dask.array<chunksize=(489, 529), meta=np.ndarray>\n",
" valid_time (time, step) datetime64[ns] dask.array<chunksize=(128, 3), meta=np.ndarray>\n",
"Dimensions without coordinates: y, x\n",
"Data variables:\n",
" grad (time, step, y, x) float32 dask.array<chunksize=(101, 2, 390, 422), meta=np.ndarray>\n",
"Attributes:\n",
" GRIB_edition: 1\n",
" GRIB_centre: eidb\n",
" GRIB_centreDescription: Dublin\n",
" GRIB_subCentre: 255\n",
" Conventions: CF-1.7\n",
" institution: Dublin\n",
" history: 2023-04-18T15:55 GRIB to CDM+CF via cfgrib-0.9.1...<xarray.Dataset>\n",
"Dimensions: (time: 128, x: 158, y: 166, height: 1)\n",
"Coordinates:\n",
" * time (time) datetime64[ns] 2013-05-01 ... 2013-05-16T21:00:00\n",
" * x (x) float64 4.15e+05 4.175e+05 ... 8.05e+05 8.075e+05\n",
" * y (y) float64 4.075e+05 4.1e+05 ... 8.175e+05 8.2e+05\n",
" * height (height) float64 0.0\n",
" spatial_ref int64 ...\n",
" Lambert_Conformal int64 ...\n",
"Data variables:\n",
" grad (time, height, y, x) float32 dask.array<chunksize=(128, 1, 166, 158), meta=np.ndarray>\n",
"Attributes:\n",
" CDI: Climate Data Interface version 2.0.5 (https://mpimet.mpg.de...\n",
" Conventions: CF-1.6\n",
" history: Sat Apr 15 21:05:39 2023: cdo -s -f nc4c -shifttime,-3hour ...\n",
" CDO: Climate Data Operators version 2.0.5 (https://mpimet.mpg.de...<xarray.Dataset>\n",
"Dimensions: (x: 158, y: 166, time: 2800)\n",
"Coordinates:\n",
" * x (x) float64 4.15e+05 4.175e+05 ... 8.05e+05 8.075e+05\n",
" * y (y) float64 4.075e+05 4.1e+05 ... 8.175e+05 8.2e+05\n",
" height float64 0.0\n",
" * time (time) datetime64[ns] 2012-01-01 ... 2019-08-31\n",
" Lambert_Conformal int64 ...\n",
" spatial_ref int64 ...\n",
"Data variables:\n",
" grad (time, y, x) float32 dask.array<chunksize=(2181, 127, 121), meta=np.ndarray>\n",
"Attributes:\n",
" CDI: Climate Data Interface version 2.0.5 (https://mpimet.mpg.de...\n",
" Conventions: CF-1.6\n",
" history: Sat Apr 15 21:01:13 2023: cdo -s -f nc4c -shifttime,-3hour ...\n",
" CDO: Climate Data Operators version 2.0.5 (https://mpimet.mpg.de...<xarray.Dataset>\n",
"Dimensions: (x: 158, y: 166, time: 2800)\n",
"Coordinates:\n",
" * x (x) float64 4.15e+05 4.175e+05 ... 8.05e+05 8.075e+05\n",
" * y (y) float64 4.075e+05 4.1e+05 ... 8.175e+05 8.2e+05\n",
" height float64 0.0\n",
" Lambert_Conformal int64 ...\n",
" * time (time) datetime64[ns] 2012-01-01 ... 2019-08-31\n",
" spatial_ref int64 ...\n",
"Data variables:\n",
" nswrs (time, y, x) float32 dask.array<chunksize=(2181, 127, 121), meta=np.ndarray>\n",
"Attributes:\n",
" CDI: Climate Data Interface version 2.0.5 (https://mpimet.mpg.de...\n",
" Conventions: CF-1.6\n",
" history: Fri Apr 14 14:07:36 2023: cdo -s -f nc4c -shifttime,-3hour ...\n",
" CDO: Climate Data Operators version 2.0.5 (https://mpimet.mpg.de...<xarray.Dataset>\n",
"Dimensions: (x: 158, y: 166, time: 2800)\n",
"Coordinates:\n",
" * x (x) float64 4.15e+05 4.175e+05 ... 8.05e+05 8.075e+05\n",
" * y (y) float64 4.075e+05 4.1e+05 ... 8.175e+05 8.2e+05\n",
" height float64 0.0\n",
" * time (time) datetime64[ns] 2012-01-01 ... 2019-08-31\n",
" Lambert_Conformal int64 ...\n",
" spatial_ref int64 ...\n",
"Data variables:\n",
" grad (time, y, x) float32 dask.array<chunksize=(2181, 127, 121), meta=np.ndarray>\n",
" nswrs (time, y, x) float32 dask.array<chunksize=(2181, 127, 121), meta=np.ndarray>\n",
" ratio (time, y, x) float32 dask.array<chunksize=(2181, 127, 121), meta=np.ndarray>\n",
"Attributes:\n",
" CDI: Climate Data Interface version 2.0.5 (https://mpimet.mpg.de...\n",
" Conventions: CF-1.6\n",
" history: Sat Apr 15 21:01:13 2023: cdo -s -f nc4c -shifttime,-3hour ...\n",
" CDO: Climate Data Operators version 2.0.5 (https://mpimet.mpg.de...<xarray.Dataset>\n",
"Dimensions: (x: 158, y: 166, time: 2800)\n",
"Coordinates:\n",
" * x (x) float64 4.15e+05 4.175e+05 ... 8.05e+05 8.075e+05\n",
" * y (y) float64 4.075e+05 4.1e+05 ... 8.175e+05 8.2e+05\n",
" height float64 0.0\n",
" Lambert_Conformal int64 ...\n",
" * time (time) datetime64[ns] 2012-01-01 ... 2019-08-31\n",
" spatial_ref int64 ...\n",
"Data variables:\n",
" nswrs (time, y, x) float32 dask.array<chunksize=(2181, 127, 121), meta=np.ndarray>\n",
" grad (time, y, x) float32 dask.array<chunksize=(2181, 127, 121), meta=np.ndarray>\n",
"Attributes:\n",
" CDI: Climate Data Interface version 2.0.5 (https://mpimet.mpg.de...\n",
" Conventions: CF-1.6\n",
" history: Fri Apr 14 14:07:36 2023: cdo -s -f nc4c -shifttime,-3hour ...\n",
" CDO: Climate Data Operators version 2.0.5 (https://mpimet.mpg.de...