{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Shaving: cut values over a threshold down to this threshold\n", "(resp. below a threshold up to)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2025-01-13T11:34:26.296794Z", "iopub.status.busy": "2025-01-13T11:34:26.296337Z", "iopub.status.idle": "2025-01-13T11:34:26.829690Z", "shell.execute_reply": "2025-01-13T11:34:26.829186Z" } }, "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:26.832015Z", "iopub.status.busy": "2025-01-13T11:34:26.831738Z", "iopub.status.idle": "2025-01-13T11:34:27.026202Z", "shell.execute_reply": "2025-01-13T11:34:27.025621Z" } }, "outputs": [], "source": [ "r = epygram.open(os.path.join(INPUTS_DIR, 'ICMSHAROM+0022'), 'r')\n", "f = r.readfield('SURFACCPLUIE')" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2025-01-13T11:34:27.028227Z", "iopub.status.busy": "2025-01-13T11:34:27.028097Z", "iopub.status.idle": "2025-01-13T11:34:27.553971Z", "shell.execute_reply": "2025-01-13T11:34:27.553538Z" } }, "outputs": [], "source": [ "fig, ax = f.cartoplot(subzone='CI', colormap='rr1h')" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2025-01-13T11:34:27.555791Z", "iopub.status.busy": "2025-01-13T11:34:27.555586Z", "iopub.status.idle": "2025-01-13T11:34:27.865683Z", "shell.execute_reply": "2025-01-13T11:34:27.865200Z" } }, "outputs": [], "source": [ "# shave at 5mm threshold: all values above are set to 5.\n", "f.shave(maxval=5.)\n", "fig, ax = f.cartoplot(subzone='CI', colormap='rr1h')" ] }, { "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": 1 }