Skip to content

Commit

Permalink
✨ Port sim_analysis_script_6d_disp to notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
s-weigand committed Jun 8, 2024
1 parent 48abbf9 commit d670cae
Showing 1 changed file with 194 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "0",
"metadata": {},
"source": [
"### Load data\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"from glotaran.io import load_dataset\n",
"\n",
"experiment_data = {\n",
" \"dataset1\": load_dataset(\"equareaIRFdispscalsim6a.ascii\"),\n",
" \"dataset2\": load_dataset(\"equareaIRFdispscalsim6b.ascii\"),\n",
" \"dataset3\": load_dataset(\"equareaIRFdispscalsim6c.ascii\"),\n",
" \"dataset4\": load_dataset(\"equareaIRFdispscalsim6d.ascii\"),\n",
" \"dataset5\": load_dataset(\"equareaIRFdispscalsim6e.ascii\"),\n",
" \"dataset6\": load_dataset(\"equareaIRFdispscalsim6f.ascii\"),\n",
"}"
]
},
{
"cell_type": "markdown",
"id": "2",
"metadata": {},
"source": [
"### Load model and parameters, define scheme\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "3",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"from glotaran.io import load_model, load_parameters\n",
"from glotaran.project.scheme import Scheme\n",
"\n",
"model = load_model(\"model.yml\")\n",
"parameters = load_parameters(\"parameters.yml\")\n",
"\n",
"scheme = Scheme(\n",
" model,\n",
" parameters,\n",
" experiment_data,\n",
" maximum_number_function_evaluations=9, # TRF needs 8m LM needs 127\n",
" # optimization_method=\"Levenberg-Marquardt\", #LM needs nfev=127\n",
")"
]
},
{
"cell_type": "markdown",
"id": "4",
"metadata": {},
"source": [
"### Optimization\n",
"\n",
"Fitting model to the data according to the scheme, optimizing the parameters.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "5",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"from glotaran.optimization.optimize import optimize\n",
"\n",
"result = optimize(scheme)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "6",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"from pyglotaran_extras.io import setup_case_study\n",
"\n",
"from glotaran.io import save_result\n",
"\n",
"results_folder, _ = setup_case_study(output_folder_name=\"pyglotaran_examples_results\")\n",
"save_result(result, results_folder / \"result.yml\", allow_overwrite=True);"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "7",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"from pyglotaran_extras import plot_overview\n",
"\n",
"plot_overview(result.data[\"dataset1\"]);"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "8",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"plot_overview(result.data[\"dataset2\"]);"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"plot_overview(result.data[\"dataset3\"]);"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "10",
"metadata": {},
"outputs": [],
"source": [
"plot_overview(result.data[\"dataset4\"]);"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "11",
"metadata": {},
"outputs": [],
"source": [
"plot_overview(result.data[\"dataset5\"]);"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "12",
"metadata": {},
"outputs": [],
"source": [
"plot_overview(result.data[\"dataset6\"]);"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "pygta-staging",
"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"
}
},
"nbformat": 4,
"nbformat_minor": 5
}

0 comments on commit d670cae

Please sign in to comment.