diff --git a/docs/source/how-tos/bufr/bufr_synop.ipynb b/docs/source/how-tos/bufr/bufr_synop.ipynb index 6131ea7df..6593d5d55 100644 --- a/docs/source/how-tos/bufr/bufr_synop.ipynb +++ b/docs/source/how-tos/bufr/bufr_synop.ipynb @@ -72,21 +72,48 @@ "ds" ] }, + { + "cell_type": "raw", + "id": "29a316e5-adec-45fa-9e9e-13ce50a768f5", + "metadata": { + "editable": true, + "raw_mimetype": "text/restructuredtext", + "slideshow": { + "slide_type": "" + }, + "tags": [] + }, + "source": [ + "To inspect BUFR data we need to convert it into a featureslist. It is a similar object to a fieldList, but it is an iterable of “features”, where a “feature” can be anything. In a BUFR featurelist each feature is a BUFR message (a :py:class:`~earthkit.data.readers.bufr.message.BUFRMessage` object)." + ] + }, { "cell_type": "code", "execution_count": 3, "id": "5eda4c70-0eea-4cc2-ba84-a915d7048eec", - "metadata": {}, + "metadata": { + "editable": true, + "slideshow": { + "slide_type": "" + }, + "tags": [] + }, "outputs": [], "source": [ - "ds = ds.to_featurelist()" + "fl = ds.to_featurelist()" ] }, { "cell_type": "code", "execution_count": 4, "id": "07571864-48af-451b-be4a-6a42436d193c", - "metadata": {}, + "metadata": { + "editable": true, + "slideshow": { + "slide_type": "" + }, + "tags": [] + }, "outputs": [ { "data": { @@ -100,7 +127,7 @@ } ], "source": [ - "len(ds)" + "len(fl)" ] }, { @@ -115,7 +142,7 @@ "tags": [] }, "source": [ - "We use :py:meth:`~earthkit.data.readers.bufr.file.BUFRList.ls` to see metadata from the header section of the BUFR messages: " + "We use :py:meth:`~earthkit.data.readers.bufr.file.BUFRList.ls` to see metadata from the header section of each BUFR message: " ] }, { @@ -387,7 +414,7 @@ } ], "source": [ - "ds.ls()" + "fl.ls()" ] }, { @@ -549,7 +576,7 @@ } ], "source": [ - "df = ds.to_pandas(columns=[\"latitude\", \"longitude\", \"heightOfStation\", \"airTemperatureAt2M\"])\n", + "df = fl.to_pandas(columns=[\"latitude\", \"longitude\", \"heightOfStation\", \"airTemperatureAt2M\"])\n", "df" ] }, @@ -573,7 +600,13 @@ "cell_type": "code", "execution_count": 7, "id": "26cebaca-9b17-4e15-9564-d92804886ea9", - "metadata": {}, + "metadata": { + "editable": true, + "slideshow": { + "slide_type": "" + }, + "tags": [] + }, "outputs": [ { "data": { @@ -636,7 +669,7 @@ } ], "source": [ - "df = ds.to_pandas(\n", + "df = fl.to_pandas(\n", " columns=[\"latitude\", \"longitude\", \"heightOfStation\", \"airTemperatureAt2M\", \"WMO_station_id\"],\n", " filters={\"WMO_station_id\": [30846, 89514]},\n", ")\n", @@ -655,7 +688,13 @@ "cell_type": "code", "execution_count": 8, "id": "04ec7393-8969-4f46-82a6-5feb8f8a54c8", - "metadata": {}, + "metadata": { + "editable": true, + "slideshow": { + "slide_type": "" + }, + "tags": [] + }, "outputs": [ { "data": { @@ -723,7 +762,7 @@ } ], "source": [ - "df = ds.to_pandas(\n", + "df = fl.to_pandas(\n", " columns=[\"latitude\", \"longitude\", \"heightOfStation\", \"airTemperatureAt2M\"],\n", " filters={\"airTemperatureAt2M\": slice(None, 290)},\n", ")\n", @@ -742,7 +781,13 @@ "cell_type": "code", "execution_count": 9, "id": "d75fe63b-baaa-43fa-8689-c3838e6b0fe5", - "metadata": {}, + "metadata": { + "editable": true, + "slideshow": { + "slide_type": "" + }, + "tags": [] + }, "outputs": [ { "data": { @@ -818,7 +863,7 @@ } ], "source": [ - "df = ds.to_pandas(\n", + "df = fl.to_pandas(\n", " columns=[\"latitude\", \"longitude\", \"heightOfStation\", \"airTemperatureAt2M\"],\n", " filters={\"airTemperatureAt2M\": slice(290, 300)},\n", ")\n", @@ -837,7 +882,13 @@ "cell_type": "code", "execution_count": 10, "id": "c7611278-9426-46fd-8c49-402545122414", - "metadata": {}, + "metadata": { + "editable": true, + "slideshow": { + "slide_type": "" + }, + "tags": [] + }, "outputs": [ { "data": { @@ -905,7 +956,7 @@ } ], "source": [ - "df = ds.to_pandas(\n", + "df = fl.to_pandas(\n", " columns=[\"latitude\", \"longitude\", \"heightOfStation\", \"airTemperatureAt2M\"],\n", " filters={\"airTemperatureAt2M\": slice(300, None)},\n", ")\n", @@ -916,7 +967,13 @@ "cell_type": "code", "execution_count": null, "id": "eb71e23d-d813-471e-8749-c283ee7e9ada", - "metadata": {}, + "metadata": { + "editable": true, + "slideshow": { + "slide_type": "" + }, + "tags": [] + }, "outputs": [], "source": [] } diff --git a/docs/source/how-tos/bufr/bufr_temp.ipynb b/docs/source/how-tos/bufr/bufr_temp.ipynb index c7e903eb9..851964675 100644 --- a/docs/source/how-tos/bufr/bufr_temp.ipynb +++ b/docs/source/how-tos/bufr/bufr_temp.ipynb @@ -38,25 +38,74 @@ "cell_type": "code", "execution_count": 2, "id": "f0430464-fd40-4964-b64d-4629ddd98909", - "metadata": {}, + "metadata": { + "editable": true, + "slideshow": { + "slide_type": "" + }, + "tags": [] + }, "outputs": [], "source": [ - "ds = ekd.from_source(\"file\", \"temp_10.bufr\").to_featurelist()" + "ds = ekd.from_source(\"file\", \"temp_10.bufr\")" ] }, { "cell_type": "markdown", "id": "b07a6358-ad5a-4bd4-a4a3-c24c635cea39", - "metadata": {}, + "metadata": { + "editable": true, + "slideshow": { + "slide_type": "" + }, + "tags": [] + }, "source": [ "#### Message list" ] }, + { + "cell_type": "raw", + "id": "e5b4949c-781b-4b3e-a20e-ba8d40e01922", + "metadata": { + "editable": true, + "raw_mimetype": "text/restructuredtext", + "slideshow": { + "slide_type": "" + }, + "tags": [] + }, + "source": [ + "To inspect BUFR data we need to convert it into a featureslist. It is a similar object to a fieldList, but it is an iterable of “features”, where a “feature” can be anything. In a BUFR featurelist each feature is a BUFR message (represented by a :py:class:`~earthkit.data.readers.bufr.message.BUFRMessage` object)." + ] + }, { "cell_type": "code", "execution_count": 3, + "id": "2d7d7146-18b2-4533-8a3c-cca3bec84753", + "metadata": { + "editable": true, + "slideshow": { + "slide_type": "" + }, + "tags": [] + }, + "outputs": [], + "source": [ + "fl = ds.to_featurelist()" + ] + }, + { + "cell_type": "code", + "execution_count": 4, "id": "07571864-48af-451b-be4a-6a42436d193c", - "metadata": {}, + "metadata": { + "editable": true, + "slideshow": { + "slide_type": "" + }, + "tags": [] + }, "outputs": [ { "data": { @@ -64,20 +113,26 @@ "10" ] }, - "execution_count": 3, + "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "len(ds)" + "len(fl)" ] }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 5, "id": "f360de9c-4584-4c78-a948-eaab7e45932d", - "metadata": {}, + "metadata": { + "editable": true, + "slideshow": { + "slide_type": "" + }, + "tags": [] + }, "outputs": [ { "data": { @@ -85,13 +140,13 @@ "BUFRMessage(type=2,subType=101,subsets=1,20081208,120000)" ] }, - "execution_count": 4, + "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "ds[1]" + "fl[1]" ] }, { @@ -106,12 +161,12 @@ "tags": [] }, "source": [ - "We can call :py:meth:`~earthkit.data.readers.bufr.file.BUFRList.head`, :py:meth:`~earthkit.data.readers.bufr.file.BUFRList.tail` and :py:meth:`~earthkit.data.readers.bufr.file.BUFRList.ls` to see metadata from the header section of the BUFR messages: " + "We can call :py:meth:`~earthkit.data.readers.bufr.file.BUFRList.head`, :py:meth:`~earthkit.data.readers.bufr.file.BUFRList.tail` or :py:meth:`~earthkit.data.readers.bufr.file.BUFRList.ls` to see metadata from the header section of the BUFR messages: " ] }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 6, "id": "30e7749a-ea8b-43d2-90d2-31907f228513", "metadata": { "editable": true, @@ -272,13 +327,13 @@ "4 14.45 " ] }, - "execution_count": 5, + "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "ds.head()" + "fl.head()" ] }, { @@ -301,12 +356,12 @@ "tags": [] }, "source": [ - "We can :py:meth:`~earthkit.data.readers.bufr.message.BUFRMessage.dump` the contents of each message into a tree view. The dump below tells us that the message represents a given station and contains vertical profiles on a set of pressure levels (see the **data section**)." + "We can :py:meth:`~earthkit.data.readers.bufr.message.BUFRMessage.describe` the contents of each message into a tree view. The dump below tells us that the message represents a given station and contains vertical profiles on a set of pressure levels (see the **data section**)." ] }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 7, "id": "613f01a9-8d0b-4dba-b74d-643aa40083ad", "metadata": { "editable": true, @@ -994,13 +1049,13 @@ "" ] }, - "execution_count": 6, + "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "ds[1].describe()" + "fl[1].describe()" ] }, { @@ -1030,7 +1085,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 8, "id": "53ac87d6-09b9-46c3-bc54-07fd2a175b05", "metadata": { "editable": true, @@ -1167,13 +1222,13 @@ "[63 rows x 4 columns]" ] }, - "execution_count": 7, + "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "df = ds.to_pandas(\n", + "df = fl.to_pandas(\n", " columns=(\"WMO_station_id\", \"data_datetime\", \"pressure\", \"airTemperature\"), filters={\"WMO_station_id\": 1415}\n", ")\n", "df" @@ -1183,7 +1238,13 @@ "cell_type": "code", "execution_count": null, "id": "06ca403f-0998-473c-a733-f834f4b61fdf", - "metadata": {}, + "metadata": { + "editable": true, + "slideshow": { + "slide_type": "" + }, + "tags": [] + }, "outputs": [], "source": [] } diff --git a/src/earthkit/data/featurelist/indexed.py b/src/earthkit/data/featurelist/indexed.py index 1f7d15de7..1b0b7ddf2 100644 --- a/src/earthkit/data/featurelist/indexed.py +++ b/src/earthkit/data/featurelist/indexed.py @@ -26,24 +26,6 @@ def create_fieldlist(fields=None): class IndexFeatureListBase(Index, FeatureList): - # @staticmethod - # def from_fields(fields): - # r"""Create a :class:`SimpleFieldList`. - - # Parameters - # ---------- - # fields: iterable - # Iterable of :obj:`Field` objects. - - # Returns - # ------- - # :class:`SimpleFieldList` - - # """ - # from earthkit.data.indexing.simple import SimpleFieldList - - # return SimpleFieldList.from_fields(fields) - def get( self, keys, diff --git a/src/earthkit/data/readers/bufr/file.py b/src/earthkit/data/readers/bufr/file.py index a3a81603f..8468d4c40 100644 --- a/src/earthkit/data/readers/bufr/file.py +++ b/src/earthkit/data/readers/bufr/file.py @@ -211,24 +211,24 @@ def ls(self, n=None, keys="default", extra_keys=None): the metadata keys and values as the column titles. If ``keys`` is None the following dict will be used to define the titles and the keys:: - { - "edition": "edition", - "type": "dataCategory", - "subtype": "dataSubCategory", - "c": "bufrHeaderCentre", - "mv": "masterTablesVersionNumber", - "lv": "localTablesVersionNumber", - "subsets": "numberOfSubsets", - "compr": "compressedData", - "typicalDate": "typicalDate", - "typicalTime": "typicalTime", - "ident": "ident", - "lat": "localLatitude", - "lon": "localLongitude", - } + [ + "edition", + "dataCategory", + "dataSubCategory", + "bufrHeaderCentre", + "masterTablesVersionNumber", + "localTablesVersionNumber", + "numberOfSubsets", + "compressedData", + "typicalDate", + "typicalTime", + "ident", + "localLatitude", + "localLongitude", + ] extra_keys: list of str, dict, None - List of additional keys to ``keys``. To specify a column title for each key in the output + List of additional keys to ``keys``s. To specify a column title for each key in the output use a dict. Returns