{ "cells": [ { "cell_type": "markdown", "id": "hourly-multimedia", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "## GRIB: writing data into FDB" ] }, { "cell_type": "code", "execution_count": 1, "id": "behind-carry", "metadata": { "tags": [] }, "outputs": [], "source": [ "import os\n", "import earthkit.data as ekd" ] }, { "cell_type": "markdown", "id": "numerous-france", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "This example demonstrates how to **write earthkit-data GRIB fields into an FDB**. \n", "\n", "FDB (Fields DataBase) is a domain-specific object store developed at ECMWF for storing, indexing and retrieving GRIB data. For more information on FBD please consult the following pages:\n", "\n", "- [FDB](https://fields-database.readthedocs.io/en/latest/)\n", "- [pyfdb](https://pyfdb.readthedocs.io/en/latest/)" ] }, { "cell_type": "markdown", "id": "b5f59f05-2596-407f-9c1d-eb18d0e2e283", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "#### Setting up the target FDB" ] }, { "cell_type": "markdown", "id": "d08c2850-8bd2-4c01-bc4c-2a941acb8e1a", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "In this example we will create an FDB in the current folder using the schema taken from the pyfdb test suite. To do so first we need to ensure the directory exists. Next, we have to specify the configuration. " ] }, { "cell_type": "code", "execution_count": 2, "id": "drawn-renewal", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "outputs": [], "source": [ "fdb_schema = \"./default_fdb_schema\"\n", "fdb_dir = \"./_fdb\"\n", "os.makedirs(fdb_dir, exist_ok=True)\n", "\n", "config = {\"type\":\"local\",\n", " \"engine\":\"toc\",\n", " \"schema\":fdb_schema,\n", " \"spaces\":[{\"handler\":\"Default\",\n", " \"roots\":[{\"path\":fdb_dir}]}]}" ] }, { "cell_type": "markdown", "id": "compound-pastor", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "#### Archiving GRIB into the target FDB" ] }, { "cell_type": "markdown", "id": "considered-excellence", "metadata": {}, "source": [ "First, we read temperature and wind GRIB data on pressure levels from a file." ] }, { "cell_type": "code", "execution_count": 3, "id": "signal-rocket", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "outputs": [ { "data": { "text/html": [ "
| \n", " | centre | \n", "shortName | \n", "typeOfLevel | \n", "level | \n", "dataDate | \n", "dataTime | \n", "stepRange | \n", "dataType | \n", "number | \n", "gridType | \n", "
|---|---|---|---|---|---|---|---|---|---|---|
| 0 | \n", "ecmf | \n", "t | \n", "isobaricInhPa | \n", "1000 | \n", "20180801 | \n", "1200 | \n", "0 | \n", "an | \n", "0 | \n", "regular_ll | \n", "
| 1 | \n", "ecmf | \n", "u | \n", "isobaricInhPa | \n", "1000 | \n", "20180801 | \n", "1200 | \n", "0 | \n", "an | \n", "0 | \n", "regular_ll | \n", "
| 2 | \n", "ecmf | \n", "v | \n", "isobaricInhPa | \n", "1000 | \n", "20180801 | \n", "1200 | \n", "0 | \n", "an | \n", "0 | \n", "regular_ll | \n", "
| 3 | \n", "ecmf | \n", "t | \n", "isobaricInhPa | \n", "850 | \n", "20180801 | \n", "1200 | \n", "0 | \n", "an | \n", "0 | \n", "regular_ll | \n", "
| 4 | \n", "ecmf | \n", "u | \n", "isobaricInhPa | \n", "850 | \n", "20180801 | \n", "1200 | \n", "0 | \n", "an | \n", "0 | \n", "regular_ll | \n", "