-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Port sim_analysis_script_6d_disp to notebook
- Loading branch information
Showing
1 changed file
with
194 additions
and
0 deletions.
There are no files selected for viewing
194 changes: 194 additions & 0 deletions
194
pyglotaran_examples/test/simultaneous_analysis_6d_disp/sim_analysis_script_6d_disp.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |