{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Exctract a level from a 3D field" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2025-01-13T11:32:48.872594Z", "iopub.status.busy": "2025-01-13T11:32:48.872124Z", "iopub.status.idle": "2025-01-13T11:32:49.409034Z", "shell.execute_reply": "2025-01-13T11:32:49.408511Z" } }, "outputs": [], "source": [ "# for figures in notebook\n", "%matplotlib inline\n", "# import & initialize epygram\n", "import epygram\n", "epygram.init_env()\n", "# path to file\n", "import os\n", "INPUTS_DIR = os.path.join('..', 'inputs')" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2025-01-13T11:32:49.411279Z", "iopub.status.busy": "2025-01-13T11:32:49.411064Z", "iopub.status.idle": "2025-01-13T11:32:49.555590Z", "shell.execute_reply": "2025-01-13T11:32:49.555040Z" } }, "outputs": [], "source": [ "# open resource as a meta-CL-resource, CL = Combine Levels\n", "r = epygram.resources.meta_resource(os.path.join(INPUTS_DIR, 'ICMSHAROM+0022'), 'r', 'CL')\n", "# in this case, field need to be defined with GRIB2 nomenclature" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2025-01-13T11:32:49.557792Z", "iopub.status.busy": "2025-01-13T11:32:49.557576Z", "iopub.status.idle": "2025-01-13T11:32:52.035816Z", "shell.execute_reply": "2025-01-13T11:32:52.035280Z" } }, "outputs": [], "source": [ "f = r.readfield({'discipline':0, 'parameterCategory':0, 'parameterNumber':0, 'typeOfFirstFixedSurface':119})" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2025-01-13T11:32:52.038027Z", "iopub.status.busy": "2025-01-13T11:32:52.037880Z", "iopub.status.idle": "2025-01-13T11:32:52.158664Z", "shell.execute_reply": "2025-01-13T11:32:52.158138Z" } }, "outputs": [], "source": [ "f.sp2gp()" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2025-01-13T11:32:52.160978Z", "iopub.status.busy": "2025-01-13T11:32:52.160721Z", "iopub.status.idle": "2025-01-13T11:32:52.165180Z", "shell.execute_reply": "2025-01-13T11:32:52.164687Z" } }, "outputs": [], "source": [ "f18 = f.getlevel(18)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2025-01-13T11:32:52.166962Z", "iopub.status.busy": "2025-01-13T11:32:52.166656Z", "iopub.status.idle": "2025-01-13T11:32:52.169269Z", "shell.execute_reply": "2025-01-13T11:32:52.168914Z" } }, "outputs": [], "source": [ "print(type(f))\n", "print(type(f18))\n", "print(f18.geometry.vcoordinate.levels)" ] }, { "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 }