5 "execution_count": null,
6 "id": "6d28f8ee-2537-4dbb-872f-863cb8fb0381",
12 "import reproducibility\n",
13 "import pickle, os, math\n",
14 "import numpy as np\n",
15 "import matplotlib.pyplot as plt\n",
16 "from data_funcs import raws_data, synthetic_data, plot_data, check_data, rmse_data, plot_one\n",
22 "execution_count": null,
23 "id": "68d5eee1-63f9-4ef9-a2f4-c1549d6909a0",
29 "filename = 'data/testing_dict_CO_202206.pickle'\n",
30 "with open(filename, 'rb') as handle:\n",
31 " test_dict = pickle.load(handle)"
36 "execution_count": null,
37 "id": "65d182ba-d9af-4ed3-ad50-b3f22e430929",
43 "for case in test_dict:\n",
44 " test_dict[case]['case'] = case\n",
45 " test_dict[case]['filename'] = filename"
50 "execution_count": null,
51 "id": "2ca2b65e-37e3-4f4f-8f1a-d7b7a6a1bc23",
57 "def plt_rain_fmd(rain,fmd):\n",
58 " plt.figure(figsize=(16,4))\n",
59 " plt.scatter(rain,fmd)\n",
60 " plt.xlabel('Rain (mm/h)')\n",
61 " plt.ylabel('FMC change (%/h)')\n",
68 "execution_count": null,
69 "id": "89e2983e-be46-4dc6-89f7-a7c41bdecb22",
75 "def rain_to_fmd(dat):\n",
76 " rain = dat['rain']\n",
80 " dat['fmg']=np.zeros(hmax)\n",
81 " dat['fmr']=np.zeros(hmax)\n",
84 " for i in range(hmin,hmax):\n",
86 " fmd = fm[i] - fm[i-1]\n",
87 " dat['fmg'][i] = fmd.copy() # fm gradient in past hour\n",
88 " dat['fmr'][i] = fmd/rain[i] # increase in fm per mm of rain\n",
89 " rain_out.append(rain[i])\n",
90 " fmd_out.append(fmd)\n",
91 " plt.figure(figsize=(16,4))\n",
92 " plot_one(hmin,hmax,dat,'fmg',linestyle='-',c='r',label='FM change in 1h')\n",
93 " plot_one(hmin,hmax,dat,'rain',linestyle='--',c='r',label='rain (mm/h)')\n",
94 " plot_one(hmin,hmax,dat,'fmr',linestyle='-',c='k',label='FM change/mm rain')\n",
95 " plt.title(case + '-' + dat['title'])\n",
96 " plt.xlabel('Time (hours)')\n",
97 " plt.ylabel('FMC (%) change/rain mm')\n",
100 " # print('rain',rain_out)\n",
101 " # print('fmd',fmd_out)\n",
102 " print(\"rain\",\" \".join(f\"{num:.2f}\" for num in rain_out))\n",
103 " print(\"fmd \",\" \".join(f\"{num:.2f}\" for num in fmd_out))\n",
105 " return rain_out,fmd_out\n"
110 "execution_count": null,
111 "id": "f23e84a7-31a6-4640-9a5f-c4a5f77eb581",
119 "for case in test_dict:\n",
120 " case_data = test_dict[case]\n",
121 " if 'Synth' not in case_data['title']: \n",
122 " print('\\n***** ',case,'*****\\n')\n",
123 " plot_data(case_data)\n",
125 " rain_out,fmd_out = rain_to_fmd(case_data)\n",
126 " plt_rain_fmd(rain_out,fmd_out)\n",
127 " rain_all.extend(rain_out)\n",
128 " fmd_all.extend(fmd_out)\n",
129 " check_data(case_data)\n",
130 "plt_rain_fmd(rain_all,fmd_all)\n"
135 "execution_count": null,
136 "id": "5499085a-eb3e-4ec5-95df-2e0021fde003",
142 "plot_data(test_dict['case'])"
147 "execution_count": null,
148 "id": "89f72f45-abf4-49d8-9623-843684c3cf33",
159 "execution_count": null,
160 "id": "87ddb08f-902e-4e2f-8d97-ec0aa66f1a6e",
168 "display_name": "Python 3 (ipykernel)",
169 "language": "python",
177 "file_extension": ".py",
178 "mimetype": "text/x-python",
180 "nbconvert_exporter": "python",
181 "pygments_lexer": "ipython3",