-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
201 move reporting to the lib (#202)
* first summary element * refinement section * test rename * utils with counting * experiments section * html summary * skeleton parameter * replace in template * paramaters as table * html formatting * html formatting * summary formatting * constained parameters * constraints in summary * summary * cleaning project info * pdf summary * summary update * code cleaning * figures in summary * only figures when requested * legends and eps files * back to jpg * notebook for project object * text adjustments project notebook * link to pdf * always add project information * pr response * reduce code complexity * trying to understand CodeFactor * more CodeFactor * trying to make CodaFactor happy * CodaFactor problems * CodeFactor * codefactor * cidefactor * codefactor * codefactor * code factor * codefactor * code factor * CodeFactor * code factor * code factor * codefactor * codafactor not using free * code factor * code factor * code facoter * count functionality back to utils
- Loading branch information
Showing
10 changed files
with
932 additions
and
20 deletions.
There are no files selected for viewing
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,315 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Project\n", | ||
"This notebook serves to demonstrate some of the functionality of the Project object.\n", | ||
"\n", | ||
"## Setup\n", | ||
"First configure matplotlib to place figures in notebook and import needed modules." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from easyreflectometry import Project\n", | ||
"from easyreflectometry.summary import Summary" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Project object\n", | ||
"\n", | ||
"First we will create a `Project` object. There should only be one such object. The project is follwoing set to have the current folder at its root and the we give it the name: `MyNewProject`. " | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"project = Project()\n", | ||
"project.set_path_project_parent('.')\n", | ||
"project._info['name'] = 'MyNewProject'" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"We will then populate this `Project` with the default model." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 4, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"EasyModels:\n", | ||
"- EasyModel:\n", | ||
" scale: 1.0\n", | ||
" background: 1.0e-08\n", | ||
" resolution: 5.0 %\n", | ||
" color: black\n", | ||
" sample:\n", | ||
" EasySample:\n", | ||
" - Superphase:\n", | ||
" Vacuum Layer:\n", | ||
" - Vacuum Layer:\n", | ||
" material:\n", | ||
" Air:\n", | ||
" sld: 0.000e-6 1/Å^2\n", | ||
" isld: 0.000e-6 1/Å^2\n", | ||
" thickness: 0.000 Å\n", | ||
" roughness: 0.000 Å\n", | ||
" - D2O:\n", | ||
" D2O Layer:\n", | ||
" - D2O Layer:\n", | ||
" material:\n", | ||
" D2O:\n", | ||
" sld: 6.335e-6 1/Å^2\n", | ||
" isld: 0.000e-6 1/Å^2\n", | ||
" thickness: 100.000 Å\n", | ||
" roughness: 3.000 Å\n", | ||
" - Subphase:\n", | ||
" Si Layer:\n", | ||
" - Si Layer:\n", | ||
" material:\n", | ||
" Si:\n", | ||
" sld: 2.074e-6 1/Å^2\n", | ||
" isld: 0.000e-6 1/Å^2\n", | ||
" thickness: 0.000 Å\n", | ||
" roughness: 1.200 Å\n", | ||
"\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"project.default_model()\n", | ||
"print(project.models)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"We can also see which materials that are defined in the `Project`." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 5, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"EasyMaterials:\n", | ||
"- Air:\n", | ||
" sld: 0.000e-6 1/Å^2\n", | ||
" isld: 0.000e-6 1/Å^2\n", | ||
"- D2O:\n", | ||
" sld: 6.335e-6 1/Å^2\n", | ||
" isld: 0.000e-6 1/Å^2\n", | ||
"- Si:\n", | ||
" sld: 2.074e-6 1/Å^2\n", | ||
" isld: 0.000e-6 1/Å^2\n", | ||
"\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"print(project._materials)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"It is possible to save a `Project` object. It will be place in the project folder and the state will be save in the file name `project.json`." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 6, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"project.save_as_json(overwrite=True)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"We can also generate a summary of the project. We are also going to store the PDF and HTML files with the summary in the project folder." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"WindowsPath('MyNewProject/summary.pdf')" | ||
] | ||
}, | ||
"execution_count": 12, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"summary = Summary(project)\n", | ||
"summary.save_pdf_summary(str(project.path / 'summary.pdf'))\n", | ||
"summary.save_html_summary(str(project.path / 'summary.html'))" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"[Link to PDF summary](MyNewProject/summary.pdf) in `MyNewProject/summary.pdf`" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"We can reset the project to a blank state." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 8, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"EasyModels: []\n", | ||
"\n", | ||
"EasyMaterials: []\n", | ||
"\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"project.reset()\n", | ||
"print(project.models)\n", | ||
"print(project._materials)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Then let us try to load the state we saved above." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 9, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"EasyModels:\n", | ||
"- EasyModel:\n", | ||
" scale: 1.0\n", | ||
" background: 1.0e-08\n", | ||
" resolution: 5.0 %\n", | ||
" color: black\n", | ||
" sample:\n", | ||
" EasySample:\n", | ||
" - Superphase:\n", | ||
" EasyLayerCollection:\n", | ||
" - Vacuum Layer:\n", | ||
" material:\n", | ||
" Air:\n", | ||
" sld: 0.000e-6 1/Å^2\n", | ||
" isld: 0.000e-6 1/Å^2\n", | ||
" thickness: 0.000 Å\n", | ||
" roughness: 0.000 Å\n", | ||
" - D2O:\n", | ||
" EasyLayerCollection:\n", | ||
" - D2O Layer:\n", | ||
" material:\n", | ||
" D2O:\n", | ||
" sld: 6.335e-6 1/Å^2\n", | ||
" isld: 0.000e-6 1/Å^2\n", | ||
" thickness: 100.000 Å\n", | ||
" roughness: 3.000 Å\n", | ||
" - Subphase:\n", | ||
" EasyLayerCollection:\n", | ||
" - Si Layer:\n", | ||
" material:\n", | ||
" Si:\n", | ||
" sld: 2.074e-6 1/Å^2\n", | ||
" isld: 0.000e-6 1/Å^2\n", | ||
" thickness: 0.000 Å\n", | ||
" roughness: 1.200 Å\n", | ||
"\n", | ||
"EasyMaterials:\n", | ||
"- Air:\n", | ||
" sld: 0.000e-6 1/Å^2\n", | ||
" isld: 0.000e-6 1/Å^2\n", | ||
"- D2O:\n", | ||
" sld: 6.335e-6 1/Å^2\n", | ||
" isld: 0.000e-6 1/Å^2\n", | ||
"- Si:\n", | ||
" sld: 2.074e-6 1/Å^2\n", | ||
" isld: 0.000e-6 1/Å^2\n", | ||
"\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"project.set_path_project_parent('.')\n", | ||
"project._info['name'] = 'MyNewProject'\n", | ||
"project.load_from_json()\n", | ||
"print(project.models)\n", | ||
"print(project._materials)" | ||
] | ||
} | ||
], | ||
"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.11.10" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
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
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
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,3 @@ | ||
from .summary import Summary | ||
|
||
__all__ = [Summary] |
Oops, something went wrong.