Files
2025-12-17 10:53:43 +08:00

313 lines
5.7 KiB
Plaintext

{
"cells": [
{
"cell_type": "code",
"execution_count": 165,
"metadata": {},
"outputs": [],
"source": [
"# load yaml files with ruamel.yaml\n",
"import sys\n",
"from ruamel.yaml import YAML\n",
"\n",
"yaml=YAML()\n",
"\n",
"fold = \"./params_log_old.yaml\"\n",
"fnew = \"./params_model_v3.yaml\"\n",
"\n",
"# load the old file as string\n",
"with open(fold, 'r') as f:\n",
" str_old = f.read()\n",
" params_in = yaml.load(str_old)\n",
"\n",
"# load the new file as string\n",
"with open(fnew, 'r') as f:\n",
" str_new = f.read()\n",
" params_v3 = yaml.load(str_new)\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 166,
"metadata": {},
"outputs": [],
"source": [
"params_v3['domain'] = params_in['domain']"
]
},
{
"cell_type": "code",
"execution_count": 167,
"metadata": {},
"outputs": [],
"source": [
"params_v3['source'] = params_in['source']"
]
},
{
"cell_type": "code",
"execution_count": 168,
"metadata": {},
"outputs": [],
"source": [
"params_v3['model'] = params_in['model']"
]
},
{
"cell_type": "code",
"execution_count": 169,
"metadata": {},
"outputs": [],
"source": [
"params_v3['parallel'] = params_in['parallel']"
]
},
{
"cell_type": "code",
"execution_count": 170,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'n_sims': 1, 'ndiv_rtp': [1, 2, 2], 'nproc_sub': 2, 'use_gpu': 0}"
]
},
"execution_count": 170,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"params_v3['parallel']"
]
},
{
"cell_type": "code",
"execution_count": 171,
"metadata": {},
"outputs": [],
"source": [
"params_v3['parallel']['use_gpu'] = True"
]
},
{
"cell_type": "code",
"execution_count": 172,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'n_sims': 1, 'ndiv_rtp': [1, 2, 2], 'nproc_sub': 2, 'use_gpu': True}"
]
},
"execution_count": 172,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"params_v3['parallel']"
]
},
{
"cell_type": "code",
"execution_count": 173,
"metadata": {},
"outputs": [],
"source": [
"# dump params_v3 as a new file\n",
"fout = fold+\".v3.yaml\"\n",
"\n",
"with open(fout, 'w') as fp:\n",
" yaml.dump(params_v3, fp)\n"
]
},
{
"cell_type": "code",
"execution_count": 135,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'src_rec_file': 'OUTPUT_FILES/src_rec_file_forward.dat', 'swap_src_rec': 1}"
]
},
"execution_count": 135,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"params_v3['source']"
]
},
{
"cell_type": "code",
"execution_count": 124,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'src_rec_file': 'OUTPUT_FILES/src_rec_file_forward.dat', 'swap_src_rec': 1}"
]
},
"execution_count": 124,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"params_in['source']"
]
},
{
"cell_type": "code",
"execution_count": 125,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'min_max_dep': [-10, 10],\n",
" 'min_max_lat': [37.7, 42.3],\n",
" 'min_max_lon': [22.7, 27.3],\n",
" 'n_rtp': [10, 50, 50]}"
]
},
"execution_count": 125,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"params_in['domain']"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.8"
},
"orig_nbformat": 4
},
"nbformat": 4,
"nbformat_minor": 2
}