{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Plot the z/p characteristics of a Hybrid-Pressure vertical coordinate\n", "### (cf. python package `pyvgrid` from PyPI and its command-line tool `mkvgrid` to build new vertical coordinates)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2025-01-13T11:35:14.503946Z", "iopub.status.busy": "2025-01-13T11:35:14.503476Z", "iopub.status.idle": "2025-01-13T11:35:14.837440Z", "shell.execute_reply": "2025-01-13T11:35:14.836945Z" } }, "outputs": [], "source": [ "# 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:35:14.839582Z", "iopub.status.busy": "2025-01-13T11:35:14.839333Z", "iopub.status.idle": "2025-01-13T11:35:17.028873Z", "shell.execute_reply": "2025-01-13T11:35:17.028361Z" } }, "outputs": [], "source": [ "# open resource in read mode\n", "r = epygram.open(os.path.join(INPUTS_DIR, 'ICMSHAROM+0022'), 'r')\n", "hybridP_geo = r.readfield('S058TEMPERATURE').geometry.vcoordinate" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2025-01-13T11:35:17.030922Z", "iopub.status.busy": "2025-01-13T11:35:17.030783Z", "iopub.status.idle": "2025-01-13T11:35:17.033365Z", "shell.execute_reply": "2025-01-13T11:35:17.032884Z" } }, "outputs": [], "source": [ "vmean = \"LAPRXPK=False\" # or 'geometric' or 'arithmetic'" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2025-01-13T11:35:17.035124Z", "iopub.status.busy": "2025-01-13T11:35:17.034997Z", "iopub.status.idle": "2025-01-13T11:35:17.047340Z", "shell.execute_reply": "2025-01-13T11:35:17.047026Z" } }, "outputs": [], "source": [ "vg = r.geometry.vcoordinate.to_vgrid(vertical_mean=vmean,\n", " vgrid_name=r.container.basename)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2025-01-13T11:35:17.048716Z", "iopub.status.busy": "2025-01-13T11:35:17.048557Z", "iopub.status.idle": "2025-01-13T11:35:17.507579Z", "shell.execute_reply": "2025-01-13T11:35:17.507089Z" } }, "outputs": [], "source": [ "# y and x may be among ('z', 'p', 'level', 'pthickness', 'zthickness')\n", "fig = vg.bokeh_plot_y_vs_x('level', 'pthickness')" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2025-01-13T11:35:17.509767Z", "iopub.status.busy": "2025-01-13T11:35:17.509546Z", "iopub.status.idle": "2025-01-13T11:35:17.511953Z", "shell.execute_reply": "2025-01-13T11:35:17.511558Z" } }, "outputs": [], "source": [ "# Save and open html output file:\n", "# vg.bokeh_fig_to_html(fig)\n", "\n", "# which will look like:" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "![title](vgrid.png)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2025-01-13T11:35:17.513630Z", "iopub.status.busy": "2025-01-13T11:35:17.513453Z", "iopub.status.idle": "2025-01-13T11:35:17.517469Z", "shell.execute_reply": "2025-01-13T11:35:17.517051Z" } }, "outputs": [], "source": [ "print(vg.write_AB_to_namelist())" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "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": 4 }