Browse Source

Print variables

FGeo 1 year ago
parent
commit
8e19a8909a
  1. 291
      5_IP_simulations_spatial_images.ipynb

291
5_IP_simulations_spatial_images.ipynb

@ -3,7 +3,13 @@ @@ -3,7 +3,13 @@
{
"cell_type": "markdown",
"id": "3b98d562-23d5-405b-bfe1-5073e8fcbd76",
"metadata": {},
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": []
},
"source": [
"# Analysis of simulated IP and temperature grouped by latitude"
]
@ -39,21 +45,20 @@ @@ -39,21 +45,20 @@
{
"cell_type": "markdown",
"id": "83163834-de47-4f28-8add-768c7b76e1d3",
"metadata": {
"jp-MarkdownHeadingCollapsed": true
},
"metadata": {},
"source": [
"### Helper functions, variables and classes"
]
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 144,
"id": "61405aa1-0b4d-4a8a-85a5-3097d37c644e",
"metadata": {},
"outputs": [],
"source": [
"month_name = [\"J\", \"F\", \"M\", \"A\", \"M\", \"J\", \"J\", \"A\", \"S\", \"O\", \"N\", \"D\"]"
"month_name = [\"J\", \"F\", \"M\", \"A\", \"M\", \"J\", \"J\", \"A\", \"S\", \"O\", \"N\", \"D\"]\n",
"month_name_3 = [\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\"]"
]
},
{
@ -92,7 +97,7 @@ @@ -92,7 +97,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 54,
"id": "4250ebc7-1c87-4ff0-bc58-faaf6732008f",
"metadata": {},
"outputs": [],
@ -168,15 +173,14 @@ @@ -168,15 +173,14 @@
"\n",
" # store latitude bands model and prettify title\n",
" self.model = model\n",
" self.title = f\"{p1}–{p2}\" # like 9°S–18°S"
" self.title = f\"{p1}–{p2}\" # like 9°S–18°S\n",
" self.label = self.title.replace(\" \", \"\")"
]
},
{
"cell_type": "markdown",
"id": "d00db06e-dd79-4422-b62b-f10ca8a81f9a",
"metadata": {
"jp-MarkdownHeadingCollapsed": true
},
"metadata": {},
"source": [
"### Loading precalculated arrays"
]
@ -212,7 +216,13 @@ @@ -212,7 +216,13 @@
"cell_type": "code",
"execution_count": 8,
"id": "69602993-2005-4fed-b425-69575f9fd2cf",
"metadata": {},
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": []
},
"outputs": [],
"source": [
"wrf_LATxMON_t2 = np.load(\"./data/WRF/WRF_T2_LATxMON.npy\")\n",
@ -244,15 +254,266 @@ @@ -244,15 +254,266 @@
},
{
"cell_type": "markdown",
"id": "497b3797-3076-43c3-a66e-e827bc00df66",
"id": "123b905f-c3c3-4592-b29d-92aeef3faf3a",
"metadata": {},
"source": [
"### Auxiliary calculations of values to mention in the text"
]
},
{
"cell_type": "code",
"execution_count": 265,
"id": "90002efb-7421-46cc-8e64-96c6d465c617",
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Model | CAPE | T2,°C | Band | % \n",
"-----------------------------------------\n",
"WRF | 500 | 25 | 9°S–9°N | 57.5%\n",
"INMCM | 800 | - | 9°S–9°N | 51.7%\n",
"WRF | 800 | - | 9°S–9°N | 60.2%\n",
"INMCM | 1000 | - | 9°S–9°N | 53.0%\n",
"WRF | 1000 | - | 9°S–9°N | 62.3%\n",
"INMCM | 1200 | - | 9°S–9°N | 53.7%\n",
"WRF | 1200 | - | 9°S–9°N | 63.4%\n",
"-----------------------------------------\n",
"INMCM | 1000 | - | 18°S–18°N | 86.1%\n",
"WRF | 1000 | - | 18°S–18°N | 92.1%\n",
"-----------------------------------------\n",
"INMCM | 1000 | - | 30°S–30°N | 96.5%\n",
"WRF | 1000 | - | 30°S–30°N | 98.8%\n"
]
}
],
"source": [
"# calculate the average contribution of the regions to \n",
"# the ionospheric potential (as % of total IP)\n",
"# for specific regions, models and parameters CAPE / T2\n",
"\n",
"band_names = [\"9S-9N\", \"18S-18N\", \"30S-30N\"]\n",
"wrf_bands = [LatitudeBand(t, model=\"WRF\") for t in band_names]\n",
"inmcm_bands = [LatitudeBand(t, model=\"INMCM\") for t in band_names]\n",
" \n",
"print(\"Model | CAPE | T2,°C | Band | % \")\n",
"for i, (wrf_band, inm_band) in enumerate(zip(wrf_bands, inmcm_bands)):\n",
" print(\"-\"*41)\n",
" capes = [1000]\n",
" if i == 0:\n",
" capes = [500, 800, 1000, 1200]\n",
"\n",
" for cape in capes:\n",
" wrf_ip = wrf_LATxMON_ip[cape][wrf_band.slice].sum(axis=0).mean() / 240e3 * 100\n",
"\n",
" if cape != 500:\n",
" inm_ip = inm_LATxMON_ip[cape][inm_band.slice].sum(axis=0).mean() / 240e3 * 100\n",
" print(f\"INMCM | {cape:4d} | - |{inm_band.label:>11} | {inm_ip:>4.1f}%\")\n",
"\n",
" p = \"25 \" if cape == 500 else \"- \"\n",
" print(f\"WRF | {cape:4d} | {p} |{wrf_band.label:>11} | {wrf_ip:>4.1f}%\") "
]
},
{
"cell_type": "code",
"execution_count": 268,
"id": "7cc0c763-f1ec-4ff4-b4fe-2730be6daec9",
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Model | CAPE | T2,°C | Band | Min | Max | Peak-to-peak, %\n",
"---------------------------------------------------------------\n",
"WRF | 500 | 25 | 90°S–9°S | Aug | Feb | 208.8%\n",
"INMCM | 800 | - | 90°S–9°S | Sep | Feb | 165.7%\n",
"WRF | 800 | - | 90°S–9°S | Aug | Feb | 201.8%\n",
"INMCM | 1000 | - | 90°S–9°S | Aug | Feb | 190.5%\n",
"WRF | 1000 | - | 90°S–9°S | Aug | Feb | 215.5%\n",
"INMCM | 1200 | - | 90°S–9°S | Aug | Feb | 212.7%\n",
"WRF | 1200 | - | 90°S–9°S | Aug | Feb | 238.8%\n",
"---------------------------------------------------------------\n",
"WRF | 500 | 25 | 9°S–9°N | Aug | Apr | 57.7%\n",
"INMCM | 800 | - | 9°S–9°N | Jul | May | 29.1%\n",
"WRF | 800 | - | 9°S–9°N | Aug | Apr | 52.1%\n",
"INMCM | 1000 | - | 9°S–9°N | Jul | May | 32.9%\n",
"WRF | 1000 | - | 9°S–9°N | Aug | Apr | 63.0%\n",
"INMCM | 1200 | - | 9°S–9°N | Jul | May | 38.4%\n",
"WRF | 1200 | - | 9°S–9°N | Aug | Apr | 72.8%\n",
"---------------------------------------------------------------\n",
"WRF | 500 | 25 | 9°N–90°N | Feb | Aug | 226.0%\n",
"INMCM | 800 | - | 9°N–90°N | Feb | Aug | 181.5%\n",
"WRF | 800 | - | 9°N–90°N | Feb | Aug | 220.5%\n",
"INMCM | 1000 | - | 9°N–90°N | Feb | Jul | 190.6%\n",
"WRF | 1000 | - | 9°N–90°N | Feb | Aug | 224.9%\n",
"INMCM | 1200 | - | 9°N–90°N | Feb | Jul | 201.6%\n",
"WRF | 1200 | - | 9°N–90°N | Feb | Aug | 226.7%\n"
]
}
],
"source": [
"band_names = [\"90S-9S\", \"9S-9N\", \"9N-90N\"]\n",
"wrf_bands = [LatitudeBand(t, model=\"WRF\") for t in band_names]\n",
"inmcm_bands = [LatitudeBand(t, model=\"INMCM\") for t in band_names]\n",
"\n",
"print(\"Model | CAPE | T2,°C | Band | Min | Max | Peak-to-peak, %\")\n",
"for i, (wrf_band, inm_band) in enumerate(zip(wrf_bands, inmcm_bands)):\n",
" print(\"-\"*63)\n",
" for cape in [500, 800, 1000, 1200]:\n",
" if cape != 500:\n",
" seas_var = inm_LATxMON_ip[cape][inm_band.slice].sum(axis=0) \n",
" month_min = month_name_3[np.argmin(seas_var)]\n",
" month_max = month_name_3[np.argmax(seas_var)]\n",
" pk_pk_ampl = (seas_var.max() - seas_var.min())/seas_var.mean() * 100\n",
" print(f\"INMCM | {cape:4} | - |{inm_band.label:>11} | {month_min} | {month_max} | {pk_pk_ampl:>5.1f}%\")\n",
" \n",
" seas_var = wrf_LATxMON_ip[cape][wrf_band.slice].sum(axis=0)\n",
" month_min = month_name_3[np.argmin(seas_var)]\n",
" month_max = month_name_3[np.argmax(seas_var)]\n",
" pk_pk_ampl = (seas_var.max() - seas_var.min())/seas_var.mean() * 100\n",
" \n",
" p = \"25 \" if cape == 500 else \"- \"\n",
" print(f\"WRF | {cape:4} | {p:<5} |{inm_band.label:>11} | {month_min} | {month_max} | {pk_pk_ampl:>5.1f}%\")"
]
},
{
"cell_type": "code",
"execution_count": 314,
"id": "12e57219-ea3e-447b-b858-5240e2f8004b",
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"CAPE = 1000 J/kg\n",
"\n",
"Model | Band | Max IP contrib.\n",
"-------------------------------\n",
"WRF | 18°N–90°N | 39632.12 V\n",
"INMCM | 18°N–90°N | 55489.63 V\n",
"-------------------------------\n",
"WRF | 9°N–18°N | 87966.76 V\n",
"INMCM | 9°N–18°N | 81507.39 V\n",
"-------------------------------\n",
"WRF | 0°–9°N | 119554.24 V\n",
"INMCM | 0°–9°N | 80137.23 V\n",
"-------------------------------\n",
"WRF | 0°–9°S | 101478.67 V\n",
"INMCM | 0°–9°S | 89818.48 V\n",
"-------------------------------\n",
"WRF | 9°S–18°S | 69905.52 V\n",
"INMCM | 9°S–18°S | 77321.06 V\n",
"-------------------------------\n",
"WRF | 18°S–90°S | 17133.10 V\n",
"INMCM | 18°S–90°S | 24639.04 V\n"
]
},
{
"data": {
"text/plain": [
"(60, 12)"
]
},
"execution_count": 314,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"band_names = [\"18N-90N\", \"9N-18N\", \"0-9N\", \"0-9S\", \"9S-18S\", \"18S-90S\"]\n",
"wrf_bands = [LatitudeBand(t, model=\"WRF\") for t in band_names]\n",
"inmcm_bands = [LatitudeBand(t, model=\"INMCM\") for t in band_names]\n",
"\n",
"print(\"CAPE = 1000 J/kg\\n\")\n",
"print(\"Model | Band | Max IP contrib.\")\n",
"for i, (wrf_band, inm_band) in enumerate(zip(wrf_bands, inmcm_bands)):\n",
" print(\"-\"*31)\n",
" wrf_max = wrf_LATxMON_ip[1000][wrf_band.slice].sum(axis=0).max()\n",
" inm_max = inm_LATxMON_ip[1000][inm_band.slice].sum(axis=0).max()\n",
" print(f\"WRF | {wrf_band.label:>9} | {wrf_max:>9.2f} V\")\n",
" print(f\"INMCM | {inm_band.label:>9} | {inm_max:>9.2f} V\")\n",
" # inm_LATxMON_ip[1000]"
]
},
{
"cell_type": "code",
"execution_count": 359,
"id": "df0d50ea-4001-4007-9a4d-bc37b8a1be9f",
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Model | Band | Min T2 | Max T2\n",
"-------------------------------------\n",
"WRF | 18°N–30°N | 18.10°C | 26.98°C\n",
"WRF | 9°N–18°N | 24.65°C | 27.64°C\n",
"WRF | 0°–9°N | 26.21°C | 27.24°C\n",
"WRF | 0°–9°S | 25.20°C | 27.02°C\n",
"WRF | 9°S–18°S | 23.15°C | 26.29°C\n",
"WRF | 18°S–30°S | 18.62°C | 24.83°C\n"
]
}
],
"source": [
"band_names = [\"18N-30N\", \"9N-18N\", \"0-9N\", \"0-9S\", \"9S-18S\", \"18S-30S\"]\n",
"wrf_bands = [LatitudeBand(t, model=\"WRF\") for t in band_names]\n",
"\n",
"print(\"Model | Band | Min T2 | Max T2\")\n",
"print(\"-\" * 37)\n",
"for wrf_band in wrf_bands:\n",
" tmp_t2 = (\n",
" wrf_LATxMON_t2[wrf_band.slice] * area_factor[wrf_band.slice, np.newaxis]\n",
" ).sum(axis=0) / area_factor[wrf_band.slice, np.newaxis].sum()\n",
"\n",
" print(f\"WRF | {wrf_band.label:>9} | {tmp_t2.min():>3.2f}°C | {tmp_t2.max():>3.2f}°C\")"
]
},
{
"cell_type": "markdown",
"id": "497b3797-3076-43c3-a66e-e827bc00df66",
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": []
},
"source": [
"### Figure 4"
]
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 273,
"id": "34e25ddd-4815-4c70-bc3b-982cad6b65b4",
"metadata": {},
"outputs": [],
@ -276,7 +537,7 @@ @@ -276,7 +537,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 274,
"id": "fc39428e-ea03-494e-97d7-c38ecd8cb044",
"metadata": {},
"outputs": [

Loading…
Cancel
Save