{ "cells": [ { "cell_type": "markdown", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "## Using NetCDF data" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import earthkit.data as ekd\n", "ekd.download_example_file(\"test.nc\")" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "fs = ekd.from_source(\"file\", \"test.nc\")" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "earthkit.data.readers.netcdf.NetCDFFieldListReader" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "type(fs)" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "2" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "len(fs)" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "NetCDFField(t2m,)\n", "NetCDFField(msl,)\n" ] } ], "source": [ "for f in fs:\n", " print(f)" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "
<xarray.Dataset> Size: 2kB\n",
       "Dimensions:     (longitude: 19, latitude: 11)\n",
       "Coordinates:\n",
       "  * longitude   (longitude) float64 152B -27.0 -23.0 -19.0 ... 37.0 41.0 45.0\n",
       "  * latitude    (latitude) float64 88B 73.0 69.0 65.0 61.0 ... 41.0 37.0 33.0\n",
       "    number      int32 4B ...\n",
       "    time        datetime64[ns] 8B ...\n",
       "    step        timedelta64[ns] 8B ...\n",
       "    surface     int32 4B ...\n",
       "    valid_time  datetime64[ns] 8B ...\n",
       "Data variables:\n",
       "    t2m         (latitude, longitude) float32 836B dask.array<chunksize=(11, 19), meta=np.ndarray>\n",
       "    msl         (latitude, longitude) float32 836B dask.array<chunksize=(11, 19), meta=np.ndarray>\n",
       "Attributes:\n",
       "    GRIB_edition:            1\n",
       "    GRIB_centre:             ecmf\n",
       "    GRIB_centreDescription:  European Centre for Medium-Range Weather Forecasts\n",
       "    GRIB_subCentre:          0\n",
       "    Conventions:             CF-1.7\n",
       "    institution:             European Centre for Medium-Range Weather Forecasts\n",
       "    history:                 GRIB to CDM+CF via cfgrib-0.9.5/ecCodes-2.17.0 w...
" ], "text/plain": [ " Size: 2kB\n", "Dimensions: (longitude: 19, latitude: 11)\n", "Coordinates:\n", " * longitude (longitude) float64 152B -27.0 -23.0 -19.0 ... 37.0 41.0 45.0\n", " * latitude (latitude) float64 88B 73.0 69.0 65.0 61.0 ... 41.0 37.0 33.0\n", " number int32 4B ...\n", " time datetime64[ns] 8B ...\n", " step timedelta64[ns] 8B ...\n", " surface int32 4B ...\n", " valid_time datetime64[ns] 8B ...\n", "Data variables:\n", " t2m (latitude, longitude) float32 836B dask.array\n", " msl (latitude, longitude) float32 836B dask.array\n", "Attributes:\n", " GRIB_edition: 1\n", " GRIB_centre: ecmf\n", " GRIB_centreDescription: European Centre for Medium-Range Weather Forecasts\n", " GRIB_subCentre: 0\n", " Conventions: CF-1.7\n", " institution: European Centre for Medium-Range Weather Forecasts\n", " history: GRIB to CDM+CF via cfgrib-0.9.5/ecCodes-2.17.0 w..." ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "fs.to_xarray()" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[BoundingBox(north=73,west=-27,south=33,east=45),\n", " BoundingBox(north=73,west=-27,south=33,east=45)]" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "fs.bounding_box()" ] } ], "metadata": { "kernelspec": { "display_name": "dev_ecc", "language": "python", "name": "dev_ecc" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.13" } }, "nbformat": 4, "nbformat_minor": 4 }