{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "334b15fa", "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "import xarray as xr\n", "import matplotlib as mpl\n", "#mpl.use('Agg') # Must be before importing matplotlib.pyplot or pylab!\n", "import matplotlib.pyplot as plt\n", "import pandas as pd\n", "import os\n", "import seaborn as sns\n", "import timeit\n", "#start_time = timeit.default_timer()\n", "from datetime import datetime,timedelta\n", "\n" ] }, { "cell_type": "markdown", "id": "70b2111f", "metadata": {}, "source": [ "Plot parameters" ] }, { "cell_type": "code", "execution_count": 3, "id": "191a1193", "metadata": {}, "outputs": [], "source": [ "mpl.rcParams['axes.linewidth'] = 2.0 #set the value globally\n", "\n", "plt.rc('font', family='serif',size = 16) # controls default text layout\n", "plt.rc('axes', titlesize=16) # fontsize of the axes title\n", "plt.rc('axes', labelsize=16) # fontsize of the x and y labels\n", "plt.rc('xtick', labelsize=10) # fontsize of the tick labels\n", "plt.rc('ytick', labelsize=16) # fontsize of the tick labels\n", "plt.rc('legend', fontsize=16) # legend fontsize\n", "plt.rc('figure', titlesize=16) # fontsize of the figure title\n", "\n", "#plt.minorticks_on()\n", "plt.rc('text', usetex=False)\n", "sns.set(font = \"Cambria\",font_scale=1.5,style=\"whitegrid\")\n", "#sns.set(font = \"Cambria\",font_scale=1.5,style=\"white\")\n", "\n", "#mpl.rc_file_defaults() #undos seaborn effects\n", "\n", "#custom fontsize, if needed\n", "font = 12\n", "\n", "%matplotlib inline" ] }, { "cell_type": "markdown", "id": "9c9d6a0f", "metadata": {}, "source": [ "## Plot the simulated tower data at the WLEF tall tower for 32 and 122m heights. Both 1 minute, high frequency data and 1 hour averaged data. For winds, T and q. For both the IOP test cases. " ] }, { "cell_type": "markdown", "id": "6e21fc03", "metadata": {}, "source": [ "### IOP02 test case" ] }, { "cell_type": "code", "execution_count": 3, "id": "de09bbaf", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'/bog/incoming/CHEESEHEAD/palm/realistic_runs'" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "pwd()" ] }, { "cell_type": "code", "execution_count": 6, "id": "83f022a0", "metadata": {}, "outputs": [], "source": [ "#using data from ensemble.member.1\n", "#open all the folders inside and read data from DATA_MASK_NETCDF_N03_M01_slice\n", "#skip if not found." ] }, { "cell_type": "code", "execution_count": 4, "id": "b443b92a", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Folder list: \n", "06.ches_IOP2.31028\n", "04.ches_IOP2.20941\n", "05.ches_IOP2.13864\n", "07.ches_IOP2.19931\n", "08.ches_IOP2.19743\n", "02.ches_IOP2.10023\n", "03.ches_IOP2.28390\n" ] } ], "source": [ "file_name = 'DATA_MASK_NETCDF_N03_M01slice'\n", "source_folder = 'ches_IOP2/ensemble.member.1'\n", "\n", "#get list of all the sub-folders, pertaining to different runs\n", "folder_list = os.listdir(source_folder)\n", "\n", "print ('Folder list: ')\n", "simulated_WLEF_data_list = []\n", "#read in the files from the folders and create a list of them \n", "for i, folder in enumerate(folder_list):\n", " file = source_folder + '/' + folder + '/' + file_name\n", " #check if file exists\n", " if os.path.exists(file):\n", " print(folder)\n", " ds = xr.open_dataset(file)\n", " ds.close()\n", " #append the data to the list\n", " simulated_WLEF_data_list.append(ds)\n", " \n", "\n", "#concatenate the list into one dataset and sort it by time \n", "simulated_WLEF_ds = xr.concat(simulated_WLEF_data_list, dim='time')\n", "simulated_WLEF_ds = simulated_WLEF_ds.sortby('time')" ] }, { "cell_type": "code", "execution_count": 5, "id": "7329ead0", "metadata": {}, "outputs": [], "source": [ "simulated_WLEF_ds['time'] = pd.to_datetime('2019-09-24') + simulated_WLEF_ds['time'].values\n" ] }, { "cell_type": "code", "execution_count": 6, "id": "b23a7df1", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
<xarray.Dataset>\n", "Dimensions: (x: 3, time: 234001, y: 3, xu: 3, yv: 3, zu_3d: 9, zw_3d: 9)\n", "Coordinates:\n", " * x (x) float64 6.069e+03 6.075e+03 6.081e+03\n", " * y (y) float64 6.177e+03 6.183e+03 6.189e+03\n", " * xu (xu) float64 6.066e+03 6.072e+03 6.078e+03\n", " * yv (yv) float64 6.174e+03 6.18e+03 6.186e+03\n", " * time (time) datetime64[ns] 2019-09-24T05:00:00.000000175 ... 2019-09-...\n", " * zu_3d (zu_3d) float64 26.0 30.0 34.0 94.0 98.0 102.0 194.0 198.0 202.0\n", " * zw_3d (zw_3d) float64 28.0 32.0 36.0 96.0 100.0 104.0 196.0 200.0 204.0\n", "Data variables: (12/19)\n", " E_UTM (time, x) float64 4.989e+05 4.989e+05 ... 4.989e+05 4.989e+05\n", " N_UTM (time, y) float64 6.082e+05 6.082e+05 ... 6.082e+05 6.082e+05\n", " Eu_UTM (time, xu) float64 4.989e+05 4.989e+05 ... 4.989e+05 4.989e+05\n", " Nu_UTM (time, y) float64 6.082e+05 6.082e+05 ... 6.082e+05 6.082e+05\n", " Ev_UTM (time, x) float64 4.989e+05 4.989e+05 ... 4.989e+05 4.989e+05\n", " Nv_UTM (time, yv) float64 6.081e+05 6.082e+05 ... 6.082e+05 6.082e+05\n", " ... ...\n", " u (time, zu_3d, y, xu) float32 -1.056 -1.043 ... -0.08569 -0.07362\n", " v (time, zu_3d, yv, x) float32 -0.8337 -0.8085 ... -0.3529 -0.3564\n", " w (time, zw_3d, y, x) float32 0.0792 0.06818 ... -0.3379 -0.3185\n", " theta (time, zu_3d, y, x) float32 283.4 283.4 283.5 ... 296.1 296.1 296.1\n", " q (time, zu_3d, y, x) float32 0.008522 0.008525 ... 0.005993 0.005993\n", " s (time, zu_3d, y, x) float32 438.2 438.2 438.2 ... 408.3 408.3 408.3\n", "Attributes: (12/27)\n", " title: PALM 21.10-rc.2 run: ches_IOP2.06 nest-id: 03 host: b...\n", " Conventions: CF-1.7\n", " creation_time: 2022-06-22 12:28:01 -06\n", " data_content: podsmasked\n", " version: 7\n", " origin_time: 2019-08-22 05:00:00 +00\n", " ... ...\n", " source: PALM 21.10-rc.2\n", " references: \n", " keywords: example, PALM-4U\n", " licence: \n", " comment: Generic crossing example\n", " VAR_LIST: ;u;v;w;theta;q;s;
\n", " | ws30 | \n", "wsSTD30 | \n", "wd30 | \n", "wdSTD30 | \n", "T30 | \n", "RH30 | \n", "q30 | \n", "ws122 | \n", "wsSTD122 | \n", "wd122 | \n", "... | \n", "ws396 | \n", "wsSTD396 | \n", "wd396 | \n", "wdSTD396 | \n", "T396 | \n", "RH396 | \n", "q396 | \n", "SFCPres | \n", "precip | \n", "PAR | \n", "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
2019-09-24 00:00:00 | \n", "1.74 | \n", "0.21 | \n", "250.67 | \n", "6.97 | \n", "17.60 | \n", "60.05 | \n", "7.94 | \n", "6.41 | \n", "0.13 | \n", "266.82 | \n", "... | \n", "8.66 | \n", "0.15 | \n", "270.20 | \n", "0.56 | \n", "15.79 | \n", "57.19 | \n", "6.73 | \n", "95.77 | \n", "0.0 | \n", "5.17 | \n", "
2019-09-24 00:01:00 | \n", "1.43 | \n", "0.23 | \n", "245.86 | \n", "8.79 | \n", "17.57 | \n", "60.24 | \n", "7.95 | \n", "6.34 | \n", "0.25 | \n", "264.77 | \n", "... | \n", "8.80 | \n", "0.15 | \n", "270.25 | \n", "1.09 | \n", "15.79 | \n", "57.39 | \n", "6.75 | \n", "95.77 | \n", "0.0 | \n", "4.44 | \n", "
2019-09-24 00:02:00 | \n", "1.47 | \n", "0.21 | \n", "247.24 | \n", "8.24 | \n", "17.54 | \n", "60.37 | \n", "7.96 | \n", "6.44 | \n", "0.29 | \n", "264.66 | \n", "... | \n", "8.49 | \n", "0.20 | \n", "271.00 | \n", "0.95 | \n", "15.79 | \n", "57.59 | \n", "6.78 | \n", "95.77 | \n", "0.0 | \n", "3.76 | \n", "
2019-09-24 00:03:00 | \n", "1.53 | \n", "0.31 | \n", "252.22 | \n", "5.67 | \n", "17.48 | \n", "60.92 | \n", "8.00 | \n", "6.67 | \n", "0.22 | \n", "266.08 | \n", "... | \n", "8.04 | \n", "0.17 | \n", "269.08 | \n", "1.45 | \n", "15.79 | \n", "57.73 | \n", "6.79 | \n", "95.78 | \n", "0.0 | \n", "3.06 | \n", "
2019-09-24 00:04:00 | \n", "1.49 | \n", "0.26 | \n", "248.44 | \n", "6.26 | \n", "17.41 | \n", "60.97 | \n", "7.97 | \n", "6.76 | \n", "0.12 | \n", "266.08 | \n", "... | \n", "8.30 | \n", "0.22 | \n", "270.94 | \n", "1.37 | \n", "15.79 | \n", "57.88 | \n", "6.81 | \n", "95.78 | \n", "0.0 | \n", "2.45 | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
2019-09-24 23:55:00 | \n", "-999.00 | \n", "-999.00 | \n", "-999.00 | \n", "-999.00 | \n", "21.24 | \n", "76.71 | \n", "12.98 | \n", "-999.00 | \n", "-999.00 | \n", "-999.00 | \n", "... | \n", "-999.00 | \n", "-999.00 | \n", "-999.00 | \n", "-999.00 | \n", "19.31 | \n", "79.57 | \n", "11.93 | \n", "94.65 | \n", "0.0 | \n", "2.99 | \n", "
2019-09-24 23:56:00 | \n", "-999.00 | \n", "-999.00 | \n", "-999.00 | \n", "-999.00 | \n", "21.20 | \n", "76.63 | \n", "12.94 | \n", "-999.00 | \n", "-999.00 | \n", "-999.00 | \n", "... | \n", "-999.00 | \n", "-999.00 | \n", "-999.00 | \n", "-999.00 | \n", "19.31 | \n", "79.66 | \n", "11.95 | \n", "94.64 | \n", "0.0 | \n", "2.72 | \n", "
2019-09-24 23:57:00 | \n", "-999.00 | \n", "-999.00 | \n", "-999.00 | \n", "-999.00 | \n", "21.19 | \n", "76.70 | \n", "12.94 | \n", "-999.00 | \n", "-999.00 | \n", "-999.00 | \n", "... | \n", "-999.00 | \n", "-999.00 | \n", "-999.00 | \n", "-999.00 | \n", "19.31 | \n", "79.71 | \n", "11.95 | \n", "94.64 | \n", "0.0 | \n", "2.40 | \n", "
2019-09-24 23:58:00 | \n", "-999.00 | \n", "-999.00 | \n", "-999.00 | \n", "-999.00 | \n", "21.19 | \n", "76.86 | \n", "12.97 | \n", "-999.00 | \n", "-999.00 | \n", "-999.00 | \n", "... | \n", "-999.00 | \n", "-999.00 | \n", "-999.00 | \n", "-999.00 | \n", "19.31 | \n", "79.75 | \n", "11.96 | \n", "94.63 | \n", "0.0 | \n", "2.11 | \n", "
2019-09-24 23:59:00 | \n", "-999.00 | \n", "-999.00 | \n", "-999.00 | \n", "-999.00 | \n", "-999.00 | \n", "-999.00 | \n", "-999.00 | \n", "-999.00 | \n", "-999.00 | \n", "-999.00 | \n", "... | \n", "-999.00 | \n", "-999.00 | \n", "-999.00 | \n", "-999.00 | \n", "-999.00 | \n", "-999.00 | \n", "-999.00 | \n", "-999.00 | \n", "-999.0 | \n", "-999.00 | \n", "
1440 rows × 24 columns
\n", "" ], "text/plain": [ " ws30 wsSTD30 wd30 wdSTD30 T30 RH30 q30 \\\n", "2019-09-24 00:00:00 1.74 0.21 250.67 6.97 17.60 60.05 7.94 \n", "2019-09-24 00:01:00 1.43 0.23 245.86 8.79 17.57 60.24 7.95 \n", "2019-09-24 00:02:00 1.47 0.21 247.24 8.24 17.54 60.37 7.96 \n", "2019-09-24 00:03:00 1.53 0.31 252.22 5.67 17.48 60.92 8.00 \n", "2019-09-24 00:04:00 1.49 0.26 248.44 6.26 17.41 60.97 7.97 \n", "... ... ... ... ... ... ... ... \n", "2019-09-24 23:55:00 -999.00 -999.00 -999.00 -999.00 21.24 76.71 12.98 \n", "2019-09-24 23:56:00 -999.00 -999.00 -999.00 -999.00 21.20 76.63 12.94 \n", "2019-09-24 23:57:00 -999.00 -999.00 -999.00 -999.00 21.19 76.70 12.94 \n", "2019-09-24 23:58:00 -999.00 -999.00 -999.00 -999.00 21.19 76.86 12.97 \n", "2019-09-24 23:59:00 -999.00 -999.00 -999.00 -999.00 -999.00 -999.00 -999.00 \n", "\n", " ws122 wsSTD122 wd122 ... ws396 wsSTD396 wd396 \\\n", "2019-09-24 00:00:00 6.41 0.13 266.82 ... 8.66 0.15 270.20 \n", "2019-09-24 00:01:00 6.34 0.25 264.77 ... 8.80 0.15 270.25 \n", "2019-09-24 00:02:00 6.44 0.29 264.66 ... 8.49 0.20 271.00 \n", "2019-09-24 00:03:00 6.67 0.22 266.08 ... 8.04 0.17 269.08 \n", "2019-09-24 00:04:00 6.76 0.12 266.08 ... 8.30 0.22 270.94 \n", "... ... ... ... ... ... ... ... \n", "2019-09-24 23:55:00 -999.00 -999.00 -999.00 ... -999.00 -999.00 -999.00 \n", "2019-09-24 23:56:00 -999.00 -999.00 -999.00 ... -999.00 -999.00 -999.00 \n", "2019-09-24 23:57:00 -999.00 -999.00 -999.00 ... -999.00 -999.00 -999.00 \n", "2019-09-24 23:58:00 -999.00 -999.00 -999.00 ... -999.00 -999.00 -999.00 \n", "2019-09-24 23:59:00 -999.00 -999.00 -999.00 ... -999.00 -999.00 -999.00 \n", "\n", " wdSTD396 T396 RH396 q396 SFCPres precip PAR \n", "2019-09-24 00:00:00 0.56 15.79 57.19 6.73 95.77 0.0 5.17 \n", "2019-09-24 00:01:00 1.09 15.79 57.39 6.75 95.77 0.0 4.44 \n", "2019-09-24 00:02:00 0.95 15.79 57.59 6.78 95.77 0.0 3.76 \n", "2019-09-24 00:03:00 1.45 15.79 57.73 6.79 95.78 0.0 3.06 \n", "2019-09-24 00:04:00 1.37 15.79 57.88 6.81 95.78 0.0 2.45 \n", "... ... ... ... ... ... ... ... \n", "2019-09-24 23:55:00 -999.00 19.31 79.57 11.93 94.65 0.0 2.99 \n", "2019-09-24 23:56:00 -999.00 19.31 79.66 11.95 94.64 0.0 2.72 \n", "2019-09-24 23:57:00 -999.00 19.31 79.71 11.95 94.64 0.0 2.40 \n", "2019-09-24 23:58:00 -999.00 19.31 79.75 11.96 94.63 0.0 2.11 \n", "2019-09-24 23:59:00 -999.00 -999.00 -999.00 -999.00 -999.00 -999.0 -999.00 \n", "\n", "[1440 rows x 24 columns]" ] }, "execution_count": 18, "metadata": {}, "output_type": "execute_result" } ], "source": [ "WLEF_20190924_df" ] }, { "cell_type": "code", "execution_count": 46, "id": "e5387ff2", "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", " | ws30 | \n", "wsSTD30 | \n", "wd30 | \n", "wdSTD30 | \n", "T30 | \n", "RH30 | \n", "q30 | \n", "ws122 | \n", "wsSTD122 | \n", "wd122 | \n", "... | \n", "wsSTD396 | \n", "wd396 | \n", "wdSTD396 | \n", "T396 | \n", "RH396 | \n", "q396 | \n", "SFCPres | \n", "precip | \n", "PAR | \n", "Timestamp | \n", "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
2019-09-24 05:00:00 | \n", "2.53 | \n", "0.35 | \n", "223.11 | \n", "7.12 | \n", "12.46 | \n", "82.10 | \n", "7.80 | \n", "9.99 | \n", "0.06 | \n", "257.23 | \n", "... | \n", "0.02 | \n", "264.51 | \n", "0.07 | \n", "15.88 | \n", "53.50 | \n", "6.33 | \n", "95.77 | \n", "0.0 | \n", "0.00 | \n", "2019-09-24 00:00:00 | \n", "
2019-09-24 05:01:00 | \n", "2.28 | \n", "0.51 | \n", "222.09 | \n", "7.41 | \n", "12.48 | \n", "81.90 | \n", "7.79 | \n", "10.02 | \n", "0.12 | \n", "257.85 | \n", "... | \n", "0.02 | \n", "264.70 | \n", "0.11 | \n", "15.88 | \n", "53.46 | \n", "6.32 | \n", "95.77 | \n", "0.0 | \n", "0.01 | \n", "2019-09-24 00:01:00 | \n", "
2019-09-24 05:02:00 | \n", "2.24 | \n", "0.50 | \n", "225.87 | \n", "7.84 | \n", "12.55 | \n", "81.60 | \n", "7.80 | \n", "9.88 | \n", "0.09 | \n", "257.72 | \n", "... | \n", "0.04 | \n", "265.11 | \n", "0.14 | \n", "15.88 | \n", "53.43 | \n", "6.32 | \n", "95.77 | \n", "0.0 | \n", "0.06 | \n", "2019-09-24 00:02:00 | \n", "
2019-09-24 05:03:00 | \n", "2.08 | \n", "0.54 | \n", "226.14 | \n", "8.71 | \n", "12.59 | \n", "81.50 | \n", "7.81 | \n", "9.55 | \n", "0.13 | \n", "255.64 | \n", "... | \n", "0.02 | \n", "265.59 | \n", "0.17 | \n", "15.89 | \n", "53.36 | \n", "6.32 | \n", "95.77 | \n", "0.0 | \n", "0.11 | \n", "2019-09-24 00:03:00 | \n", "
2019-09-24 05:04:00 | \n", "2.02 | \n", "0.31 | \n", "222.46 | \n", "7.22 | \n", "12.58 | \n", "81.60 | \n", "7.81 | \n", "9.21 | \n", "0.14 | \n", "253.02 | \n", "... | \n", "0.03 | \n", "266.15 | \n", "0.15 | \n", "15.93 | \n", "53.31 | \n", "6.33 | \n", "95.77 | \n", "0.0 | \n", "0.12 | \n", "2019-09-24 00:04:00 | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
2019-09-26 04:56:00 | \n", "2.88 | \n", "0.76 | \n", "270.15 | \n", "14.76 | \n", "9.57 | \n", "72.34 | \n", "5.68 | \n", "-999.00 | \n", "-999.00 | \n", "-999.00 | \n", "... | \n", "0.20 | \n", "295.05 | \n", "0.64 | \n", "8.21 | \n", "65.51 | \n", "4.69 | \n", "95.27 | \n", "0.0 | \n", "0.11 | \n", "2019-09-25 23:56:00 | \n", "
2019-09-26 04:57:00 | \n", "3.30 | \n", "0.65 | \n", "277.63 | \n", "12.01 | \n", "9.57 | \n", "72.63 | \n", "5.71 | \n", "-999.00 | \n", "-999.00 | \n", "-999.00 | \n", "... | \n", "0.18 | \n", "295.22 | \n", "0.51 | \n", "8.22 | \n", "65.25 | \n", "4.67 | \n", "95.27 | \n", "0.0 | \n", "0.10 | \n", "2019-09-25 23:57:00 | \n", "
2019-09-26 04:58:00 | \n", "2.68 | \n", "0.53 | \n", "275.87 | \n", "12.52 | \n", "9.54 | \n", "72.69 | \n", "5.70 | \n", "-999.00 | \n", "-999.00 | \n", "-999.00 | \n", "... | \n", "0.10 | \n", "294.42 | \n", "0.50 | \n", "8.28 | \n", "64.84 | \n", "4.66 | \n", "95.27 | \n", "0.0 | \n", "0.11 | \n", "2019-09-25 23:58:00 | \n", "
2019-09-26 04:59:00 | \n", "3.03 | \n", "0.82 | \n", "281.42 | \n", "14.56 | \n", "9.54 | \n", "72.62 | \n", "5.69 | \n", "-999.00 | \n", "-999.00 | \n", "-999.00 | \n", "... | \n", "0.12 | \n", "294.93 | \n", "0.53 | \n", "8.31 | \n", "65.11 | \n", "4.69 | \n", "95.27 | \n", "0.0 | \n", "0.09 | \n", "2019-09-25 23:59:00 | \n", "
2019-09-26 05:00:00 | \n", "2.99 | \n", "0.99 | \n", "267.06 | \n", "15.81 | \n", "9.51 | \n", "72.84 | \n", "5.70 | \n", "-999.00 | \n", "-999.00 | \n", "-999.00 | \n", "... | \n", "0.11 | \n", "294.60 | \n", "0.48 | \n", "8.31 | \n", "65.32 | \n", "4.71 | \n", "95.27 | \n", "0.0 | \n", "0.09 | \n", "2019-09-26 00:00:00 | \n", "
2881 rows × 25 columns
\n", "