{ "cells": [ { "cell_type": "markdown", "id": "59447ad6-ac47-494e-b696-4335b36b205b", "metadata": {}, "source": [ "# CfRadial1" ] }, { "cell_type": "code", "execution_count": null, "id": "6f96b5d8-2b96-4fd7-b8ba-166c34a8dcd2", "metadata": {}, "outputs": [], "source": [ "import xarray as xr\n", "import xradar as xd\n", "from open_radar_data import DATASETS" ] }, { "cell_type": "markdown", "id": "33d50be4-dfe5-4d99-a936-67a9a76bac94", "metadata": {}, "source": [ "## Download\n", "\n", "Fetching CfRadial1 radar data file from [open-radar-data](https://github.com/openradar/open-radar-data) repository." ] }, { "cell_type": "code", "execution_count": null, "id": "d3c6d408-5ab2-43c3-afd1-b3a703ef3b24", "metadata": {}, "outputs": [], "source": [ "filename = DATASETS.fetch(\"cfrad.20080604_002217_000_SPOL_v36_SUR.nc\")" ] }, { "cell_type": "markdown", "id": "b987dcfd-5105-4483-932e-71b8002e5f09", "metadata": {}, "source": [ "## xr.open_dataset\n", "\n", "Making use of the xarray `cfradial1` backend. We also need to provide the group." ] }, { "cell_type": "code", "execution_count": null, "id": "0e0a7a18-3a4c-4940-96e0-6059f0b3da48", "metadata": {}, "outputs": [], "source": [ "ds = xr.open_dataset(filename, group=\"sweep_0\", engine=\"cfradial1\")\n", "display(ds)" ] }, { "cell_type": "markdown", "id": "8d754b45-a02a-4e08-be5b-300d184441b6", "metadata": {}, "source": [ "### Plot Time vs. Azimuth\n", "\n", "We need to sort by time and specify the coordinate." ] }, { "cell_type": "code", "execution_count": null, "id": "7651de30-7c6c-48c7-b92a-e0c3b47304b0", "metadata": {}, "outputs": [], "source": [ "ds.azimuth.plot(y=\"time\")" ] }, { "cell_type": "markdown", "id": "e797795b-e628-40ea-b46a-39cc7feaa497", "metadata": {}, "source": [ "### Plot Range vs. Time\n", "\n", "We need to sort by time and specify the coordinate." ] }, { "cell_type": "code", "execution_count": null, "id": "63b4a9ca-2882-4240-8c39-d6dd2d872a04", "metadata": {}, "outputs": [], "source": [ "ds.DBZ.sortby(\"time\").plot(y=\"time\")" ] }, { "cell_type": "markdown", "id": "01ec8c90-2da8-46ae-a0b5-0e1792a79bbe", "metadata": {}, "source": [ "### Plot Range vs. Azimuth\n" ] }, { "cell_type": "code", "execution_count": null, "id": "34429720-e689-4786-99e3-5af9742d19ad", "metadata": {}, "outputs": [], "source": [ "ds.DBZ.plot()" ] }, { "cell_type": "markdown", "id": "d904cd09-8590-42e2-8dce-41d3949d313c", "metadata": {}, "source": [ "## backend_kwargs\n", "\n", "The cfradial1 backend can be parameterized via kwargs. Please observe the possibilities below." ] }, { "cell_type": "code", "execution_count": null, "id": "2f11f5f9-2151-42cf-97f6-4675e8094b09", "metadata": {}, "outputs": [], "source": [ "?xd.io.CfRadial1BackendEntrypoint" ] }, { "cell_type": "code", "execution_count": null, "id": "6f7f47b3-6851-420c-8f4c-48dc0964abb2", "metadata": {}, "outputs": [], "source": [ "ds = xr.open_dataset(filename, group=\"sweep_0\", engine=\"cfradial1\", first_dim=\"time\")\n", "display(ds)" ] }, { "cell_type": "code", "execution_count": null, "id": "6479a374-25ab-42be-b53e-82849b6faffc", "metadata": {}, "outputs": [], "source": [ "ds = xr.open_dataset(\n", " filename, group=\"sweep_1\", engine=\"cfradial1\", backend_kwargs=dict(first_dim=\"time\")\n", ")\n", "display(ds)" ] }, { "cell_type": "markdown", "id": "a53f70a0-d9ba-46e8-b12b-9963cd47f4de", "metadata": {}, "source": [ "## open_cfradial1_datatree\n", "\n", "The same works analoguous with the datatree loader. But additionally we can provide a sweep number or list." ] }, { "cell_type": "code", "execution_count": null, "id": "53ab485e-2aa1-496d-9656-847483bec39a", "metadata": {}, "outputs": [], "source": [ "?xd.io.open_cfradial1_datatree" ] }, { "cell_type": "code", "execution_count": null, "id": "5389dd95-3e10-4eb3-9495-2acc6b26e18d", "metadata": {}, "outputs": [], "source": [ "dtree = xd.io.open_cfradial1_datatree(\n", " filename,\n", " first_dim=\"time\",\n", " optional=False,\n", ")\n", "display(dtree)" ] }, { "cell_type": "markdown", "id": "4e8378a1-3fde-4eba-9a9d-c6e705d901d3", "metadata": {}, "source": [ "### Plot Sweep Range vs. Time" ] }, { "cell_type": "code", "execution_count": null, "id": "fe841e2d-6f73-4ffa-915e-29c83b268f7a", "metadata": {}, "outputs": [], "source": [ "dtree[\"sweep_0\"].ds.DBZ.plot()" ] }, { "cell_type": "markdown", "id": "096daea4-e94d-49d3-9c3d-cb28d866c744", "metadata": {}, "source": [ "### Plot Sweep Range vs. Azimuth" ] }, { "cell_type": "code", "execution_count": null, "id": "83d5c9a9-e584-409a-8a8a-52fb008ca0b7", "metadata": {}, "outputs": [], "source": [ "dtree[\"sweep_0\"].ds.DBZ.sortby(\"azimuth\").plot(y=\"azimuth\")" ] }, { "cell_type": "code", "execution_count": null, "id": "971c5baa-119b-4c21-b35f-b6024e5d5d06", "metadata": {}, "outputs": [], "source": [ "dtree = xd.io.open_cfradial1_datatree(filename, sweep=[0, 1, 8])\n", "display(dtree)" ] }, { "cell_type": "code", "execution_count": null, "id": "6c2a5c3b-3979-437f-a302-4ec429f05f89", "metadata": {}, "outputs": [], "source": [ "dtree = xd.io.open_cfradial1_datatree(filename, sweep=[\"sweep_0\", \"sweep_4\", \"sweep_8\"])\n", "display(dtree)" ] } ], "metadata": { "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.11.5" } }, "nbformat": 4, "nbformat_minor": 5 }