{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Compute vor/div from u/v" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2025-01-13T11:34:20.245144Z", "iopub.status.busy": "2025-01-13T11:34:20.244641Z", "iopub.status.idle": "2025-01-13T11:34:20.767014Z", "shell.execute_reply": "2025-01-13T11:34:20.766507Z" } }, "outputs": [], "source": [ "# for figures in notebook\n", "%matplotlib inline\n", "\n", "# import & initialize epygram\n", "import epygram\n", "epygram.init_env()" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2025-01-13T11:34:20.769177Z", "iopub.status.busy": "2025-01-13T11:34:20.768976Z", "iopub.status.idle": "2025-01-13T11:34:20.917589Z", "shell.execute_reply": "2025-01-13T11:34:20.917094Z" } }, "outputs": [], "source": [ "import os\n", "INPUTS_DIR = os.path.join('..', 'inputs')\n", "# open resource in read mode\n", "r = epygram.open(os.path.join(INPUTS_DIR, 'ICMSHAROM+0022'), 'r')" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2025-01-13T11:34:20.919666Z", "iopub.status.busy": "2025-01-13T11:34:20.919461Z", "iopub.status.idle": "2025-01-13T11:34:22.970406Z", "shell.execute_reply": "2025-01-13T11:34:22.969910Z" } }, "outputs": [], "source": [ "u = r.readfield('S080WIND.U.PHYS')\n", "v = r.readfield('S080WIND.V.PHYS')\n", "# re-compute u/v from psi/khi\n", "uv = epygram.fields.make_vector_field(u, v)\n", "spgeom = u.spectral_geometry\n", "uv.sp2gp()" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2025-01-13T11:34:22.972413Z", "iopub.status.busy": "2025-01-13T11:34:22.972274Z", "iopub.status.idle": "2025-01-13T11:34:23.702091Z", "shell.execute_reply": "2025-01-13T11:34:23.701577Z" } }, "outputs": [], "source": [ "fig, ax = uv.cartoplot(subsampling=5, vector_plot_method='quiver',\n", " components_are_projected_on='grid')" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2025-01-13T11:34:23.707038Z", "iopub.status.busy": "2025-01-13T11:34:23.706871Z", "iopub.status.idle": "2025-01-13T11:34:23.723629Z", "shell.execute_reply": "2025-01-13T11:34:23.723190Z" } }, "outputs": [], "source": [ "# fields need to be spectral to compute vor/div : spectral derivatives are used\n", "uv.gp2sp(spgeom)\n", "vor, div = uv.compute_vordiv()" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2025-01-13T11:34:23.725363Z", "iopub.status.busy": "2025-01-13T11:34:23.725171Z", "iopub.status.idle": "2025-01-13T11:34:24.362899Z", "shell.execute_reply": "2025-01-13T11:34:24.362405Z" } }, "outputs": [], "source": [ "# map factor due to stretching:\n", "fig, ax = vor.cartoplot()\n", "fig, ax = div.cartoplot()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "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.12" } }, "nbformat": 4, "nbformat_minor": 2 }