{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "from matplotlib import pyplot as plt\n", "import netCDF4 as nc\n", "import re\n", "import shutil\n", "%matplotlib inline" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "src='/data/eolson/results/MEOPAR/tmp/SalishSea_03032640_restart_trc.nc'" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "f=nc.Dataset(src,'r+')" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "dict_keys(['nav_lon', 'nav_lat', 'nav_lev', 'time_counter', 'kt', 'ndastp', 'adatrj', 'rnf_pis_NO3_b', 'rnf_pis_NH4_b', 'rnf_pis_Si_b', 'rnf_pis_DIAT_b', 'rnf_pis_PHY_b', 'rnf_pis_MYRI_b', 'rnf_pis_MICZ_b', 'rnf_pis_DON_b', 'rnf_pis_PON_b', 'rnf_pis_bSi_b', 'rnf_pis_TRA_b', 'rnf_pis_DIC_b', 'rnf_pis_TA_b', 'rnf_pis_O2_b', 'sbc_NO3_b', 'sbc_NH4_b', 'sbc_Si_b', 'sbc_DIAT_b', 'sbc_PHY_b', 'sbc_MYRI_b', 'sbc_MICZ_b', 'sbc_DON_b', 'sbc_PON_b', 'sbc_bSi_b', 'sbc_TRA_b', 'sbc_DIC_b', 'sbc_TA_b', 'sbc_O2_b', 'rdttrc1', 'TRNNO3', 'TRNNH4', 'TRNSi', 'TRNDIAT', 'TRNPHY', 'TRNMYRI', 'TRNMICZ', 'TRNDON', 'TRNPON', 'TRNbSi', 'TRNTRA', 'TRNDIC', 'TRNTA', 'TRNO2', 'TRBNO3', 'TRBNH4', 'TRBSi', 'TRBDIAT', 'TRBPHY', 'TRBMYRI', 'TRBMICZ', 'TRBDON', 'TRBPON', 'TRBbSi', 'TRBTRA', 'TRBDIC', 'TRBTA', 'TRBO2'])\n", "rnf_pis_MYRI_b\n", "sbc_MYRI_b\n", "TRNMYRI\n", "TRBMYRI\n" ] } ], "source": [ "print(f.variables.keys())\n", "for var in f.variables.keys():\n", " if 'MYRI' in var:\n", " print(var)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "for var in ('rnf_pis_MYRI_b','sbc_MYRI_b','TRNMYRI','TRBMYRI'):\n", " f.variables[var][:]=0.0" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "for var in ('rnf_pis_MYRI_b','sbc_MYRI_b','TRNMYRI','TRBMYRI'):\n", " f.variables[var][:]=0.0" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "f.close()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "f=nc.Dataset(dst)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "np.max(f.variables['TRNPHY']), np.min(f.variables['TRNPHY'])" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "f.close()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python (py39)", "language": "python", "name": "py39" }, "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.9.2" } }, "nbformat": 4, "nbformat_minor": 4 }