-
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.
Merge pull request #27 from scipp/orso-filewriter
Reimplement ORSO filewriter
- Loading branch information
Showing
29 changed files
with
606 additions
and
250 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 |
---|---|---|
|
@@ -12,6 +12,7 @@ requirements: | |
- setuptools_scm | ||
run: | ||
- dask | ||
- python-dateutil | ||
- graphviz | ||
- plopp | ||
- pythreejs | ||
|
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 |
---|---|---|
|
@@ -29,7 +29,8 @@ | |
:template: module-template.rst | ||
:recursive: | ||
types | ||
amor | ||
orso | ||
supermirror | ||
types | ||
``` |
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 |
---|---|---|
|
@@ -29,7 +29,7 @@ | |
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"params={\n", | ||
"params = {\n", | ||
" **default_parameters,\n", | ||
" QBins: sc.geomspace(dim='Q', start=0.008, stop=0.075, num=200, unit='1/angstrom'),\n", | ||
" SampleRotation[Sample]: sc.scalar(0.7989, unit='deg'),\n", | ||
|
@@ -118,6 +118,150 @@ | |
"source": [ | ||
"This plot can be used to check if the value of the sample rotation angle $\\omega$ is correct. The bright triangles should be pointing back to the origin $\\lambda = \\theta = 0$." | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Save data\n", | ||
"\n", | ||
"We can save the computed $I(Q)$ to an [ORSO](https://www.reflectometry.org) [.ort](https://github.com/reflectivity/file_format/blob/master/specification.md) file using the [orsopy](https://orsopy.readthedocs.io/en/latest/index.html) package.\n", | ||
"\n", | ||
"First, we need to collect the metadata for that file.\n", | ||
"To this end, we build a pipeline with additional providers.\n", | ||
"We also insert a parameter to indicate the creator of the processed data." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from essreflectometry import orso\n", | ||
"from essreflectometry.amor import orso as amor_orso\n", | ||
"from orsopy import fileio" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"providers_with_metadata = (\n", | ||
" *providers,\n", | ||
" *orso.providers,\n", | ||
" *amor_orso.providers,\n", | ||
")\n", | ||
"\n", | ||
"params[orso.OrsoCreator] = orso.OrsoCreator(fileio.base.Person(\n", | ||
" name='Max Mustermann',\n", | ||
" affiliation='European Spallation Source ERIC',\n", | ||
" contact='[email protected]',\n", | ||
"))\n", | ||
"\n", | ||
"metadata_pipeline = sciline.Pipeline(\n", | ||
" providers_with_metadata,\n", | ||
" params=params\n", | ||
")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Then, we recompute $I(Q)$ and and combine it with the ORSO metadata:" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"iofq_dataset = metadata_pipeline.compute(orso.OrsoIofQDataset)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Unfortunately, some metadata could not be determined autoamtically.\n", | ||
"In particular, we need to specify the sample manually:" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"iofq_dataset.info.data_source.sample" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"iofq_dataset.info.data_source.sample = fileio.data_source.Sample(\n", | ||
" name='Ni / Ti Multilayer',\n", | ||
" model=fileio.data_source.SampleModel(\n", | ||
" stack='air | (Ni | Ti) * 5 | Si',\n", | ||
" ),\n", | ||
")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"And we also add the URL of this notebook to make it easier to reproduce the data:" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"iofq_dataset.info.reduction.script = 'https://scipp.github.io/essreflectometry/examples/amor.html'" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Finally, we can save the data to a file.\n", | ||
"Note that `iofq_dataset` is an [orsopy.fileio.orso.OrsoDataset](https://orsopy.readthedocs.io/en/latest/orsopy.fileio.orso.html#orsopy.fileio.orso.OrsoDataset)." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"iofq_dataset.save('amor_reduced_iofq.ort')" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Look at the first 50 lines of the file to inspect the metadata:" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"!head amor_reduced_iofq.ort -n50" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
|
@@ -136,7 +280,7 @@ | |
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.10.12" | ||
"version": "3.10.13" | ||
} | ||
}, | ||
"nbformat": 4, | ||
|
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
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
Oops, something went wrong.