|
25 | 25 | "source": [
|
26 | 26 | "## Functions covered\n",
|
27 | 27 | "- [dewtemp_trh](https://www.ncl.ucar.edu/Document/Functions/Built-in/dewtemp_trh.shtml)\n",
|
28 |
| - "- [daylight_fao56](https://www.ncl.ucar.edu/Document/Functions/Crop/daylight_fao56.shtml)" |
| 28 | + "- [daylight_fao56](https://www.ncl.ucar.edu/Document/Functions/Crop/daylight_fao56.shtml)\n", |
| 29 | + "- [satvpr_temp_fao56](https://www.ncl.ucar.edu/Document/Functions/Crop/satvpr_temp_fao56.shtml)" |
29 | 30 | ]
|
30 | 31 | },
|
31 | 32 | {
|
|
41 | 42 | "id": "3d70616a8934f0fb",
|
42 | 43 | "metadata": {},
|
43 | 44 | "source": [
|
44 |
| - "```{literalinclude} ../ncl_raw/dewtemp_trh.ncl\n", |
45 |
| - "\n", |
46 |
| - "```" |
47 |
| - ] |
48 |
| - }, |
49 |
| - { |
50 |
| - "cell_type": "markdown", |
51 |
| - "id": "3b32a066-055f-454b-a843-e57dca954dad", |
52 |
| - "metadata": {}, |
53 |
| - "source": [ |
54 |
| - "```{literalinclude} ../ncl_raw/daylight_fao56.ncl\n", |
| 45 | + "```{literalinclude} ../ncl_raw/meteorology.ncl\n", |
55 | 46 | "\n",
|
56 | 47 | "```"
|
57 | 48 | ]
|
|
184 | 175 | " geocat_daylight[pair] = max_daylight(doy, lat)"
|
185 | 176 | ]
|
186 | 177 | },
|
| 178 | + { |
| 179 | + "cell_type": "markdown", |
| 180 | + "id": "a1401358-81a8-4477-9bc9-bbdaf4224c76", |
| 181 | + "metadata": {}, |
| 182 | + "source": [ |
| 183 | + "### satvpr_temp_fao56" |
| 184 | + ] |
| 185 | + }, |
| 186 | + { |
| 187 | + "cell_type": "code", |
| 188 | + "execution_count": null, |
| 189 | + "id": "39c75093-80bc-44c8-880e-ad7f3cfc605c", |
| 190 | + "metadata": {}, |
| 191 | + "outputs": [], |
| 192 | + "source": [ |
| 193 | + "#### Collect NCL values for satvpr_temp_fao56 from geocat-datafiles\n", |
| 194 | + "import geocat.datafiles as gdf\n", |
| 195 | + "import numpy as np\n", |
| 196 | + "\n", |
| 197 | + "satvpr_temp_fao56_data = gdf.get(\n", |
| 198 | + " 'applications_files/ncl_outputs/satvpr_temp_fao56_output.txt'\n", |
| 199 | + ")\n", |
| 200 | + "satvpr_temp_fao56_data = np.loadtxt(satvpr_temp_fao56_data, delimiter=',', skiprows=6)" |
| 201 | + ] |
| 202 | + }, |
| 203 | + { |
| 204 | + "cell_type": "code", |
| 205 | + "execution_count": null, |
| 206 | + "id": "00f0ba20-176f-4139-bc65-a14e01695494", |
| 207 | + "metadata": {}, |
| 208 | + "outputs": [], |
| 209 | + "source": [ |
| 210 | + "### Collect NCL `satvpr_temp_fao56` value and associated (temp, satvpr_temp) values\n", |
| 211 | + "ncl_satvpr_temp_fao56 = dict(\n", |
| 212 | + " zip(satvpr_temp_fao56_data[::, 0], satvpr_temp_fao56_data[::, 1])\n", |
| 213 | + ")" |
| 214 | + ] |
| 215 | + }, |
| 216 | + { |
| 217 | + "cell_type": "code", |
| 218 | + "execution_count": null, |
| 219 | + "id": "128843eb-c4ad-425a-a1ec-de89545bcb15", |
| 220 | + "metadata": {}, |
| 221 | + "outputs": [], |
| 222 | + "source": [ |
| 223 | + "### Calculate GeoCAT-Comp `satvpr_temp_fao56`\n", |
| 224 | + "from geocat.comp import saturation_vapor_pressure\n", |
| 225 | + "\n", |
| 226 | + "geocat_satvpr_temp_fao56 = {}\n", |
| 227 | + "\n", |
| 228 | + "for temp in range(33, 212 + 1):\n", |
| 229 | + " geocat_satvpr_temp_fao56[temp] = saturation_vapor_pressure(temp)" |
| 230 | + ] |
| 231 | + }, |
187 | 232 | {
|
188 | 233 | "cell_type": "markdown",
|
189 | 234 | "id": "3237a0bffc6827fc",
|
|
192 | 237 | "## Comparison"
|
193 | 238 | ]
|
194 | 239 | },
|
| 240 | + { |
| 241 | + "cell_type": "markdown", |
| 242 | + "id": "38089ce5-395d-4956-8297-cde6ef5aa99e", |
| 243 | + "metadata": {}, |
| 244 | + "source": [ |
| 245 | + "### dewtemp_trh" |
| 246 | + ] |
| 247 | + }, |
195 | 248 | {
|
196 | 249 | "cell_type": "code",
|
197 | 250 | "execution_count": null,
|
|
215 | 268 | " print(f\"\\tDifference: {ncl_dewtemp[pair] - geocat_dewtemp[pair]}\")"
|
216 | 269 | ]
|
217 | 270 | },
|
| 271 | + { |
| 272 | + "cell_type": "markdown", |
| 273 | + "id": "b9cd9ad4-f898-460c-b79b-eef6f7a8e89d", |
| 274 | + "metadata": {}, |
| 275 | + "source": [ |
| 276 | + "### daylight_fao56" |
| 277 | + ] |
| 278 | + }, |
218 | 279 | {
|
219 | 280 | "cell_type": "code",
|
220 | 281 | "execution_count": null,
|
221 | 282 | "id": "840d88ab-7ecc-485a-9aaf-d8de846196a9",
|
222 | 283 | "metadata": {},
|
223 | 284 | "outputs": [],
|
224 | 285 | "source": [
|
| 286 | + "import math\n", |
| 287 | + "\n", |
225 | 288 | "for pair in ncl_daylight.keys():\n",
|
226 | 289 | " assert math.isclose(\n",
|
227 | 290 | " ncl_daylight[pair], geocat_daylight[pair].flatten()[0], rel_tol=1e-05\n",
|
228 | 291 | " ) # within 5 decimal points"
|
229 | 292 | ]
|
| 293 | + }, |
| 294 | + { |
| 295 | + "cell_type": "markdown", |
| 296 | + "id": "db0d8bbd-4899-4932-a28d-107c08e12a15", |
| 297 | + "metadata": {}, |
| 298 | + "source": [ |
| 299 | + "### satvpr_temp_fao56" |
| 300 | + ] |
| 301 | + }, |
| 302 | + { |
| 303 | + "cell_type": "code", |
| 304 | + "execution_count": null, |
| 305 | + "id": "134f8583-0e96-43fe-8b0b-94a5e58566be", |
| 306 | + "metadata": {}, |
| 307 | + "outputs": [], |
| 308 | + "source": [ |
| 309 | + "import math\n", |
| 310 | + "\n", |
| 311 | + "for key in ncl_satvpr_temp_fao56.keys():\n", |
| 312 | + " assert math.isclose(\n", |
| 313 | + " ncl_satvpr_temp_fao56[key], geocat_satvpr_temp_fao56[key], rel_tol=1e-05\n", |
| 314 | + " ) # within 5 decimal points" |
| 315 | + ] |
230 | 316 | }
|
231 | 317 | ],
|
232 | 318 | "metadata": {
|
|
245 | 331 | "name": "python",
|
246 | 332 | "nbconvert_exporter": "python",
|
247 | 333 | "pygments_lexer": "ipython3",
|
248 |
| - "version": "3.11.8" |
| 334 | + "version": "3.12.7" |
249 | 335 | }
|
250 | 336 | },
|
251 | 337 | "nbformat": 4,
|
|
0 commit comments