{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Extract a V1D+T profile from a 4D field" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2025-01-13T11:32:56.684627Z", "iopub.status.busy": "2025-01-13T11:32:56.684137Z", "iopub.status.idle": "2025-01-13T11:32:57.214387Z", "shell.execute_reply": "2025-01-13T11:32:57.213903Z" } }, "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:32:57.216499Z", "iopub.status.busy": "2025-01-13T11:32:57.216256Z", "iopub.status.idle": "2025-01-13T11:32:57.542833Z", "shell.execute_reply": "2025-01-13T11:32:57.542345Z" } }, "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:32:57.544864Z", "iopub.status.busy": "2025-01-13T11:32:57.544683Z", "iopub.status.idle": "2025-01-13T11:33:23.059505Z", "shell.execute_reply": "2025-01-13T11:33:23.059004Z" } }, "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:23.061668Z", "iopub.status.busy": "2025-01-13T11:33:23.061477Z", "iopub.status.idle": "2025-01-13T11:33:23.064225Z", "shell.execute_reply": "2025-01-13T11:33:23.063861Z" } }, "outputs": [], "source": [ "print(f.getdata(d4=True).shape)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2025-01-13T11:33:23.066027Z", "iopub.status.busy": "2025-01-13T11:33:23.065880Z", "iopub.status.idle": "2025-01-13T11:33:23.097925Z", "shell.execute_reply": "2025-01-13T11:33:23.097517Z" } }, "outputs": [], "source": [ "p = f.extractprofile(-55,5)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2025-01-13T11:33:23.099524Z", "iopub.status.busy": "2025-01-13T11:33:23.099376Z", "iopub.status.idle": "2025-01-13T11:33:23.101915Z", "shell.execute_reply": "2025-01-13T11:33:23.101547Z" } }, "outputs": [], "source": [ "print(type(p))\n", "print(p.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 }