Skip to content

Commit

Permalink
🩹 Refine ex_spectral_constraints notbook to generate same files as sc…
Browse files Browse the repository at this point in the history
…ript
  • Loading branch information
s-weigand committed Jun 8, 2024
1 parent c644714 commit 12a2b40
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@
")\n",
"\n",
"# optimization with first scheme\n",
"result = optimize(scheme_no_penalties)\n",
"result_no_penalties_first_run = optimize(scheme_no_penalties)\n",
"# optimization with second scheme,\n",
"# where we change the maximum number of function evaluations\n",
"scheme2 = result.get_scheme()\n",
"scheme2 = result_no_penalties_first_run.get_scheme()\n",
"scheme2.maximum_number_function_evaluations = 2\n",
"result_no_penalties = optimize(scheme2)"
]
Expand All @@ -84,8 +84,14 @@
"from glotaran.io import save_result\n",
"\n",
"base_results_folder, _ = setup_case_study(output_folder_name=\"pyglotaran_examples_results\")\n",
"results_folder = base_results_folder / \"no_penalties\"\n",
"save_result(result_no_penalties, results_folder / \"result.yml\", allow_overwrite=True)"
"save_result(\n",
" result_no_penalties_first_run,\n",
" base_results_folder / \"no_penalties_first_run/result.yml\",\n",
" allow_overwrite=True,\n",
")\n",
"save_result(\n",
" result_no_penalties, base_results_folder / \"no_penalties/result.yml\", allow_overwrite=True\n",
");"
]
},
{
Expand All @@ -97,6 +103,7 @@
"source": [
"from pyglotaran_extras.plotting.plot_overview import plot_simple_overview\n",
"\n",
"plot_simple_overview(result_no_penalties_first_run.data[\"dataset1\"])\n",
"plot_simple_overview(result_no_penalties.data[\"dataset1\"]);"
]
},
Expand Down Expand Up @@ -132,43 +139,65 @@
" maximum_number_function_evaluations=7,\n",
")\n",
"\n",
"result_equal_area = optimize(scheme_equal_area)"
"result_equal_area_first_run = optimize(scheme_equal_area)"
]
},
{
"cell_type": "markdown",
"cell_type": "code",
"execution_count": null,
"id": "9",
"metadata": {},
"outputs": [],
"source": [
"#### Plotting"
"save_result(\n",
" result_equal_area_first_run,\n",
" base_results_folder / \"with_penalties_first_run/result.yml\",\n",
" allow_overwrite=True,\n",
");"
]
},
{
"cell_type": "markdown",
"id": "10",
"metadata": {},
"source": [
"#### Run again with results from first run and save"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "10",
"id": "11",
"metadata": {},
"outputs": [],
"source": [
"from pyglotaran_extras.plotting.plot_overview import plot_simple_overview\n",
"\n",
"plot_simple_overview(result_equal_area.data[\"dataset1\"]);"
"result_equal_area = optimize(result_equal_area_first_run.get_scheme())\n",
"save_result(\n",
" result_equal_area,\n",
" base_results_folder / \"with_penalties/result.yml\",\n",
" allow_overwrite=True,\n",
");"
]
},
{
"cell_type": "markdown",
"id": "12",
"metadata": {},
"source": [
"#### Plotting"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "11",
"id": "13",
"metadata": {},
"outputs": [],
"source": [
"from pyglotaran_extras.io import setup_case_study\n",
"\n",
"from glotaran.io import save_result\n",
"from pyglotaran_extras.plotting.plot_overview import plot_simple_overview\n",
"\n",
"base_results_folder, _ = setup_case_study(output_folder_name=\"pyglotaran_examples_results\")\n",
"results_folder = base_results_folder / \"with_penalties_first_run\"\n",
"save_result(result_equal_area, results_folder / \"result.yml\", allow_overwrite=True)"
"plot_simple_overview(result_equal_area_first_run.data[\"dataset1\"])\n",
"plot_simple_overview(result_equal_area.data[\"dataset1\"]);"
]
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ irf:
center: irf.center
width: irf.width

clp_area_penalties:
clp_penalties:
- type: equal_area
source: s2
source_intervals: [[0, 1000]]
Expand Down

0 comments on commit 12a2b40

Please sign in to comment.