{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Plot profile(s)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2025-01-13T11:31:17.085017Z", "iopub.status.busy": "2025-01-13T11:31:17.084500Z", "iopub.status.idle": "2025-01-13T11:31:17.608462Z", "shell.execute_reply": "2025-01-13T11:31:17.607977Z" } }, "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:31:17.610727Z", "iopub.status.busy": "2025-01-13T11:31:17.610513Z", "iopub.status.idle": "2025-01-13T11:31:17.932273Z", "shell.execute_reply": "2025-01-13T11:31:17.931783Z" } }, "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:31:17.934268Z", "iopub.status.busy": "2025-01-13T11:31:17.934122Z", "iopub.status.idle": "2025-01-13T11:31:43.247716Z", "shell.execute_reply": "2025-01-13T11:31:43.247115Z" } }, "outputs": [], "source": [ "f = r.readfield({'shortName':'t', 'typeOfFirstFixedSurface':100}) # temperature on pressure levels\n", "p = f.extractprofile(-55,5) # extract a profile" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2025-01-13T11:31:43.249781Z", "iopub.status.busy": "2025-01-13T11:31:43.249622Z", "iopub.status.idle": "2025-01-13T11:31:43.252384Z", "shell.execute_reply": "2025-01-13T11:31:43.252002Z" } }, "outputs": [], "source": [ "print(type(p))\n", "print(p.getdata(d4=True).shape)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2025-01-13T11:31:43.254007Z", "iopub.status.busy": "2025-01-13T11:31:43.253837Z", "iopub.status.idle": "2025-01-13T11:31:43.495341Z", "shell.execute_reply": "2025-01-13T11:31:43.494815Z" } }, "outputs": [], "source": [ "fig, ax = p.plotfield(title='Vertical profile evolution')" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2025-01-13T11:31:43.497195Z", "iopub.status.busy": "2025-01-13T11:31:43.497029Z", "iopub.status.idle": "2025-01-13T11:31:43.499870Z", "shell.execute_reply": "2025-01-13T11:31:43.499470Z" } }, "outputs": [], "source": [ "p0 = p.getvalidity(0)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2025-01-13T11:31:43.501455Z", "iopub.status.busy": "2025-01-13T11:31:43.501270Z", "iopub.status.idle": "2025-01-13T11:31:43.827834Z", "shell.execute_reply": "2025-01-13T11:31:43.827353Z" } }, "outputs": [], "source": [ "fig, ax = p0.plotfield(labels=['temperature'], unit='K')" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2025-01-13T11:31:43.829611Z", "iopub.status.busy": "2025-01-13T11:31:43.829454Z", "iopub.status.idle": "2025-01-13T11:31:43.965908Z", "shell.execute_reply": "2025-01-13T11:31:43.965409Z" } }, "outputs": [], "source": [ "profiles = [p.getvalidity(i) for i in range(len(p.validity))]\n", "fig, ax = epygram.fields.V1DField.plotprofiles(profiles,\n", " labels=[pp.validity.get() for pp in profiles],\n", " unit='K')" ] }, { "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 }