|
25 | 25 | {
|
26 | 26 | "cell_type": "code",
|
27 | 27 | "execution_count": 2,
|
28 |
| - "id": "9d83f101-2549-4fb9-991d-bf011853dc34", |
29 |
| - "metadata": {}, |
30 |
| - "outputs": [], |
31 |
| - "source": [ |
32 |
| - "# load functions.py (like `import`)\n", |
33 |
| - "%run '/home/561/vo7653/.jupyter-root/functions.ipynb'" |
34 |
| - ] |
35 |
| - }, |
36 |
| - { |
37 |
| - "cell_type": "code", |
38 |
| - "execution_count": 3, |
39 | 28 | "id": "b2a3b6a9-ad5b-4642-9088-0cce8fa64b10",
|
40 | 29 | "metadata": {},
|
41 | 30 | "outputs": [],
|
42 | 31 | "source": [
|
43 |
| - "sns.set_context(\"talk\")\n", |
44 |
| - "#sns.set_context(\"notebook\")\n", |
45 |
| - "\n", |
46 |
| - "# Global variables (for plotting mainly)\n", |
47 |
| - "\n", |
48 |
| - "# symbol for phase\n", |
49 |
| - "phi = r'$\\varphi$'" |
| 32 | + "sns.set_context(\"talk\")" |
50 | 33 | ]
|
51 | 34 | },
|
52 | 35 | {
|
|
63 | 46 | "cell_type": "markdown",
|
64 | 47 | "id": "017ae224-572b-4981-b757-8fac10b2a5da",
|
65 | 48 | "metadata": {
|
66 |
| - "jp-MarkdownHeadingCollapsed": true, |
67 | 49 | "tags": []
|
68 | 50 | },
|
69 | 51 | "source": [
|
|
72 | 54 | },
|
73 | 55 | {
|
74 | 56 | "cell_type": "code",
|
75 |
| - "execution_count": 4, |
| 57 | + "execution_count": 3, |
76 | 58 | "id": "32757b76-1621-4c0e-9c21-51a3c18e5751",
|
77 | 59 | "metadata": {
|
78 | 60 | "tags": []
|
79 | 61 | },
|
80 | 62 | "outputs": [],
|
81 | 63 | "source": [
|
82 |
| - "## CODE FROM MARTIN'S REPOSITORY!\n", |
| 64 | + "## CODE FROM MARTIN'S AOSTOOLS REPOSITORY!\n", |
83 | 65 | "# Just copied here to modify the return of StatTes() function.\n",
|
84 |
| - "# Maybe worth add this changes as a flag in aostools.climate.py\n", |
85 |
| - "# Talk to Martin!!\n", |
86 | 66 | "\n",
|
87 | 67 | "def StackArray(x,dim):\n",
|
88 |
| - "\t'''return stacked array with only one dimension left\n", |
89 |
| - "\n", |
90 |
| - "\tINPUTS:\n", |
91 |
| - "\t x : xarray.DataArray or Dataset to be stacked\n", |
92 |
| - "\t dim: sole dimension to remain after stacking, None if all dimensions to be stacked\n", |
93 |
| - "\tOUTPUTS:\n", |
94 |
| - "\t stacked: same as x, but stacked\n", |
95 |
| - "\t'''\n", |
96 |
| - "\tif len(x.dims) == 0:\n", |
97 |
| - "\t\treturn x\n", |
98 |
| - "\tif dim not in x.dims or dim is None:\n", |
99 |
| - "\t\tdims = list(x.dims)\n", |
100 |
| - "\telse:\n", |
101 |
| - "\t\tdims = []\n", |
102 |
| - "\t\tfor d in x.dims:\n", |
103 |
| - "\t\t\tif d != dim:\n", |
104 |
| - "\t\t\t\tdims.append(d)\n", |
105 |
| - "\treturn x.stack(stacked=dims)\n", |
| 68 | + " '''return stacked array with only one dimension left\n", |
| 69 | + " INPUTS:\n", |
| 70 | + " x : xarray.DataArray or Dataset to be stacked\n", |
| 71 | + " dim: sole dimension to remain after stacking, None if all dimensions to be stacked\n", |
| 72 | + " OUTPUTS:\n", |
| 73 | + " stacked: same as x, but stacked\n", |
| 74 | + " '''\n", |
| 75 | + " if len(x.dims) == 0:\n", |
| 76 | + " return x\n", |
| 77 | + " if dim not in x.dims or dim is None:\n", |
| 78 | + " dims = list(x.dims)\n", |
| 79 | + " else:\n", |
| 80 | + " dims = []\n", |
| 81 | + " for d in x.dims:\n", |
| 82 | + " if d != dim:\n", |
| 83 | + " dims.append(d)\n", |
| 84 | + " return x.stack(stacked=dims)\n", |
106 | 85 | "\n",
|
107 | 86 | "def ComputeStat(i,sx,y,sy,test, tstat_r=False):\n",
|
108 | 87 | " '''This is part of StatTest, but for parmap.map to work, it has to be an\n",
|
|
204 | 183 | },
|
205 | 184 | {
|
206 | 185 | "cell_type": "code",
|
207 |
| - "execution_count": 6, |
| 186 | + "execution_count": 4, |
208 | 187 | "id": "8d6ae13c-31fb-433b-904d-d7d8cf6a7b09",
|
209 | 188 | "metadata": {
|
210 | 189 | "tags": []
|
|
494 | 473 | },
|
495 | 474 | {
|
496 | 475 | "cell_type": "code",
|
497 |
| - "execution_count": null, |
| 476 | + "execution_count": 5, |
498 | 477 | "id": "11d45ea5-5539-47a4-9572-f0f51858f9cc",
|
499 | 478 | "metadata": {
|
500 | 479 | "tags": []
|
|
615 | 594 | },
|
616 | 595 | {
|
617 | 596 | "cell_type": "code",
|
618 |
| - "execution_count": null, |
| 597 | + "execution_count": 6, |
619 | 598 | "id": "ee02374b-4751-4ddb-9599-f0cab5493d32",
|
620 | 599 | "metadata": {
|
621 | 600 | "tags": []
|
|
1126 | 1105 | "cell_type": "markdown",
|
1127 | 1106 | "id": "a98e7e9e-fd80-4e07-acce-1166602c3f08",
|
1128 | 1107 | "metadata": {
|
| 1108 | + "jp-MarkdownHeadingCollapsed": true, |
1129 | 1109 | "tags": []
|
1130 | 1110 | },
|
1131 | 1111 | "source": [
|
|
1135 | 1115 | },
|
1136 | 1116 | {
|
1137 | 1117 | "cell_type": "code",
|
1138 |
| - "execution_count": 8, |
| 1118 | + "execution_count": 7, |
1139 | 1119 | "id": "3432156b-c171-4cdc-ac4b-43930acab88f",
|
1140 | 1120 | "metadata": {
|
1141 | 1121 | "tags": []
|
1142 | 1122 | },
|
1143 | 1123 | "outputs": [],
|
1144 | 1124 | "source": [
|
1145 | 1125 | "# ERA5 data dir\n",
|
| 1126 | + "# (replace here with the path where your ERA5 data is stored)\n", |
1146 | 1127 | "era5_dir = '/g/data/w40/vo7653/downsized_data/ERA5/daily_data/'\n",
|
1147 | 1128 | "\n",
|
1148 | 1129 | "# daily meridional wind\n",
|
|
1176 | 1157 | },
|
1177 | 1158 | {
|
1178 | 1159 | "cell_type": "code",
|
1179 |
| - "execution_count": 10, |
| 1160 | + "execution_count": 8, |
1180 | 1161 | "id": "081f8a87-91d7-456e-ba67-bb665adf66d3",
|
1181 | 1162 | "metadata": {
|
1182 | 1163 | "tags": []
|
|
1223 | 1204 | "cell_type": "markdown",
|
1224 | 1205 | "id": "05ebaf5f-eb50-484c-9c26-df1b14384449",
|
1225 | 1206 | "metadata": {
|
| 1207 | + "jp-MarkdownHeadingCollapsed": true, |
1226 | 1208 | "tags": []
|
1227 | 1209 | },
|
1228 | 1210 | "source": [
|
|
1232 | 1214 | },
|
1233 | 1215 | {
|
1234 | 1216 | "cell_type": "code",
|
1235 |
| - "execution_count": 14, |
| 1217 | + "execution_count": 9, |
1236 | 1218 | "id": "e68ef92a-f1fd-4e99-a588-a03e5f90ceec",
|
1237 | 1219 | "metadata": {
|
1238 | 1220 | "tags": []
|
|
1311 | 1293 | "cell_type": "markdown",
|
1312 | 1294 | "id": "8aac5c14-5fcc-4184-a032-98024691fc42",
|
1313 | 1295 | "metadata": {
|
| 1296 | + "jp-MarkdownHeadingCollapsed": true, |
1314 | 1297 | "tags": []
|
1315 | 1298 | },
|
1316 | 1299 | "source": [
|
|
1345 | 1328 | "cell_type": "markdown",
|
1346 | 1329 | "id": "20873277-cb2e-4ec4-ba71-0ce6e5a734ce",
|
1347 | 1330 | "metadata": {
|
| 1331 | + "jp-MarkdownHeadingCollapsed": true, |
1348 | 1332 | "tags": []
|
1349 | 1333 | },
|
1350 | 1334 | "source": [
|
|
1407 | 1391 | "\n",
|
1408 | 1392 | "# gp\n",
|
1409 | 1393 | "gp_comp_ = []\n",
|
1410 |
| - "for s in ['DJF', 'MAM', 'JJA', 'SON']:\n", |
| 1394 | + "for s in ['DJF']:#, 'MAM', 'JJA', 'SON']:\n", |
1411 | 1395 | " gp_comp_s = lag_compose_on_w3(gp_roll_anom, phase, amp, bins, lags, V=Vtp_79, season=s)\n",
|
1412 | 1396 | " gp_comp_s['stdd'] = gp_comp_s['z']\n",
|
1413 | 1397 | " gp_comp_s['season'] = s \n",
|
|
1478 | 1462 | {
|
1479 | 1463 | "cell_type": "markdown",
|
1480 | 1464 | "id": "1ac4f1d6-7e39-42b9-8423-5acf60bdc3da",
|
1481 |
| - "metadata": {}, |
| 1465 | + "metadata": { |
| 1466 | + "jp-MarkdownHeadingCollapsed": true, |
| 1467 | + "tags": [] |
| 1468 | + }, |
1482 | 1469 | "source": [
|
1483 | 1470 | "#### Figure 1, Figure 2"
|
1484 | 1471 | ]
|
|
1522 | 1509 | "cell_type": "markdown",
|
1523 | 1510 | "id": "4abb3cea-727d-4d39-9bb0-0586028c575f",
|
1524 | 1511 | "metadata": {
|
| 1512 | + "jp-MarkdownHeadingCollapsed": true, |
1525 | 1513 | "tags": []
|
1526 | 1514 | },
|
1527 | 1515 | "source": [
|
|
1566 | 1554 | "cell_type": "markdown",
|
1567 | 1555 | "id": "4e1acf9f-4bee-4475-abc7-2c4a94122d4f",
|
1568 | 1556 | "metadata": {
|
| 1557 | + "jp-MarkdownHeadingCollapsed": true, |
1569 | 1558 | "tags": []
|
1570 | 1559 | },
|
1571 | 1560 | "source": [
|
|
1605 | 1594 | "cell_type": "markdown",
|
1606 | 1595 | "id": "cd46fa21-e910-4a04-985d-142fa3e9bca6",
|
1607 | 1596 | "metadata": {
|
| 1597 | + "jp-MarkdownHeadingCollapsed": true, |
1608 | 1598 | "tags": []
|
1609 | 1599 | },
|
1610 | 1600 | "source": [
|
|
1886 | 1876 | "prob_H_ZW3phase = xr.concat(prob_H_ZW3phase, dim='sam_thresh')"
|
1887 | 1877 | ]
|
1888 | 1878 | },
|
1889 |
| - { |
1890 |
| - "cell_type": "markdown", |
1891 |
| - "id": "e317d462-aa4e-4bf1-af2d-5ccc1c34a193", |
1892 |
| - "metadata": {}, |
1893 |
| - "source": [ |
1894 |
| - "#### Figure 6" |
1895 |
| - ] |
1896 |
| - }, |
1897 | 1879 | {
|
1898 | 1880 | "cell_type": "code",
|
1899 | 1881 | "execution_count": 28,
|
|
1984 | 1966 | "cell_type": "markdown",
|
1985 | 1967 | "id": "5ffdd456-86f5-4991-86c2-bd0f6dab4561",
|
1986 | 1968 | "metadata": {
|
| 1969 | + "jp-MarkdownHeadingCollapsed": true, |
1987 | 1970 | "tags": []
|
1988 | 1971 | },
|
1989 | 1972 | "source": [
|
|
2055 | 2038 | "prob_H_PSA1 = p_H_idx(psa1, n=nbins, box=regs[reg], extrm=ph, pct=pct, min_ssize=nstar, wdw=wdw, season=s)\n",
|
2056 | 2039 | "prob_H_PSA2 = p_H_idx(psa2, n=nbins, box=regs[reg], extrm=ph, pct=pct, min_ssize=nstar, wdw=wdw, season=s)\n",
|
2057 | 2040 | "\n",
|
2058 |
| - "# # Probability of (ZW3, Index)\n", |
2059 |
| - "# prob_ZW3phase_SAM = p_zw3phase_and_idx(phase, bins, sam, n=nbins, amp=amp_std, amp_thresh=Athresh, season=s)\n", |
2060 |
| - "# prob_ZW3phase_Nino = p_zw3phase_and_idx(phase_nino, bins, nino, n=nbins, amp=amp_nino_std, amp_thresh=Athresh, season=s)\n", |
2061 |
| - "# prob_ZW3phase_IOD = p_zw3phase_and_idx(phase_nino, bins, iod, n=nbins, amp=amp_nino_std, amp_thresh=Athresh, season=s)\n", |
2062 |
| - "# prob_ZW3phase_PSA1 = p_zw3phase_and_idx(phase, bins, psa1, n=nbins, amp=amp_std, amp_thresh=Athresh, season=s)\n", |
2063 |
| - "# prob_ZW3phase_PSA2 = p_zw3phase_and_idx(phase, bins, psa2, n=nbins, amp=amp_std, amp_thresh=Athresh, season=s)\n", |
2064 |
| - "\n", |
2065 | 2041 | "# Probability of H given ZW3 and Index\n",
|
2066 | 2042 | "nstar2 = 30 if timescale=='30dRM' else 5\n",
|
2067 | 2043 | "\n",
|
|
2292 | 2268 | {
|
2293 | 2269 | "cell_type": "markdown",
|
2294 | 2270 | "id": "6a3647dc-bb98-4478-b7b3-dd940520cf42",
|
2295 |
| - "metadata": {}, |
| 2271 | + "metadata": { |
| 2272 | + "tags": [] |
| 2273 | + }, |
2296 | 2274 | "source": [
|
2297 | 2275 | "#### Figure 9 \n",
|
2298 | 2276 | "SST composites comparison"
|
|
2513 | 2491 | },
|
2514 | 2492 | {
|
2515 | 2493 | "cell_type": "code",
|
2516 |
| - "execution_count": 1, |
2517 |
| - "id": "fa066966-1cd6-49cc-9246-b7cabac3977f", |
2518 |
| - "metadata": {}, |
2519 |
| - "outputs": [ |
2520 |
| - { |
2521 |
| - "data": { |
2522 |
| - "text/plain": [ |
2523 |
| - "'/home/561/vo7653'" |
2524 |
| - ] |
2525 |
| - }, |
2526 |
| - "execution_count": 1, |
2527 |
| - "metadata": {}, |
2528 |
| - "output_type": "execute_result" |
2529 |
| - } |
2530 |
| - ], |
2531 |
| - "source": [ |
2532 |
| - "pwd" |
2533 |
| - ] |
2534 |
| - }, |
2535 |
| - { |
2536 |
| - "cell_type": "code", |
2537 |
| - "execution_count": 42, |
| 2494 | + "execution_count": 2, |
2538 | 2495 | "id": "38d3a7a3-ade1-4396-88a0-12f1b109ee0b",
|
2539 | 2496 | "metadata": {
|
2540 | 2497 | "tags": []
|
2541 | 2498 | },
|
2542 |
| - "outputs": [ |
2543 |
| - { |
2544 |
| - "ename": "NameError", |
2545 |
| - "evalue": "name 'skt_comp_' is not defined", |
2546 |
| - "output_type": "error", |
2547 |
| - "traceback": [ |
2548 |
| - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", |
2549 |
| - "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)", |
2550 |
| - "\u001b[0;32m/jobfs/116478024.gadi-pbs/ipykernel_975632/72449981.py\u001b[0m in \u001b[0;36m<cell line: 2>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0mlevels\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mlinspace\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m-\u001b[0m\u001b[0;36m0.72\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m0.72\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m19\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0mskt_all\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mplot_SSTs\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mpval\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m0.1\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mlevels\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mlevels\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 3\u001b[0m \u001b[0;31m# save fig\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0;31m#skt_all.savefig(f'{path_figs}skt_comps.pdf', bbox_inches='tight', facecolor='white', transparent=False)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", |
2551 |
| - "\u001b[0;32m/jobfs/116478024.gadi-pbs/ipykernel_975632/1986014422.py\u001b[0m in \u001b[0;36mplot_SSTs\u001b[0;34m(pval, levels, cmap, regions, var2)\u001b[0m\n\u001b[1;32m 12\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mvar1\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0msig_mask1\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 13\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 14\u001b[0;31m \u001b[0mdalist\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0mskt_comp_\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mskt_comp_g\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mskt_comp_w1\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 15\u001b[0m \u001b[0mdanames\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0;34m'Fourier ZW3'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'Goyal ZW3'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'Fourier ZW1'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 16\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", |
2552 |
| - "\u001b[0;31mNameError\u001b[0m: name 'skt_comp_' is not defined" |
2553 |
| - ] |
2554 |
| - } |
2555 |
| - ], |
| 2499 | + "outputs": [], |
2556 | 2500 | "source": [
|
2557 | 2501 | "levels = np.linspace(-0.72, 0.72, 19)\n",
|
2558 | 2502 | "skt_all = plot_SSTs(pval=0.1, levels=levels)\n",
|
2559 | 2503 | "# save fig\n",
|
2560 | 2504 | "#skt_all.savefig(f'{path_figs}skt_comps.pdf', bbox_inches='tight', facecolor='white', transparent=False)"
|
2561 | 2505 | ]
|
2562 |
| - }, |
2563 |
| - { |
2564 |
| - "cell_type": "code", |
2565 |
| - "execution_count": 87, |
2566 |
| - "id": "ec15ef0c-ba52-47f4-8f1f-853c7b5b9bbe", |
2567 |
| - "metadata": {}, |
2568 |
| - "outputs": [], |
2569 |
| - "source": [] |
2570 |
| - }, |
2571 |
| - { |
2572 |
| - "cell_type": "code", |
2573 |
| - "execution_count": null, |
2574 |
| - "id": "214b8339-59aa-4f7f-a88d-a9a05a7c1a31", |
2575 |
| - "metadata": {}, |
2576 |
| - "outputs": [], |
2577 |
| - "source": [] |
2578 | 2506 | }
|
2579 | 2507 | ],
|
2580 | 2508 | "metadata": {
|
|
0 commit comments