{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Extract a zoom from various geometries" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2025-01-13T11:34:40.656014Z", "iopub.status.busy": "2025-01-13T11:34:40.655492Z", "iopub.status.idle": "2025-01-13T11:34:41.181932Z", "shell.execute_reply": "2025-01-13T11:34:41.181432Z" } }, "outputs": [], "source": [ "%matplotlib inline\n", "# for figures in notebook\n", "\n", "# 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:34:41.184128Z", "iopub.status.busy": "2025-01-13T11:34:41.183900Z", "iopub.status.idle": "2025-01-13T11:34:41.564601Z", "shell.execute_reply": "2025-01-13T11:34:41.564097Z" } }, "outputs": [], "source": [ "# open resource in read mode\n", "l = epygram.open(os.path.join(INPUTS_DIR, 'ICMSHAROM+0022'), 'r')\n", "g = epygram.open(os.path.join(INPUTS_DIR, 'analysis.full-arpege.tl149-c24.fa'), 'r')\n", "llr = epygram.open(os.path.join(INPUTS_DIR, 'grid.arome-forecast.guyane0025+0000:00.grib'), 'r')" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2025-01-13T11:34:41.566717Z", "iopub.status.busy": "2025-01-13T11:34:41.566564Z", "iopub.status.idle": "2025-01-13T11:34:41.835350Z", "shell.execute_reply": "2025-01-13T11:34:41.834847Z" } }, "outputs": [], "source": [ "# extract lon/lat area from Lon/Lat regular field: keep projection\n", "f = llr.readfield('shortName:2r')\n", "z = f.extract_zoom(dict(lonmin=-55,lonmax=-50,latmin=4,latmax=7))\n", "z.geometry" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## but" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2025-01-13T11:34:41.837345Z", "iopub.status.busy": "2025-01-13T11:34:41.837146Z", "iopub.status.idle": "2025-01-13T11:34:42.034114Z", "shell.execute_reply": "2025-01-13T11:34:42.033751Z" } }, "outputs": [], "source": [ "# extract lon/lat area from Lambert projection grid => unstructured\n", "f = l.readfield('SURFTEMPERATURE')\n", "z = f.extract_zoom(dict(lonmin=7,lonmax=8.5,latmin=45,latmax=46))\n", "z.geometry" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2025-01-13T11:34:42.035920Z", "iopub.status.busy": "2025-01-13T11:34:42.035738Z", "iopub.status.idle": "2025-01-13T11:34:42.189921Z", "shell.execute_reply": "2025-01-13T11:34:42.189402Z" } }, "outputs": [], "source": [ "# extract lon/lat area from Gauss grid => unstructured\n", "f = g.readfield('SURFTEMPERATURE')\n", "z = f.extract_zoom(dict(lonmin=7,lonmax=8.5,latmin=45,latmax=46))\n", "z.geometry" ] }, { "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 }