{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# CfRadial1 <-> CfRadial2" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Imports" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import xarray as xr\n", "from open_radar_data import DATASETS\n", "\n", "import xradar as xd" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Load Data" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "file = DATASETS.fetch(\"cfrad.20080604_002217_000_SPOL_v36_SUR.nc\")\n", "dtree = xd.io.open_cfradial1_datatree(file)\n", "display(dtree)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Transform CF2 to CF1" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "ds = dtree.xradar.to_cfradial1_dataset()\n", "display(ds)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Transform CF1 to CF2" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "dtree = ds.xradar.to_cfradial2_datatree()\n", "display(dtree)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "del ds, dtree" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Alternate Method" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We can directly use xarray to read the data and then transform it to CF2 datatree." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "ds = xr.open_dataset(file)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "ds" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "radar = ds.xradar.to_cf2()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "display(radar)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "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.12.7" } }, "nbformat": 4, "nbformat_minor": 4 }