Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clean up notebook #1196

Merged
merged 1 commit into from
Nov 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 31 additions & 37 deletions pcmdi_metrics/graphics/demo/variability_modes_plots_all-stats.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -64,7 +64,7 @@
},
{
"cell_type": "code",
"execution_count": 56,
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -95,7 +95,7 @@
},
{
"cell_type": "code",
"execution_count": 57,
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -116,7 +116,7 @@
},
{
"cell_type": "code",
"execution_count": 58,
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -146,7 +146,7 @@
},
{
"cell_type": "code",
"execution_count": 59,
"execution_count": 5,
"metadata": {},
"outputs": [
{
Expand All @@ -164,14 +164,14 @@
}
],
"source": [
"json_list = sorted(glob.glob(os.path.join(json_dir, '*' + mip + '*' + '.json')))\n",
"json_list = sorted(glob.glob(os.path.join(json_dir, 'var_mode_*' + mip + '*' + '.json')))\n",
"for json_file in json_list:\n",
" print(json_file.split('/')[-1])"
]
},
{
"cell_type": "code",
"execution_count": 60,
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -188,37 +188,32 @@
},
{
"cell_type": "code",
"execution_count": 61,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"def dict_to_df(cmip_result_dict):\n",
" models = sorted(list(cmip_result_dict['NAM'].keys()))\n",
" #print(models)\n",
"\n",
" df = pd.DataFrame()\n",
" df['model'] = models\n",
" df['num_runs'] = np.nan\n",
" \n",
" mode_season_list = list()\n",
"\n",
" models_ens = list()\n",
" modes = ['SAM', 'NAM', 'NAO', 'NPO', 'PNA', 'NPGO', 'PDO']\n",
" for mode in modes:\n",
" #print(mode)\n",
" if mode in ['PDO', 'NPGO']:\n",
" seasons = ['monthly']\n",
" else:\n",
" seasons = ['DJF', 'MAM', 'JJA', 'SON']\n",
"\n",
" for season in seasons:\n",
" #print(mode, season)\n",
" df[mode+\"_\"+season] = np.nan\n",
" mode_season_list.append(mode+\"_\"+season)\n",
" for index, model in enumerate(models):\n",
" if model in list(cmip_result_dict[mode].keys()):\n",
" runs = sort_human(list(cmip_result_dict[mode][model].keys()))\n",
" #print(model, runs)\n",
" stat_run_list = list()\n",
" for run in runs:\n",
" stat_run = cmip_result_dict[mode][model][run]['defaultReference'][mode][season]['cbf'][stat]\n",
Expand All @@ -231,13 +226,12 @@
" else:\n",
" stat_model = np.nan\n",
" num_runs = 0\n",
" #print(mode, season, model, num_runs, stat_model)\n",
" return df, mode_season_list"
]
},
{
"cell_type": "code",
"execution_count": 62,
"execution_count": 8,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -610,7 +604,7 @@
"[65 rows x 24 columns]"
]
},
"execution_count": 62,
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -622,7 +616,7 @@
},
{
"cell_type": "code",
"execution_count": 64,
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -631,7 +625,7 @@
},
{
"cell_type": "code",
"execution_count": 65,
"execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -647,7 +641,7 @@
},
{
"cell_type": "code",
"execution_count": 67,
"execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -664,7 +658,7 @@
},
{
"cell_type": "code",
"execution_count": 68,
"execution_count": 12,
"metadata": {},
"outputs": [
{
Expand All @@ -687,7 +681,7 @@
},
{
"cell_type": "code",
"execution_count": 69,
"execution_count": 13,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -717,7 +711,7 @@
},
{
"cell_type": "code",
"execution_count": 70,
"execution_count": 14,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -731,7 +725,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 15,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -752,7 +746,7 @@
},
{
"cell_type": "code",
"execution_count": 72,
"execution_count": 16,
"metadata": {},
"outputs": [
{
Expand All @@ -761,7 +755,7 @@
"(22, 65)"
]
},
"execution_count": 72,
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -781,7 +775,7 @@
},
{
"cell_type": "code",
"execution_count": 73,
"execution_count": 17,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -797,7 +791,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 18,
"metadata": {},
"outputs": [
{
Expand All @@ -806,7 +800,7 @@
"Text(0.5, 1.0, 'Variability Modes: RMSE')"
]
},
"execution_count": 107,
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
},
Expand Down Expand Up @@ -847,7 +841,7 @@
},
{
"cell_type": "code",
"execution_count": 75,
"execution_count": 19,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -866,7 +860,7 @@
},
{
"cell_type": "code",
"execution_count": 76,
"execution_count": 20,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -902,7 +896,7 @@
},
{
"cell_type": "code",
"execution_count": 77,
"execution_count": 21,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -918,7 +912,7 @@
},
{
"cell_type": "code",
"execution_count": 78,
"execution_count": 22,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -948,7 +942,7 @@
" Text(21, 0, 'PDO_monthly')]"
]
},
"execution_count": 78,
"execution_count": 22,
"metadata": {},
"output_type": "execute_result"
},
Expand Down Expand Up @@ -983,7 +977,7 @@
},
{
"cell_type": "code",
"execution_count": 79,
"execution_count": 23,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -1000,7 +994,7 @@
},
{
"cell_type": "code",
"execution_count": 87,
"execution_count": 24,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -1030,7 +1024,7 @@
" Text(21, 0, 'PDO_monthly')]"
]
},
"execution_count": 87,
"execution_count": 24,
"metadata": {},
"output_type": "execute_result"
},
Expand Down Expand Up @@ -1070,7 +1064,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "pmp_devel_20241106_xcdat0.7.3",
"display_name": "pmp_devel_20241118_numpy2",
"language": "python",
"name": "python3"
},
Expand Down
Loading