{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": true }, "outputs": [], "source": [ "import numpy as np\n", "import xarray as xr\n", "import math\n", "import matplotlib.pyplot as plt\n", "import pandas as pd\n", "import seaborn as sns\n", "import os\n", "\n", "%matplotlib inline\n", "plt.rcParams['image.cmap'] = 'Paired'\n", "#sns.set(font_scale=2)" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# Parent directory for the results of this run\n", "group_results_directory = '/data/jpetrie/MEOPAR/SalishSea/results/remin_param_sweep_new_depth//'\n", "tracer_file = 'SS5x5_1h_20150201_20150501_ptrc_T.nc'\n", "mesh_mask_file = 'mesh_mask.nc'\n", "individual_directories = []\n", "param_vals = []\n", "for file in os.listdir(group_results_directory):\n", " if file.startswith(\"nampisrem_zz_remin_D_PON_\"):\n", " val = float(file.split(\"nampisrem_zz_remin_D_PON_\")[1])\n", " individual_directories.append(file)\n", " param_vals.append(val)\n", "\n", "\n", "tracer_datasets = [xr.open_dataset(group_results_directory + '/' + file +'/' + tracer_file) for file in individual_directories]\n", "dataset_dict = dict(zip(param_vals, tracer_datasets))" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": true }, "outputs": [], "source": [ "depths = dataset_dict[param_vals[0]].deptht.values\n", "\n", "min_depth_index = np.argmax(depths > 150)\n", "max_depth_index = len(depths)\n", "\n", "#for param in param_vals:\n", "t = np.array([float(x) for x in dataset_dict[param_vals[0]].time_centered.values]) \n", "days = (t[:] - t[0])/10**9/3600/24\n", "\n", "min_day_index = np.argmax(days > 30)\n", "max_day_index = len(days)" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": true }, "outputs": [], "source": [ "mesh_mask = xr.open_dataset(group_results_directory + individual_directories[0] + '/' + mesh_mask_file)\n", "grid_heights = np.array(mesh_mask['e3t_1d'][0])" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "collapsed": true }, "outputs": [], "source": [ "NO3_quantity = ((dataset_dict[param_vals[0]].NO3.values)*(grid_heights.reshape((1,40,1,1))))" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
\n", " | PARAM | \n", "MEAN_NO3 | \n", "MEAN_POC | \n", "MEAN_NH4 | \n", "
---|---|---|---|---|
0 | \n", "3.645254e-07 | \n", "27.774619 | \n", "0.338328 | \n", "1.092818 | \n", "
1 | \n", "2.300000e-08 | \n", "27.604593 | \n", "0.486928 | \n", "1.056695 | \n", "
2 | \n", "1.451202e-06 | \n", "28.038497 | \n", "0.078631 | \n", "1.025275 | \n", "
3 | \n", "2.300000e-07 | \n", "27.717229 | \n", "0.404078 | \n", "1.088427 | \n", "
4 | \n", "3.645254e-08 | \n", "27.612870 | \n", "0.482154 | \n", "1.059693 | \n", "
5 | \n", "5.777339e-08 | \n", "27.625719 | \n", "0.474482 | \n", "1.064191 | \n", "
6 | \n", "1.451202e-07 | \n", "27.674775 | \n", "0.440640 | \n", "1.079094 | \n", "
7 | \n", "9.156465e-07 | \n", "27.937223 | \n", "0.157172 | \n", "1.064996 | \n", "
8 | \n", "5.777339e-07 | \n", "27.847876 | \n", "0.250091 | \n", "1.086484 | \n", "
9 | \n", "9.156465e-08 | \n", "27.645379 | \n", "0.461891 | \n", "1.070633 | \n", "