{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Extract a V2D+T section from a 4D field" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2025-01-13T11:33:24.931520Z", "iopub.status.busy": "2025-01-13T11:33:24.931018Z", "iopub.status.idle": "2025-01-13T11:33:25.458442Z", "shell.execute_reply": "2025-01-13T11:33:25.457919Z" } }, "outputs": [], "source": [ "%matplotlib inline\n", "# for figures in notebook\n", "\n", "# import & initialize epygram\n", "import epygram\n", "epygram.init_env()\n", "\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:33:25.460513Z", "iopub.status.busy": "2025-01-13T11:33:25.460282Z", "iopub.status.idle": "2025-01-13T11:33:25.790155Z", "shell.execute_reply": "2025-01-13T11:33:25.789690Z" } }, "outputs": [], "source": [ "paths = [os.path.join(INPUTS_DIR, 'grid.arome-forecast.guyane0025+00{:02}:00.grib'.format(i))\n", " for i in (0, 12, 24)]\n", "r = epygram.resources.meta_resource(paths, 'r', 'CL+MV')" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2025-01-13T11:33:25.792232Z", "iopub.status.busy": "2025-01-13T11:33:25.792065Z", "iopub.status.idle": "2025-01-13T11:33:51.420371Z", "shell.execute_reply": "2025-01-13T11:33:51.419887Z" } }, "outputs": [], "source": [ "f = r.readfield({'shortName':'t', 'typeOfFirstFixedSurface':100}) # temperature on pressure levels" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2025-01-13T11:33:51.422391Z", "iopub.status.busy": "2025-01-13T11:33:51.422200Z", "iopub.status.idle": "2025-01-13T11:33:51.425066Z", "shell.execute_reply": "2025-01-13T11:33:51.424654Z" } }, "outputs": [], "source": [ "print(f.getdata(d4=True).shape)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2025-01-13T11:33:51.426913Z", "iopub.status.busy": "2025-01-13T11:33:51.426712Z", "iopub.status.idle": "2025-01-13T11:33:51.893232Z", "shell.execute_reply": "2025-01-13T11:33:51.892781Z" } }, "outputs": [], "source": [ "s = f.extractsection((-55,5), (-55,2))" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2025-01-13T11:33:51.895106Z", "iopub.status.busy": "2025-01-13T11:33:51.894955Z", "iopub.status.idle": "2025-01-13T11:33:51.897788Z", "shell.execute_reply": "2025-01-13T11:33:51.897335Z" } }, "outputs": [], "source": [ "print(type(s))\n", "print(s.getdata(d4=True).shape)" ] }, { "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 }