{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Spectral filtering (spectral round-trip at a lower truncation)\n", "\n", "and vizualisation of differences as (DCT) variance spectrum plot" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2025-01-13T11:34:00.159904Z", "iopub.status.busy": "2025-01-13T11:34:00.158570Z", "iopub.status.idle": "2025-01-13T11:34:00.688149Z", "shell.execute_reply": "2025-01-13T11:34:00.687560Z" } }, "outputs": [], "source": [ "%matplotlib inline\n", "# for figures in notebook\n", "\n", "# import & initialize epygram\n", "import epygram\n", "epygram.init_env()\n", "\n", "import os\n", "INPUTS_DIR = os.path.join('..', 'inputs')" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2025-01-13T11:34:00.690407Z", "iopub.status.busy": "2025-01-13T11:34:00.690202Z", "iopub.status.idle": "2025-01-13T11:34:02.897233Z", "shell.execute_reply": "2025-01-13T11:34:02.896608Z" } }, "outputs": [], "source": [ "r = epygram.open(os.path.join(INPUTS_DIR, 'ICMSHAROM+0022'), 'r')\n", "t59 = r.readfield('S059TEMPERATURE')\n", "spgeom = r.spectral_geometry\n", "t59.sp2gp()" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2025-01-13T11:34:02.899286Z", "iopub.status.busy": "2025-01-13T11:34:02.899152Z", "iopub.status.idle": "2025-01-13T11:34:03.086863Z", "shell.execute_reply": "2025-01-13T11:34:03.086358Z" } }, "outputs": [], "source": [ "# initial field spectrum\n", "sp59 = t59.dctspectrum()\n", "sp59.name = t59.fid['FA']" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2025-01-13T11:34:03.089076Z", "iopub.status.busy": "2025-01-13T11:34:03.088811Z", "iopub.status.idle": "2025-01-13T11:34:03.213998Z", "shell.execute_reply": "2025-01-13T11:34:03.213475Z" } }, "outputs": [], "source": [ "# set new spectral space\n", "print(spgeom.truncation['in_X'], spgeom.truncation['in_Y'])\n", "trunc_spgeom = spgeom.deepcopy()\n", "trunc_spgeom.truncation['in_X'] = 100\n", "trunc_spgeom.truncation['in_Y'] = 100\n", "# spectral roundtrip\n", "t59.gp2sp(trunc_spgeom)\n", "t59.sp2gp()\n", "# and compute DCT spectrum\n", "sp59f = t59.dctspectrum()\n", "sp59f.name = sp59.name + '(filtered)'" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2025-01-13T11:34:03.215956Z", "iopub.status.busy": "2025-01-13T11:34:03.215736Z", "iopub.status.idle": "2025-01-13T11:34:03.678853Z", "shell.execute_reply": "2025-01-13T11:34:03.678243Z" } }, "outputs": [], "source": [ "# and plot\n", "fig, ax = epygram.spectra.plotspectra([sp59, sp59f])" ] }, { "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": 1 }